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

```asm
<tofile2>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x138,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x128(%rsp)
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  call   <puts0@plt>
  lea    0x20(%rsp),%rax
  lea    0x30(%rsp),%rdx
L28:
  movb   $0x0,(%rax)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L28
  lea    0x20(%rsp),%rdi
  mov    $0x100,%esi
  mov    $0x0,%eax
  call   <getsn@plt>
  mov    $0x0,%eax
L56:
  movzbl 0x20(%rsp,%rax,1),%edx
  mov    %dl,(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    $0x10,%rax
  jne    L56
  movb   $0x0,0x10(%rsp)
  lea    D98(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    %rsp,%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  lea    D53(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    $0x2,%esi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <open_@plt>
  cmp    $0x1,%ax
  je     L45
  lea    D36(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
L1:
  lea    D94(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  lea    0x20(%rsp),%rbx
  mov    $0x100,%esi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <getsn@plt>
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <atoi@plt>
  mov    %eax,%ebx
  mov    %eax,%ebp
  lea    D48(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  movzwl %bx,%edi
  mov    $0x0,%eax
  call   <putdec@plt>
  lea    D71(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  test   %bx,%bx
  je     L29
  mov    $0x0,%ebx
L21:
  mov    $0x40,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <writec@plt>
  mov    $0x40,%edi
  mov    $0x0,%eax
  call   <putch@plt>
  add    $0x1,%ebx
  cmp    %bx,%bp
  jne    L21
L29:
  lea    D26(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <close_@plt>
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <putdec@plt>
  lea    D71(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    0x128(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L67
  add    $0x138,%rsp
  pop    %rbx
  pop    %rbp
  ret
L45:
  lea    D86(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  jmp    L1
L67:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D9
type_guessed: string
name: parse_data
arguments: tag: D98
type_guessed: string
name: parse_data
arguments: tag: D53
type_guessed: string
name: parse_data
arguments: tag: D36
type_guessed: string
name: parse_data
arguments: tag: D94
type_guessed: string
name: parse_data
arguments: tag: D48
type_guessed: string
name: parse_data
arguments: tag: D71
type_guessed: string
name: parse_data
arguments: tag: D26
type_guessed: string
name: parse_data
arguments: tag: D86
type_guessed: string

tool: D9: file ? 

tool: D98: 
'

tool: D53: '


tool: D36: open not ok


tool: D94: count ? 

tool: D48: n=

tool: D71: 


tool: D26: close rc=

tool: D86: open OK


assistant: ```c
void tofile2(void) {
  unsigned short int i;
  unsigned short int j;
  unsigned short int n;
  unsigned short int equal;
  unsigned char device;
  unsigned char filename[16 + 2];
  unsigned char str[256];
  puts0("file ? ");
  for (i = 0; i < 16; i++)
    str[i] = 0;
  getsn(str, 256);
  for (i = 0; i < 16; i++)
    filename[i] = str[i];
  filename[16] = 0;
  puts0("\r\n'");
  puts0(filename);
  puts0("'\r\n");
  i = open_(filename, 2);
  if (i == 1)
    puts0("open OK\r\n");
  else
    puts0("open not ok\r\n");
  puts0("count ? ");
  getsn(str, 256);
  n = atoi(str);
  puts0("n=");
  putdec(n);
  puts0("\r\n");
  for (i = 0; i < n; i++) {
    writec(0, '@');
    putch('@');
  }
  puts0("close rc=");
  putdec(close_(0));
  puts0("\r\n");
}
```