#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 printUsage(char *);
int run();
int /*<<< orphan*/ setenv(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int runCompile(int argp, int argc, char *argv[]) {
  if (argc - argp < 2)
    return printUsage("Missing argument(s).");
  char *kind = argv[argp++];
  char *infile = argv[argp++];
  if (argc - argp > 0)
    return printUsage("Too many arguments.");
  char *wrapper = NULL;
  if (strcmp(kind, "header") == 0)
    wrapper = "ComputeHeader";
  else if (strcmp(kind, "rules") == 0)
    wrapper = "ComputeRules";
  else if (strcmp(kind, "sorts") == 0)
    wrapper = "ComputeSorts";
  else if (strcmp(kind, "symbols") == 0)
    wrapper = "ComputeSymbols";
  else if (strcmp(kind, "opt1") == 0)
    wrapper = "Optimize1";
  else
    return printUsage("Invalid compile mode.");
  setenv("input", infile, 1);
  setenv("wrapper", wrapper, 1);
  return run();
}


x86 assembly (clang, -O0):
<runCompile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x2,%eax
jge    1175 <runCompile+0x35>
lea    0xe98(%rip),%rdi
call   1060 <printUsage@plt>
mov    %eax,-0x4(%rbp)
jmp    1302 <runCompile+0x1c2>
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x0,%eax
jle    11cc <runCompile+0x8c>
lea    0xe56(%rip),%rdi
call   1060 <printUsage@plt>
mov    %eax,-0x4(%rbp)
jmp    1302 <runCompile+0x1c2>
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11fe <runCompile+0xbe>
lea    0xe3b(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12ce <runCompile+0x18e>
mov    -0x20(%rbp),%rdi
lea    0xe35(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1228 <runCompile+0xe8>
lea    0xe25(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12c9 <runCompile+0x189>
mov    -0x20(%rbp),%rdi
lea    0xe1e(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1252 <runCompile+0x112>
lea    0xe0e(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12c4 <runCompile+0x184>
mov    -0x20(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    127c <runCompile+0x13c>
lea    0xdf9(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12bf <runCompile+0x17f>
mov    -0x20(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    12a6 <runCompile+0x166>
lea    0xde3(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    12ba <runCompile+0x17a>
lea    0xddd(%rip),%rdi
call   1060 <printUsage@plt>
mov    %eax,-0x4(%rbp)
jmp    1302 <runCompile+0x1c2>
jmp    12bf <runCompile+0x17f>
jmp    12c4 <runCompile+0x184>
jmp    12c9 <runCompile+0x189>
jmp    12ce <runCompile+0x18e>
mov    -0x28(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    -0x30(%rbp),%rsi
lea    0xdb8(%rip),%rdi
mov    $0x1,%edx
call   1030 <setenv@plt>
mov    $0x0,%al
call   1040 <run@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<runCompile>:
push   %r14
push   %rbx
push   %rax
mov    %esi,%eax
sub    %edi,%eax
cmp    $0x1,%eax
jg     1156 <runCompile+0x16>
lea    0xeac(%rip),%rdi
jmp    1164 <runCompile+0x24>
lea    0x2(%rdi),%eax
cmp    %esi,%eax
jge    1170 <runCompile+0x30>
lea    0xeb1(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <printUsage@plt>
movslq %edi,%rax
mov    (%rdx,%rax,8),%rbx
mov    0x8(%rdx,%rax,8),%r14
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11ec <runCompile+0xac>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11f5 <runCompile+0xb5>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11fe <runCompile+0xbe>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1207 <runCompile+0xc7>
lea    0xea8(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1210 <runCompile+0xd0>
lea    0xea3(%rip),%rdi
jmp    1164 <runCompile+0x24>
lea    0xe3d(%rip),%rbx
jmp    1217 <runCompile+0xd7>
lea    0xe48(%rip),%rbx
jmp    1217 <runCompile+0xd7>
lea    0xe52(%rip),%rbx
jmp    1217 <runCompile+0xd7>
lea    0xe5e(%rip),%rbx
jmp    1217 <runCompile+0xd7>
lea    0xe69(%rip),%rbx
lea    0xe82(%rip),%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <setenv@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <run@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Missing argument(s).\00"
@.str.1 = [20 x i8] c"Too many arguments.\00"
@.str.2 = [7 x i8] c"header\00"
@.str.3 = [14 x i8] c"ComputeHeader\00"
@.str.4 = [6 x i8] c"rules\00"
@.str.5 = [13 x i8] c"ComputeRules\00"
@.str.6 = [6 x i8] c"sorts\00"
@.str.7 = [13 x i8] c"ComputeSorts\00"
@.str.8 = [8 x i8] c"symbols\00"
@.str.9 = [15 x i8] c"ComputeSymbols\00"
@.str.10 = [5 x i8] c"opt1\00"
@.str.11 = [10 x i8] c"Optimize1\00"
@.str.12 = [22 x i8] c"Invalid compile mode.\00"
@.str.13 = [6 x i8] c"input\00"
@.str.14 = [8 x i8] c"wrapper\00"
define i32 @runCompile(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%11 = load i32, i32* %6
%12 = load i32, i32* %5
%13 = sub nsw i32 %11, %12
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 @printUsage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %4
br label %73
17: ; preds = %3
%18 = load i8**, i8*** %7
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 1
store i32 %20, i32* %5
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8*, i8** %18, i64 %21
%23 = load i8*, i8** %22
store i8* %23, i8** %8
%24 = load i8**, i8*** %7
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8*, i8** %24, i64 %27
%29 = load i8*, i8** %28
store i8* %29, i8** %9
%30 = load i32, i32* %6
%31 = load i32, i32* %5
%32 = sub nsw i32 %30, %31
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %17
%35 = call i32 @printUsage(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
store i32 %35, i32* %4
br label %73
36: ; preds = %17
store i8* null, i8** %10
%37 = load i8*, i8** %8
%38 = call i64 @strcmp(i8* %37, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %36
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8** %10
br label %67
41: ; preds = %36
%42 = load i8*, i8** %8
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %41
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8** %10
br label %66
46: ; preds = %41
%47 = load i8*, i8** %8
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %51
50: ; preds = %46
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), i8** %10
br label %65
51: ; preds = %46
%52 = load i8*, i8** %8
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %51
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), i8** %10
br label %64
56: ; preds = %51
%57 = load i8*, i8** %8
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8** %10
br label %63
61: ; preds = %56
%62 = call i32 @printUsage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
store i32 %62, i32* %4
br label %73
63: ; preds = %60
br label %64
64: ; preds = %63, %55
br label %65
65: ; preds = %64, %50
br label %66
66: ; preds = %65, %45
br label %67
67: ; preds = %66, %40
%68 = load i8*, i8** %9
%69 = call i32 @setenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %68, i32 1)
%70 = load i8*, i8** %10
%71 = call i32 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* %70, i32 1)
%72 = call i32 (...) @run()
store i32 %72, i32* %4
br label %73
73: ; preds = %67, %61, %34, %15
%74 = load i32, i32* %4
ret i32 %74
}

LLVM IR (-O2):
@.str = [21 x i8] c"Missing argument(s).\00"
@.str.1 = [20 x i8] c"Too many arguments.\00"
@.str.2 = [7 x i8] c"header\00"
@.str.3 = [14 x i8] c"ComputeHeader\00"
@.str.4 = [6 x i8] c"rules\00"
@.str.5 = [13 x i8] c"ComputeRules\00"
@.str.6 = [6 x i8] c"sorts\00"
@.str.7 = [13 x i8] c"ComputeSorts\00"
@.str.8 = [8 x i8] c"symbols\00"
@.str.9 = [15 x i8] c"ComputeSymbols\00"
@.str.10 = [5 x i8] c"opt1\00"
@.str.11 = [10 x i8] c"Optimize1\00"
@.str.12 = [22 x i8] c"Invalid compile mode.\00"
@.str.13 = [6 x i8] c"input\00"
@.str.14 = [8 x i8] c"wrapper\00"
define i32 @runCompile(i32 %0, i32 %1, i8** nocapture %2) {
%4 = sub nsw i32 %1, %0
%5 = icmp slt i32 %4, 2
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @printUsage(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %42
8: ; preds = %3
%9 = add nsw i32 %0, 1
%10 = sext i32 %0 to i64
%11 = getelementptr inbounds i8*, i8** %2, i64 %10
%12 = load i8*, i8** %11
%13 = add nsw i32 %0, 2
%14 = sext i32 %9 to i64
%15 = getelementptr inbounds i8*, i8** %2, i64 %14
%16 = load i8*, i8** %15
%17 = icmp slt i32 %13, %1
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = tail call i32 @printUsage(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %42
20: ; preds = %8
%21 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %37, label %23
23: ; preds = %20
%24 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %37, label %26
26: ; preds = %23
%27 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %26
%30 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %37, label %32
32: ; preds = %29
%33 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %32
%36 = tail call i32 @printUsage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.12, i64 0, i64 0))
br label %42
37: ; preds = %32, %29, %26, %23, %20
%38 = phi i8* [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), %20 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), %23 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0), %26 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), %29 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), %32 ]
%39 = tail call i32 @setenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.13, i64 0, i64 0), i8* %16, i32 1)
%40 = tail call i32 @setenv(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8* %38, i32 1)
%41 = tail call i32 (...) @run()
br label %42
42: ; preds = %18, %37, %35, %6
%43 = phi i32 [ %7, %6 ], [ %19, %18 ], [ %41, %37 ], [ %36, %35 ]
ret i32 %43
}