#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 EXIT_SUCCESS;
int /*<<< orphan*/ executeChild();
int /*<<< orphan*/ executeParent();
int fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ wait(int *);
int main(int argc, char *argv[]) {
  int pid = fork();
  if (pid) {
    executeParent();
    printf("Parent waiting...\n");
    int status = 0;
    wait(&status);
    printf("Parent done\n");
  } else {
    executeChild();
    printf("Child done!\n");
  }
  return EXIT_SUCCESS;
}


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)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11ae <main+0x5e>
mov    $0x0,%al
call   1050 <executeParent@plt>
lea    0xe78(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
call   1060 <wait@plt>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
jmp    11c1 <main+0x71>
mov    $0x0,%al
call   1030 <executeChild@plt>
lea    0xe64(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
test   %eax,%eax
je     118a <main+0x3a>
xor    %eax,%eax
call   1050 <executeParent@plt>
lea    0xea2(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1060 <wait@plt>
lea    0xe96(%rip),%rdi
jmp    1198 <main+0x48>
xor    %eax,%eax
call   1030 <executeChild@plt>
lea    0xe68(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Parent waiting...\0A\00"
@.str.1 = [13 x i8] c"Parent done\0A\00"
@.str.2 = [13 x i8] c"Child done!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 (...) @fork()
store i32 %8, i32* %6
%9 = load i32, i32* %6
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = call i32 (...) @executeParent()
%13 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %7
%14 = call i32 @wait(i32* %7)
%15 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %19
16: ; preds = %2
%17 = call i32 (...) @executeChild()
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %16, %11
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@str = [12 x i8] c"Child done!\00"
@str.3 = [18 x i8] c"Parent waiting...\00"
@str.4 = [12 x i8] c"Parent done\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = tail call i32 (...) @fork()
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 (...) @executeParent()
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
%9 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%10 = call i32 @wait(i32* %3)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.4, i64 0, i64 0))
br label %15
12: ; preds = %2
%13 = tail call i32 (...) @executeChild()
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %15
15: ; preds = %12, %6
%16 = load i32, i32* @EXIT_SUCCESS
ret i32 %16
}