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

```asm
<ft_atoi>:
  endbr64
  sub    $0x38,%rsp
  movdqa D28(%rip),%xmm0
  movzbl (%rdi),%r9d
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  mov    D0(%rip),%rax
  movaps %xmm0,(%rsp)
  movdqa D12(%rip),%xmm0
  mov    %rax,0x20(%rsp)
  movaps %xmm0,0x10(%rsp)
  test   %r9b,%r9b
  je     L147
  mov    %rdi,%rsi
  lea    0x1(%rdi),%rax
  xor    %edx,%edx
  nopl   0x0(%rax,%rax,1)
L146:
  add    $0x1,%rax
  mov    %edx,%edi
  add    $0x1,%edx
  cmpb   $0x0,-0x1(%rax)
  jne    L146
  mov    %edi,%ecx
  xor    %r8d,%r8d
  cmp    $0x2d,%r9b
  je     L120
L88:
  movslq %r8d,%rax
  movsbl (%rsi,%rax,1),%eax
  sub    $0x30,%eax
  cmp    $0x9,%eax
  ja     L267
  movslq %ecx,%r10
  lea    -0x1(%rcx),%r11d
  imul   (%rsp,%r10,4),%eax
  lea    0x1(%r8),%r10d
  cmp    %r8d,%edi
  jle    L199
  movslq %r10d,%r10
  movsbl (%rsi,%r10,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L222
  movslq %r11d,%r11
  lea    -0x2(%rcx),%r10d
  imul   (%rsp,%r11,4),%edi
  add    %edi,%eax
  lea    0x2(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x3(%rcx),%r10d
  add    %edi,%eax
  lea    0x3(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x4(%rcx),%r10d
  add    %edi,%eax
  lea    0x4(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x5(%rcx),%r10d
  add    %edi,%eax
  lea    0x5(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x6(%rcx),%r10d
  add    %edi,%eax
  lea    0x6(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x7(%rcx),%r10d
  add    %edi,%eax
  lea    0x7(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x8(%rcx),%r10d
  add    %edi,%eax
  lea    0x8(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%edi
  sub    $0x30,%edi
  cmp    $0x9,%edi
  ja     L3
  movslq %r10d,%r10
  imul   (%rsp,%r10,4),%edi
  lea    -0x9(%rcx),%r10d
  add    %edi,%eax
  lea    0x9(%r8),%edi
  cmp    %edi,%edx
  jle    L199
  movslq %edi,%rdi
  movsbl (%rsi,%rdi,1),%esi
  sub    $0x30,%esi
  cmp    $0x9,%esi
  ja     L3
  movslq %r10d,%r10
  add    $0xa,%r8d
  sub    $0xa,%ecx
  imul   (%rsp,%r10,4),%esi
  add    %esi,%eax
  cmp    %r8d,%edx
  jle    L199
L129:
  add    $0x1,%ecx
  cltd
  movslq %ecx,%rcx
  idivl  (%rsp,%rcx,4)
L199:
  mov    %eax,%edx
  neg    %edx
  cmp    $0x2d,%r9b
  cmove  %edx,%eax
L166:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L41
  add    $0x38,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L120:
  lea    -0x1(%rdi),%ecx
  cmp    $0x1,%edx
  je     L147
  mov    $0x1,%r8d
  jmp    L88
  nopl   0x0(%rax,%rax,1)
L3:
  mov    %r10d,%ecx
  jmp    L129
  nopl   (%rax)
L147:
  xor    %eax,%eax
  jmp    L166
L267:
  xor    %eax,%eax
  jmp    L129
L222:
  mov    %r11d,%ecx
  jmp    L129
L41:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D28
data_type: byte[16]
name: retrieve_data
arguments: tag: D0
data_type: byte[8]
name: retrieve_data
arguments: tag: D12
data_type: byte[16]

tool: {"D28": [0x01,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0xe8,0x03,0x00,0x00]}

tool: {"D0": [0x00,0xe1,0xf5,0x05,0x00,0xca,0x9a,0x3b]}

tool: {"D12": [0x10,0x27,0x00,0x00,0xa0,0x86,0x01,0x00,0x40,0x42,0x0f,0x00,0x80,0x96,0x98,0x00]}

assistant: ```c
int ft_atoi(const char *str) {
  int pos[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
  int result = 0;
  int i = 0;
  int n = 0;
  int size = 0;
  int num = 0;
  while (str[size])
    size++;
  n = size - 1;
  if (str[0] == '-') {
    i++;
    n--;
  }
  while (i < size) {
    num = str[i] - 48;
    if (num < 0 || num > 9) {
      result = result / pos[n + 1];
      break;
    }
    result += num * pos[n];
    i++;
    n--;
  }
  if (str[0] == '-')
    result = result * -1;
  return (result);
}
```