#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 WEXITSTATUS(int);
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int *);
int main(int ArgCount, char *ArgVals[], char *EnvVals[]) {
  if (ArgCount < 2) {
    fprintf(stderr, "Usage: %s FileToCompile\n", ArgVals[0]);
    exit(1);
  }
  pid_t ChildPid = fork();
  if (ChildPid) {
    int Status;
    wait(&Status);
    printf("\nCompilation exited with code %d\n", WEXITSTATUS(Status));
  } else {
    char *Arguments[] = {"gcc", ArgVals[1], 0};
    execve("/usr/bin/gcc", Arguments, EnvVals);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ba <main+0x4a>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe55(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1090 <fork@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11f4 <main+0x84>
lea    -0x24(%rbp),%rdi
call   1080 <wait@plt>
mov    -0x24(%rbp),%edi
call   1060 <WEXITSTATUS@plt>
mov    %eax,%esi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    1227 <main+0xb7>
lea    0xe49(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe19(%rip),%rdi
call   1040 <execve@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jle    11e7 <main+0x77>
mov    %rdx,%r14
xor    %eax,%eax
call   1090 <fork@plt>
test   %rax,%rax
je     11ae <main+0x3e>
mov    %rsp,%rdi
call   1080 <wait@plt>
mov    (%rsp),%edi
call   1060 <WEXITSTATUS@plt>
lea    0xe74(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
jmp    11dd <main+0x6d>
lea    0xe8f(%rip),%rax
mov    %rax,(%rsp)
mov    0x8(%rbx),%rax
mov    %rax,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe69(%rip),%rdi
mov    %rsp,%rsi
mov    %r14,%rdx
call   1040 <execve@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe06(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s FileToCompile\0A\00"
@.str.1 = [34 x i8] c"\0ACompilation exited with code %d\0A\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [13 x i8] c"/usr/bin/gcc\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i32
%10 = alloca [3 x i8*]
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %6
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %3
%21 = call i64 (...) @fork()
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %20
%25 = call i32 @wait(i32* %9)
%26 = load i32, i32* %9
%27 = call i32 @WEXITSTATUS(i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %27)
br label %39
29: ; preds = %20
%30 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %30
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8**, i8*** %6
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
store i8* %34, i8** %31
%35 = getelementptr inbounds i8*, i8** %31, i64 1
store i8* null, i8** %35
%36 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
%37 = load i8**, i8*** %7
%38 = call i32 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %36, i8** %37)
br label %39
39: ; preds = %29, %24
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Usage: %s FileToCompile\0A\00"
@.str.1 = [34 x i8] c"\0ACompilation exited with code %d\0A\00"
@.str.2 = [4 x i8] c"gcc\00"
@.str.3 = [13 x i8] c"/usr/bin/gcc\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** %2) {
%4 = alloca i32
%5 = alloca [3 x i8*]
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %12
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %3
%13 = tail call i64 (...) @fork()
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = bitcast i32* %4 to i8*
%17 = call i32 @wait(i32* %4)
%18 = load i32, i32* %4
%19 = call i32 @WEXITSTATUS(i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %29
21: ; preds = %12
%22 = bitcast [3 x i8*]* %5 to i8*
%23 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 0
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 1
%25 = getelementptr inbounds i8*, i8** %1, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %24
%27 = getelementptr inbounds [3 x i8*], [3 x i8*]* %5, i64 0, i64 2
store i8* null, i8** %27
%28 = call i32 @execve(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %23, i8** %2)
br label %29
29: ; preds = %21, %15
ret i32 0
}