// File: /workspace/github_c_makefile_star2_O0/motet-a[P]libforks/examples/fizz_buzz_threads.c
// Function: echo_upper_main
static void echo_upper_main(libforks_ServerConn conn, int socket_fd) {
  // not strictly required but recommended
  assert(libforks_free_conn(conn) == libforks_OK);

  int out, ready_fd;
  char c;
  assert(libforks_read_socket_fds(socket_fd, &c, 1, &out, 1) == 0);
  assert(c == 'a');
  assert(libforks_read_socket_fds(socket_fd, &c, 1, &ready_fd, 1) == 0);
  assert(c == 'b');

  assert(dup2(socket_fd, STDIN_FILENO) != -1);
  assert(dup2(out, STDOUT_FILENO) != -1);
  close(socket_fd);
  close(out);

  // Inform the parent process that we’re ready to receive input
  assert(write(ready_fd, "c", 1) == 1);
  close(ready_fd);

  execlp("tr", "tr", "[:lower:]", "[:upper:]", NULL); // uppercase!
  perror("execlp");
  abort();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
callq 0x2c50
cmpl $0x0, %eax
jne 0x192f
jmp 0x194e
leaq 0x28b1(%rip), %rdi      # 0x41e7
leaq 0x26ec(%rip), %rsi      # 0x4029
movl $0x1f, %edx
leaq 0x2abe(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0xc(%rbp), %edi
leaq -0x15(%rbp), %rsi
movl $0x1, %r8d
leaq -0x10(%rbp), %rcx
movq %r8, %rdx
callq 0x1b80
cmpl $0x0, %eax
jne 0x196e
jmp 0x198d
leaq 0x2ac1(%rip), %rdi      # 0x4436
leaq 0x26ad(%rip), %rsi      # 0x4029
movl $0x23, %edx
leaq 0x2a7f(%rip), %rcx      # 0x4407
callq 0x10e0
movsbl -0x15(%rbp), %eax
cmpl $0x61, %eax
jne 0x1998
jmp 0x19b7
leaq 0x2ad0(%rip), %rdi      # 0x446f
leaq 0x2683(%rip), %rsi      # 0x4029
movl $0x24, %edx
leaq 0x2a55(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0xc(%rbp), %edi
leaq -0x15(%rbp), %rsi
movl $0x1, %r8d
leaq -0x14(%rbp), %rcx
movq %r8, %rdx
callq 0x1b80
cmpl $0x0, %eax
jne 0x19d7
jmp 0x19f6
leaq 0x2a9a(%rip), %rdi      # 0x4478
leaq 0x2644(%rip), %rsi      # 0x4029
movl $0x25, %edx
leaq 0x2a16(%rip), %rcx      # 0x4407
callq 0x10e0
movsbl -0x15(%rbp), %eax
cmpl $0x62, %eax
jne 0x1a01
jmp 0x1a20
leaq 0x2aae(%rip), %rdi      # 0x44b6
leaq 0x261a(%rip), %rsi      # 0x4029
movl $0x26, %edx
leaq 0x29ec(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0xc(%rbp), %edi
xorl %esi, %esi
callq 0x10c0
cmpl $-0x1, %eax
je 0x1a31
jmp 0x1a50
leaq 0x2800(%rip), %rdi      # 0x4238
leaq 0x25ea(%rip), %rsi      # 0x4029
movl $0x28, %edx
leaq 0x29bc(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0x10(%rbp), %edi
movl $0x1, %esi
callq 0x10c0
cmpl $-0x1, %eax
je 0x1a64
jmp 0x1a83
leaq 0x2a54(%rip), %rdi      # 0x44bf
leaq 0x25b7(%rip), %rsi      # 0x4029
movl $0x29, %edx
leaq 0x2989(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0xc(%rbp), %edi
callq 0x1100
movl -0x10(%rbp), %edi
callq 0x1100
movl -0x14(%rbp), %edi
leaq 0x25a7(%rip), %rsi      # 0x4044
movl $0x1, %edx
callq 0x1080
cmpq $0x1, %rax
jne 0x1aaf
jmp 0x1ace
leaq 0x2a28(%rip), %rdi      # 0x44de
leaq 0x256c(%rip), %rsi      # 0x4029
movl $0x2e, %edx
leaq 0x293e(%rip), %rcx      # 0x4407
callq 0x10e0
movl -0x14(%rbp), %edi
callq 0x1100
leaq 0x2a1e(%rip), %rsi      # 0x44fb
leaq 0x2a1a(%rip), %rdx      # 0x44fe
leaq 0x2a1d(%rip), %rcx      # 0x4508
xorl %eax, %eax
movl %eax, %r8d
movq %rsi, %rdi
movb $0x0, %al
callq 0x1230
leaq 0x2763(%rip), %rdi      # 0x4264
callq 0x11f0
callq 0x1040
nopl (%rax,%rax)