user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strtol>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0x20,%al
  jne    L24
L197:
  jmp    L197
  nopl   (%rax)
L24:
  push   %rbp
  mov    %rsi,%r10
  mov    %rdi,%rcx
  mov    %edx,%esi
  push   %rbx
  cmp    $0x2d,%al
  je     L141
  cmp    $0x2b,%al
  mov    $0x1,%ebx
  sete   %al
  movzbl %al,%eax
  add    %rax,%rcx
L113:
  mov    %esi,%eax
  and    $0xfffffff7,%eax
  test   $0xffffffef,%esi
  jne    L178
  movsbl (%rcx),%edx
  cmp    $0x30,%dl
  je     L38
  test   %eax,%eax
  jne    L152
  test   %esi,%esi
  jne    L152
  mov    $0xa,%esi
L201:
  test   %dl,%dl
  je     L240
  movslq %esi,%rdi
  lea    0x36(%rsi),%r8d
  lea    0x56(%rsi),%r11d
  xor    %eax,%eax
  lea    0x2f(%rsi),%r9d
  nopl   0x0(%rax)
L14:
  imul   %rdi,%rax
  lea    -0x30(%rdx),%ebp
  cmp    $0x9,%bpl
  ja     L102
  cmp    %edx,%r9d
  jge    L175
L289:
  imul   %rbx,%rax
  mov    %rcx,(%r10)
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L178:
  test   %eax,%eax
  je     L212
L152:
  lea    -0x2(%rsi),%edx
  xor    %eax,%eax
  cmp    $0x22,%edx
  jbe    L76
L7:
  mov    %rcx,(%r10)
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L212:
  cmpb   $0x30,(%rcx)
  jne    L152
  movsbl 0x1(%rcx),%edx
  jmp    L273
  xchg   %ax,%ax
L102:
  cmp    $0xa,%esi
  setg   %bpl
  cmp    $0x60,%dl
  jle    L53
  test   %bpl,%bpl
  je     L53
  cmp    %edx,%r11d
  jl     L289
  sub    $0x57,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  nop
L9:
  movsbl 0x1(%rcx),%edx
  add    $0x1,%rcx
  test   %dl,%dl
  jne    L14
  jmp    L289
  nopw   0x0(%rax,%rax,1)
L53:
  cmp    $0x40,%dl
  jle    L289
  test   %bpl,%bpl
  je     L289
  cmp    %edx,%r8d
  jl     L289
  sub    $0x37,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  jmp    L9
  nopw   0x0(%rax,%rax,1)
L175:
  sub    $0x30,%edx
  movslq %edx,%rdx
  add    %rdx,%rax
  jmp    L9
  nopl   0x0(%rax,%rax,1)
L141:
  add    $0x1,%rcx
  mov    $0xffffffffffffffff,%rbx
  jmp    L113
L38:
  movsbl 0x1(%rcx),%edx
  cmp    $0x78,%dl
  je     L199
  test   %eax,%eax
  jne    L152
L273:
  add    $0x1,%rcx
  mov    $0x8,%esi
  jmp    L201
L199:
  movsbl 0x2(%rcx),%edx
  mov    $0x10,%esi
  add    $0x2,%rcx
  jmp    L201
L76:
  movsbl (%rcx),%edx
  jmp    L201
L240:
  xor    %eax,%eax
  jmp    L7
```

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;
}
```