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

```asm
<strtol>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %edx,%r9d
  mov    %rdi,%rcx
L94:
  movzbl (%rcx),%eax
  cmp    $0xd,%al
  jg     L52
  cmp    $0x8,%al
  jg     L132
L62:
  lea    -0x2b(%rax),%edx
  mov    $0x0,%r12d
  test   $0xfd,%dl
  jne    L36
  add    $0x1,%rcx
  cmp    $0x2d,%al
  sete   %r12b
  movzbl %r12b,%r12d
L36:
  test   %r9d,%r9d
  jne    L124
  mov    $0xa,%r9d
  cmpb   $0x30,(%rcx)
  je     L268
L150:
  mov    $0x0,%r8d
  mov    $0x0,%edi
  mov    $0x0,%esi
  movslq %r9d,%r11
  mov    $0x1,%r10d
  jmp    L169
L52:
  cmp    $0x20,%al
  jne    L62
L132:
  add    $0x1,%rcx
  jmp    L94
L268:
  movzbl 0x1(%rcx),%eax
  and    $0xffffffdf,%eax
  mov    $0x8,%r9d
  cmp    $0x58,%al
  jne    L150
  add    $0x2,%rcx
  mov    $0x10,%r9d
  jmp    L150
L124:
  cmp    $0x10,%r9d
  je     L163
  cmp    $0x24,%r9d
  jbe    L150
  mov    $0x0,%esi
  test   %rbp,%rbp
  je     L18
  mov    %rbx,%rcx
  mov    $0x0,%edi
  mov    $0x0,%esi
  jmp    L47
L163:
  cmpb   $0x30,(%rcx)
  jne    L150
  movzbl 0x1(%rcx),%eax
  and    $0xffffffdf,%eax
  lea    0x2(%rcx),%rdx
  cmp    $0x58,%al
  cmove  %rdx,%rcx
  jmp    L150
L264:
  mov    %edx,%eax
L95:
  cmp    %r9d,%eax
  jge    L164
  mov    %r11,%rdx
  imul   %rsi,%rdx
  cltq
  add    %rdx,%rax
  cmp    %rax,%rsi
  cmovg  %r10d,%edi
  add    $0x1,%rcx
  add    $0x1,%r8d
  mov    %rax,%rsi
L169:
  movsbl (%rcx),%eax
  lea    -0x30(%rax),%edx
  cmp    $0x9,%edx
  jbe    L264
  lea    -0x61(%rax),%edx
  cmp    $0x19,%edx
  ja     L192
  sub    $0x57,%eax
  jmp    L95
L192:
  lea    -0x41(%rax),%edx
  cmp    $0x19,%edx
  ja     L164
  sub    $0x37,%eax
  jmp    L95
L164:
  test   %r8d,%r8d
  cmove  %rbx,%rcx
  test   %rbp,%rbp
  je     L130
L47:
  mov    %rcx,0x0(%rbp)
L130:
  test   %edi,%edi
  je     L18
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  mov    D27(%rip),%rax
  mov    %edx,(%rax)
  test   %r12d,%r12d
  je     L114
  mov    D9(%rip),%rax
  mov    (%rax),%rsi
  jmp    L99
L114:
  mov    D4(%rip),%rax
  mov    (%rax),%rsi
  jmp    L99
L18:
  mov    %rsi,%rax
  neg    %rax
  test   %r12d,%r12d
  cmovne %rax,%rsi
L99:
  mov    %rsi,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
long strtol(const char *nptr, char **endptr, int base) {
  const char *p;
  long n, nn;
  int c, ovfl, v, neg, ndig;
  p = nptr;
  neg = 0;
  n = 0;
  ndig = 0;
  ovfl = 0;
  for (;; p++) {
    switch (*p) {
    case ' ':
    case '\t':
    case '\n':
    case '\f':
    case '\r':
    case '\v':
      continue;
    }
    break;
  }
  if (*p == '-' || *p == '+')
    if (*p++ == '-')
      neg = 1;
  if (base == 0) {
    if (*p != '0')
      base = 10;
    else {
      base = 8;
      if (p[1] == 'x' || p[1] == 'X') {
        p += 2;
        base = 16;
      }
    }
  } else if (base == 16 && *p == '0') {
    if (p[1] == 'x' || p[1] == 'X')
      p += 2;
  } else if (base < 0 || 36 < base)
    goto Return;
  for (;; p++, ndig++) {
    c = *p;
    v = base;
    if ('0' <= c && c <= '9')
      v = c - '0';
    else if ('a' <= c && c <= 'z')
      v = c - 'a' + 10;
    else if ('A' <= c && c <= 'Z')
      v = c - 'A' + 10;
    if (v >= base)
      break;
    nn = n * base + v;
    if (nn < n)
      ovfl = 1;
    n = nn;
  }
Return:
  if (ndig == 0)
    p = nptr;
  if (endptr)
    *endptr = (char *)p;
  if (ovfl) {
    errno = ERANGE;
    if (neg)
      return LONG_MIN;
    return LONG_MAX;
  }
  if (neg)
    return -n;
  return n;
}
```