user: 下面的汇编指令对应的C源代码是什么：

```asm
<string_envformat>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x118,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  lea    0x200(%rax),%ebp
  movslq %ebp,%rbp
  mov    %rbp,%rdi
  call   <malloc@plt>
  movsbl (%rbx),%edi
  mov    %rax,%r12
  lea    -0x1(%rax,%rbp,1),%rbp
  mov    %rax,%r14
  test   %dil,%dil
  je     L112
  cmp    %rbp,%rax
  jae    L112
  xor    %r15d,%r15d
  mov    %rsp,%r13
  jmp    L119
  nopl   0x0(%rax)
L50:
  test   %r15,%r15
  jne    L63
  mov    %dil,(%r14)
  mov    %rbx,%rax
  add    $0x1,%r14
L45:
  movsbl 0x1(%rax),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L43
L79:
  cmp    %rbp,%r14
  jae    L112
L119:
  cmp    $0x24,%dil
  jne    L50
  movsbl 0x1(%rbx),%edi
  lea    0x1(%rbx),%rax
  cmp    $0x24,%dil
  je     L133
  mov    %dil,(%rsp)
  mov    %rax,%rbx
  mov    %r13,%r15
L63:
  call   <isalnum@plt>
  test   %rax,%rax
  je     L12
  movzbl (%rbx),%eax
  add    $0x1,%r15
  mov    %al,-0x1(%r15)
  mov    %rbx,%rax
  add    $0x1,%rbx
  movsbl 0x1(%rax),%edi
  test   %dil,%dil
  jne    L79
L43:
  test   %r15,%r15
  je     L112
  movb   $0x0,(%r15)
  mov    %rsp,%rdi
  call   <getenv@plt>
  mov    %ebp,%edx
  mov    %r14,%rdi
  sub    %r14d,%edx
  mov    %rax,%r13
  mov    %rax,%rsi
  call   <strncpy@plt>
  mov    %r13,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%r14
L112:
  movb   $0x0,(%r14)
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L87
  add    $0x118,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L12:
  movb   $0x0,(%r15)
  mov    %r13,%rdi
  call   <getenv@plt>
  mov    %ebp,%edx
  mov    %r14,%rdi
  mov    %rax,%r15
  sub    %r14d,%edx
  mov    %rax,%rsi
  call   <strncpy@plt>
  mov    %r15,%rdi
  call   <strlen@plt>
  cltq
  add    %r14,%rax
  cmp    %rbp,%rax
  ja     L112
  movzbl (%rbx),%edx
  lea    0x1(%rax),%r14
  xor    %r15d,%r15d
  mov    %dl,(%rax)
  mov    %rbx,%rax
  jmp    L45
  nopl   (%rax)
L133:
  movb   $0x24,(%r14)
  mov    %rax,%rbx
  add    $0x1,%r14
  jmp    L50
L87:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
char *string_envformat(const char *str) {
  size_t ressize = strlen(str) + 512;
  char *begin_res = malloc(ressize);
  char *res = begin_res;
  char *resend = res + ressize - 1;
  char tvarname[256];
  char *varname = NULL;
  while (*str) {
    if (res >= resend) {
      goto end;
    }
    if (*str == '$') {
      str++;
      if (*str == '$') {
        *res++ = '$';
      } else {
        varname = tvarname;
        *varname = *str;
      }
    }
    if (varname) {
      if (isalnum(*str))
        *varname++ = *str;
      else {
        *varname = 0;
        char *env = getenv(tvarname);
        strncpy(res, env, resend - res);
        size_t lenv = strlen(env);
        if (res + lenv > resend)
          goto end;
        res += lenv;
        varname = NULL;
        *res++ = *str;
      }
    } else
      *res++ = *str;
    str++;
  }
  if (varname) {
    *varname = 0;
    char *env = getenv(tvarname);
    strncpy(res, env, resend - res);
    res += strlen(env);
  }
end:
  *res = 0;
  return begin_res;
}
```