#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*/ execute_cfile(int);
int /*<<< orphan*/ execute_pyfile();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_extension(char *);
int /*<<< orphan*/ get_running_dir();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "usage: ./a.out input_file\n");
    return 0;
  }
  get_running_dir();
  int filetype = get_extension(argv[1]);
  if (filetype < 0)
    fprintf(stderr, "unrecognized file\n");
  if (filetype == 1 || filetype == 2) {
    fprintf(stderr, "input file is c or c++\n");
    execute_cfile(filetype);
  }
  if (filetype == 3) {
    fprintf(stderr, "input file is python\n");
    execute_pyfile();
  }
  if (filetype == 4) {
    fprintf(stderr, "input file is java\n");
  }
  exit(0);
}


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)
cmpl   $0x2,-0x8(%rbp)
je     119d <main+0x3d>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1030 <get_running_dir@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <get_extension@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11d3 <main+0x73>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1050 <fprintf@plt>
cmpl   $0x1,-0x14(%rbp)
je     11e7 <main+0x87>
cmpl   $0x2,-0x14(%rbp)
jne    1204 <main+0xa4>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1040 <execute_cfile@plt>
cmpl   $0x3,-0x14(%rbp)
jne    122a <main+0xca>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1060 <execute_pyfile@plt>
cmpl   $0x4,-0x14(%rbp)
jne    1249 <main+0xe9>
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
lea    0xe18(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
je     117f <main+0x1f>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    %rsi,%rbx
xor    %eax,%eax
call   1030 <get_running_dir@plt>
mov    0x8(%rbx),%rdi
call   1080 <get_extension@plt>
mov    %eax,%ebx
test   %eax,%eax
jns    11af <main+0x4f>
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
call   1050 <fprintf@plt>
jmp    11d3 <main+0x73>
lea    -0x1(%rbx),%eax
cmp    $0x1,%eax
ja     11d3 <main+0x73>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1050 <fprintf@plt>
mov    %ebx,%edi
call   1040 <execute_cfile@plt>
cmp    $0x4,%ebx
je     1200 <main+0xa0>
cmp    $0x3,%ebx
jne    1215 <main+0xb5>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe59(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1060 <execute_pyfile@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
call   1050 <fprintf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"usage: ./a.out input_file\0A\00"
@.str.1 = [19 x i8] c"unrecognized file\0A\00"
@.str.2 = [24 x i8] c"input file is c or c++\0A\00"
@.str.3 = [22 x i8] c"input file is python\0A\00"
@.str.4 = [20 x i8] c"input file is java\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
ret i32 0
12: ; preds = %2
%13 = call i32 (...) @get_running_dir()
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @get_extension(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %12
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %20, %12
%24 = load i32, i32* %6
%25 = icmp eq i32 %24, 1
br i1 %25, label %29, label %26
26: ; preds = %23
%27 = load i32, i32* %6
%28 = icmp eq i32 %27, 2
br i1 %28, label %29, label %34
29: ; preds = %26, %23
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* %6
%33 = call i32 @execute_cfile(i32 %32)
br label %34
34: ; preds = %29, %26
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 (...) @execute_pyfile()
br label %41
41: ; preds = %37, %34
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 4
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %44, %41
%48 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"usage: ./a.out input_file\0A\00"
@.str.1 = [19 x i8] c"unrecognized file\0A\00"
@.str.2 = [24 x i8] c"input file is c or c++\0A\00"
@.str.3 = [22 x i8] c"input file is python\0A\00"
@.str.4 = [20 x i8] c"input file is java\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
ret i32 0
7: ; preds = %2
%8 = tail call i32 (...) @get_running_dir()
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @get_extension(i8* %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %23
16: ; preds = %7
%17 = add nsw i32 %11, -1
%18 = icmp ult i32 %17, 2
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @execute_cfile(i32 %11)
br label %23
23: ; preds = %13, %16, %19
switch i32 %11, label %31 [
i32 3, label %24
i32 4, label %28
]
24: ; preds = %23
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%27 = tail call i32 (...) @execute_pyfile()
br label %31
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %24, %23, %28
%32 = tail call i32 @exit(i32 0)
unreachable
}