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

```asm
<__itoa>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %edi,%ebx
  mov    %rsi,-0x80(%rbp)
  mov    %edx,%r13d
  mov    %ecx,-0x74(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  mov    %ecx,%eax
  add    $0x1,%eax
  cltq
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L39:
  cmp    %rdx,%rsp
  je     L49
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L39
L49:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L105
  orq    $0x0,-0x8(%rsp,%rax,1)
L105:
  mov    %rsp,%r15
  movabs $0x3736353433323130,%rax
  movabs $0x6665646362613938,%rdx
  mov    %rax,-0x70(%rbp)
  mov    %rdx,-0x68(%rbp)
  lea    -0x2(%r13),%eax
  cmp    $0xe,%eax
  ja     L135
  cmpq   $0x0,-0x80(%rbp)
  je     L135
  mov    $0x0,%r12d
  mov    $0x1f,%r14d
  test   %ebx,%ebx
  je     L130
L48:
  mov    %r14d,%esi
  sub    %r12d,%esi
  mov    %r13d,%edi
  call   <pow@plt>
  mov    %eax,%ecx
  mov    %ebx,%eax
  cltd
  idiv   %ecx
  cltq
  movzbl -0x70(%rbp,%rax,1),%eax
  mov    %al,-0x60(%rbp,%r12,1)
  mov    %edx,%ebx
  add    $0x1,%r12
  cmp    $0x20,%r12
  jne    L48
  mov    $0x20,%edx
  mov    -0x74(%rbp),%eax
  sub    %eax,%edx
  cmp    $0x1f,%edx
  jg     L23
  mov    %eax,%esi
  mov    $0x0,%eax
  movslq %edx,%rdx
  lea    -0x60(%rbp,%rdx,1),%rcx
L66:
  movzbl (%rcx,%rax,1),%edx
  mov    %dl,(%r15,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L66
L23:
  movslq -0x74(%rbp),%rax
  movb   $0x0,(%r15,%rax,1)
  movzbl (%r15),%eax
  test   %al,%al
  je     L151
  mov    %r15,%rdx
L98:
  cmp    $0x30,%al
  jne    L32
  add    $0x1,%rdx
  movzbl (%rdx),%eax
  test   %al,%al
  jne    L98
  jmp    L151
L130:
  lea    D6(%rip),%rsi
  mov    -0x80(%rbp),%rbx
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
  jmp    L92
L32:
  mov    %rdx,%r15
L151:
  mov    %r15,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%rdx
  mov    %r15,%rsi
  mov    -0x80(%rbp),%rbx
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %rbx,%rax
L92:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L40
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L135:
  mov    $0x0,%eax
  jmp    L92
L40:
  call   <__stack_chk_fail@plt>
```

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

tool: D6: 0

assistant: ```c
char *__itoa(int val, char *result, int base, int nbrNum) {
  int j = 0;
  int i = 0;
  int k = 0;
  int l = 0;
  int temp;
  char *p, *p2;
  char res[32];
  char res2[nbrNum + 1];
  char cList[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
  if (result == NULL || base > 16 || base < 2)
    return NULL;
  if (0 == val) {
    strcpy(result, "0");
    return result;
  }
  j = val;
  i = 31;
  while (i >= 0) {
    l = pow(base, i);
    temp = (int)j / l;
    res[k++] = cList[temp];
    j -= temp * l;
    i--;
  }
  i = 0;
  j = 31 - (nbrNum - 1);
  for (k = j; k < 32; k++) {
    res2[i++] = res[k];
  }
  res2[nbrNum] = '\0';
  p = p2 = res2;
  while (*p) {
    if (*p != '0') {
      p2 = p;
      break;
    }
    p++;
  }
  memcpy(result, p2, strlen(p2) + 1);
  return result;
}
```