#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*/ create_proc(char *, char *);
int /*<<< orphan*/ print(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    print("parent\n");
    create_proc(argv[0], "child");
    print("parent exiting\n");
  } else if (argc == 2 && strcmp(argv[1], "child") == 0) {
    print("child\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1180 <main+0x50>
lea    0xea9(%rip),%rdi
call   1030 <print@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe9e(%rip),%rsi
call   1050 <create_proc@plt>
lea    0xe98(%rip),%rdi
call   1030 <print@plt>
jmp    11b9 <main+0x89>
cmpl   $0x2,-0x8(%rbp)
jne    11b4 <main+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11b4 <main+0x84>
lea    0xe6f(%rip),%rdi
call   1030 <print@plt>
jmp    11b9 <main+0x89>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1162 <main+0x32>
cmp    $0x1,%edi
jne    1183 <main+0x53>
lea    0xebb(%rip),%rdi
call   1030 <print@plt>
mov    (%rbx),%rdi
lea    0xeb4(%rip),%rsi
call   1050 <create_proc@plt>
lea    0xeae(%rip),%rdi
jmp    117e <main+0x4e>
mov    0x8(%rbx),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1183 <main+0x53>
lea    0xea0(%rip),%rdi
call   1030 <print@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"parent\0A\00"
@.str.1 = [6 x i8] c"child\00"
@.str.2 = [16 x i8] c"parent exiting\0A\00"
@.str.3 = [7 x i8] c"child\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 1
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = call i32 @print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @create_proc(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @print(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br label %27
15: ; preds = %2
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %15
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = call i32 @print(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %24, %18, %15
br label %27
27: ; preds = %26, %8
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [8 x i8] c"parent\0A\00"
@.str.1 = [6 x i8] c"child\00"
@.str.2 = [16 x i8] c"parent exiting\0A\00"
@.str.3 = [7 x i8] c"child\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
switch i32 %0, label %15 [
i32 1, label %3
i32 2, label %7
]
3: ; preds = %2
%4 = tail call i32 @print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %1
%6 = tail call i32 @create_proc(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %12
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %7, %3
%13 = phi i8* [ getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), %3 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), %7 ]
%14 = tail call i32 @print(i8* %13)
br label %15
15: ; preds = %12, %2, %7
ret i32 0
}