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

```asm
<main>:
  endbr64
  push   %r12
  push   %rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <getpid@plt>
  lea    D46(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  call   <fork@plt>
  mov    %eax,%ebp
  xor    %eax,%eax
  call   <getpid@plt>
  cmp    $0xffffffff,%ebp
  je     L47
  mov    %eax,%r12d
  xor    %eax,%eax
  test   %ebp,%ebp
  jle    L17
  call   <getppid@plt>
  mov    %ebp,%edx
  mov    %r12d,%esi
  lea    D42(%rip),%rdi
  mov    %eax,%ecx
  xor    %eax,%eax
  xor    %r12d,%r12d
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  xor    %edx,%edx
  mov    %ebp,%edi
  call   <waitpid@plt>
  mov    0x4(%rsp),%edi
  mov    %eax,%ebp
  call   <WIFEXITED@plt>
  mov    %ebp,%esi
  lea    D31(%rip),%rdi
  mov    %eax,%edx
  xor    %eax,%eax
  call   <printf@plt>
L58:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L53
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
L17:
  call   <getppid@plt>
  lea    D55(%rip),%rbp
  mov    %r12d,%esi
  lea    D41(%rip),%rdi
  mov    %eax,%edx
  xor    %eax,%eax
  xor    %r12d,%r12d
  call   <printf@plt>
  mov    %rbp,%rdi
  call   <system@plt>
  lea    D14(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    %rbp,%rsi
  lea    D39(%rip),%rdi
  call   <execle@plt>
  add    $0x1,%eax
  jne    L58
  lea    D68(%rip),%rdi
  call   <puts@plt>
  jmp    L58
L47:
  lea    D78(%rip),%rdi
  mov    $0x1,%r12d
  call   <puts@plt>
  jmp    L58
L53:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D46
type_guessed: string
name: read_data
arguments: data_tag: D42
type_guessed: string
name: read_data
arguments: data_tag: D31
type_guessed: string
name: read_data
arguments: data_tag: D55
type_guessed: string
name: read_data
arguments: data_tag: D41
type_guessed: string
name: read_data
arguments: data_tag: D14
type_guessed: string
name: read_data
arguments: data_tag: D39
type_guessed: string
name: read_data
arguments: data_tag: D68
type_guessed: string
name: read_data
arguments: data_tag: D78
type_guessed: string

tool: D46: pid:%d


tool: D42: parent %d's child %d, parent %d.


tool: D31: wait return %d, WIFEXITED=%d.


tool: D55: date

tool: D41: child %d's parent %d.


tool: D14: system() return %d.


tool: D39: /bin/date

tool: D68: failed to exec. 

tool: D78: failed to fork.

assistant: ```c
int main() {
  pid_t pid = getpid();
  printf("pid:%d\n", pid);
  pid_t fork_pid = fork();
  pid = getpid();
  if (fork_pid == -1) {
    puts("failed to fork.");
    return 1;
  } else if (fork_pid > 0) {
    printf("parent %d's child %d, parent %d.\n", pid, fork_pid, getppid());
    int status;
    pid_t wait_pid;
    wait_pid = waitpid(fork_pid, &status, 0);
    printf("wait return %d, WIFEXITED=%d.\n", wait_pid, WIFEXITED(status));
  } else {
    printf("child %d's parent %d.\n", pid, getppid());
    int system_ret = system("date");
    printf("system() return %d.\n", system_ret);
    int exec_ret = execle("/bin/date", "date", 0, 0, NULL);
    if (exec_ret == -1) {
      puts("failed to exec. ");
    }
  }
  return 0;
}
```