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

```asm
<_globdir_split_pattern>:
  endbr64
  test   %rdi,%rdi
  je     L116
  push   %r13
  mov    %rdi,%rax
  mov    $0x2,%esi
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  movzbl (%rdi),%edx
  test   %dl,%dl
  jne    L124
  jmp    L82
  xchg   %ax,%ax
L184:
  movzbl 0x1(%rcx),%edx
  add    $0x1,%rax
  test   %dl,%dl
  je     L47
L124:
  mov    %rax,%rcx
  cmp    $0x2f,%dl
  jne    L184
  nopl   0x0(%rax)
L27:
  add    $0x1,%rax
  cmpb   $0x2f,(%rax)
  je     L27
  mov    %rax,%rcx
  add    $0x1,%rsi
  add    $0x1,%rax
  movzbl 0x1(%rcx),%edx
  test   %dl,%dl
  jne    L124
  nopl   0x0(%rax)
L47:
  mov    $0x8,%edi
  call   <calloc@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L113
  xor    %r12d,%r12d
  cmpb   $0x2f,0x0(%rbp)
  je     L160
  nopl   0x0(%rax,%rax,1)
L159:
  mov    $0x2f,%esi
  mov    %rbp,%rdi
  add    $0x1,%r12
  call   <_globat_strchrnul@plt>
  mov    %rbp,%rdi
  mov    %eax,%esi
  mov    %rax,%rbx
  sub    %ebp,%esi
  call   <strndup@plt>
  mov    %rax,-0x8(%r13,%r12,8)
  test   %rax,%rax
  je     L193
  cmpb   $0x0,(%rbx)
  jne    L43
  jmp    L113
  nopl   0x0(%rax)
L139:
  add    $0x1,%rbx
L43:
  movzbl 0x1(%rbx),%eax
  cmp    $0x2f,%al
  je     L139
  test   %al,%al
  je     L37
  lea    0x1(%rbx),%rbp
  jmp    L159
L37:
  lea    D18(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,0x0(%r13,%r12,8)
  test   %rax,%rax
  jne    L113
L193:
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <_globdir_freepattern@plt>
L113:
  add    $0x8,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L82:
  add    $0x8,%rsp
  mov    $0x1,%esi
  mov    $0x8,%edi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    10a0 <calloc@plt>
L160:
  lea    D18(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,0x0(%r13)
  test   %rax,%rax
  jne    L80
  jmp    L193
  nopl   (%rax)
L117:
  add    $0x1,%rbp
L80:
  cmpb   $0x2f,0x0(%rbp)
  je     L117
  mov    $0x1,%r12d
  jmp    L159
L116:
  mov    $0x1,%esi
  mov    $0x8,%edi
  jmp    10a0 <calloc@plt>
```

tool_calls: name: read_data
arguments: label: D18
type_infered: string

tool: D18: /

assistant: ```c
char **_globdir_split_pattern(const char *pattern) {
  size_t i, count = 1;
  char **parts = NULL;
  const char *c;
  if (pattern == NULL || pattern[0] == '\0') {
    return calloc(sizeof(char *), 1);
  }
  for (c = pattern; *c != '\0'; c++) {
    if (*c == '/') {
      count++;
      while (*c == '/') {
        c++;
      }
    }
  }
  if ((parts = calloc(sizeof(char *), count + 1)) == NULL) {
    return NULL;
  }
  c = pattern;
  i = 0;
  if (*c == '/') {
    if ((parts[i++] = strdup("/")) == NULL) {
      goto error;
    }
    while (*c == '/') {
      c++;
    }
  }
  while (1) {
    const char *sep = _globat_strchrnul(c, '/');
    if ((parts[i++] = strndup(c, sep - c)) == NULL) {
      goto error;
    }
    if (sep[0] == '\0') {
      break;
    }
    while (sep[1] == '/') {
      sep++;
    }
    if (sep[1] == '\0') {
      if ((parts[i++] = strdup("/")) == NULL) {
        goto error;
      }
      break;
    } else {
      c = sep + 1;
    }
  }
  return parts;
error:
  _globdir_freepattern(parts);
  return NULL;
}
```