#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ fork();
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ sleep(int);
int main() {
  pid_t f1, f2;
  f1 = fork();
  if (f1 != 0) {
    f2 = fork();
    if (f2 == 0) {
      puts("F");
      puts("P");
    } else {
      puts("R");
      puts("Z");
    }
  } else {
    puts("S");
    puts("Q");
  }
  sleep(15);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11a5 <main+0x75>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1188 <main+0x58>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
jmp    11a0 <main+0x70>
lea    0xe75(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
jmp    11bd <main+0x8d>
lea    0xe5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
mov    $0xf,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
je     116d <main+0x3d>
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
lea    0xeb2(%rip),%rax
lea    0xeaf(%rip),%rdi
cmove  %rax,%rdi
lea    0xea2(%rip),%rax
lea    0xe9f(%rip),%rbx
cmove  %rax,%rbx
jmp    117b <main+0x4b>
lea    0xe96(%rip),%rbx
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    $0xf,%edi
call   1040 <sleep@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"F\00"
@.str.1 = [2 x i8] c"P\00"
@.str.2 = [2 x i8] c"R\00"
@.str.3 = [2 x i8] c"Z\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"Q\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i64 (...) @fork()
store i64 %4, i64* %2
%5 = load i64, i64* %2
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %0
%8 = call i64 (...) @fork()
store i64 %8, i64* %3
%9 = load i64, i64* %3
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
14: ; preds = %7
%15 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %14, %11
br label %21
18: ; preds = %0
%19 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @puts(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %21
21: ; preds = %18, %17
%22 = call i32 @sleep(i32 15)
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"F\00"
@.str.1 = [2 x i8] c"P\00"
@.str.2 = [2 x i8] c"R\00"
@.str.3 = [2 x i8] c"Z\00"
@.str.4 = [2 x i8] c"S\00"
@.str.5 = [2 x i8] c"Q\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %8, label %3
3: ; preds = %0
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
%6 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%7 = select i1 %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0)
br label %8
8: ; preds = %0, %3
%9 = phi i8* [ %6, %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), %0 ]
%10 = phi i8* [ %7, %3 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), %0 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
%12 = tail call i32 @puts(i8* dereferenceable(1) %10)
%13 = tail call i32 @sleep(i32 15)
ret i32 0
}