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

```asm
<create_dir>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  sub    $0xa0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  jmp    L140
  nopl   (%rax)
L131:
  cltq
  lea    -0x1(%rbp,%rax,1),%rax
  cmpb   $0x2f,(%rax)
  jne    L121
  movb   $0x0,(%rax)
L140:
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    $0x1,%eax
  jg     L131
L121:
  lea    0x4(%rsp),%r14
  mov    %rbp,%rdi
  mov    %r14,%rsi
  call   <stat@plt>
  test   %rax,%rax
  jne    L74
  mov    0xc(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %eax,%eax
  jne    L61
L74:
  lea    0x10(%rsp),%r13
  mov    %rbp,%rsi
  mov    $0x80,%edx
  mov    %r13,%rdi
  call   <strncpy@plt>
  mov    $0x2f,%esi
  mov    %r13,%rdi
  call   <strrchr@plt>
  cmp    %r13,%rax
  je     L96
  movb   $0x0,(%rax)
L29:
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <create_dir>
  mov    %eax,%r12d
  test   %eax,%eax
  je     L60
L145:
  mov    $0x1,%r12d
L128:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L144
  add    $0xa0,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L60:
  mov    %r14,%rsi
  mov    %r13,%rdi
  call   <stat@plt>
  mov    0xc(%rsp),%esi
  mov    %rbp,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  jne    L11
  test   %ebx,%ebx
  je     L13
  mov    0x4(%rsp),%edx
  mov    0x8(%rsp),%esi
  mov    %rbp,%rdi
  call   <chown@plt>
  jmp    L128
L13:
  mov    %rbp,%rdx
  lea    D3(%rip),%rsi
  mov    $0x2,%edi
  call   <log_event@plt>
  mov    0x4(%rsp),%edx
  mov    0x8(%rsp),%esi
  mov    %rbp,%rdi
  call   <chown@plt>
  test   %rax,%rax
  jne    L26
  nopl   0x0(%rax,%rax,1)
L61:
  xor    %r12d,%r12d
  jmp    L128
L96:
  movb   $0x0,0x11(%rsp)
  jmp    L29
  nopw   0x0(%rax,%rax,1)
L11:
  test   %ebx,%ebx
  jne    L145
  mov    %rbp,%rdx
  lea    D9(%rip),%rsi
  mov    $0x1,%edi
  call   <log_event@plt>
  jmp    L145
L26:
  mov    %rbp,%rdx
  lea    D13(%rip),%rsi
  mov    $0x4,%edi
  call   <log_event@plt>
  jmp    L128
L144:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D3
datatype: string
name: unpack_data
arguments: label: D9
datatype: string
name: unpack_data
arguments: label: D13
datatype: string

tool: D3: directory created

tool: D9: failed to create directory

tool: D13: failed to set owner on directory (non fatal)

assistant: ```c
int create_dir(char *dirname, int nolog) {
  struct stat fstatus;
  char buffer[128], *delim;
  int i;
  while ((i = strlen(dirname)) > 1 && dirname[i - 1] == '/')
    dirname[i - 1] = '\0';
  if (stat(dirname, &fstatus) || !S_ISDIR(fstatus.st_mode)) {
    strncpy(buffer, dirname, 128);
    delim = strrchr(buffer, '/');
    if (delim != buffer)
      delim[0] = '\0';
    else
      delim[1] = '\0';
    if (create_dir(buffer, nolog) != 0)
      return 1;
    stat(buffer, &fstatus);
    if (mkdir(dirname, fstatus.st_mode) != 0) {
      if (!nolog)
        log_event(1, "failed to create directory", dirname);
      return 1;
    } else if (!nolog)
      log_event(2, "directory created", dirname);
    if (chown(dirname, fstatus.st_uid, fstatus.st_gid) != 0)
      if (!nolog)
        log_event(4, "failed to set owner on directory (non fatal)", dirname);
  }
  return 0;
}
```