user: Converte this assembly snippet into its equivalent C code:

```asm
<buildConfigPath>:
  endbr64
  push   %r15
  xor    %r15d,%r15d
  push   %r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  sub    $0x638,%rsp
  mov    %rdi,0x10(%rsp)
  lea    0x20(%rsp),%rbx
  mov    %rbx,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x628(%rsp)
  xor    %eax,%eax
  call   <strcpy@plt>
  lea    D2(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcat@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%ebp
  lea    0x220(%rsp),%rax
  mov    %rax,(%rsp)
  nopl   (%rax)
L138:
  cmp    %ebp,%r15d
  jge    L128
L56:
  movslq %r15d,%r8
  mov    $0x24,%esi
  lea    (%rbx,%r8,1),%r13
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L28
  sub    %rbx,%rax
  mov    %eax,%edx
  sub    %r15d,%edx
  test   %edx,%edx
  jg     L116
  add    %edx,%r12d
  mov    %eax,%r15d
L49:
  lea    0x1(%r15),%r10d
  mov    $0x1,%edx
  movabs $0xffff3feffffffffe,%rax
  movslq %r10d,%rsi
  movzbl 0x20(%rsp,%rsi,1),%ecx
  sar    %cl,%rax
  and    $0x1,%eax
  cmp    $0x30,%cl
  cmovae %edx,%eax
  cmp    $0x7e,%cl
  je     L88
  test   %al,%al
  je     L88
  movslq %r15d,%rax
  mov    $0x1,%edx
  lea    (%rbx,%rax,1),%rdi
  nopl   0x0(%rax,%rax,1)
L120:
  movzbl 0x1(%rdi,%rdx,1),%eax
  mov    %edx,%r8d
  lea    (%r10,%rdx,1),%r15d
  add    $0x1,%rdx
  cmp    $0x2f,%al
  ja     L5
  movabs $0xffff3feffffffffe,%rcx
  bt     %rax,%rcx
  jb     L120
L136:
  lea    0x420(%rsp),%rdi
  add    %rbx,%rsi
  mov    %r8d,%edx
  mov    %r8d,0x1c(%rsp)
  mov    %rdi,0x8(%rsp)
  call   <memcpy@plt>
  movslq 0x1c(%rsp),%r8
  mov    0x8(%rsp),%rdi
  movb   $0x0,0x420(%rsp,%r8,1)
  call   <getenv@plt>
  test   %rax,%rax
  je     L138
  mov    %rax,%rdi
  mov    %rax,0x8(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rsi
  lea    (%r12,%rax,1),%r8d
  mov    %eax,%edx
  cmp    $0x1fd,%r8d
  jg     L138
  movslq %r12d,%rdi
  add    (%rsp),%rdi
  mov    %r8d,0x8(%rsp)
  call   <memcpy@plt>
  mov    0x8(%rsp),%r12d
  cmp    %ebp,%r15d
  jl     L56
  nopw   0x0(%rax,%rax,1)
L128:
  mov    (%rsp),%rsi
  mov    0x10(%rsp),%rdi
  movslq %r12d,%r12
  movb   $0x0,0x220(%rsp,%r12,1)
  call   <strcpy@plt>
  mov    0x628(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L111
  add    $0x638,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L28:
  mov    %ebp,%r14d
  movslq %r12d,%rdi
  mov    %r13,%rsi
  add    (%rsp),%rdi
  sub    %r15d,%r14d
  mov    %ebp,%r15d
  mov    %r14d,%edx
  add    %r14d,%r12d
  call   <memcpy@plt>
  jmp    L138
  nopl   0x0(%rax,%rax,1)
L5:
  cmp    $0x7e,%al
  jne    L120
  jmp    L136
  nopl   (%rax)
L116:
  movslq %r12d,%rdi
  mov    %r13,%rsi
  add    (%rsp),%rdi
  mov    %edx,0x8(%rsp)
  mov    %eax,%r15d
  call   <memcpy@plt>
  mov    0x8(%rsp),%edx
  add    %edx,%r12d
  jmp    L49
L88:
  mov    %r10d,%r15d
  xor    %r8d,%r8d
  jmp    L136
L111:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D2
data_type: string

tool: D2: dumpasn1.cfg

assistant: ```c
void buildConfigPath(char *path, const char *pathTemplate) {
  char pathBuffer[512], newPath[512];
  int pathLen, pathPos = 0, newPathPos = 0;
  strcpy(pathBuffer, pathTemplate);
  strcat(pathBuffer, "dumpasn1.cfg");
  pathLen = strlen(pathBuffer);
  while (pathPos < pathLen) {
    char *strPtr;
    int substringSize;
    if ((strPtr = strstr(pathBuffer + pathPos, "$")) != NULL)
      substringSize = (int)((strPtr - pathBuffer) - pathPos);
    else
      substringSize = pathLen - pathPos;
    if (substringSize > 0) {
      memcpy(newPath + newPathPos, pathBuffer + pathPos, substringSize);
    }
    newPathPos += substringSize;
    pathPos += substringSize;
    if (strPtr != NULL) {
      char envName[512], *envString;
      int i;
      pathPos++;
      for (i = 0; !(((pathBuffer[pathPos + i]) == '/') || ((pathBuffer[pathPos + i]) == '.') || ((pathBuffer[pathPos + i]) == '$') || ((pathBuffer[pathPos + i]) == '\0') || ((pathBuffer[pathPos + i]) == '~')); i++)
        ;
      memcpy(envName, pathBuffer + pathPos, i);
      envName[i] = '\0';
      if ((envString = getenv(envName)) != NULL) {
        const int envStrLen = strlen(envString);
        if (newPathPos + envStrLen < 512 - 2) {
          memcpy(newPath + newPathPos, envString, envStrLen);
          newPathPos += envStrLen;
        }
      }
      pathPos += i;
    }
  }
  newPath[newPathPos] = '\0';
  strcpy(path, newPath);
}
```