#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*/ printf(char *, ...);
int process_til(int, char **);
int process_wcd(int, char **);
int process_wpa(int, char **);
int process_wpg(int, char **);
int /*<<< orphan*/ strcmp(char *, char *);
size_t strlen(char *);
int main(int argc, char **argv) {
  char *ext;
  size_t fname_len;
  if (argc < 2) {
    printf("usage: *.exe file_in");
    return (1);
  }
  fname_len = strlen(argv[1]);
  ext = argv[1] + fname_len - 3;
  printf("EXTENSION IS: %s\n\n\n", ext);
  if (!strcmp(ext, "wcd")) {
    return process_wcd(argc, argv);
  }
  if (!strcmp(ext, "wpg")) {
    return process_wpg(argc, argv);
  }
  if (!strcmp(ext, "til")) {
    return process_til(argc, argv);
  }
  if (!strcmp(ext, "wpa")) {
    return process_wpa(argc, argv);
  }
  return 1;
}


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)
jge    11aa <main+0x3a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    129c <main+0x12c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
add    -0x20(%rbp),%rax
add    $0xfffffffffffffffd,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    120e <main+0x9e>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <process_wcd@plt>
mov    %eax,-0x4(%rbp)
jmp    129c <main+0x12c>
mov    -0x18(%rbp),%rdi
lea    0xe14(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    123b <main+0xcb>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <process_wpg@plt>
mov    %eax,-0x4(%rbp)
jmp    129c <main+0x12c>
mov    -0x18(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1268 <main+0xf8>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <process_til@plt>
mov    %eax,-0x4(%rbp)
jmp    129c <main+0x12c>
mov    -0x18(%rbp),%rdi
lea    0xdc2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1295 <main+0x125>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1090 <process_wpa@plt>
mov    %eax,-0x4(%rbp)
jmp    129c <main+0x12c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     1191 <main+0x21>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
add    %rax,%rbx
add    $0xfffffffffffffffd,%rbx
lea    0xe65(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1214 <main+0xa4>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1222 <main+0xb2>
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1230 <main+0xc0>
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
jne    1187 <main+0x17>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1090 <process_wpa@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <process_wcd@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <process_wpg@plt>
mov    %ebp,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1080 <process_til@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"usage: *.exe file_in\00"
@.str.1 = [20 x i8] c"EXTENSION IS: %s\0A\0A\0A\00"
@.str.2 = [4 x i8] c"wcd\00"
@.str.3 = [4 x i8] c"wpg\00"
@.str.4 = [4 x i8] c"til\00"
@.str.5 = [4 x i8] c"wpa\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %57
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strlen(i8* %15)
store i64 %16, i64* %7
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i64, i64* %7
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = getelementptr inbounds i8, i8* %21, i64 -3
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @strcmp(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp ne i32 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %12
%29 = load i32, i32* %4
%30 = load i8**, i8*** %5
%31 = call i32 @process_wcd(i32 %29, i8** %30)
store i32 %31, i32* %3
br label %57
32: ; preds = %12
%33 = load i8*, i8** %6
%34 = call i32 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %40, label %36
36: ; preds = %32
%37 = load i32, i32* %4
%38 = load i8**, i8*** %5
%39 = call i32 @process_wpg(i32 %37, i8** %38)
store i32 %39, i32* %3
br label %57
40: ; preds = %32
%41 = load i8*, i8** %6
%42 = call i32 @strcmp(i8* %41, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i32, i32* %4
%46 = load i8**, i8*** %5
%47 = call i32 @process_til(i32 %45, i8** %46)
store i32 %47, i32* %3
br label %57
48: ; preds = %40
%49 = load i8*, i8** %6
%50 = call i32 @strcmp(i8* %49, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%51 = icmp ne i32 %50, 0
br i1 %51, label %56, label %52
52: ; preds = %48
%53 = load i32, i32* %4
%54 = load i8**, i8*** %5
%55 = call i32 @process_wpa(i32 %53, i8** %54)
store i32 %55, i32* %3
br label %57
56: ; preds = %48
store i32 1, i32* %3
br label %57
57: ; preds = %56, %52, %44, %36, %28, %10
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [21 x i8] c"usage: *.exe file_in\00"
@.str.1 = [20 x i8] c"EXTENSION IS: %s\0A\0A\0A\00"
@.str.2 = [4 x i8] c"wcd\00"
@.str.3 = [4 x i8] c"wpg\00"
@.str.4 = [4 x i8] c"til\00"
@.str.5 = [4 x i8] c"wpa\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %32
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strlen(i8* dereferenceable(1) %8)
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = getelementptr inbounds i8, i8* %10, i64 -3
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %6
%16 = tail call i32 @process_wcd(i32 %0, i8** %1)
br label %32
17: ; preds = %6
%18 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 @process_wpg(i32 %0, i8** %1)
br label %32
22: ; preds = %17
%23 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @process_til(i32 %0, i8** %1)
br label %32
27: ; preds = %22
%28 = tail call i32 @strcmp(i8* %11, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @process_wpa(i32 %0, i8** %1)
br label %32
32: ; preds = %27, %30, %25, %20, %15, %4
%33 = phi i32 [ 1, %4 ], [ %31, %30 ], [ %26, %25 ], [ %21, %20 ], [ %16, %15 ], [ 1, %27 ]
ret i32 %33
}