user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<strtoul>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %rsi,%r14
  mov    %edx,%r12d
  mov    %rdi,%rbx
L71:
  mov    %rbx,%r15
  add    $0x1,%rbx
  movzbl -0x1(%rbx),%ebp
  movzbl %bpl,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L71
  cmp    $0x2d,%bpl
  je     L273
  movl   $0x0,0xc(%rsp)
  cmp    $0x2b,%bpl
  je     L137
L220:
  test   $0xffffffef,%r12d
  jne    L296
  cmp    $0x30,%bpl
  je     L160
L296:
  test   %r12d,%r12d
  jne    L196
  cmp    $0x30,%bpl
  setne  %r12b
  movzbl %r12b,%r12d
  lea    0x8(%r12,%r12,1),%r12d
L14:
  mov    D1(%rip),%rax
  mov    (%rax),%r10d
  mov    %r10d,%eax
  cltd
  idiv   %r12d
  movslq %eax,%r8
  mov    $0x0,%esi
  mov    $0x0,%eax
  mov    $0xffffffff,%r9d
  movslq %r12d,%r15
  mov    $0x1,%r11d
  jmp    L208
L273:
  movzbl (%rbx),%ebp
  lea    0x2(%r15),%rbx
  movl   $0x1,0xc(%rsp)
  jmp    L220
L137:
  movzbl (%rbx),%ebp
  lea    0x2(%r15),%rbx
  jmp    L220
L160:
  movzbl (%rbx),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L264
  movzbl 0x1(%rbx),%ebp
  mov    %ebp,%eax
  and    $0xffffffdf,%eax
  sub    $0x41,%eax
  cmp    $0x5,%al
  jbe    L118
  lea    -0x30(%rbp),%eax
  cmp    $0x9,%al
  jbe    L118
L264:
  mov    $0x30,%ebp
  test   %r12d,%r12d
  jne    L196
  mov    $0x30,%ebp
  mov    $0x8,%r12d
  jmp    L14
L118:
  add    $0x2,%rbx
  mov    $0x10,%r12d
  jmp    L14
L196:
  lea    -0x2(%r12),%edx
  mov    $0x0,%eax
  cmp    $0x22,%edx
  jbe    L14
L123:
  mov    D44(%rip),%rdx
  mov    (%rdx),%ecx
  mov    D12(%rip),%rdx
  mov    %ecx,(%rdx)
  test   %r14,%r14
  je     L55
L164:
  mov    %r13,(%r14)
L55:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L172:
  mov    %r9d,%esi
L112:
  add    $0x1,%rbx
  movzbl -0x1(%rbx),%ebp
L208:
  mov    %ebp,%edi
  lea    -0x30(%rbp),%ecx
  cmp    $0x9,%cl
  jbe    L68
  sub    $0x41,%ebp
  lea    -0x37(%rdi),%ecx
  cmp    $0x19,%bpl
  jbe    L68
  lea    -0x61(%rdi),%ecx
  cmp    $0x19,%cl
  ja     L191
  lea    -0x57(%rdi),%ecx
L68:
  movsbl %cl,%edi
  cmp    %r12d,%edi
  jge    L191
  test   %esi,%esi
  js     L172
  cmp    %r8,%rax
  ja     L172
  cmp    %edx,%edi
  jle    L85
  mov    %r9d,%esi
  cmp    %r8,%rax
  je     L112
L85:
  imul   %r15,%rax
  movsbq %cl,%rcx
  add    %rcx,%rax
  mov    %r11d,%esi
  jmp    L112
L191:
  test   %esi,%esi
  js     L105
  je     L123
  mov    %rax,%rdx
  neg    %rdx
  cmpl   $0x0,0xc(%rsp)
  cmovne %rdx,%rax
  jmp    L282
L105:
  movslq %r10d,%rax
  mov    D21(%rip),%rdx
  mov    (%rdx),%ecx
  mov    D12(%rip),%rdx
  mov    %ecx,(%rdx)
L282:
  lea    -0x1(%rbx),%r13
  test   %r14,%r14
  jne    L164
  jmp    L55
```

assistant: ```c
unsigned long strtoul(const char *__restrict nptr, char **__restrict endptr, int base) {
  const char *s;
  unsigned long acc;
  char c;
  unsigned long cutoff;
  int neg, any, cutlim;
  s = nptr;
  do {
    c = *s++;
  } while (isspace((unsigned char)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') && ((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') || (s[1] >= 'a' && s[1] <= 'f'))) {
    c = s[1];
    s += 2;
    base = 16;
  }
  if (base == 0)
    base = c == '0' ? 8 : 10;
  acc = any = 0;
  if (base < 2 || base > 36)
    goto noconv;
  cutoff = ULONG_MAX / base;
  cutlim = ULONG_MAX % base;
  for (;; c = *s++) {
    if (c >= '0' && c <= '9')
      c -= '0';
    else if (c >= 'A' && c <= 'Z')
      c -= 'A' - 10;
    else if (c >= 'a' && c <= 'z')
      c -= '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 (!any) {
  noconv:
    errno = EINVAL;
  } else if (neg)
    acc = -acc;
  if (endptr != NULL)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```