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

```asm
<strtoul>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  movl   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  cmpl   $0x0,-0x34(%rbp)
  js     L293
  cmpl   $0x1,-0x34(%rbp)
  je     L293
  cmpl   $0x24,-0x34(%rbp)
  jle    L240
L293:
  mov    D6(%rip),%rax
  mov    (%rax),%edx
  mov    D65(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L296
L51:
  addq   $0x1,-0x28(%rbp)
L240:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L51
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  jne    L85
  addq   $0x1,-0x28(%rbp)
  jmp    L100
L85:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L100
  movl   $0x1,-0x18(%rbp)
  addq   $0x1,-0x28(%rbp)
L100:
  cmpl   $0x0,-0x34(%rbp)
  je     L285
  cmpl   $0x10,-0x34(%rbp)
  jne    L287
L285:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L287
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  jne    L287
  movl   $0x10,-0x34(%rbp)
  addq   $0x2,-0x28(%rbp)
  jmp    L350
L287:
  cmpl   $0x0,-0x34(%rbp)
  jne    L72
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L72
  movl   $0x8,-0x34(%rbp)
  addq   $0x1,-0x28(%rbp)
  jmp    L350
L72:
  cmpl   $0x0,-0x34(%rbp)
  jne    L350
  movl   $0xa,-0x34(%rbp)
L350:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x19(%rbp)
  movl   $0xffffffff,-0x14(%rbp)
  cmpb   $0x40,-0x19(%rbp)
  jle    L169
  cmpb   $0x5a,-0x19(%rbp)
  jg     L169
  movsbl -0x19(%rbp),%eax
  sub    $0x37,%eax
  mov    %eax,-0x14(%rbp)
  jmp    L156
L169:
  cmpb   $0x60,-0x19(%rbp)
  jle    L314
  cmpb   $0x7a,-0x19(%rbp)
  jg     L314
  movsbl -0x19(%rbp),%eax
  sub    $0x57,%eax
  mov    %eax,-0x14(%rbp)
  jmp    L156
L314:
  cmpb   $0x2f,-0x19(%rbp)
  jle    L156
  cmpb   $0x39,-0x19(%rbp)
  jg     L156
  movsbl -0x19(%rbp),%eax
  sub    $0x30,%eax
  mov    %eax,-0x14(%rbp)
L156:
  cmpl   $0x0,-0x14(%rbp)
  js     L294
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L134
L294:
  cmpq   $0x0,-0x30(%rbp)
  je     L128
  mov    -0x30(%rbp),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,(%rax)
  jmp    L128
L134:
  mov    -0x34(%rbp),%eax
  cltq
  mov    -0x10(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x34(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  div    %rcx
  cmp    %rax,-0x10(%rbp)
  jne    L265
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  cmp    %rax,-0x8(%rbp)
  ja     L265
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  jne    L351
L265:
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    D30(%rip),%rax
  mov    (%rax),%edx
  mov    D65(%rip),%rax
  mov    %edx,(%rax)
  jmp    L225
L351:
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
L225:
  addq   $0x1,-0x28(%rbp)
  jmp    L350
L128:
  nop
  cmpl   $0x0,-0x18(%rbp)
  je     L253
  mov    D64(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  je     L253
  negq   -0x10(%rbp)
L253:
  mov    -0x10(%rbp),%rax
L296:
  leave
  ret
```

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