The function inserts an 'h' before the third character of the input string and changes the last character based on the rules: e -> S, d -> T, g -> U, or add b if the last character doesn't match any rule.
[CODE]:
```
def approx_function(input_str):
    input_str = input_str[:2] + 'h' + input_str[2:]
    
    if input_str[-1] == 'e':
        input_str = input_str[:-1] + 'S'
    elif input_str[-1] == 'd':
        input_str = input_str[:-1] + 'T'
    elif input_str[-1] == 'g':
        input_str = input_str[:-1] + 'U'
    else:
        input_str += 'b'
    
    return input_str
```