user: Translate the below assembly code into C programming language:

```asm
<strtol>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %rsi,(%rsp)
  mov    %edx,%r15d
  jmp    L161
L230:
  add    $0x1,%rbx
L161:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L230
  movzbl (%rbx),%eax
  cmp    $0x2d,%al
  je     L216
  movb   $0x0,0xf(%rsp)
  cmp    $0x2b,%al
  je     L77
L166:
  test   %r15d,%r15d
  jne    L48
  mov    $0xa,%r13d
  cmpb   $0x30,(%rbx)
  je     L33
L169:
  movslq %r13d,%r14
  jmp    L190
L216:
  add    $0x1,%rbx
  movb   $0x1,0xf(%rsp)
  jmp    L166
L77:
  add    $0x1,%rbx
  jmp    L166
L33:
  movzbl 0x1(%rbx),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  sete   %r13b
  movzbl %r13b,%r13d
  lea    0x8(,%r13,8),%r13d
  jmp    L169
L48:
  mov    %r15d,%r13d
  cmp    $0x10,%r15d
  jne    L169
  cmpb   $0x30,(%rbx)
  jne    L169
  movzbl 0x1(%rbx),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L169
  add    $0x2,%rbx
  jmp    L169
L147:
  cmp    %r13b,%dl
  jge    L70
  mov    %r14,%rax
  imul   %rbp,%rax
  movsbq %dl,%rdx
  add    %rax,%rdx
  cmp    %rdx,%rbp
  jg     L89
  mov    %rdx,%rbp
L190:
  mov    %rbx,%r12
  add    $0x1,%rbx
  movsbl -0x1(%rbx),%edi
  call   <toupper@plt>
  lea    -0x37(%rax),%edx
  cmp    $0x40,%al
  jg     L147
  sub    $0x30,%eax
  mov    %eax,%edx
  test   %al,%al
  jns    L147
L70:
  cmpq   $0x0,(%rsp)
  je     L204
  test   %r15d,%r15d
  jne    L28
  movzbl (%r12),%eax
  sub    $0x4c,%eax
  cmp    $0x29,%al
  ja     L28
  movabs $0x20110000001,%rdx
  bt     %rax,%rdx
  jb     L270
  jmp    L28
L89:
  cmpb   $0x0,0xf(%rsp)
  je     L202
  mov    D31(%rip),%rax
  mov    (%rax),%rbp
L83:
  mov    D32(%rip),%rax
  mov    (%rax),%edx
  mov    D24(%rip),%rax
  mov    %edx,(%rax)
  jmp    L70
L202:
  mov    D7(%rip),%rax
  mov    (%rax),%rbp
  jmp    L83
L251:
  bt     %rax,%rdx
  jae    L28
L270:
  add    $0x1,%r12
  movzbl (%r12),%eax
  sub    $0x4c,%eax
  cmp    $0x29,%al
  jbe    L251
L28:
  mov    (%rsp),%rax
  mov    %r12,(%rax)
L204:
  mov    %rbp,%rax
  neg    %rax
  cmpb   $0x0,0xf(%rsp)
  cmovne %rax,%rbp
  mov    %rbp,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
long strtol(const char *__restrict nptr, char **__restrict endptr, int base) {
  long sum, psum;
  char sign;
  int radix = base;
  char *cp = (char *)nptr;
  char digit;
  while (isspace(*cp))
    ++cp;
  sign = 0;
  if (*cp == (char)'-') {
    sign = 1;
    ++cp;
  } else if (*cp == (char)'+')
    ++cp;
  if (base == 0) {
    radix = 10;
    if (*cp == (char)'0') {
      if (cp[1] == (char)'x' || cp[1] == (char)'X') {
        radix = 16;
      } else {
        radix = 8;
      }
    }
  }
  if (base == 16 && *cp == (char)'0' && (cp[1] == (char)'x' || cp[1] == (char)'X'))
    cp += 2;
  sum = 0;
  for (;;) {
    digit = toupper(*(cp++));
    if (digit >= (char)'A')
      digit = (digit - (char)'A') + (char)10;
    else
      digit -= (char)'0';
    if (digit < (char)0 || digit >= (char)radix)
      break;
    psum = sum;
    sum *= radix;
    sum += digit;
    if (sum < psum) {
      sum = sign ? LONG_MIN : LONG_MAX;
      errno = ERANGE;
      break;
    }
  }
  if (endptr) {
    --cp;
    if (base == 0) {
      while (*cp == (char)'h' || *cp == (char)'u' || *cp == (char)'l' || *cp == (char)'L')
        ++cp;
    }
    *endptr = (char *)cp;
  }
  return (sign ? -sum : sum);
}
```