user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <SYNC_INIT@plt>
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  js     L0
  mov    %rax,%rbp
  lea    D55(%rip),%r13
  lea    D78(%rip),%r12
  je     L12
  nopw   0x0(%rax,%rax,1)
L85:
  xor    %edi,%edi
  call   <SYNC_WAIT@plt>
  mov    %r13,%rdi
  call   <puts@plt>
  xor    %eax,%eax
  call   <read_increase_write@plt>
  mov    %rbp,%rdi
  mov    $0x1,%esi
  mov    %eax,%ebx
  call   <SYNC_TELL@plt>
  mov    %r12,%rdi
  call   <puts@plt>
  cmp    $0x9,%ebx
  jbe    L85
  lea    0x4(%rsp),%rdi
  movl   $0x0,0x4(%rsp)
  call   <wait@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  js     L41
L98:
  mov    0x4(%rsp),%edi
  call   <WEXITSTATUS@plt>
  mov    %rbp,%rsi
  lea    D66(%rip),%rdi
  mov    %eax,%edx
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x1,%eax
L75:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L77
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L41:
  lea    D23(%rip),%rdi
  call   <err_sys@plt>
  jmp    L98
L12:
  xor    %eax,%eax
  lea    D18(%rip),%rbp
  lea    D52(%rip),%r12
  call   <getpid@plt>
  lea    D59(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L81
  nopl   0x0(%rax)
L72:
  mov    $0x1,%edi
  call   <SYNC_WAIT@plt>
  xor    %eax,%eax
  call   <getppid@plt>
  mov    %r12,%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
L81:
  xor    %eax,%eax
  call   <read_increase_write@plt>
  mov    %eax,%ebx
  xor    %eax,%eax
  call   <getppid@plt>
  xor    %esi,%esi
  movslq %eax,%rdi
  call   <SYNC_TELL@plt>
  mov    %rbp,%rdi
  call   <puts@plt>
  cmp    $0x9,%ebx
  jbe    L72
  mov    $0x2,%eax
  jmp    L75
L0:
  lea    D58(%rip),%rdi
  call   <err_sys@plt>
  or     $0xffffffff,%eax
  jmp    L75
L77:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D55
data_type: string
name: extract_symbolic_data
arguments: tag: D78
data_type: string
name: extract_symbolic_data
arguments: tag: D66
data_type: string
name: extract_symbolic_data
arguments: tag: D23
data_type: string
name: extract_symbolic_data
arguments: tag: D18
data_type: string
name: extract_symbolic_data
arguments: tag: D52
data_type: string
name: extract_symbolic_data
arguments: tag: D59
data_type: string
name: extract_symbolic_data
arguments: tag: D58
data_type: string

tool: D55: wait child

tool: D78: notify child

tool: D66: wait child %u exit %d


tool: D23: wait error

tool: D18: notify parent

tool: D52: wait parent %u


tool: D59: child %u running


tool: D58: fork error

assistant: ```c
int main(void) {
  int ret = 0;
  pid_t cid = 0;
  SYNC_INIT();
  cid = fork();
  if (cid < 0) {
    err_sys("fork error");
    return -1;
  } else if (cid == 0) {
    printf("child %u running\n", getpid());
    while (ret < 10) {
      ret = read_increase_write();
      SYNC_TELL(getppid(), 0);
      printf("notify parent\n");
      if (ret < 0 || ret >= 10)
        break;
      SYNC_WAIT(1);
      printf("wait parent %u\n", getppid());
    }
    return 2;
  }
  while (ret < 10 && ret >= 0) {
    SYNC_WAIT(0);
    printf("wait child\n");
    ret = read_increase_write();
    SYNC_TELL(cid, 1);
    printf("notify child\n");
  }
  pid_t wid = 0;
  int status = 0;
  if ((wid = wait(&status)) < 0)
    err_sys("wait error");
  printf("wait child %u exit %d\n", wid, WEXITSTATUS(status));
  return 1;
}
```