user: 请将以下的汇编代码转换成C语言代码：

```asm
<ConfigConvertStrWithResolvEnvToStr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  call   <strdup@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L157
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L157
  xor    %r13d,%r13d
  jmp    L29
  nopl   0x0(%rax)
L86:
  mov    %rbp,%r13
L95:
  cmp    %r13,%r14
  jbe    L157
L29:
  cmpb   $0x24,(%r12,%r13,1)
  lea    0x1(%r13),%rbp
  jne    L86
  cmpb   $0x7b,0x1(%r12,%r13,1)
  mov    %rbp,%rbx
  sete   %al
  cmovne %r13,%rbx
  movzbl %al,%eax
  mov    %eax,0x8(%rsp)
  cmp    %r14,%rbx
  jae    L48
  nopl   0x0(%rax,%rax,1)
L110:
  add    $0x1,%rbx
  movzbl (%r12,%rbx,1),%edx
  mov    %edx,%eax
  and    $0xffffffdf,%eax
  sub    $0x41,%eax
  cmp    $0x19,%al
  jbe    L5
  lea    -0x30(%rdx),%eax
  cmp    $0x9,%al
  jbe    L5
  cmp    $0x5f,%dl
  jne    L48
L5:
  cmp    %r14,%rbx
  jne    L110
L48:
  mov    %rbx,%r15
  sub    %rbp,%r15
  lea    0x1(%r15),%rdi
  call   <malloc@plt>
  test   %rax,%rax
  je     L113
  movslq 0x8(%rsp),%rsi
  mov    %rax,%rdi
  mov    %rax,0x10(%rsp)
  sub    %rsi,%r15
  add    %rbp,%rsi
  add    %r12,%rsi
  mov    %r15,%rdx
  call   <strncpy@plt>
  mov    0x10(%rsp),%r8
  cmpl   $0x1,0x8(%rsp)
  movb   $0x0,(%r8,%r15,1)
  mov    %rbx,%r15
  jne    L46
  lea    0x1(%rbx),%r15
  cmp    %r14,%r15
  cmova  %rbx,%r15
L46:
  mov    %r8,%rdi
  mov    %r8,0x8(%rsp)
  call   <getenv@plt>
  mov    0x8(%rsp),%r8
  test   %rax,%rax
  je     L56
  mov    %r12,%rdi
  mov    %r8,0x18(%rsp)
  mov    %rax,0x10(%rsp)
  call   <strlen@plt>
  mov    0x10(%rsp),%rdi
  mov    %rax,0x8(%rsp)
  call   <strlen@plt>
  mov    %rbp,%rcx
  mov    0x8(%rsp),%rbp
  sub    %r15,%rcx
  add    %rcx,%rbp
  add    %rbp,%rax
  lea    0x1(%rax),%rdi
  mov    %rax,0x8(%rsp)
  call   <malloc@plt>
  mov    0x10(%rsp),%r9
  mov    0x18(%rsp),%r8
  test   %rax,%rax
  mov    %rax,%rbp
  je     L56
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %rax,%rdi
  mov    %r8,0x10(%rsp)
  mov    %r9,0x18(%rsp)
  call   <strncpy@plt>
  movb   $0x0,0x0(%rbp,%r13,1)
  mov    0x18(%rsp),%rsi
  mov    %rbp,%rdi
  mov    $0x1,%r13d
  call   <strcat@plt>
  lea    (%r12,%r15,1),%rsi
  mov    %rbp,%rdi
  call   <strcat@plt>
  mov    %r12,%rdi
  mov    %rbp,%r12
  call   <free@plt>
  mov    0x8(%rsp),%r14
  mov    0x10(%rsp),%r8
L81:
  mov    %r8,%rdi
  call   <free@plt>
  cmp    %r13,%r14
  ja     L29
L157:
  add    $0x28,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L56:
  lea    0x1(%rbx),%r13
  jmp    L81
L113:
  lea    0x1(%rbx),%r13
  jmp    L95
```

assistant: ```c
char *ConfigConvertStrWithResolvEnvToStr(const char *str) {
  size_t beg, end, i, max;
  char *env_var, *env_str, *new, *res;
  if ((res = strdup(str)) == NULL)
    return NULL;
  max = strlen(res);
  for (i = 0; i < max; i++)
    if (res[i] == '$') {
      int firstIsBlock = 0;
      beg = i + 1;
      if (res[beg] == '{') {
        firstIsBlock = 1;
        i++;
      }
      while (i < max) {
        i++;
        if (!((res[i] >= 'a' && res[i] <= 'z') || (res[i] >= 'A' && res[i] <= 'Z') || (res[i] >= '0' && res[i] <= '9') || (res[i] == '_')))
          break;
      }
      end = i;
      env_str = malloc(end - beg + 1);
      if (env_str != NULL) {
        strncpy(env_str, res + beg + firstIsBlock, end - beg - firstIsBlock);
        env_str[end - beg - firstIsBlock] = '\0';
        if (firstIsBlock == 1 && (end + 1) <= max)
          end++;
        if ((env_var = getenv(env_str))) {
          size_t len;
          len = strlen(res) - (end - beg) + strlen(env_var) + 1;
          new = malloc(len);
          if (new != NULL) {
            strncpy(new, res, beg - 1);
            new[beg - 1] = '\0';
            strcat(new, env_var);
            strcat(new, res + end);
            free(res);
            res = new;
            i = 0;
            max = len - 1;
          }
        }
        free(env_str);
      }
    }
  return (res);
}
```