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

```asm
<strtol>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0x20,%al
  jne    L177
L103:
  jmp    L103
  nopl   (%rax)
L177:
  push   %rbp
  mov    %rsi,%r10
  mov    %rdi,%rcx
  mov    %edx,%esi
  push   %rbx
  cmp    $0x2d,%al
  je     L45
  cmp    $0x2b,%al
  mov    $0x1,%ebx
  sete   %al
  movzbl %al,%eax
  add    %rax,%rcx
L250:
  mov    %esi,%eax
  and    $0xfffffff7,%eax
  test   $0xffffffef,%esi
  jne    L274
  cmpb   $0x30,(%rcx)
  je     L262
  test   %eax,%eax
  jne    L238
  test   %esi,%esi
  jne    L238
  movsbl (%rcx),%edx
  mov    $0xa,%esi
L51:
  test   %dl,%dl
  je     L99
  movslq %esi,%rdi
  lea    0x36(%rsi),%r8d
  lea    0x56(%rsi),%r11d
  xor    %eax,%eax
  lea    0x2f(%rsi),%r9d
  nopl   0x0(%rax)
L300:
  imul   %rdi,%rax
  lea    -0x30(%rdx),%ebp
  cmp    $0x9,%bpl
  ja     L83
  cmp    %edx,%r9d
  jge    L95
L40:
  imul   %rbx,%rax
  mov    %rcx,(%r10)
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L274:
  test   %eax,%eax
  je     L149
L238:
  lea    -0x2(%rsi),%edx
  xor    %eax,%eax
  cmp    $0x22,%edx
  jbe    L6
L190:
  mov    %rcx,(%r10)
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L149:
  cmpb   $0x30,(%rcx)
  jne    L238
  movsbl 0x1(%rcx),%edx
  jmp    L165
  xchg   %ax,%ax
L83:
  cmp    $0xa,%esi
  setg   %bpl
  cmp    $0x60,%dl
  jle    L309
  test   %bpl,%bpl
  je     L309
  cmp    %edx,%r11d
  jl     L40
  sub    $0x57,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  nop
L125:
  movsbl 0x1(%rcx),%edx
  add    $0x1,%rcx
  test   %dl,%dl
  jne    L300
  jmp    L40
  nopw   0x0(%rax,%rax,1)
L309:
  cmp    $0x40,%dl
  jle    L40
  test   %bpl,%bpl
  je     L40
  cmp    %edx,%r8d
  jl     L40
  sub    $0x37,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  jmp    L125
  nopw   0x0(%rax,%rax,1)
L95:
  sub    $0x30,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  jmp    L125
  nopl   0x0(%rax,%rax,1)
L45:
  add    $0x1,%rcx
  mov    $0xffffffffffffffff,%rbx
  jmp    L250
L262:
  movsbl 0x1(%rcx),%edx
  cmp    $0x78,%dl
  je     L191
  test   %eax,%eax
  jne    L238
L165:
  add    $0x1,%rcx
  mov    $0x8,%esi
  jmp    L51
L191:
  movsbl 0x2(%rcx),%edx
  mov    $0x10,%esi
  add    $0x2,%rcx
  jmp    L51
L6:
  movsbl (%rcx),%edx
  jmp    L51
L99:
  xor    %eax,%eax
  jmp    L190
```

assistant: ```c
long int strtol(const char *nptr, char **endptr, int base) {
  long int n = 0;
  long int sign = 1;
  while (*nptr == ' ')
    ;
  if (*nptr == '-') {
    sign = -1;
    nptr++;
  } else if (*nptr == '+') {
    nptr++;
  }
  if ((base == 0 || base == 16) && nptr[0] == '0' && nptr[1] == 'x') {
    nptr += 2;
    base = 16;
  } else if ((base == 0 || base == 8) && nptr[0] == '0') {
    nptr++;
    base = 8;
  } else if (base == 0) {
    base = 10;
  }
  if (base < 2 || base > 36) {
    *endptr = (char *)nptr;
    return sign * n;
  }
  while (*nptr != '\0') {
    n *= base;
    if (*nptr >= '0' && *nptr <= '9' && *nptr < ('0' + base)) {
      n += *nptr - '0';
    } else if (base > 10 && *nptr >= 'a' && *nptr < ('a' + (base - 10))) {
      n += *nptr - 'a' + 10;
    } else if (base > 10 && *nptr >= 'A' && *nptr < ('A' + (base - 10))) {
      n += *nptr - 'A' + 10;
    } else {
      break;
    }
    nptr++;
  }
  *endptr = (char *)nptr;
  return sign * n;
}
```