user: Converte this assembly snippet into its equivalent C code:

```asm
<strtoul>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x24(%rbp)
L284:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L284
  cmpl   $0x2d,-0x28(%rbp)
  jne    L159
  movl   $0x1,-0x24(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L82
L159:
  cmpl   $0x2b,-0x28(%rbp)
  jne    L82
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x28(%rbp)
L82:
  cmpl   $0x0,-0x44(%rbp)
  je     L53
  cmpl   $0x10,-0x44(%rbp)
  jne    L78
L53:
  cmpl   $0x30,-0x28(%rbp)
  jne    L78
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  je     L133
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x58,%al
  jne    L78
L133:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x28(%rbp)
  addq   $0x2,-0x18(%rbp)
  movl   $0x10,-0x44(%rbp)
L78:
  cmpl   $0x0,-0x44(%rbp)
  jne    L80
  cmpl   $0x30,-0x28(%rbp)
  jne    L108
  mov    $0x8,%eax
  jmp    L225
L108:
  mov    $0xa,%eax
L225:
  mov    %eax,-0x44(%rbp)
L80:
  mov    D42(%rip),%rax
  mov    (%rax),%rax
  mov    -0x44(%rbp),%edx
  movslq %edx,%rsi
  mov    $0x0,%edx
  div    %rsi
  mov    %rax,-0x8(%rbp)
  mov    D42(%rip),%rax
  mov    (%rax),%rax
  mov    -0x44(%rbp),%edx
  movslq %edx,%rcx
  mov    $0x0,%edx
  div    %rcx
  mov    %rdx,%rax
  mov    %eax,-0x1c(%rbp)
  movq   $0x0,-0x10(%rbp)
  movl   $0x0,-0x20(%rbp)
L121:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L223
  subl   $0x30,-0x28(%rbp)
  jmp    L28
L223:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L162
  mov    -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L6
  mov    $0x37,%eax
  jmp    L219
L6:
  mov    $0x57,%eax
L219:
  sub    %eax,-0x28(%rbp)
L28:
  mov    -0x28(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jge    L301
  cmpl   $0x0,-0x20(%rbp)
  js     L222
  mov    -0x10(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  ja     L222
  mov    -0x10(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jne    L171
  mov    -0x28(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L171
L222:
  movl   $0xffffffff,-0x20(%rbp)
  jmp    L76
L171:
  movl   $0x1,-0x20(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  mov    -0x10(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%eax
  cltq
  add    %rax,-0x10(%rbp)
L76:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x28(%rbp)
  jmp    L121
L162:
  nop
  jmp    L79
L301:
  nop
L79:
  cmpl   $0x0,-0x20(%rbp)
  jns    L280
  mov    D42(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    D30(%rip),%rax
  mov    (%rax),%edx
  mov    D6(%rip),%rax
  mov    %edx,(%rax)
  jmp    L147
L280:
  cmpl   $0x0,-0x24(%rbp)
  je     L147
  negq   -0x10(%rbp)
L147:
  cmpq   $0x0,-0x40(%rbp)
  je     L158
  cmpl   $0x0,-0x20(%rbp)
  je     L248
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  jmp    L150
L248:
  mov    -0x38(%rbp),%rax
L150:
  mov    -0x40(%rbp),%rdx
  mov    %rax,(%rdx)
L158:
  mov    -0x10(%rbp),%rax
  leave
  ret
```

assistant: ```c
unsigned long strtoul(const char *str, char **endptr, int base) {
  const char *s = str;
  unsigned long acc;
  int c;
  unsigned long cutoff;
  int neg = 0, any, cutlim;
  do {
    c = *s++;
  } while (isspace(c));
  if (c == '-') {
    neg = 1;
    c = *s++;
  } else 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 = (unsigned long)ULONG_MAX / (unsigned long)base;
  cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
  for (acc = 0, any = 0;; c = *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) || (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 (neg)
    acc = -acc;
  if (endptr != 0)
    *endptr = (any) ? (char *)(s - 1) : (char *)str;
  return (acc);
}
```