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

```asm
<atoi>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%edi
  cmp    $0x30,%dil
  je     L83
  cmp    $0x2d,%dil
  je     L164
  xor    %r12d,%r12d
  test   %dil,%dil
  jne    L51
L99:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L37:
  movsbl (%rbx),%eax
  movsbl 0x1(%rbx),%edi
  lea    (%r12,%r12,4),%edx
  add    $0x1,%rbx
  lea    -0x30(%rax,%rdx,2),%r12d
  test   %dil,%dil
  je     L99
L51:
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L37
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L83:
  movsbl 0x1(%rbx),%esi
  mov    %esi,%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L29
  movsbl 0x2(%rbx),%edi
  lea    0x2(%rbx),%rbp
  xor    %r12d,%r12d
  test   %dil,%dil
  je     L99
  lea    D6(%rip),%rbx
  lea    D25(%rip),%r13
  jmp    L203
  nopl   (%rax)
L121:
  movsbl 0x0(%rbp),%eax
  shl    $0x4,%r12d
  lea    -0x30(%r12,%rax,1),%r12d
L205:
  movsbl 0x1(%rbp),%edi
  add    $0x1,%rbp
  test   %dil,%dil
  je     L99
L203:
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L121
  movsbl 0x0(%rbp),%esi
  mov    %rbx,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L200
  movsbl 0x0(%rbp),%eax
  shl    $0x4,%r12d
  lea    -0x37(%r12,%rax,1),%r12d
  jmp    L205
L29:
  add    $0x1,%rbx
  xor    %r12d,%r12d
  lea    D8(%rip),%rbp
  test   %sil,%sil
  jne    L139
  jmp    L99
  nopl   0x0(%rax,%rax,1)
L43:
  movsbl (%rbx),%eax
  movsbl 0x1(%rbx),%esi
  add    $0x1,%rbx
  lea    -0x30(%rax,%r12,8),%r12d
  test   %sil,%sil
  je     L99
L139:
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L43
  jmp    L99
  nopl   0x0(%rax,%rax,1)
L200:
  movsbl 0x0(%rbp),%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L99
  movsbl 0x0(%rbp),%eax
  shl    $0x4,%r12d
  lea    -0x57(%r12,%rax,1),%r12d
  jmp    L205
  nopw   0x0(%rax,%rax,1)
L164:
  add    $0x1,%rbx
  xor    %r12d,%r12d
  jmp    L163
  nopl   0x0(%rax)
L174:
  movsbl (%rbx),%eax
  lea    (%r12,%r12,4),%edx
  add    $0x1,%rbx
  lea    -0x30(%rax,%rdx,2),%r12d
L163:
  movsbl (%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L174
  add    $0x8,%rsp
  neg    %r12d
  pop    %rbx
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D6
type_guessed: string
name: retrieve_data
arguments: tag: D25
type_guessed: string
name: retrieve_data
arguments: tag: D8
type_guessed: string

tool: D6: ABCDEF

tool: D25: abcdef

tool: D8: 01234567

assistant: ```c
int atoi(const char *s) {
  int a = 0;
  if (*s == '0') {
    s++;
    if (*s == 'x' || *s == 'X') {
      s++;
      while (*s) {
        if (isdigit(*s))
          a = (a << 4) + *s - '0';
        else if (strchr("ABCDEF", *s))
          a = (a << 4) + *s - 'A' + 10;
        else if (strchr("abcdef", *s))
          a = (a << 4) + *s - 'a' + 10;
        else
          return a;
        s++;
      }
      return a;
    }
    while (*s) {
      if (strchr("01234567", *s))
        a = (a << 3) + *s - '0';
      else
        return a;
      s++;
    }
    return a;
  }
  if (*s == '-') {
    s++;
    for (;;) {
      if (isdigit(*s))
        a = (a * 10) + *s - '0';
      else
        return -a;
      s++;
    }
  }
  while (*s) {
    if (isdigit(*s))
      a = (a * 10) + *s - '0';
    else
      return a;
    s++;
  }
  return a;
}
```