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

```asm
<strtoul>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %edx,%r14d
  mov    %rdi,%rbp
L102:
  mov    %rbp,%r12
  add    $0x1,%rbp
  movsbl -0x1(%rbp),%ebx
  mov    %ebx,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L102
  cmp    $0x2d,%ebx
  je     L66
  movl   $0x0,0x1c(%rsp)
  cmp    $0x2b,%ebx
  je     L136
L42:
  test   $0xffffffef,%r14d
  jne    L200
  cmp    $0x30,%ebx
  je     L235
L200:
  test   %r14d,%r14d
  jne    L110
  cmp    $0x30,%ebx
  setne  %r14b
  movzbl %r14b,%r14d
  lea    0x8(%r14,%r14,1),%r14d
L110:
  mov    D6(%rip),%rax
  mov    (%rax),%rax
  movslq %r14d,%rcx
  mov    %rcx,(%rsp)
  mov    $0x0,%edx
  div    %rcx
  mov    %rax,%r15
  mov    %edx,0x18(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%r12d
  jmp    L39
L66:
  movsbl 0x0(%rbp),%ebx
  lea    0x2(%r12),%rbp
  movl   $0x1,0x1c(%rsp)
  jmp    L42
L136:
  movsbl 0x0(%rbp),%ebx
  lea    0x2(%r12),%rbp
  jmp    L42
L235:
  movzbl 0x0(%rbp),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L92
  movsbl 0x1(%rbp),%ebx
  add    $0x2,%rbp
  mov    $0x10,%r14d
  jmp    L110
L92:
  mov    $0x30,%ebx
  jmp    L200
L254:
  mov    %ebx,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L112
  mov    %ebx,%edi
  call   <isupper@plt>
  cmp    $0x1,%rax
  sbb    %eax,%eax
  and    $0x20,%eax
  add    $0x37,%eax
  sub    %eax,%ebx
  jmp    L249
L4:
  mov    $0xffffffff,%r13d
L95:
  add    $0x1,%rbp
  movsbl -0x1(%rbp),%ebx
L39:
  mov    %ebx,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L254
  sub    $0x30,%ebx
L249:
  cmp    %ebx,%r14d
  jle    L112
  test   %r13d,%r13d
  js     L4
  cmp    %r15,%r12
  ja     L4
  jne    L206
  mov    $0xffffffff,%r13d
  cmp    0x18(%rsp),%ebx
  jg     L95
L206:
  imul   (%rsp),%r12
  movslq %ebx,%rbx
  add    %rbx,%r12
  mov    $0x1,%r13d
  jmp    L95
L112:
  test   %r13d,%r13d
  js     L220
  mov    %r12,%rax
  neg    %rax
  cmpl   $0x0,0x1c(%rsp)
  cmovne %rax,%r12
  cmpq   $0x0,0x8(%rsp)
  je     L207
  test   %r13d,%r13d
  jne    L163
L194:
  mov    0x8(%rsp),%rax
  mov    0x10(%rsp),%rsi
  mov    %rsi,(%rax)
L207:
  mov    %r12,%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L220:
  mov    D6(%rip),%rax
  mov    (%rax),%r12
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  mov    D37(%rip),%rax
  mov    %edx,(%rax)
  cmpq   $0x0,0x8(%rsp)
  je     L207
L163:
  lea    -0x1(%rbp),%rax
  mov    %rax,0x10(%rsp)
  jmp    L194
```

assistant: ```c
unsigned long strtoul(const char *str, char **endptr, int base) {
  const char *s = str;
  unsigned long acc;
  int c;
  unsigned long cutoff;
  int neg = 0, any, cutlim;
  do {
    c = *s++;
  } while (isspace(c));
  if (c == '-') {
    neg = 1;
    c = *s++;
  } else if (c == '+')
    c = *s++;
  if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
    c = s[1];
    s += 2;
    base = 16;
  }
  if (base == 0)
    base = c == '0' ? 8 : 10;
  cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
  cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
  for (acc = 0, any = 0;; c = *s++) {
    if (isdigit(c))
      c -= '0';
    else if (isalpha(c))
      c -= isupper(c) ? 'A' - 10 : 'a' - 10;
    else
      break;
    if (c >= base)
      break;
    if (((any < 0) || (acc > cutoff)) || ((acc == cutoff) && (c > cutlim)))
      any = -1;
    else {
      any = 1;
      acc *= base;
      acc += c;
    }
  }
  if (any < 0) {
    acc = ULONG_MAX;
    errno = ERANGE;
  } else if (neg)
    acc = -acc;
  if (endptr != 0)
    *endptr = (any) ? (char *)(s - 1) : (char *)str;
  return (acc);
}
```