user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  cmp    $0x2,%edi
  jle    L33
L106:
  xor    %eax,%eax
  call   <setup_shared_mem@plt>
  mov    %rax,%r12
  xor    %eax,%eax
  call   <setup_semid@plt>
  test   %rax,%rax
  jne    L180
L22:
  call   <fork@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L99
  js     L104
L131:
  mov    %ebx,%esi
  lea    D27(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  call   <fork@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  je     L24
  js     L120
L55:
  lea    D28(%rip),%rdi
  xor    %eax,%eax
  lea    0x4(%rsp),%r13
  mov    %ebp,%esi
  call   <printf@plt>
  mov    %r13,%rdi
  mov    $0x2,%r12d
  lea    D79(%rip),%r14
  lea    D82(%rip),%r15
  call   <wait@plt>
  cmp    %eax,%ebx
  je     L153
L93:
  cmp    %eax,%ebp
  je     L155
  mov    %r14,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L18:
  cmp    $0x1,%r12d
  jne    L187
  lea    D85(%rip),%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <free_resources@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L165
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L187:
  mov    %r13,%rdi
  mov    $0x1,%r12d
  call   <wait@plt>
  cmp    %eax,%ebx
  jne    L93
L153:
  lea    D61(%rip),%rdi
  call   <puts@plt>
  jmp    L18
L155:
  mov    %r15,%rdi
  call   <puts@plt>
  jmp    L18
L120:
  xor    %eax,%eax
  call   <free_resources@plt>
  lea    D89(%rip),%rdi
  call   <perror@plt>
  or     $0xffffffff,%edi
  call   <exit@plt>
  jmp    L55
L104:
  xor    %eax,%eax
  call   <free_resources@plt>
  lea    D89(%rip),%rdi
  call   <perror@plt>
  or     $0xffffffff,%edi
  call   <exit@plt>
  jmp    L131
L24:
  mov    0x10(%r13),%rsi
  mov    %r12,%rdi
  call   <writer@plt>
  xor    %edi,%edi
  call   <exit@plt>
  jmp    L55
L99:
  mov    0x8(%r13),%rsi
  mov    %r12,%rdi
  call   <reader@plt>
  xor    %edi,%edi
  call   <exit@plt>
  jmp    L131
L180:
  xor    %eax,%eax
  call   <free_resources@plt>
  jmp    L22
L33:
  lea    D8(%rip),%rdi
  call   <printf@plt>
  xor    %edi,%edi
  call   <exit@plt>
  jmp    L106
L165:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D27
type_infered: string
name: retrieve_data
arguments: tag: D28
type_infered: string
name: retrieve_data
arguments: tag: D79
type_infered: string
name: retrieve_data
arguments: tag: D82
type_infered: string
name: retrieve_data
arguments: tag: D85
type_infered: string
name: retrieve_data
arguments: tag: D61
type_infered: string
name: retrieve_data
arguments: tag: D89
type_infered: string
name: retrieve_data
arguments: tag: D8
type_infered: string

tool: D27: Created reader task %d


tool: D28: Created writer task %d


tool: D79:  Some pid terminated %d


tool: D82: writer terminated

tool: D85: Everything done

tool: D61: reader terminated

tool: D89: reader fork error

tool: D8: usage: %s infile outfile


assistant: ```c
int main(int argc, char *argv[]) {
  struct copy_buffs *shared_stuff;
  int i, pid_reader, pid_writer, pid, status;
  if (argc < 3) {
    printf("usage: %s infile outfile\n");
    exit(0);
  }
  shared_stuff = setup_shared_mem();
  if (setup_semid()) {
    free_resources();
  }
  pid_reader = fork();
  if (pid_reader == 0) {
    reader(shared_stuff, argv[1]);
    exit(0);
  }
  if (pid_reader < 0) {
    free_resources();
    perror("reader fork error");
    exit(-1);
  }
  printf("Created reader task %d\n", pid_reader);
  pid_writer = fork();
  if (pid_writer == 0) {
    writer(shared_stuff, argv[2]);
    exit(0);
  }
  if (pid_writer < 0) {
    free_resources();
    perror("reader fork error");
    exit(-1);
  }
  printf("Created writer task %d\n", pid_writer);
  for (i = 0; i < 2; i++) {
    pid = wait(&status);
    if (pid == pid_reader)
      printf("reader terminated\n");
    else if (pid == pid_writer)
      printf("writer terminated\n");
    else
      printf(" Some pid terminated %d\n");
  }
  printf("Everything done\n");
  free_resources();
}
```