user: 请将以下的汇编代码转换成C语言代码:

```asm
<ftp>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0xfb0,%rsp
  mov    $0x3f2,%ecx
  pxor   %xmm0,%xmm0
  mov    $0x1fa0,%edx
  mov    %fs:0x28,%rax
  mov    %rax,0x1fa8(%rsp)
  xor    %eax,%eax
  mov    %edi,%r12d
  lea    0x10(%rsp),%rdi
  mov    %rsp,%rbp
  mov    %esi,%r13d
  mov    %rbp,%rsi
  movaps %xmm0,(%rsp)
  rep stos %rax,%es:(%rdi)
  movb   $0x0,(%rdi)
  mov    %r12d,%edi
  call   <read@plt>
  lea    0x1(%rax),%rdx
  cmp    $0x1,%rdx
  jbe    L157
  lea    -0x1(%rax),%rdx
  cmp    $0x1f9e,%rdx
  ja     L19
  movb   $0x0,(%rsp,%rax,1)
L127:
  xor    %edx,%edx
  jmp    L224
  nopw   0x0(%rax,%rax,1)
L238:
  add    $0x1,%rdx
  cmp    %rdx,%rax
  jle    L114
L224:
  movzbl 0x0(%rbp,%rdx,1),%ecx
  cmp    $0xd,%cl
  je     L91
  cmp    $0xa,%cl
  jne    L238
L91:
  movb   $0x2a,0x0(%rbp,%rdx,1)
  add    $0x1,%rdx
  cmp    %rdx,%rax
  jg     L224
L114:
  mov    %r13d,%edx
  mov    %rbp,%rsi
  lea    D30(%rip),%rdi
  call   <printf@plt>
  mov    $0x4,%edx
  lea    D10(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L222
  movzbl 0x5(%rsp),%eax
  cmp    $0x2e,%al
  je     L68
  cmp    $0x7c,%al
  jne    L115
L240:
  lea    D39(%rip),%rdx
  lea    D80(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  mov    %r12d,%edi
  mov    $0x1fa0,%edx
  mov    %rbp,%rsi
  call   <write@plt>
  mov    %r12d,%edi
  call   <close@plt>
L73:
  mov    $0x1,%edi
  call   <sleep@plt>
  mov    %r12d,%edi
  call   <close@plt>
  xor    %eax,%eax
L135:
  mov    0x1fa8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L174
  add    $0x1fb0,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nop
L19:
  movb   $0x0,(%rsp)
  test   %rax,%rax
  jg     L127
  jmp    L114
  nopw   0x0(%rax,%rax,1)
L222:
  mov    $0x4,%edx
  lea    D66(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L132
  mov    $0x3,%edx
  lea    D71(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L168
  lea    0x3(%rsp),%rsi
  mov    %r12d,%edi
  call   <lsFunction@plt>
  jmp    L73
  nopw   0x0(%rax,%rax,1)
L68:
  cmpb   $0x2e,0x6(%rsp)
  je     L240
L115:
  lea    0x4(%rsp),%rsi
  mov    %r12d,%edi
  call   <getFunction@plt>
  jmp    L73
  nopl   (%rax)
L132:
  lea    0x5(%rsp),%rsi
  mov    %r12d,%edi
  call   <putFunction@plt>
  jmp    L73
  nopw   0x0(%rax,%rax,1)
L157:
  mov    %r12d,%edi
  call   <close@plt>
  mov    $0x1,%eax
  jmp    L135
L168:
  mov    $0x4,%edx
  lea    D76(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L81
  mov    $0x3,%edx
  lea    D65(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L164
  lea    0x3(%rsp),%rsi
  mov    %r12d,%edi
  call   <cdFunction@plt>
  jmp    L73
L81:
  lea    0x5(%rsp),%rsi
  mov    %r12d,%edi
  call   <mgetFunction@plt>
  jmp    L73
L164:
  mov    $0x5,%edx
  lea    D6(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L73
  mov    %r12d,%edi
  call   <cdResetFunction@plt>
  jmp    L73
L174:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D30
data_type: string
name: read_data
arguments: data_label: D10
data_type: string
name: read_data
arguments: data_label: D39
data_type: string
name: read_data
arguments: data_label: D80
data_type: string
name: read_data
arguments: data_label: D66
data_type: string
name: read_data
arguments: data_label: D71
data_type: string
name: read_data
arguments: data_label: D76
data_type: string
name: read_data
arguments: data_label: D65
data_type: string
name: read_data
arguments: data_label: D6
data_type: string

tool: D30: LOG request %s - hit %d


tool: D10: get 

tool: D39: negado

tool: D80: %s

tool: D66: put 

tool: D71: ls 

tool: D76: mget 

tool: D65: cd 

tool: D6: reset 

assistant: ```c
int ftp(int fd, int hit) {
  int j, file_fd, filedesc;
  long i, ret, len;
  char *fstr;
  char buffer[8096 + 1] = {0};
  ret = read(fd, buffer, 8096);
  if (ret == 0 || ret == -1) {
    close(fd);
    return 1;
  }
  if (ret > 0 && ret < 8096)
    buffer[ret] = 0;
  else
    buffer[0] = 0;
  for (i = 0; i < ret; i++)
    if (buffer[i] == '\r' || buffer[i] == '\n')
      buffer[i] = '*';
  printf("LOG request %s - hit %d\n", buffer, hit);
  if (!strncmp(buffer, "get ", 4)) {
    if ((buffer[5] == '.' && buffer[6] == '.') || buffer[5] == '|') {
      sprintf(buffer, "%s", "negado");
      write(fd, buffer, 8096);
      close(fd);
    } else {
      getFunction(fd, &buffer[4]);
    }
  } else if (!strncmp(buffer, "put ", 4)) {
    putFunction(fd, &buffer[5]);
  } else if (!strncmp(buffer, "ls ", 3)) {
    lsFunction(fd, &buffer[3]);
  } else if (!strncmp(buffer, "mget ", 4)) {
    mgetFunction(fd, &buffer[5]);
  } else if (!strncmp(buffer, "cd ", 3)) {
    cdFunction(fd, &buffer[3]);
  } else if (!strncmp(buffer, "reset ", 5)) {
    cdResetFunction(fd);
  }
  sleep(1);
  close(fd);
  return 0;
}
```