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

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1018(%rsp)
  xor    %eax,%eax
  lea    0x8(%rsp),%rdi
  call   <pipe@plt>
  test   %eax,%eax
  js     L40
L61:
  mov    $0x0,%eax
  call   <fork@plt>
  test   %rax,%rax
  je     L20
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %rax,%rbp
  mov    0x8(%rsp),%edi
  call   <close@plt>
  lea    D39(%rip),%rbx
  mov    %rbx,%rdx
  mov    %ebp,%esi
  lea    D26(%rip),%r12
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbx,%rsi
  mov    0xc(%rsp),%edi
  call   <write@plt>
  lea    D43(%rip),%rbx
  mov    %rbx,%rdx
  mov    %ebp,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %eax,%edx
  mov    %rbx,%rsi
  mov    0xc(%rsp),%edi
  call   <write@plt>
L64:
  mov    %rbp,%rsi
  lea    D2(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
  mov    0x1018(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L67
  mov    $0x0,%eax
  add    $0x1028,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L40:
  lea    D33(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L61
L20:
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %rax,%rbp
  mov    0xc(%rsp),%edi
  call   <close@plt>
  lea    0x10(%rsp),%rdi
  mov    $0x1000,%edx
  mov    $0x0,%esi
  call   <memset@plt>
  lea    D0(%rip),%r12
  jmp    L30
L47:
  lea    0x10(%rsp),%rbx
  mov    %rbx,%rdx
  mov    %ebp,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x1000,%edx
  mov    $0x0,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
L30:
  lea    0x10(%rsp),%rsi
  mov    $0x1000,%edx
  mov    0x8(%rsp),%edi
  call   <read@plt>
  test   %rax,%rax
  jne    L47
  mov    %ebp,%esi
  lea    D8(%rip),%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%edi
  call   <close@plt>
  jmp    L64
L67:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D39
type_guessed: string
name: disassemble_data
arguments: data_label: D26
type_guessed: string
name: disassemble_data
arguments: data_label: D43
type_guessed: string
name: disassemble_data
arguments: data_label: D2
type_guessed: string
name: disassemble_data
arguments: data_label: D33
type_guessed: string
name: disassemble_data
arguments: data_label: D0
type_guessed: string
name: disassemble_data
arguments: data_label: D8
type_guessed: string

tool: D39: a string made by the parent


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


tool: D43: and another string

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


tool: D33: error creating pipe

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


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


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