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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x98,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x88(%rsp)
  xor    %eax,%eax
  lea    D10(%rip),%rdi
  call   <puts0@plt>
  lea    0x20(%rsp),%r12
  lea    0x31(%rsp),%rdx
  mov    %r12,%rax
L2:
  movb   $0x0,(%rax)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L2
  lea    0x20(%rsp),%rdi
  mov    $0x64,%esi
  mov    $0x0,%eax
  call   <getsn@plt>
  mov    $0x0,%eax
L126:
  movzbl 0x20(%rsp,%rax,1),%edx
  mov    %dl,(%rsp,%rax,1)
  add    $0x1,%rax
  cmp    $0x11,%rax
  jne    L126
  movb   $0x0,0x11(%rsp)
  lea    D69(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    %rsp,%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  lea    D32(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    $0x2,%esi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <open@plt>
  cmp    $0x1,%ax
  jne    L113
  lea    D24(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    $0x1,%r13d
  lea    D58(%rip),%r15
  lea    0x64(%r12),%rbx
  lea    D69(%rip),%r14
  jmp    L52
L113:
  lea    D75(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
L12:
  mov    0x88(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L37
  add    $0x98,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L76:
  mov    $0x0,%r13d
L52:
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    %r12,%rax
L70:
  movb   $0x0,(%rax)
  add    $0x1,%rax
  cmp    %rbx,%rax
  jne    L70
  lea    0x20(%rsp),%rbp
  mov    $0x64,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <getsn@plt>
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  lea    D32(%rip),%rdi
  mov    $0x0,%eax
  call   <puts0@plt>
  cmpb   $0x5d,0x20(%rsp)
  je     L83
  test   %r13d,%r13d
  je     L31
L128:
  mov    %r12,%rbp
L129:
  movzbl 0x0(%rbp),%esi
  test   %sil,%sil
  je     L76
  movzbl %sil,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <writec@plt>
  movzbl 0x0(%rbp),%edi
  mov    $0x0,%eax
  call   <putch@plt>
  add    $0x1,%rbp
  cmp    %rbx,%rbp
  jne    L129
  jmp    L76
L31:
  mov    $0xa,%esi
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <writec@plt>
  jmp    L128
L83:
  mov    $0x0,%edi
  mov    $0x0,%eax
  call   <close@plt>
  jmp    L12
L37:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D10
type_infered: string
name: unpack_data
arguments: tag: D69
type_infered: string
name: unpack_data
arguments: tag: D32
type_infered: string
name: unpack_data
arguments: tag: D24
type_infered: string
name: unpack_data
arguments: tag: D58
type_infered: string
name: unpack_data
arguments: tag: D75
type_infered: string

tool: D10: file ? 

tool: D69: 
'

tool: D32: '


tool: D24: open OK


tool: D58: data to file (] - end of text) ? 

tool: D75: open not ok


assistant: ```c
void main(void) {
  unsigned short int i;
  unsigned short int j;
  unsigned short int equal;
  unsigned char device;
  unsigned char filename[17 + 2];
  unsigned char str[100];
  int first_line;
  puts0("file ? ");
  for (i = 0; i < 17; i++)
    str[i] = 0;
  getsn(str, 100);
  for (i = 0; i < 17; i++)
    filename[i] = str[i];
  filename[17] = 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");
    return;
  }
  first_line = 1;
  while (1) {
    puts0("data to file (] - end of text) ? ");
    for (i = 0; i < 100; i++)
      str[i] = 0;
    getsn(str, 100);
    puts0("\r\n'");
    puts0(str);
    puts0("'\r\n");
    if (str[0] == ']')
      break;
    if (first_line == 0)
      writec(0, '\n');
    else
      first_line = 0;
    for (i = 0; i < 100; i++)
      if (str[i]) {
        writec(0, str[i]);
        putch(str[i]);
      } else
        break;
  }
  close(0);
}
```