#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*/ cExec(char *);
int /*<<< orphan*/ cppExec(char *);
int /*<<< orphan*/ erlExec(char *);
int /*<<< orphan*/ haskExec(char *);
int /*<<< orphan*/ jExec(char *);
int /*<<< orphan*/ printf(char *);
void detLang(char *fileName) {
  int i = 0;
  while (fileName[i] != '.')
    i++;
  if (fileName[i + 1] == 'c' && fileName[i + 2] == '\0') {
    if (1)
      printf("Determined to be a C file.\nCompiling.\n");
    cExec(fileName);
  } else if (fileName[i + 1] == 'j') {
    if (1)
      printf("Determined to be a java file.\nCompiling.\n");
    jExec(fileName);
  } else if (fileName[i + 1] == 'c' && fileName[i + 2] == 'p') {
    if (1)
      printf("Determined to be a C++ file.\nCompiling.\n");
    cppExec(fileName);
  } else if (fileName[i + 1] == 'e') {
    if (1)
      printf("Determined to be an Erlang file.\nCompiling.\n");
    erlExec(fileName);
  } else if (fileName[i + 1] == 'h') {
    if (1)
      printf("Determined to be a Haskell file.\nCompiling.\n");
    haskExec(fileName);
  }
}


x86 assembly (clang, -O0):
<detLang>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2e,%eax
je     1196 <detLang+0x36>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1173 <detLang+0x13>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    11e4 <detLang+0x84>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11e4 <detLang+0x84>
lea    0xe2f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <cExec@plt>
jmp    12dd <detLang+0x17d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x6a,%eax
jne    1218 <detLang+0xb8>
lea    0xe22(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <jExec@plt>
jmp    12d8 <detLang+0x178>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x63,%eax
jne    1266 <detLang+0x106>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x70,%eax
jne    1266 <detLang+0x106>
lea    0xdfe(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <cppExec@plt>
jmp    12d3 <detLang+0x173>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x65,%eax
jne    129a <detLang+0x13a>
lea    0xdf3(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <erlExec@plt>
jmp    12ce <detLang+0x16e>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x68,%eax
jne    12c9 <detLang+0x169>
lea    0xdec(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <haskExec@plt>
jmp    12ce <detLang+0x16e>
jmp    12d3 <detLang+0x173>
jmp    12d8 <detLang+0x178>
jmp    12dd <detLang+0x17d>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detLang>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x2e,(%rbx,%rax,1)
lea    0x1(%rax),%rax
jne    1170 <detLang+0x10>
mov    %eax,%ecx
mov    (%rbx,%rcx,1),%cl
add    $0x9d,%cl
cmp    $0x7,%cl
ja     11bd <detLang+0x5d>
movzbl %cl,%ecx
lea    0xe6f(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    $0x1,%eax
mov    (%rbx,%rax,1),%al
cmp    $0x70,%al
je     11fe <detLang+0x9e>
test   %al,%al
jne    11bd <detLang+0x5d>
lea    0xf1a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <cExec@plt>
pop    %rbx
ret
lea    0xe5a(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1060 <haskExec@plt>
lea    0xe71(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <erlExec@plt>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1080 <jExec@plt>
lea    0xe73(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <cppExec@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Determined to be a C file.\0ACompiling.\0A\00"
@.str.1 = [42 x i8] c"Determined to be a java file.\0ACompiling.\0A\00"
@.str.2 = [41 x i8] c"Determined to be a C++ file.\0ACompiling.\0A\00"
@.str.3 = [45 x i8] c"Determined to be an Erlang file.\0ACompiling.\0A\00"
@.str.4 = [45 x i8] c"Determined to be a Haskell file.\0ACompiling.\0A\00"
define void @detLang(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %12, %1
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 46
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
store i32 %14, i32* %3
br label %4
15: ; preds = %4
%16 = load i8*, i8** %2
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %16, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 99
br i1 %23, label %24, label %37
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 2
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %25, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %24
%34 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%35 = load i8*, i8** %2
%36 = call i32 @cExec(i8* %35)
br label %102
37: ; preds = %24, %15
%38 = load i8*, i8** %2
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 106
br i1 %45, label %46, label %50
46: ; preds = %37
%47 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0))
%48 = load i8*, i8** %2
%49 = call i32 @jExec(i8* %48)
br label %101
50: ; preds = %37
%51 = load i8*, i8** %2
%52 = load i32, i32* %3
%53 = add nsw i32 %52, 1
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i8, i8* %51, i64 %54
%56 = load i8, i8* %55
%57 = sext i8 %56 to i32
%58 = icmp eq i32 %57, 99
br i1 %58, label %59, label %72
59: ; preds = %50
%60 = load i8*, i8** %2
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 2
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %60, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = icmp eq i32 %66, 112
br i1 %67, label %68, label %72
68: ; preds = %59
%69 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
%70 = load i8*, i8** %2
%71 = call i32 @cppExec(i8* %70)
br label %100
72: ; preds = %59, %50
%73 = load i8*, i8** %2
%74 = load i32, i32* %3
%75 = add nsw i32 %74, 1
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
%78 = load i8, i8* %77
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 101
br i1 %80, label %81, label %85
81: ; preds = %72
%82 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0))
%83 = load i8*, i8** %2
%84 = call i32 @erlExec(i8* %83)
br label %99
85: ; preds = %72
%86 = load i8*, i8** %2
%87 = load i32, i32* %3
%88 = add nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %86, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 104
br i1 %93, label %94, label %98
94: ; preds = %85
%95 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0))
%96 = load i8*, i8** %2
%97 = call i32 @haskExec(i8* %96)
br label %98
98: ; preds = %94, %85
br label %99
99: ; preds = %98, %81
br label %100
100: ; preds = %99, %68
br label %101
101: ; preds = %100, %46
br label %102
102: ; preds = %101, %33
ret void
}

LLVM IR (-O2):
@str = [44 x i8] c"Determined to be a Haskell file.\0ACompiling.\00"
@str.5 = [44 x i8] c"Determined to be an Erlang file.\0ACompiling.\00"
@str.6 = [40 x i8] c"Determined to be a C++ file.\0ACompiling.\00"
@str.7 = [41 x i8] c"Determined to be a java file.\0ACompiling.\00"
@str.8 = [38 x i8] c"Determined to be a C file.\0ACompiling.\00"
define void @detLang(i8* %0) {
br label %2
2: ; preds = %2, %1
%3 = phi i64 [ %7, %2 ], [ 0, %1 ]
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = load i8, i8* %4
%6 = icmp eq i8 %5, 46
%7 = add nuw i64 %3, 1
br i1 %6, label %8, label %2
8: ; preds = %2
%9 = add i64 %3, 1
%10 = and i64 %9, 4294967295
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = load i8, i8* %11
switch i8 %12, label %33 [
i8 99, label %13
i8 106, label %21
i8 101, label %27
i8 104, label %30
]
13: ; preds = %8
%14 = add i64 %3, 2
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds i8, i8* %0, i64 %15
%17 = load i8, i8* %16
switch i8 %17, label %33 [
i8 0, label %18
i8 112, label %24
]
18: ; preds = %13
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.8, i64 0, i64 0))
%20 = tail call i32 @cExec(i8* %0)
br label %33
21: ; preds = %8
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.7, i64 0, i64 0))
%23 = tail call i32 @jExec(i8* %0)
br label %33
24: ; preds = %13
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.6, i64 0, i64 0))
%26 = tail call i32 @cppExec(i8* %0)
br label %33
27: ; preds = %8
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.5, i64 0, i64 0))
%29 = tail call i32 @erlExec(i8* %0)
br label %33
30: ; preds = %8
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
%32 = tail call i32 @haskExec(i8* %0)
br label %33
33: ; preds = %13, %8, %21, %27, %30, %24, %18
ret void
}