#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 */
int /*<<< orphan*/ execl(char *, char *, char *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  int i = 1;
  pid_t pid;
  pid = fork();
  if (pid < 0) {
    fprintf(stderr, "Fork Failed");
    return 1;
  }
  if (pid == 0) {
    execl("/data/misc/ptreeARM", "ptreeARM", ((char *)NULL));
  } else {
    wait(NULL);
    printf("Child Complete.");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jge    119d <main+0x4d>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11d9 <main+0x89>
cmpq   $0x0,-0x10(%rbp)
jne    11c4 <main+0x74>
lea    0xe5d(%rip),%rdi
lea    0xe61(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <execl@plt>
jmp    11d9 <main+0x89>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1176 <main+0x26>
je     1192 <main+0x42>
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <wait@plt>
lea    0xeb1(%rip),%rdi
call   1030 <printf@plt>
jmp    11a9 <main+0x59>
mov    0x2e63(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%ebx
jmp    11a9 <main+0x59>
lea    0xe73(%rip),%rdi
lea    0xe77(%rip),%rsi
xor    %ebx,%ebx
xor    %edx,%edx
call   1050 <execl@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [12 x i8] c"Fork Failed\00"
@.str.1 = [20 x i8] c"/data/misc/ptreeARM\00"
@.str.2 = [9 x i8] c"ptreeARM\00"
@.str.3 = [16 x i8] c"Child Complete.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 0, i32* %1
store i32 1, i32* %2
%4 = call i64 (...) @fork()
store i64 %4, i64* %3
%5 = load i64, i64* %3
%6 = icmp slt i64 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %18
10: ; preds = %0
%11 = load i64, i64* %3
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* null)
br label %18
15: ; preds = %10
%16 = call i32 @wait(i32* null)
%17 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %18
18: ; preds = %7, %15, %13
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [12 x i8] c"Fork Failed\00"
@.str.1 = [20 x i8] c"/data/misc/ptreeARM\00"
@.str.2 = [9 x i8] c"ptreeARM\00"
@.str.3 = [16 x i8] c"Child Complete.\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp slt i64 %1, 0
br i1 %2, label %3, label %6
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
6: ; preds = %0
%7 = icmp eq i64 %1, 0
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = tail call i32 @execl(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* null)
br label %13
10: ; preds = %6
%11 = tail call i32 @wait(i32* null)
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %13
13: ; preds = %8, %10, %3
%14 = phi i32 [ 1, %3 ], [ 0, %10 ], [ 0, %8 ]
ret i32 %14
}