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

```asm
<_strtoul>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %edx,%r14d
  mov    %rdi,%rbp
L191:
  mov    %rbp,%r12
  add    $0x1,%rbp
  movzbl -0x1(%rbp),%ebx
  mov    %ebx,%edi
  call   <_isspace@plt>
  test   %rax,%rax
  jne    L191
  cmp    $0x2d,%ebx
  je     L264
  movl   $0x0,0x14(%rsp)
  cmp    $0x2b,%ebx
  je     L117
L47:
  test   $0xffffffef,%r14d
  jne    L239
  cmp    $0x30,%ebx
  je     L201
L239:
  test   %r14d,%r14d
  jne    L104
  cmp    $0x30,%ebx
  setne  %r14b
  movzbl %r14b,%r14d
  lea    0x8(%r14,%r14,1),%r14d
L104:
  movslq %r14d,%rcx
  mov    %rcx,(%rsp)
  mov    $0xffffffff,%eax
  mov    $0x0,%edx
  div    %rcx
  mov    %rax,%r15
  mov    %edx,0x10(%rsp)
  mov    $0x0,%r13d
  mov    $0x0,%r12d
  jmp    L89
L264:
  movsbl 0x0(%rbp),%ebx
  lea    0x2(%r12),%rbp
  movl   $0x1,0x14(%rsp)
  jmp    L47
L117:
  movsbl 0x0(%rbp),%ebx
  lea    0x2(%r12),%rbp
  jmp    L47
L201:
  movzbl 0x0(%rbp),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L138
  movsbl 0x1(%rbp),%ebx
  add    $0x2,%rbp
  mov    $0x10,%r14d
  jmp    L104
L138:
  mov    $0x30,%ebx
  jmp    L239
L88:
  mov    %ebx,%edi
  call   <_isalpha@plt>
  test   %rax,%rax
  je     L124
  mov    %ebx,%edi
  call   <_isupper@plt>
  cmp    $0x1,%rax
  sbb    %eax,%eax
  and    $0x20,%eax
  add    $0x37,%eax
  sub    %eax,%ebx
  jmp    L4
L171:
  mov    D16(%rip),%rax
  mov    (%rax),%edx
  mov    D10(%rip),%rax
  mov    %edx,(%rax)
  mov    $0xffffffff,%r13d
  mov    $0xffffffff,%r12d
L265:
  add    $0x1,%rbp
  movzbl -0x1(%rbp),%ebx
L89:
  mov    %ebx,%edi
  call   <_isdigit@plt>
  test   %rax,%rax
  je     L88
  sub    $0x30,%ebx
L4:
  cmp    %ebx,%r14d
  jle    L124
  test   %r13d,%r13d
  js     L265
  cmp    %r15,%r12
  ja     L171
  jne    L269
  cmp    0x10(%rsp),%ebx
  jg     L171
L269:
  imul   (%rsp),%r12
  movslq %ebx,%rbx
  add    %rbx,%r12
  mov    $0x1,%r13d
  jmp    L265
L124:
  cmpl   $0x0,0x14(%rsp)
  je     L156
  test   %r13d,%r13d
  jle    L156
  neg    %r12
  cmpq   $0x0,0x8(%rsp)
  je     L268
L96:
  lea    -0x1(%rbp),%rax
  mov    %rax,0x18(%rsp)
  jmp    L19
L156:
  cmpq   $0x0,0x8(%rsp)
  je     L268
  test   %r13d,%r13d
  jne    L96
L19:
  mov    0x8(%rsp),%rax
  mov    0x18(%rsp),%rsi
  mov    %rsi,(%rax)
L268:
  mov    %r12,%rax
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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);
}
```