user: Please show me the C implementation that matches the assembly code listed below:

```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    L262
L156:
  test   %rbp,%rbp
  je     L283
  mov    %rbx,0x0(%rbp)
L283:
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L262:
  call   <isspace@plt>
  test   %rax,%rax
  je     L160
  nopw   0x0(%rax,%rax,1)
L259:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isspace@plt>
  test   %rax,%rax
  jne    L259
  mov    $0x1,%r12d
  jmp    L156
  nopw   0x0(%rax,%rax,1)
L160:
  movsbl (%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L222
  cmpb   $0x30,(%rbx)
  movzbl 0x1(%rbx),%eax
  je     L252
  xchg   %ax,%ax
L180:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L180
L341:
  movzbl (%rbx),%eax
  mov    $0x2,%r12d
  cmp    $0x2e,%al
  je     L362
L48:
  and    $0xffffffdf,%eax
  cmp    $0x45,%al
  jne    L156
  movzbl 0x1(%rbx),%eax
  lea    -0x2b(%rax),%edx
  and    $0xfd,%edx
  jne    L320
  movzbl 0x2(%rbx),%eax
  add    $0x1,%rbx
L320:
  movsbl %al,%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  je     L40
  nopw   0x0(%rax,%rax,1)
L163:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L163
  jmp    L156
  nopw   0x0(%rax,%rax,1)
L222:
  movzbl (%rbx),%ecx
  cmp    $0x2e,%cl
  je     L78
L218:
  cmp    $0x27,%cl
  je     L357
  cmp    $0x22,%cl
  je     L357
  cmp    $0x5f,%cl
  je     L241
  movsbl %cl,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L212
  nopl   0x0(%rax)
L241:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  cmp    $0x5f,%dil
  je     L241
  call   <isalnum@plt>
  test   %rax,%rax
  jne    L241
  mov    $0x4,%r12d
  jmp    L156
  nopl   0x0(%rax,%rax,1)
L66:
  test   %al,%al
  je     L200
L349:
  mov    %rdx,%rbx
L357:
  movzbl 0x1(%rbx),%eax
  lea    0x1(%rbx),%rdx
  cmp    %cl,%al
  je     L126
  cmp    $0x5c,%al
  jne    L66
  cmpb   $0x0,0x2(%rbx)
  lea    0x2(%rbx),%rdx
  jne    L349
L200:
  mov    %rdx,%rbx
  mov    $0xffffffff,%r12d
  jmp    L156
  nopl   0x0(%rax,%rax,1)
L362:
  mov    %rbx,%r12
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L362
  movzbl 0x1(%r12),%eax
  mov    $0x3,%r12d
  jmp    L48
L252:
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L180
  add    $0x1,%rbx
  nopl   (%rax)
L91:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  call   <isxdigit@plt>
  test   %rax,%rax
  jne    L91
  mov    $0x2,%r12d
  jmp    L156
L78:
  movsbl 0x1(%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L341
  movzbl (%rbx),%ecx
  jmp    L218
L126:
  add    $0x2,%rbx
  mov    $0x6,%r12d
  jmp    L156
L212:
  movsbl (%rbx),%edi
  call   <ispunct@plt>
  test   %rax,%rax
  je     L40
  add    $0x1,%rbx
  mov    $0x5,%r12d
  jmp    L156
L40:
  or     $0xffffffff,%r12d
  jmp    L156
```

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