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

```asm
<nbl_extract_all>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L7
  movl   $0x0,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  add    $0x21,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  jmp    L10
L7:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  add    $0x21,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x38(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x18(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  je     L10
  mov    -0x18(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  je     L10
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movb   $0x2f,(%rax)
L10:
  mov    -0x28(%rbp),%rax
  mov    0xc(%rax),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L14
L6:
  mov    -0x1c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  shl    $0x5,%eax
  cltq
  lea    0x40(%rax),%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    $0x20,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x10(%rbp),%rax
  lea    D7(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L2
  mov    -0x1c(%rbp),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  shl    $0x5,%eax
  cltq
  lea    0x64(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x1c(%rbp),%ecx
  mov    %ecx,%eax
  add    %eax,%eax
  add    %ecx,%eax
  shl    $0x5,%eax
  cltq
  lea    0x60(%rax),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  mov    %eax,%ecx
  mov    -0x30(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x8(%rbp),%rax
  mov    %rax,%rcx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L2:
  addl   $0x1,-0x1c(%rbp)
L14:
  mov    -0x1c(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L6
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D7
type_guessed: string

tool: D7: wb

assistant: ```c
void nbl_extract_all(char *pstrBuffer, char *pstrData, char *pstrDestPath) {
  int i, iNbChunks, iLen;
  FILE *pFile;
  char *pstrFilename;
  if (pstrDestPath == NULL) {
    iLen = 0;
    pstrFilename = malloc(iLen + 0x20 + 1);
  } else {
    iLen = strlen(pstrDestPath);
    pstrFilename = malloc(iLen + 0x20 + 1);
    strcpy(pstrFilename, pstrDestPath);
    if (pstrDestPath[iLen - 1] != '/' && pstrDestPath[iLen - 1] != '\\')
      pstrFilename[iLen++] = '/';
  }
  iNbChunks = (*((int *)(pstrBuffer + 0x0C)));
  for (i = 0; i < iNbChunks; i++) {
    strncpy(pstrFilename + iLen, pstrBuffer + 0x40 + i * 0x60, 0x20);
    pFile = fopen(pstrFilename, "wb");
    if (pFile) {
      fwrite(pstrData + (*((unsigned int *)(pstrBuffer + 0x60 + i * 0x60))), 1, (*((unsigned int *)(pstrBuffer + 0x64 + i * 0x60))), pFile);
      fclose(pFile);
    }
  }
  free(pstrFilename);
}
```