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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x50,%rsp
  mov    %edi,-0x1044(%rbp)
  mov    %rsi,-0x1050(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x1018(%rbp),%rax
  mov    %rax,%rdi
  call   <pipe@plt>
  mov    %eax,-0x1034(%rbp)
  cmpl   $0x0,-0x1034(%rbp)
  jns    L6
  lea    D25(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L6:
  mov    $0x0,%eax
  call   <fork@plt>
  mov    %rax,-0x1028(%rbp)
  cmpq   $0x0,-0x1028(%rbp)
  je     L5
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %rax,-0x1030(%rbp)
  mov    -0x1018(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  lea    D65(%rip),%rax
  mov    %rax,-0x1020(%rbp)
  mov    -0x1030(%rbp),%rax
  mov    %eax,%ecx
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x1014(%rbp),%eax
  mov    -0x1020(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  lea    D56(%rip),%rax
  mov    %rax,-0x1020(%rbp)
  mov    -0x1030(%rbp),%rax
  mov    %eax,%ecx
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1020(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    -0x1014(%rbp),%eax
  mov    -0x1020(%rbp),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  jmp    L8
L5:
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %rax,-0x1030(%rbp)
  mov    -0x1014(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  lea    -0x1010(%rbp),%rax
  mov    $0x1000,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  jmp    L24
L19:
  mov    -0x1030(%rbp),%rax
  mov    %eax,%ecx
  lea    -0x1010(%rbp),%rax
  mov    %rax,%rdx
  mov    %ecx,%esi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    -0x1010(%rbp),%rax
  mov    $0x1000,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
L24:
  mov    -0x1018(%rbp),%eax
  lea    -0x1010(%rbp),%rcx
  mov    $0x1000,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  test   %rax,%rax
  jne    L19
  mov    -0x1030(%rbp),%rax
  mov    %eax,%esi
  lea    D32(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x1018(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
L8:
  mov    -0x1030(%rbp),%rax
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L30
  call   <__stack_chk_fail@plt>
L30:
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D25
type_guessed: string
name: read_data
arguments: data_label: D65
type_guessed: string
name: read_data
arguments: data_label: D6
type_guessed: string
name: read_data
arguments: data_label: D56
type_guessed: string
name: read_data
arguments: data_label: D19
type_guessed: string
name: read_data
arguments: data_label: D32
type_guessed: string
name: read_data
arguments: data_label: D9
type_guessed: string

tool: D25: error creating pipe

tool: D65: a string made by the parent


tool: D6: pid: %d -- writing %s to pipe_desc[1]


tool: D56: and another string

tool: D19: pid: %d -- received %s from parent


tool: D32: pid: %d -- child detects write end closed


tool: D9: pid: %d -- I am exiting


assistant: ```c
int main(int argc, char **argv) {
  pid_t child_id;
  pid_t my_id;
  int pipe_desc[2];
  char *string;
  char read_buffer[4096];
  int err;
  err = pipe(pipe_desc);
  if (err < 0) {
    printf("error creating pipe\n");
    exit(1);
  }
  child_id = fork();
  if (child_id != 0) {
    my_id = getpid();
    close(pipe_desc[0]);
    string = "a string made by the parent\n";
    printf("pid: %d -- writing %s to pipe_desc[1]\n", (int)my_id, string);
    write(pipe_desc[1], string, strlen(string));
    string = "and another string";
    printf("pid: %d -- writing %s to pipe_desc[1]\n", (int)my_id, string);
    write(pipe_desc[1], string, strlen(string));
  } else {
    my_id = getpid();
    close(pipe_desc[1]);
    memset(read_buffer, 0, sizeof(read_buffer));
    while (read(pipe_desc[0], read_buffer, sizeof(read_buffer))) {
      printf("pid: %d -- received %s from parent\n", (int)my_id, read_buffer);
      memset(read_buffer, 0, sizeof(read_buffer));
    }
    printf("pid: %d -- child detects write end closed\n", (int)my_id);
    close(pipe_desc[0]);
  }
  printf("pid: %d -- I am exiting\n", my_id);
  exit(0);
}
```