user: 请从给定的汇编指令推导出C源代码:

```asm
<forktest>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  call   <fork@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L20
  call   <fork@plt>
  mov    %eax,-0x28(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  je     L20
  mov    $0x0,%eax
  call   <yield@plt>
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  call   <ps@plt>
L20:
  movw   $0x58,-0x1a(%rbp)
  mov    $0x0,%eax
  call   <getpid@plt>
  add    $0x61,%eax
  mov    %al,-0x1a(%rbp)
  movl   $0x0,-0x20(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L27
  cmpl   $0x0,-0x28(%rbp)
  jne    L8
L27:
  lea    D38(%rip),%rax
  mov    %rax,%rdi
  call   <setpsname@plt>
  mov    $0x0,%eax
  call   <getpid@plt>
  lea    0x64(%rax),%ebx
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %ebx,%edx
  mov    %eax,%esi
  lea    D25(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  call   <getpid@plt>
  add    $0x64,%eax
  mov    %eax,%edi
  call   <exit@plt>
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %eax,%esi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L17
L8:
  lea    -0x2c(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <waitpid@plt>
  mov    -0x2c(%rbp),%ebx
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %ebx,%edx
  mov    %eax,%esi
  lea    D30(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    -0x2c(%rbp),%rcx
  mov    -0x28(%rbp),%eax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <waitpid@plt>
  mov    -0x2c(%rbp),%ebx
  mov    $0x0,%eax
  call   <getpid@plt>
  mov    %ebx,%edx
  mov    %eax,%esi
  lea    D30(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L17:
  mov    -0x18(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L54
  call   <__stack_chk_fail@plt>
L54:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D29
type_guessed: string
name: extract_symbolic_data
arguments: label: D38
type_guessed: string
name: extract_symbolic_data
arguments: label: D25
type_guessed: string
name: extract_symbolic_data
arguments: label: D43
type_guessed: string
name: extract_symbolic_data
arguments: label: D30
type_guessed: string

tool: D29: Parent calling ps():

tool: D38: forktest

tool: D25: [%d]u I am a child. Calling exit(%d).


tool: D43: [%d]u ERROR: Code nach exit.


tool: D30: [%d]u waitpid() returns %d


assistant: ```c
void forktest() {
  int pid1, pid2;
  pid1 = fork();
  if (pid1 != 0) {
    pid2 = fork();
    if (pid2 != 0) {
      yield();
      printf("Parent calling ps():\n");
      ps();
    };
  };
  char string[] = "X";
  string[0] = 'a' + getpid();
  int i = 0;
  int status;
  if (pid1 == 0 || pid2 == 0) {
    setpsname("forktest");
    printf("[%d]u I am a child. Calling exit(%d).\n", getpid(), 100 + getpid());
    exit(100 + getpid());
    printf("[%d]u ERROR: Code nach exit.\n", getpid());
  } else {
    waitpid(pid1, &status, 0);
    printf("[%d]u waitpid() returns %d\n", getpid(), status);
    waitpid(pid2, &status, 0);
    printf("[%d]u waitpid() returns %d\n", getpid(), status);
    return;
  }
}
```