user: 请将以下的汇编代码转换成C语言代码:

```asm
<strtoul>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edx,%ebx
  jmp    L21
  nopl   0x0(%rax)
L50:
  add    $0x1,%r13
L21:
  movsbl 0x0(%r13),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L50
  movzbl 0x0(%r13),%eax
  cmp    $0x2d,%al
  je     L189
  xor    %r14d,%r14d
  cmp    $0x2b,%al
  sete   %al
  movzbl %al,%eax
  add    %rax,%r13
L58:
  cmp    $0x10,%ebx
  je     L82
  test   %ebx,%ebx
  jne    L210
  movzbl 0x0(%r13),%edx
  mov    $0xa,%ebx
  cmp    $0x30,%dl
  je     L134
L269:
  mov    %r13,%rcx
  xor    %esi,%esi
  test   %dl,%dl
  je     L53
L147:
  mov    D72(%rip),%rax
  xor    %esi,%esi
  movslq %ebx,%rdi
  mov    $0x1,%r9d
  mov    (%rax),%r8d
  xor    %eax,%eax
  sar    $0x8,%r8d
  movslq %r8d,%r8
  jmp    L247
  nop
L183:
  mov    $0xff,%edx
  mov    $0xffffffff,%r10d
  cmp    %ebx,%edx
  jge    L100
L202:
  movzbl %al,%edx
  movzbl %r10b,%r10d
  shr    $0x8,%rax
  imul   %rdi,%rdx
  imul   %rdi,%rax
  add    %r10,%rdx
  mov    %rdx,%r10
  movzbl %dl,%edx
  shr    $0x8,%r10
  add    %r10,%rax
  cmp    %rax,%r8
  cmovb  %r9d,%esi
  shl    $0x8,%rax
  add    $0x1,%rcx
  add    %rdx,%rax
  movzbl (%rcx),%edx
  test   %dl,%dl
  je     L100
L247:
  cmp    $0x40,%dl
  ja     L220
  cmp    $0x39,%dl
  ja     L183
L220:
  lea    -0x30(%rdx),%r10d
  movzbl %r10b,%edx
  cmp    %ebx,%edx
  jl     L202
L100:
  cmp    %rcx,%r13
  je     L53
L211:
  test   %rbp,%rbp
  je     L93
  mov    %rcx,0x0(%rbp)
L93:
  test   %esi,%esi
  jne    L76
  mov    %rax,%rdx
  pop    %rbx
  pop    %rbp
  neg    %rdx
  test   %r14d,%r14d
  pop    %r12
  pop    %r13
  cmovne %rdx,%rax
  pop    %r14
  ret
  nopl   0x0(%rax)
L82:
  movzbl 0x0(%r13),%edx
  cmp    $0x30,%dl
  jne    L269
L81:
  movzbl 0x1(%r13),%eax
  mov    %r13,%rcx
  mov    $0x30,%edx
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L147
  movsbl 0x2(%r13),%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L146
  movzbl 0x2(%r13),%edx
  lea    0x2(%r13),%rcx
  test   %dl,%dl
  je     L161
  mov    $0x10,%ebx
  jmp    L147
  nopl   0x0(%rax)
L189:
  add    $0x1,%r13
  mov    $0x1,%r14d
  jmp    L58
  nop
L76:
  mov    D13(%rip),%rax
  mov    (%rax),%edx
  mov    D62(%rip),%rax
  mov    %edx,(%rax)
  mov    D72(%rip),%rax
  pop    %rbx
  pop    %rbp
  movslq (%rax),%rax
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L53:
  mov    D39(%rip),%rax
  mov    %r12,%rcx
  mov    (%rax),%edx
  mov    D62(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  jmp    L211
  nopl   0x0(%rax)
L210:
  lea    -0x2(%rbx),%eax
  cmp    $0x22,%eax
  jbe    L146
  mov    D39(%rip),%rax
  mov    (%rax),%edx
  mov    D62(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L146:
  movzbl 0x0(%r13),%edx
  jmp    L269
  nopw   0x0(%rax,%rax,1)
L134:
  mov    $0x8,%ebx
  jmp    L81
L161:
  xor    %eax,%eax
  xor    %esi,%esi
  jmp    L100
```

assistant: ```c
unsigned long int strtoul(const char *ptr, char **endptr, int base) {
  int neg = 0, overflow = 0;
  unsigned long int v = 0;
  const char *orig;
  const char *nptr = ptr;
  while (isspace(*nptr))
    ++nptr;
  if (*nptr == '-') {
    neg = 1;
    nptr++;
  } else if (*nptr == '+')
    ++nptr;
  orig = nptr;
  if (base == 16 && nptr[0] == '0')
    goto skip0x;
  if (base) {
    register unsigned int b = base - 2;
    if (b > 34) {
      errno = EINVAL;
      return 0;
    }
  } else {
    if (*nptr == '0') {
      base = 8;
    skip0x:
      if ((nptr[1] == 'x' || nptr[1] == 'X') && isxdigit(nptr[2])) {
        nptr += 2;
        base = 16;
      }
    } else
      base = 10;
  }
  while (*nptr) {
    register unsigned char c = *nptr;
    c = (((c >= 'a' ? (c - 'a' + 10) : (c >= 'A')) ? (c - 'A' + 10) : (c <= '9')) ? (c - '0') : 0xff);
    if (c >= base)
      break;
    {
      register unsigned long x = (v & 0xff) * base + c;
      register unsigned long w = (v >> 8) * base + (x >> 8);
      if (w > (ULONG_MAX >> 8))
        overflow = 1;
      v = (w << 8) + (x & 0xff);
    }
    ++nptr;
  }
  if (nptr == orig) {
    nptr = ptr;
    errno = EINVAL;
    v = 0;
  }
  if (endptr)
    *endptr = (char *)nptr;
  if (overflow) {
    errno = ERANGE;
    return ULONG_MAX;
  }
  return (neg ? -v : v);
}
```