user: What is the c source code of the assembly code below:

```asm
<string_envformat>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x118,%rsp
  mov    %rdi,%rbx
  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>
  mov    %rax,%r14
  lea    -0x1(%rax,%rbp,1),%r13
  movzbl (%rbx),%eax
  test   %al,%al
  je     L41
  cmp    %r13,%r14
  jae    L149
  mov    %r14,%rbp
  mov    $0x0,%r12d
  mov    %rsp,%r15
  jmp    L67
L15:
  lea    0x1(%rbx),%rdx
  movzbl 0x1(%rbx),%eax
  cmp    $0x24,%al
  je     L54
  mov    %al,(%rsp)
  mov    %rdx,%rbx
  mov    %r15,%r12
L118:
  movsbl (%rbx),%edi
  call   <isalnum@plt>
  test   %rax,%rax
  je     L93
  movzbl (%rbx),%eax
  mov    %al,(%r12)
  mov    %rbx,%rax
  lea    0x1(%r12),%r12
L10:
  lea    0x1(%rax),%rbx
  movzbl 0x1(%rax),%eax
  test   %al,%al
  je     L126
  cmp    %r13,%rbp
  jae    L103
L67:
  cmp    $0x24,%al
  je     L15
L53:
  test   %r12,%r12
  jne    L118
  movzbl (%rbx),%eax
  mov    %al,0x0(%rbp)
  mov    %rbx,%rax
  lea    0x1(%rbp),%rbp
  jmp    L10
L54:
  movb   $0x24,0x0(%rbp)
  lea    0x1(%rbp),%rbp
  mov    %rdx,%rbx
  jmp    L53
L93:
  movb   $0x0,(%r12)
  mov    %r15,%rdi
  call   <getenv@plt>
  mov    %rax,%r12
  mov    %r13d,%edx
  sub    %ebp,%edx
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    %r12,%rdi
  call   <strlen@plt>
  cltq
  add    %rbp,%rax
  cmp    %r13,%rax
  ja     L103
  lea    0x1(%rax),%rbp
  movzbl (%rbx),%edx
  mov    %dl,(%rax)
  mov    %rbx,%rax
  mov    $0x0,%r12d
  jmp    L10
L126:
  test   %r12,%r12
  je     L103
  movb   $0x0,(%r12)
  mov    %rsp,%rdi
  call   <getenv@plt>
  mov    %rax,%rbx
  mov    %r13d,%edx
  sub    %ebp,%edx
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  cltq
  add    %rax,%rbp
L103:
  movb   $0x0,0x0(%rbp)
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L115
  mov    %r14,%rax
  add    $0x118,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L41:
  mov    %r14,%rbp
  jmp    L103
L149:
  mov    %r14,%rbp
  jmp    L103
L115:
  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;
}
```