user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r15
  lea    D13(%rip),%rdi
  push   %r14
  lea    D23(%rip),%r14
  push   %r13
  lea    D4(%rip),%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  lea    0x30(%rsp),%rbp
  lea    0x10(%rsp),%r12
  call   <puts0@plt>
  pxor   %xmm0,%xmm0
  mov    $0x64,%esi
  xor    %eax,%eax
  mov    %rbp,%rdi
  movaps %xmm0,0x30(%rsp)
  movb   $0x0,0x40(%rsp)
  call   <getsn@plt>
  movzbl 0x40(%rsp),%eax
  movdqa 0x30(%rsp),%xmm1
  mov    %r13,%rdi
  movb   $0x0,0x21(%rsp)
  mov    %al,0x20(%rsp)
  xor    %eax,%eax
  movaps %xmm1,0x10(%rsp)
  call   <puts0@plt>
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  xor    %eax,%eax
  mov    $0x2,%esi
  mov    %r12,%rdi
  call   <open@plt>
  cmp    $0x1,%ax
  jne    L13
  lea    D38(%rip),%rdi
  xor    %eax,%eax
  lea    D22(%rip),%r15
  call   <puts0@plt>
  movl   $0x1,0xc(%rsp)
L18:
  mov    %r15,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  xor    %eax,%eax
  mov    $0xc,%ecx
  mov    %rbp,%rdi
  rep stos %rax,%es:(%rdi)
  mov    $0x64,%esi
  movl   $0x0,(%rdi)
  mov    %rbp,%rdi
  call   <getsn@plt>
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  movzbl 0x30(%rsp),%esi
  cmp    $0x5d,%sil
  je     L51
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  je     L58
L14:
  movl   $0x0,0xc(%rsp)
  mov    %rbp,%r12
  lea    0x94(%rsp),%rbx
  nopl   0x0(%rax)
L5:
  test   %sil,%sil
  je     L18
  xor    %edi,%edi
  xor    %eax,%eax
  add    $0x1,%r12
  call   <writec@plt>
  movzbl -0x1(%r12),%edi
  xor    %eax,%eax
  call   <putch@plt>
  cmp    %r12,%rbx
  je     L18
  movzbl (%r12),%esi
  jmp    L5
L58:
  mov    $0xa,%esi
  xor    %edi,%edi
  xor    %eax,%eax
  call   <writec@plt>
  movzbl 0x30(%rsp),%esi
  jmp    L14
L51:
  xor    %edi,%edi
  xor    %eax,%eax
  call   <close@plt>
L32:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L64
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L13:
  lea    D18(%rip),%rdi
  xor    %eax,%eax
  call   <puts0@plt>
  jmp    L32
L64:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D13
datatype: string
name: extract_symbolic_data
arguments: data_label: D23
datatype: string
name: extract_symbolic_data
arguments: data_label: D4
datatype: string
name: extract_symbolic_data
arguments: data_label: D38
datatype: string
name: extract_symbolic_data
arguments: data_label: D22
datatype: string
name: extract_symbolic_data
arguments: data_label: D18
datatype: string

tool: D13: file ? 

tool: D23: '


tool: D4: 
'

tool: D38: open OK


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

tool: D18: 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);
}
```