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

```asm
<strtoul>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  cmp    $0x1,%edx
  je     L228
  mov    %rdi,%r12
  mov    %rsi,%rbp
  mov    %edx,%ebx
  cmp    $0x24,%edx
  jbe    L32
L228:
  mov    D45(%rip),%rax
  xor    %r8d,%r8d
  mov    (%rax),%edx
  mov    D6(%rip),%rax
  mov    %edx,(%rax)
L195:
  pop    %rbx
  mov    %r8,%rax
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L49:
  add    $0x1,%r12
L32:
  movsbl (%r12),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L49
  movzbl (%r12),%eax
  cmp    $0x2b,%al
  je     L120
  xor    %r10d,%r10d
  cmp    $0x2d,%al
  je     L102
L84:
  test   $0xffffffef,%ebx
  jne    L234
  cmp    $0x30,%al
  je     L7
  test   %ebx,%ebx
  mov    $0xa,%edx
  cmove  %edx,%ebx
L234:
  mov    D42(%rip),%rdx
  xor    %r8d,%r8d
  movslq %ebx,%rsi
  mov    (%rdx),%rdi
  mov    D30(%rip),%rdx
  mov    (%rdx),%r9d
  jmp    L209
  nopl   0x0(%rax)
L136:
  sub    $0x37,%eax
  movsbl %al,%ecx
L0:
  cmp    %ebx,%ecx
  jge    L96
  mov    %rsi,%rax
  mul    %r8
  jo     L161
  movslq %ecx,%rdx
  add    %rax,%rdx
  jb     L161
  cmp    %r8,%rdi
  je     L161
  mov    %rdx,%r8
  nopw   0x0(%rax,%rax,1)
L163:
  movzbl 0x1(%r12),%eax
  add    $0x1,%r12
L209:
  lea    -0x41(%rax),%edx
  cmp    $0x19,%dl
  jbe    L136
  lea    -0x61(%rax),%edx
  cmp    $0x19,%dl
  ja     L21
  sub    $0x57,%eax
  movsbl %al,%ecx
  jmp    L0
  nopw   0x0(%rax,%rax,1)
L161:
  mov    D6(%rip),%rax
  mov    %rdi,%r8
  mov    %r9d,(%rax)
  jmp    L163
  nopw   0x0(%rax,%rax,1)
L21:
  sub    $0x30,%eax
  cmp    $0x9,%al
  jbe    L172
L96:
  test   %rbp,%rbp
  je     L5
  mov    %r12,0x0(%rbp)
L5:
  test   %r10d,%r10d
  je     L195
  mov    %r8,%rax
  pop    %rbx
  pop    %rbp
  neg    %rax
  cmp    %r8,%rdi
  pop    %r12
  cmovne %rax,%r8
  mov    %r8,%rax
  ret
  xchg   %ax,%ax
L172:
  movsbl %al,%ecx
  jmp    L0
  nopl   0x0(%rax,%rax,1)
L102:
  movzbl 0x1(%r12),%eax
  mov    $0x1,%r10d
  add    $0x1,%r12
  jmp    L84
  nopl   (%rax)
L7:
  movzbl 0x1(%r12),%edx
  cmp    $0x78,%dl
  je     L185
  test   %ebx,%ebx
  jne    L234
  add    $0x1,%r12
  mov    %edx,%eax
  mov    $0x8,%ebx
  jmp    L234
  nopl   0x0(%rax,%rax,1)
L120:
  movzbl 0x1(%r12),%eax
  xor    %r10d,%r10d
  add    $0x1,%r12
  jmp    L84
L185:
  movzbl 0x2(%r12),%eax
  mov    $0x10,%ebx
  add    $0x2,%r12
  jmp    L234
```

assistant: ```c
unsigned long strtoul(const char *nptr, char **endptr, int base) {
  int neg = 0;
  unsigned long ret = 0;
  if (base < 0 || base == 1 || base > 36) {
    errno = EINVAL;
    return 0;
  }
  while (isspace(*nptr)) {
    nptr++;
  }
  if (*nptr == '+') {
    nptr++;
  } else if (*nptr == '-') {
    neg = 1;
    nptr++;
  }
  if ((base == 0 || base == 16) && nptr[0] == '0' && nptr[1] == 'x') {
    base = 16;
    nptr += 2;
  } else if (base == 0 && nptr[0] == '0') {
    base = 8;
    nptr++;
  } else if (base == 0) {
    base = 10;
  }
  for (;;) {
    char c = *nptr;
    int v = -1;
    unsigned long new_ret;
    if (c >= 'A' && c <= 'Z') {
      v = c - 'A' + 10;
    } else if (c >= 'a' && c <= 'z') {
      v = c - 'a' + 10;
    } else if (c >= '0' && c <= '9') {
      v = c - '0';
    }
    if (v < 0 || v >= base) {
      if (endptr) {
        *endptr = (char *)nptr;
      }
      break;
    }
    new_ret = ret * base;
    if (new_ret / base != ret || new_ret + v < new_ret || ret == ULONG_MAX) {
      ret = ULONG_MAX;
      errno = ERANGE;
    } else {
      ret = new_ret + v;
    }
    nptr++;
  }
  if (neg && ret != ULONG_MAX) {
    ret = -ret;
  }
  return ret;
}
```