user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<expand_envars>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r14
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <strlen@plt>
  add    %eax,%eax
  mov    %eax,-0x48(%rbp)
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,%r15
  movzbl (%r14),%eax
  test   %al,%al
  je     L32
  mov    $0x0,%r13d
  jmp    L162
L229:
  cmpb   $0x7b,0x1(%r14)
  je     L161
  lea    0x1(%r14),%rax
  mov    %rax,-0x58(%rbp)
  movzbl 0x1(%r14),%edi
  movl   $0x0,-0x5c(%rbp)
  test   %dil,%dil
  je     L154
L123:
  mov    -0x58(%rbp),%r12
  mov    $0x0,%ebx
  jmp    L20
L154:
  movl   $0x0,-0x44(%rbp)
  mov    $0x0,%ebx
  jmp    L241
L161:
  lea    0x2(%r14),%rax
  mov    %rax,-0x58(%rbp)
  movzbl 0x2(%r14),%edi
  test   %dil,%dil
  je     L177
  movl   $0x1,-0x5c(%rbp)
  jmp    L123
L236:
  mov    -0x50(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x44(%rbp)
  add    $0x1,%rbx
  add    $0x1,%r12
  movzbl (%r12),%edi
  test   %dil,%dil
  je     L222
L20:
  mov    %ebx,-0x50(%rbp)
  mov    %ebx,-0x44(%rbp)
  movsbl %dil,%edi
  call   <isalnum@plt>
  test   %rax,%rax
  jne    L236
  cmpb   $0x5f,(%r12)
  je     L236
  cmpl   $0x0,-0x5c(%rbp)
  je     L241
  cmpb   $0x7d,(%r12)
  jne    L177
L241:
  mov    %rsp,-0x50(%rbp)
  mov    -0x44(%rbp),%eax
  add    $0x1,%eax
  cltq
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L37:
  cmp    %rdx,%rsp
  je     L268
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L37
L268:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L126
  orq    $0x0,-0x8(%rsp,%rax,1)
L126:
  mov    %rsp,%r12
  mov    -0x44(%rbp),%edx
  mov    -0x58(%rbp),%rsi
  mov    %rsp,%rdi
  call   <strncpy@plt>
  movslq -0x44(%rbp),%rax
  movb   $0x0,(%rsp,%rax,1)
  lea    D9(%rip),%rsi
  mov    %rsp,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L92
  movzbl (%r12),%eax
  sub    $0x30,%eax
  cmp    $0x9,%al
  ja     L12
L92:
  mov    %r12,%rdi
  call   <getenv@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L159
  movslq %r13d,%rax
  movb   $0x0,(%r15,%rax,1)
L12:
  mov    -0x50(%rbp),%rsp
  jmp    L177
L159:
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %eax,%r13d
  cmp    -0x48(%rbp),%r13d
  jge    L74
L66:
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   <strcat@plt>
  mov    -0x5c(%rbp),%eax
  lea    0x1(%rax,%rax,1),%eax
  cltq
  add    %rbx,%rax
  add    %rax,%r14
  mov    -0x50(%rbp),%rsp
  jmp    L79
L74:
  mov    -0x48(%rbp),%ecx
  lea    (%rax,%rcx,2),%eax
  mov    %eax,-0x48(%rbp)
  mov    %eax,%esi
  mov    %r15,%rdi
  call   <realloc@plt>
  mov    %rax,%r15
  jmp    L66
L61:
  movzbl (%r14),%eax
  movslq %r13d,%r13
  mov    %al,(%r15,%r13,1)
  movslq %ebx,%rax
  movb   $0x0,(%r15,%rax,1)
  mov    %ebx,%r13d
  lea    0x1(%r14),%r14
L79:
  movzbl (%r14),%eax
  test   %al,%al
  je     L248
L162:
  cmp    $0x24,%al
  je     L229
L177:
  lea    0x1(%r13),%ebx
  cmp    -0x48(%rbp),%ebx
  jl     L61
  shll   -0x48(%rbp)
  mov    -0x48(%rbp),%eax
  mov    %eax,%esi
  mov    %r15,%rdi
  call   <realloc@plt>
  mov    %rax,%r15
  jmp    L61
L32:
  mov    $0x0,%r13d
L248:
  movslq %r13d,%r13
  movb   $0x0,(%r15,%r13,1)
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L291
  mov    %r15,%rax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L222:
  cmpl   $0x0,-0x5c(%rbp)
  jne    L177
  jmp    L241
L291:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D9
datatype: string

tool: D9: ONDIRWD

assistant: ```c
char *expand_envars(const char *in) {
  int inlen = strlen(in), outmax = inlen * 2, outlen = 0;
  char *out = calloc(1, outmax);
  while (*in) {
    const char *mark = in;
    if (*in == '$') {
      int bracketed = 0, varlen = 0;
      const char *varstart;
      ++in;
      if (*in == '{') {
        ++in;
        bracketed = 1;
      }
      varstart = in;
      while (in[varlen] && (isalnum(in[varlen]) || in[varlen] == '_'))
        ++varlen;
      if (bracketed && in[varlen] != '}')
        in = mark;
      else {
        char var[varlen + 1];
        const char *val;
        strncpy(var, varstart, varlen);
        var[varlen] = 0;
        if (strcmp(var, "ONDIRWD") && (var[0] < '0' || var[0] > '9')) {
          in = mark;
        } else {
          val = getenv(var);
          if (val) {
            int vallen = strlen(val);
            if (outlen + vallen >= outmax) {
              outmax = outmax * 2 + vallen;
              out = realloc(out, outmax);
            }
            strcat(out, val);
            outlen += vallen;
            in = mark + varlen + bracketed * 2 + 1;
            continue;
          } else {
            in = mark;
            out[outlen] = 0;
          }
        }
      }
    }
    if (outlen + 1 >= outmax) {
      outmax *= 2;
      out = realloc(out, outmax);
    }
    out[outlen++] = *in++;
    out[outlen] = 0;
  }
  out[outlen] = 0;
  return out;
}
```