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

```asm
<_strtoul>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x8(%rsp)
  nopl   0x0(%rax)
L108:
  mov    %r15,%rbx
  movzbl (%r15),%r14d
  add    $0x1,%r15
  mov    %r14d,%edi
  call   <_isspace@plt>
  test   %rax,%rax
  jne    L108
  cmp    $0x2d,%r14d
  je     L98
  movb   $0x0,0x1f(%rsp)
  cmp    $0x2b,%r14d
  je     L261
L239:
  test   $0xffffffef,%ebp
  jne    L80
  cmp    $0x30,%r14d
  je     L42
  test   %ebp,%ebp
  jne    L80
  movl   $0x5,0x18(%rsp)
  mov    $0x19999999,%r13d
  mov    $0xa,%ebp
  movq   $0xa,(%rsp)
  jmp    L193
L99:
  test   %ebp,%ebp
  je     L83
  nopl   0x0(%rax)
L80:
  movslq %ebp,%rsi
  mov    $0xffffffff,%eax
  xor    %edx,%edx
  div    %rsi
  mov    %rsi,(%rsp)
  mov    %edx,0x18(%rsp)
  mov    %rax,%r13
L193:
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  jmp    L190
  nopw   0x0(%rax,%rax,1)
L89:
  cmp    %ecx,%ebp
  jle    L211
L191:
  cmp    $0xffffffff,%ebx
  je     L206
  cmp    %r13,%r12
  ja     L50
  jne    L255
  cmp    0x18(%rsp),%ecx
  jle    L255
L50:
  mov    D13(%rip),%rax
  mov    $0xffffffff,%ebx
  mov    $0xffffffff,%r12d
  mov    (%rax),%edx
  mov    D6(%rip),%rax
  mov    %edx,(%rax)
L206:
  movzbl (%r15),%r14d
  add    $0x1,%r15
L190:
  mov    %r14d,%edi
  call   <_isdigit@plt>
  lea    -0x30(%r14),%ecx
  test   %rax,%rax
  jne    L89
  mov    %r14d,%edi
  call   <_isalpha@plt>
  test   %rax,%rax
  je     L211
  mov    %r14d,%edi
  call   <_isupper@plt>
  mov    %r14d,%ecx
  cmp    $0x1,%rax
  sbb    %eax,%eax
  and    $0x20,%eax
  add    $0x37,%eax
  sub    %eax,%ecx
  cmp    %ecx,%ebp
  jg     L191
L211:
  test   %ebx,%ebx
  jle    L38
  cmpb   $0x0,0x1f(%rsp)
  je     L38
  neg    %r12
  cmpq   $0x0,0x8(%rsp)
  je     L249
L115:
  lea    -0x1(%r15),%rax
  mov    %rax,0x10(%rsp)
  mov    0x8(%rsp),%rax
  mov    0x10(%rsp),%rsi
  mov    %rsi,(%rax)
L249:
  add    $0x28,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L255:
  imul   (%rsp),%r12
  movslq %ecx,%rcx
  mov    $0x1,%ebx
  add    %rcx,%r12
  jmp    L206
  nopl   (%rax)
L38:
  cmpq   $0x0,0x8(%rsp)
  je     L249
  test   %ebx,%ebx
  jne    L115
  mov    0x8(%rsp),%rax
  mov    0x10(%rsp),%rsi
  mov    %rsi,(%rax)
  jmp    L249
  nopl   0x0(%rax,%rax,1)
L261:
  movsbl (%r15),%r14d
  lea    0x2(%rbx),%r15
  jmp    L239
  nopl   (%rax)
L98:
  movsbl (%r15),%r14d
  movb   $0x1,0x1f(%rsp)
  lea    0x2(%rbx),%r15
  jmp    L239
  nopw   0x0(%rax,%rax,1)
L42:
  movzbl (%r15),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L99
  movsbl 0x1(%r15),%r14d
  movl   $0xf,0x18(%rsp)
  add    $0x2,%r15
  mov    $0xfffffff,%r13d
  movq   $0x10,(%rsp)
  mov    $0x10,%ebp
  jmp    L193
L83:
  movl   $0x7,0x18(%rsp)
  mov    $0x1fffffff,%r13d
  mov    $0x8,%ebp
  movq   $0x8,(%rsp)
  jmp    L193
```

assistant: ```c
unsigned long _strtoul(const char *nptr, char **endptr, int base) {
  const char *s;
  unsigned long acc, cutoff;
  int c;
  int neg, any, cutlim;
  s = nptr;
  do {
    c = (unsigned char)*s++;
  } while (_isspace(c));
  if (c == '-') {
    neg = 1;
    c = *s++;
  } else {
    neg = 0;
    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 = 4294967295UL / (unsigned long)base;
  cutlim = 4294967295UL % (unsigned long)base;
  for (acc = 0, any = 0;; c = (unsigned char)*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)
      continue;
    if (acc > cutoff || (acc == cutoff && c > cutlim)) {
      any = -1;
      acc = 4294967295UL;
      errno = ERANGE;
    } else {
      any = 1;
      acc *= (unsigned long)base;
      acc += c;
    }
  }
  if (neg && any > 0)
    acc = -acc;
  if (endptr != 0)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```