user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<capitalisepath>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    D14(%rip),%rax
  movq   $0x0,(%rax)
  call   <strlen@plt>
  lea    0x1(%rax),%edi
  call   <malloc@plt>
  mov    %rax,(%r14)
  test   %rax,%rax
  je     L156
  mov    %r13,%rdi
  call   <strlen@plt>
  lea    -0x1(%rax),%edx
  mov    %rdx,%r15
  test   %edx,%edx
  je     L113
  add    %r13,%rdx
  jmp    L129
  nopw   0x0(%rax,%rax,1)
L100:
  sub    $0x1,%rdx
  sub    $0x1,%r15d
  je     L58
L129:
  cmpb   $0x2f,(%rdx)
  jne    L100
  mov    %r15d,%edx
  xor    %ebx,%ebx
  xor    %ebp,%ebp
  jmp    L40
  nopl   0x0(%rax)
L75:
  add    %rbx,%r12
  cmp    $0x2f,%al
  je     L56
  cmp    $0x20,%al
  je     L56
  mov    %dil,(%r12)
L177:
  add    $0x1,%rbx
  cmp    %rdx,%rbx
  je     L169
L40:
  movzbl 0x0(%r13,%rbx,1),%edi
  mov    %ebp,%eax
  mov    %edi,%ebp
  test   %dil,%dil
  je     L169
  mov    (%r14),%r12
  test   %rbx,%rbx
  jne    L75
  cmp    $0x2f,%dil
  je     L63
  movzbl %dil,%edi
  mov    %rdx,0x8(%rsp)
  call   <toupper@plt>
  mov    %al,(%r12)
  mov    0x8(%rsp),%rdx
  jmp    L177
  nopw   0x0(%rax,%rax,1)
L184:
  movzbl 0x0(%r13,%rdx,1),%ecx
  mov    (%r14),%rax
  add    $0x1,%r15d
  mov    %r13,%rdi
  mov    %cl,(%rax,%rdx,1)
  call   <strlen@plt>
  mov    %r15d,%edx
L113:
  cmp    %rax,%rdx
  jb     L184
  mov    (%r14),%rdx
  movb   $0x0,(%rdx,%rax,1)
  mov    (%r14),%rdi
  call   <strlen@plt>
  mov    D17(%rip),%rdx
  cmp    %rax,(%rdx)
  mov    $0x0,%edx
  cmovb  %edx,%eax
L64:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L56:
  mov    %rdx,0x8(%rsp)
  call   <toupper@plt>
  mov    %al,(%r12)
  mov    0x8(%rsp),%rdx
  jmp    L177
  nopl   0x0(%rax,%rax,1)
L63:
  movb   $0x2f,(%r12)
  jmp    L177
  nopw   0x0(%rax,%rax,1)
L169:
  mov    %r13,%rdi
  mov    %rdx,0x8(%rsp)
  call   <strlen@plt>
  mov    0x8(%rsp),%rdx
  jmp    L113
  nopw   0x0(%rax,%rax,1)
L58:
  xor    %edx,%edx
  jmp    L113
L156:
  mov    $0xffffffff,%eax
  jmp    L64
```

assistant: ```c
int capitalisepath(const char *string, char **result) {
  unsigned char lastchar = 0;
  unsigned long len;
  errno = 0;
  if (!(*result = (char *)malloc(strlen(string) + 1))) {
    ;
    return -1;
  }
  unsigned int max;
  for (max = strlen(string) - 1; max > 0; --max) {
    unsigned char c = string[max];
    if (c == '/')
      break;
  }
  for (unsigned int n = 0; n < max; n++) {
    unsigned char c = string[n];
    if (0 == c)
      break;
    if (0 == n) {
      lastchar = c;
      if (lastchar != '/')
        (*result)[n] = toupper(c);
      else
        (*result)[n] = c;
    } else {
      if (lastchar == '/' || lastchar == ' ')
        (*result)[n] = toupper(c);
      else
        (*result)[n] = c;
      lastchar = c;
    }
  }
  for (; max < strlen(string); max++) {
    unsigned char c = string[max];
    (*result)[max] = c;
  }
  (*result)[strlen(string)] = '\0';
  len = strlen(*result);
  if (len > INT_MAX) {
    return 0;
  } else {
    return (int)len;
  }
}
```