#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 fork();
int /*<<< orphan*/ printf(char *);
int main() {
  int pid1 = fork();
  printf("**1**\n");
  int pid2 = fork();
  printf("**2**\n");
  if (pid1 == 0) {
    int pid3 = fork();
    printf("**3**\n");
  } else {
    printf("**4**\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <fork@plt>
mov    %eax,-0x8(%rbp)
lea    0xec0(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <fork@plt>
mov    %eax,-0xc(%rbp)
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1180 <main+0x60>
mov    $0x0,%al
call   1040 <fork@plt>
mov    %eax,-0x10(%rbp)
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
jmp    118c <main+0x6c>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <fork@plt>
mov    %eax,%ebx
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <fork@plt>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
test   %ebx,%ebx
je     1156 <main+0x36>
lea    0xeb8(%rip),%rdi
jmp    1164 <main+0x44>
xor    %eax,%eax
call   1040 <fork@plt>
lea    0xeae(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

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

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