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

```asm
<stok>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  movsbl (%rdi),%edi
  test   %dil,%dil
  jne    L308
L300:
  test   %rbp,%rbp
  je     L333
  mov    %rbx,0x0(%rbp)
L333:
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L308:
  call   <isspace@plt>
  test   %rax,%rax
  je     L356
  nopw   0x0(%rax,%rax,1)
L340:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isspace@plt>
  test   %rax,%rax
  jne    L340
  mov    $0x1,%r12d
  jmp    L300
  nopw   0x0(%rax,%rax,1)
L356:
  movsbl (%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L299
  cmpb   $0x30,(%rbx)
  movsbl 0x1(%rbx),%edi
  jne    L63
  mov    %edi,%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L63
  add    $0x1,%rbx
  nopw   0x0(%rax,%rax,1)
L311:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isxdigit@plt>
  test   %rax,%rax
  jne    L311
  mov    $0x2,%r12d
  jmp    L300
  nopl   (%rax)
L32:
  movsbl 0x1(%rbx),%edi
L63:
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L32
L280:
  movzbl (%rbx),%eax
  mov    $0x2,%r12d
  cmp    $0x2e,%al
  je     L67
L366:
  and    $0xffffffdf,%eax
  cmp    $0x45,%al
  jne    L300
  movzbl 0x1(%rbx),%eax
  lea    -0x2b(%rax),%edx
  and    $0xfd,%edx
  jne    L246
  movzbl 0x2(%rbx),%eax
  add    $0x1,%rbx
L246:
  movsbl %al,%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  je     L150
  nopw   0x0(%rax,%rax,1)
L25:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L25
  jmp    L300
  nopw   0x0(%rax,%rax,1)
L299:
  movzbl (%rbx),%edx
  cmp    $0x2e,%dl
  je     L218
L60:
  cmp    $0x27,%dl
  je     L146
  cmp    $0x22,%dl
  je     L146
  cmp    $0x5f,%dl
  je     L354
  movsbl %dl,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L241
  nopl   0x0(%rax)
L354:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  cmp    $0x5f,%dil
  je     L354
  call   <isalnum@plt>
  test   %rax,%rax
  jne    L354
  mov    $0x4,%r12d
  jmp    L300
  nopl   0x0(%rax,%rax,1)
L143:
  mov    %rcx,%rbx
L260:
  test   %al,%al
  je     L150
L146:
  movzbl 0x1(%rbx),%eax
  lea    0x1(%rbx),%rcx
  cmp    %dl,%al
  je     L71
  cmp    $0x5c,%al
  jne    L143
  movzbl 0x2(%rbx),%eax
  add    $0x2,%rbx
  jmp    L260
  nopl   0x0(%rax)
L67:
  mov    %rbx,%r12
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L67
  movzbl 0x1(%r12),%eax
  mov    $0x3,%r12d
  jmp    L366
L218:
  movsbl 0x1(%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L280
  movzbl (%rbx),%edx
  jmp    L60
L71:
  add    $0x2,%rbx
  mov    $0x6,%r12d
  jmp    L300
L150:
  mov    $0xffffffff,%r12d
  jmp    L300
L241:
  movsbl (%rbx),%edi
  call   <ispunct@plt>
  test   %rax,%rax
  je     L150
  add    $0x1,%rbx
  mov    $0x5,%r12d
  jmp    L300
```

assistant: ```c
int stok(const char *s, char **endptr) {
  int rc;
  const char *t = s;
  if (*t == '\0') {
    rc = 0;
  } else if (isspace(*t)) {
    while (isspace(*++t))
      ;
    rc = 1;
  } else if (isdigit(*t)) {
    rc = 2;
    if (*t == '0' && (t[1] == 'x' || t[1] == 'X')) {
      ++t;
      while (isxdigit(*++t))
        ;
    } else {
      while (isdigit(*++t))
        ;
    tok_float:
      if (*t == '.') {
        rc = 3;
        while (isdigit(*++t))
          ;
      }
      if (*t == 'e' || *t == 'E') {
        if (t[1] == '+' || t[1] == '-')
          ++t;
        if (!isdigit(*++t)) {
          rc = (-1);
        } else {
          while (isdigit(*++t))
            ;
        }
      }
    }
  } else if (*t == '.' && isdigit(t[1])) {
    goto tok_float;
  } else if (*t == '\'' || *t == '"') {
    char delimiter = *t;
    rc = 6;
    while (*++t != delimiter) {
      if (*t == '\\')
        ++t;
      if (*t == '\0') {
        rc = (-1);
        --t;
        break;
      }
    }
    ++t;
  } else if (*t == '_' || isalpha(*t)) {
    while (*++t == '_' || isalnum(*t))
      ;
    rc = 4;
  } else if (ispunct(*t)) {
    ++t;
    rc = 5;
  } else {
    rc = (-1);
  }
  if (endptr) {
    *endptr = (char *)t;
  }
  return rc;
}
```