user: Please show me the C implementation that matches the assembly code listed below:

```asm
<SubVar>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r12
  push   %rbx
  sub    $0x60,%rsp
  mov    %edi,%eax
  mov    %rsi,-0x50(%rbp)
  mov    %rdx,-0x58(%rbp)
  mov    %rcx,-0x60(%rbp)
  mov    %r8,-0x68(%rbp)
  mov    %al,-0x44(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x38(%rbp)
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x34(%rbp)
  mov    -0x68(%rbp),%rax
  mov    (%rax),%ebx
  mov    -0x50(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x38(%rbp),%eax
  sub    %edx,%eax
  lea    -0x1(%rax),%r12d
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    %r12d,%eax
  cmp    %eax,%ebx
  jg     L46
  mov    -0x68(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x34(%rbp),%eax
  mov    $0x200,%edx
  cmp    %edx,%eax
  cmovl  %edx,%eax
  add    %ecx,%eax
  movslq %eax,%rdx
  mov    -0x60(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x30(%rbp)
  mov    -0x68(%rbp),%rax
  mov    (%rax),%ecx
  mov    -0x34(%rbp),%eax
  mov    $0x200,%edx
  cmp    %edx,%eax
  cmovl  %edx,%eax
  lea    (%rcx,%rax,1),%edx
  mov    -0x68(%rbp),%rax
  mov    %edx,(%rax)
  jmp    L102
L46:
  mov    -0x60(%rbp),%rax
  mov    %rax,-0x30(%rbp)
L102:
  mov    -0x68(%rbp),%rax
  mov    (%rax),%eax
  cltq
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x30(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  cmpq   $0x0,-0x20(%rbp)
  jne    L117
  lea    D0(%rip),%rax
  mov    %rax,%rsi
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <html_error@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L117:
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  jmp    L47
L10:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    %al,-0x44(%rbp)
  jne    L35
  mov    -0x28(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jbe    L76
  mov    -0x28(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L76
  addq   $0x1,-0x28(%rbp)
  jmp    L47
L76:
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  lea    D22(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcspn@plt>
  mov    %eax,-0x34(%rbp)
  mov    -0x34(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x39(%rbp)
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x50(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %eax,%eax
  jne    L3
  mov    -0x28(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdi
  movsbl -0x39(%rbp),%esi
  mov    -0x58(%rbp),%rcx
  mov    -0x20(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  mov    %rdi,%r9
  mov    %esi,%r8d
  lea    D36(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  mov    -0x30(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L17
L3:
  mov    -0x18(%rbp),%rax
  movzbl -0x39(%rbp),%edx
  mov    %dl,(%rax)
L17:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x28(%rbp)
  jmp    L47
L35:
  addq   $0x1,-0x28(%rbp)
L47:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L10
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x30(%rbp),%rax
  add    $0x60,%rsp
  pop    %rbx
  pop    %r12
  pop    %rbp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D0
data_type: string
name: parse_data
arguments: data_label: D10
data_type: string
name: parse_data
arguments: data_label: D22
data_type: string
name: parse_data
arguments: data_label: D36
data_type: string

tool: D0: Unable to allocate memory

tool: D10: FI Error

tool: D22:  ,()'
:;.{}[]-+=~!@#$%^*<>"

tool: D36: %s%s%c%s

assistant: ```c
char *SubVar(char sep, char *var_name, char *var_value, char *oldbuf, int *bufsize) {
  char *buf, *s, *t;
  int l, n;
  char o;
  char *local_buf;
  l = strlen(oldbuf);
  n = strlen(var_value);
  if (l - (int)strlen(var_name) - 1 + (int)strlen(var_value) > (int)(*bufsize - 1)) {
    buf = realloc(oldbuf, *bufsize + ((n > 512) ? n : 512));
    *bufsize += ((n > 512) ? n : 512);
  } else
    buf = oldbuf;
  local_buf = malloc(*bufsize * sizeof(char));
  strcpy(local_buf, buf);
  if (!local_buf) {
    html_error("FI Error", "Unable to allocate memory");
    exit(-1);
  }
  s = local_buf;
  while (*s != '\0') {
    if (*s == sep) {
      if (s > local_buf && *(s - 1) == '\\') {
        s++;
        continue;
      }
      n = strcspn(s + 1, " ,()'\n:;.{}[]-+=~!@#$%^*<>\"");
      t = s + n + 1;
      o = *t;
      *t = '\0';
      if (!strcasecmp(var_name, s + 1)) {
        *s = '\0';
        sprintf(buf, "%s%s%c%s", local_buf, var_value, o, t + 1);
        strcpy(local_buf, buf);
      } else {
        *t = o;
      }
      s = t + 1;
    } else
      s++;
  }
  free(local_buf);
  return (buf);
}
```