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

```asm
<strtol>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  movq   $0x0,-0x18(%rbp)
  movl   $0x0,-0x20(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L356
  mov    $0x0,%eax
  jmp    L84
L356:
  cmpl   $0xf,-0x34(%rbp)
  jle    L348
  movl   $0x10,-0x34(%rbp)
  jmp    L348
L203:
  addq   $0x1,-0x28(%rbp)
L348:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L203
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L77
  movl   $0x1,-0x20(%rbp)
  addq   $0x1,-0x28(%rbp)
  jmp    L114
L77:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2b,%al
  jne    L114
  addq   $0x1,-0x28(%rbp)
L114:
  cmpl   $0x10,-0x34(%rbp)
  je     L377
  cmpl   $0x0,-0x34(%rbp)
  jne    L64
L377:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L64
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  je     L283
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x58,%al
  jne    L64
L283:
  addq   $0x2,-0x28(%rbp)
  movl   $0x10,-0x34(%rbp)
  jmp    L61
L64:
  cmpl   $0x0,-0x34(%rbp)
  je     L135
  cmpl   $0x2,-0x34(%rbp)
  jne    L61
L135:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L61
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x62,%al
  je     L392
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x42,%al
  jne    L61
L392:
  addq   $0x2,-0x28(%rbp)
  movl   $0x2,-0x34(%rbp)
L61:
  cmpl   $0x0,-0x34(%rbp)
  jne    L150
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L82
  movl   $0x8,-0x34(%rbp)
  jmp    L150
L82:
  movl   $0xa,-0x34(%rbp)
L150:
  movq   $0x0,-0x10(%rbp)
  cmpl   $0x0,-0x20(%rbp)
  je     L228
  movq   $0xffffffff80000000,-0x10(%rbp)
  jmp    L189
L228:
  movq   $0x7fffffff,-0x10(%rbp)
L189:
  mov    -0x34(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x10(%rbp),%rax
  mov    $0x0,%edx
  div    %rcx
  mov    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x34(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x10(%rbp),%rax
  mov    $0x0,%edx
  div    %rsi
  mov    %rax,-0x10(%rbp)
  jmp    L180
L187:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L233
  subl   $0x30,-0x1c(%rbp)
  jmp    L108
L233:
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L67
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L215
  subl   $0x37,-0x1c(%rbp)
  jmp    L108
L215:
  subl   $0x57,-0x1c(%rbp)
L108:
  mov    -0x1c(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jge    L316
  mov    -0x18(%rbp),%rax
  cmp    %rax,-0x10(%rbp)
  jb     L224
  mov    -0x18(%rbp),%rax
  cmp    %rax,-0x10(%rbp)
  jne    L372
  mov    -0x1c(%rbp),%eax
  cltq
  cmp    %rax,-0x8(%rbp)
  jl     L224
L372:
  mov    -0x34(%rbp),%eax
  cltq
  mov    -0x18(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  cltq
  add    %rax,-0x18(%rbp)
  addq   $0x1,-0x28(%rbp)
L180:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L187
  jmp    L224
L67:
  nop
  jmp    L224
L316:
  nop
L224:
  cmpq   $0x0,-0x30(%rbp)
  je     L221
  mov    -0x30(%rbp),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,(%rax)
L221:
  cmpl   $0x0,-0x20(%rbp)
  je     L366
  mov    -0x18(%rbp),%rax
  neg    %rax
  jmp    L84
L366:
  mov    -0x18(%rbp),%rax
L84:
  leave
  ret
```

assistant: ```c
long int strtol(const char *str, char **endptr, int base) {
  long int value = 0;
  int neg = 0;
  if (str == NULL)
    return (0);
  if (base >= 16)
    base = 16;
  while (isspace(*str))
    str++;
  if (*str == '-') {
    neg = 1;
    str++;
  } else if (*str == '+')
    str++;
  if ((base == 16 || base == 0) && *str == '0' && (*(str + 1) == 'x' || *(str + 1) == 'X')) {
    str += 2;
    base = 16;
  } else if ((base == 0 || base == 2) && *str == '0' && (*(str + 1) == 'b' || *(str + 1) == 'B')) {
    str += 2;
    base = 2;
  }
  if (base == 0) {
    if (*str == '0') {
      base = 8;
    } else
      base = 10;
  }
  unsigned long cutoff_value = 0;
  if (neg)
    cutoff_value = -(unsigned long)(0x80000000L);
  else
    cutoff_value = (unsigned long)(0x7FFFFFFFL);
  long int cutlim_value = cutoff_value % (unsigned long)base;
  cutoff_value /= base;
  while (*str != '\0') {
    int c = *str;
    if (isdigit(c))
      c -= '0';
    else if (isalpha(c)) {
      if (isupper(c))
        c -= ('A' - 10);
      else
        c -= ('a' - 10);
    } else
      break;
    if (c >= base)
      break;
    if (value > cutoff_value || (value == cutoff_value && c > cutlim_value))
      break;
    else {
      value *= base;
      value += c;
    }
    str++;
  }
  if (endptr)
    *endptr = (char *)str;
  if (neg)
    return -value;
  else
    return value;
}
```