user: What would the C source look like for the assembly code provided here?

```asm
<wg_split>:
  endbr64
  xor    %eax,%eax
  test   %ecx,%ecx
  je     L127
  push   %r15
  mov    %rdi,%r15
  push   %r14
  lea    -0x1(%rcx),%r14d
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x8,%rsp
  movzbl (%rdx),%ebx
  nop
L109:
  cmp    %r14d,%r13d
  jge    L266
L39:
  test   %bl,%bl
  je     L98
L166:
  cmp    $0x2,%eax
  je     L76
  cmp    $0x3,%eax
  je     L58
  test   %eax,%eax
  je     L210
  test   %bl,%bl
  jne    L166
L98:
  movb   $0x0,(%r12)
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L52:
  add    $0x1,%rbp
  mov    %bl,-0x1(%r12)
  movzbl 0x0(%rbp),%ebx
  test   %bl,%bl
  je     L151
L76:
  movsbl %bl,%edi
  call   <isspace@plt>
  test   %eax,%eax
  jne    L241
L240:
  cmp    $0x27,%bl
  je     L96
  add    $0x1,%r12
  cmp    $0x5c,%bl
  jne    L52
  movzbl 0x1(%rbp),%eax
  test   %al,%al
  je     L52
  mov    %eax,%ebx
  add    $0x2,%rbp
  mov    %bl,-0x1(%r12)
  movzbl 0x0(%rbp),%ebx
  test   %bl,%bl
  jne    L76
  xchg   %ax,%ax
L151:
  mov    $0x2,%eax
  cmp    %r14d,%r13d
  jl     L39
L266:
  test   %bl,%bl
  je     L98
  lea    0x1(%r13),%eax
  movslq %r13d,%r13
  mov    %r12,(%r15,%r13,8)
  movzbl 0x0(%rbp),%edx
  test   %dl,%dl
  je     L155
  nopl   (%rax)
L113:
  add    $0x1,%rbp
  mov    %dl,(%r12)
  add    $0x1,%r12
  movzbl 0x0(%rbp),%edx
  test   %dl,%dl
  jne    L113
L155:
  movb   $0x0,(%r12)
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L115:
  add    $0x1,%rbp
L210:
  movsbl 0x0(%rbp),%edi
  call   <isspace@plt>
  test   %eax,%eax
  jne    L115
  movslq %r13d,%rax
  add    $0x1,%r13d
  mov    %r12,(%r15,%rax,8)
  movzbl 0x0(%rbp),%ebx
  test   %bl,%bl
  je     L151
  movsbl %bl,%edi
  call   <isspace@plt>
  test   %eax,%eax
  je     L240
  nopl   0x0(%rax)
L241:
  movb   $0x0,(%r12)
  add    $0x1,%rbp
  movzbl 0x0(%rbp),%ebx
  xor    %eax,%eax
  add    $0x1,%r12
  jmp    L109
L213:
  add    $0x1,%rbp
L261:
  mov    %bl,-0x1(%r12)
  movzbl 0x0(%rbp),%ebx
  test   %bl,%bl
  je     L151
L58:
  cmp    $0x27,%bl
  je     L160
  add    $0x1,%r12
  cmp    $0x5c,%bl
  jne    L213
  movzbl 0x1(%rbp),%eax
  test   %al,%al
  je     L213
  add    $0x2,%rbp
  mov    %eax,%ebx
  jmp    L261
  nopl   0x0(%rax,%rax,1)
L96:
  movzbl 0x1(%rbp),%ebx
  mov    $0x3,%eax
  add    $0x1,%rbp
  jmp    L109
  nopw   0x0(%rax,%rax,1)
L160:
  movzbl 0x1(%rbp),%ebx
  mov    $0x2,%eax
  add    $0x1,%rbp
  jmp    L109
L127:
  ret
```

assistant: ```c
unsigned int wg_split(char **result, char *dest, char *src, int maxsegments) {
  char *p = src;
  char *w = dest;
  int cnt = 0;
  int state = 0;
  if (maxsegments == 0) {
    return 0;
  }
  maxsegments--;
  while (cnt < maxsegments && *p) {
    switch (state) {
    case 0:
      while (isspace((int)*p)) {
        p++;
      }
      state = 1;
    case 1:
      result[cnt] = w;
      cnt++;
      state = 2;
    case 2:
      while (*p) {
        if (isspace((int)*p)) {
          *w++ = '\0';
          p++;
          state = 0;
          break;
        } else if (*p == '\'') {
          p++;
          state = 3;
          break;
        } else if (*p == '\\' && p[1]) {
          p++;
          *w++ = *p++;
        } else {
          *w++ = *p++;
        }
      }
      break;
    case 3:
      while (*p) {
        if (*p == '\'') {
          p++;
          break;
        } else if (*p == '\\' && p[1]) {
          p++;
          *w++ = *p++;
        } else {
          *w++ = *p++;
        }
      }
      state = 2;
      break;
    }
  }
  if (!*p) {
    *w = '\0';
    return cnt;
  }
  result[cnt++] = w;
  while (*p) {
    *w++ = *p++;
  }
  *w = '\0';
  return cnt;
}
```