#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 */

/* Variables and functions */
int /*<<< orphan*/ child();
int fork();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, const char *argv[]) {
  for (int i = 1; i <= 3; i++) {
    printf("P %2d\n", i);
  }
  int pid = fork();
  if (pid == 0) {
    child();
  } else {
    for (int i = 7; i <= 9; i++) {
      printf("P %2d\n", i);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jg     1174 <main+0x44>
mov    -0x14(%rbp),%esi
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114d <main+0x1d>
mov    $0x0,%al
call   1050 <fork@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1194 <main+0x64>
mov    $0x0,%al
call   1030 <child@plt>
jmp    11c7 <main+0x97>
movl   $0x7,-0x1c(%rbp)
cmpl   $0x9,-0x1c(%rbp)
jg     11c2 <main+0x92>
mov    -0x1c(%rbp),%esi
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119b <main+0x6b>
jmp    11c7 <main+0x97>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <fork@plt>
test   %eax,%eax
je     119a <main+0x6a>
lea    0xe8f(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1040 <printf@plt>
jmp    11a1 <main+0x71>
xor    %eax,%eax
call   1030 <child@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"P %2d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %15, %2
%10 = load i32, i32* %6
%11 = icmp sle i32 %10, 3
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* %6
%14 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %12
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %9
18: ; preds = %9
%19 = call i32 (...) @fork()
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 (...) @child()
br label %35
24: ; preds = %18
store i32 7, i32* %8
br label %25
25: ; preds = %31, %24
%26 = load i32, i32* %8
%27 = icmp sle i32 %26, 9
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %25
34: ; preds = %25
br label %35
35: ; preds = %34, %22
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"P %2d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 2)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 3)
%6 = tail call i32 (...) @fork()
%7 = icmp eq i32 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 8)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 9)
br label %14
12: ; preds = %2
%13 = tail call i32 (...) @child()
br label %14
14: ; preds = %8, %12
ret i32 0
}