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

```asm
<do_parse_glob>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdx,%r14
  xor    %edx,%edx
  push   %r13
  push   %r12
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x38,%rsp
  mov    %r9,0x8(%rsp)
  lea    0x10(%rsp),%r13
  mov    %r13,%rcx
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    D19(%rip),%rax
  mov    (%rax),%esi
  call   <glob@plt>
  mov    0x8(%rsp),%r9
  test   %eax,%eax
  mov    %eax,%r12d
  jne    L174
  test   %r9,%r9
  je     L58
  cmpb   $0x0,(%r9)
  je     L0
L58:
  mov    $0x1,%edi
  call   <assert@plt>
  mov    (%rbx),%rdi
  test   %rdi,%rdi
  je     L172
  call   <free@plt>
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <w_newword@plt>
  mov    %rax,(%rbx)
L172:
  mov    0x10(%rsp),%eax
  xor    %ebx,%ebx
  test   %eax,%eax
  jg     L112
  jmp    L105
  nopl   0x0(%rax,%rax,1)
L179:
  mov    %rbp,%rdi
  call   <w_addword@plt>
  test   %rax,%rax
  jne    L160
  add    $0x1,%rbx
  cmp    %ebx,0x10(%rsp)
  jle    L105
L112:
  mov    0x18(%rsp),%rax
  mov    (%rax,%rbx,8),%rdi
  call   <strdup@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  jne    L179
L160:
  mov    %r13,%rdi
  call   <globfree@plt>
L43:
  mov    D3(%rip),%rax
  mov    (%rax),%r12d
L120:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L183
  add    $0x38,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L105:
  mov    %r13,%rdi
  call   <globfree@plt>
  jmp    L120
  nopw   0x0(%rax,%rax,1)
L174:
  mov    D32(%rip),%rax
  xor    %edi,%edi
  cmp    %r12d,(%rax)
  sete   %dil
  call   <assert@plt>
  mov    D3(%rip),%rax
  mov    (%rax),%r12d
  jmp    L120
  nopl   0x0(%rax)
L0:
  mov    0x18(%rsp),%rax
  xor    %edi,%edi
  cmpq   $0x0,(%rax)
  setne  %dil
  xor    %ebp,%ebp
  call   <assert@plt>
  mov    0x18(%rsp),%rax
  mov    (%rbx),%rdi
  mov    %r15,%rdx
  mov    %r14,%rsi
  mov    (%rax),%rcx
  call   <w_addstr@plt>
  cmpl   $0x1,0x10(%rsp)
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  jg     L143
  jmp    L118
  nopl   0x0(%rax,%rax,1)
L86:
  mov    0x18(%rsp),%rax
  add    $0x1,%rbp
  mov    %r15,%rdx
  mov    %r14,%rsi
  mov    (%rax,%rbp,8),%rcx
  call   <w_addstr@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  lea    0x1(%rbp),%eax
  cmp    0x10(%rsp),%eax
  jge    L118
L143:
  test   %rdi,%rdi
  je     L118
  mov    $0x20,%ecx
  mov    %r15,%rdx
  mov    %r14,%rsi
  call   <w_addchar@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  jne    L86
L118:
  mov    %r13,%rdi
  call   <globfree@plt>
  cmpq   $0x0,(%rbx)
  jne    L120
  jmp    L43
L183:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int do_parse_glob(const char *glob_word, char **word, size_t *word_length, size_t *max_length, wordexp_t *pwordexp, const char *ifs) {
  int error;
  int match;
  glob_t globbuf;
  error = glob(glob_word, GLOB_NOCHECK, NULL, &globbuf);
  if (error != 0) {
    assert(error == GLOB_NOSPACE);
    return WRDE_NOSPACE;
  }
  if (ifs && !*ifs) {
    assert(globbuf.gl_pathv[0] != NULL);
    *word = w_addstr(*word, word_length, max_length, globbuf.gl_pathv[0]);
    for (match = 1; match < globbuf.gl_pathc && *word != NULL; ++match) {
      *word = w_addchar(*word, word_length, max_length, ' ');
      if (*word != NULL)
        *word = w_addstr(*word, word_length, max_length, globbuf.gl_pathv[match]);
    }
    globfree(&globbuf);
    return *word ? 0 : WRDE_NOSPACE;
  }
  assert(ifs == NULL || *ifs != '\0');
  if (*word != NULL) {
    free(*word);
    *word = w_newword(word_length, max_length);
  }
  for (match = 0; match < globbuf.gl_pathc; ++match) {
    char *matching_word = strdup(globbuf.gl_pathv[match]);
    if (matching_word == NULL || w_addword(pwordexp, matching_word)) {
      globfree(&globbuf);
      return WRDE_NOSPACE;
    }
  }
  globfree(&globbuf);
  return 0;
}
```