#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *);
char *rindex(char *, char);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
scalar_t__ strstr(char *, char *);
int main(int argc, char **argv) {
  char *cp;
  char *cp1;
  int build;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
    return -1;
  }
  cp = argv[1];
  cp1 = rindex(cp, '/');
  if (cp1)
    cp = cp1 + 1;
  if (strstr(cp, "_cachedmulti.elf"))
    build = 3;
  else if (strstr(cp, "_multi.elf"))
    build = 2;
  else if (strstr(cp, "_cached.elf"))
    build = 1;
  else
    build = 0;
  if (strncmp(cp, "test_raw_mc_", 12) == 0) {
    switch (build) {
    case 0:
      printf("-Traw.ld\n");
      break;
    case 1:
      printf("-Traw_cached.ld obj/init_cached.o\n");
      break;
    case 2:
      printf("-Traw.ld\n");
      break;
    case 3:
      printf("-Traw_cached.ld obj/init_cached.o\n");
    }
  } else if (strncmp(cp, "test_raw_", 9) == 0) {
    switch (build) {
    case 0:
      printf("-Traw.ld\n");
      break;
    case 1:
      printf("-Traw_cached.ld obj/init_cached.o\n");
      break;
    case 2:
      printf("-Traw_multi.ld obj/init_multi.o\n");
      break;
    case 3:
      printf("-Traw_cachedmulti.ld obj/init_multi.o\n");
      break;
    }
  } else {
    switch (build) {
    case 0:
      printf("-Ttest.ld obj/lib.o\n");
      break;
    case 1:
      printf("-Ttest_cached.ld obj/init_cached.o obj/lib.o\n");
      break;
    case 2:
      printf("-Ttest_cached.ld obj/lib.o\n");
      break;
    case 3:
      printf("-Ttest_cached.ld obj/init_cached.o obj/lib.o\n");
      break;
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    1198 <main+0x48>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xea9(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13d5 <main+0x285>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <rindex@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11cd <main+0x7d>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     11f3 <main+0xa3>
movl   $0x3,-0x24(%rbp)
jmp    1250 <main+0x100>
mov    -0x18(%rbp),%rdi
lea    0xe59(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     1219 <main+0xc9>
movl   $0x2,-0x24(%rbp)
jmp    124b <main+0xfb>
mov    -0x18(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1070 <strstr@plt>
cmp    $0x0,%rax
je     123f <main+0xef>
movl   $0x1,-0x24(%rbp)
jmp    1246 <main+0xf6>
movl   $0x0,-0x24(%rbp)
jmp    124b <main+0xfb>
jmp    1250 <main+0x100>
mov    -0x18(%rbp),%rdi
lea    0xe13(%rip),%rsi
mov    $0xc,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12d8 <main+0x188>
mov    -0x24(%rbp),%eax
mov    %rax,-0x30(%rbp)
sub    $0x3,%rax
ja     12d3 <main+0x183>
mov    -0x30(%rbp),%rax
lea    0xd95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xde0(%rip),%rdi
call   1040 <printf@plt>
jmp    12d3 <main+0x183>
lea    0xdd9(%rip),%rdi
call   1040 <printf@plt>
jmp    12d3 <main+0x183>
lea    0xdbe(%rip),%rdi
call   1040 <printf@plt>
jmp    12d3 <main+0x183>
lea    0xdb7(%rip),%rdi
call   1040 <printf@plt>
jmp    13ce <main+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xdc5(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1360 <main+0x210>
mov    -0x24(%rbp),%eax
mov    %rax,-0x38(%rbp)
sub    $0x3,%rax
ja     135b <main+0x20b>
mov    -0x38(%rbp),%rax
lea    0xcfd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd58(%rip),%rdi
call   1040 <printf@plt>
jmp    135b <main+0x20b>
lea    0xd51(%rip),%rdi
call   1040 <printf@plt>
jmp    135b <main+0x20b>
lea    0xd6d(%rip),%rdi
call   1040 <printf@plt>
jmp    135b <main+0x20b>
lea    0xd7d(%rip),%rdi
call   1040 <printf@plt>
jmp    13c9 <main+0x279>
mov    -0x24(%rbp),%eax
mov    %rax,-0x40(%rbp)
sub    $0x3,%rax
ja     13c4 <main+0x274>
mov    -0x40(%rbp),%rax
lea    0xc84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd6e(%rip),%rdi
call   1040 <printf@plt>
jmp    13c4 <main+0x274>
lea    0xd72(%rip),%rdi
call   1040 <printf@plt>
jmp    13c4 <main+0x274>
lea    0xd8f(%rip),%rdi
call   1040 <printf@plt>
jmp    13c4 <main+0x274>
lea    0xd50(%rip),%rdi
call   1040 <printf@plt>
jmp    13c9 <main+0x279>
jmp    13ce <main+0x27e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jg     117b <main+0x2b>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xec4(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    128c <main+0x13c>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1060 <rindex@plt>
lea    0x1(%rax),%r14
test   %rax,%rax
cmove  %rbx,%r14
lea    0xea8(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
mov    $0x3,%ebx
test   %rax,%rax
jne    11e0 <main+0x90>
lea    0xea0(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
mov    $0x2,%ebx
test   %rax,%rax
jne    11e0 <main+0x90>
lea    0xe92(%rip),%rsi
mov    %r14,%rdi
call   1070 <strstr@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
lea    0xe87(%rip),%rsi
mov    %r14,%rdi
mov    $0xc,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     122d <main+0xdd>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     123f <main+0xef>
mov    %ebx,%eax
lea    0xde5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe75(%rip),%rdi
jmp    1285 <main+0x135>
mov    %ebx,%eax
lea    0xdea(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    %ebx,%eax
lea    0xdc8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef1(%rip),%rdi
jmp    1285 <main+0x135>
lea    0xec6(%rip),%rdi
jmp    1285 <main+0x135>
lea    0xe63(%rip),%rdi
jmp    1285 <main+0x135>
lea    0xe12(%rip),%rdi
jmp    1285 <main+0x135>
lea    0xe8b(%rip),%rdi
jmp    1285 <main+0x135>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [17 x i8] c"_cachedmulti.elf\00"
@.str.2 = [11 x i8] c"_multi.elf\00"
@.str.3 = [12 x i8] c"_cached.elf\00"
@.str.4 = [13 x i8] c"test_raw_mc_\00"
@.str.5 = [10 x i8] c"-Traw.ld\0A\00"
@.str.6 = [35 x i8] c"-Traw_cached.ld obj/init_cached.o\0A\00"
@.str.7 = [10 x i8] c"test_raw_\00"
@.str.8 = [33 x i8] c"-Traw_multi.ld obj/init_multi.o\0A\00"
@.str.9 = [39 x i8] c"-Traw_cachedmulti.ld obj/init_multi.o\0A\00"
@.str.10 = [21 x i8] c"-Ttest.ld obj/lib.o\0A\00"
@.str.11 = [46 x i8] c"-Ttest_cached.ld obj/init_cached.o obj/lib.o\0A\00"
@.str.12 = [28 x i8] c"-Ttest_cached.ld obj/lib.o\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %15)
store i32 -1, i32* %3
br label %89
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i8* @rindex(i8* %21, i8 signext 47)
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i8*, i8** %7
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %6
br label %28
28: ; preds = %25, %17
%29 = load i8*, i8** %6
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 3, i32* %8
br label %46
33: ; preds = %28
%34 = load i8*, i8** %6
%35 = call i64 @strstr(i8* %34, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i32 2, i32* %8
br label %45
38: ; preds = %33
%39 = load i8*, i8** %6
%40 = call i64 @strstr(i8* %39, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 1, i32* %8
br label %44
43: ; preds = %38
store i32 0, i32* %8
br label %44
44: ; preds = %43, %42
br label %45
45: ; preds = %44, %37
br label %46
46: ; preds = %45, %32
%47 = load i8*, i8** %6
%48 = call i64 @strncmp(i8* %47, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %61
50: ; preds = %46
%51 = load i32, i32* %8
switch i32 %51, label %60 [
i32 0, label %52
i32 1, label %54
i32 2, label %56
i32 3, label %58
]
52: ; preds = %50
%53 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %60
54: ; preds = %50
%55 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %60
56: ; preds = %50
%57 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %60
58: ; preds = %50
%59 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %60
60: ; preds = %58, %50, %56, %54, %52
br label %88
61: ; preds = %46
%62 = load i8*, i8** %6
%63 = call i64 @strncmp(i8* %62, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 9)
%64 = icmp eq i64 %63, 0
br i1 %64, label %65, label %76
65: ; preds = %61
%66 = load i32, i32* %8
switch i32 %66, label %75 [
i32 0, label %67
i32 1, label %69
i32 2, label %71
i32 3, label %73
]
67: ; preds = %65
%68 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %75
69: ; preds = %65
%70 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
br label %75
71: ; preds = %65
%72 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %75
73: ; preds = %65
%74 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
br label %75
75: ; preds = %65, %73, %71, %69, %67
br label %87
76: ; preds = %61
%77 = load i32, i32* %8
switch i32 %77, label %86 [
i32 0, label %78
i32 1, label %80
i32 2, label %82
i32 3, label %84
]
78: ; preds = %76
%79 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %86
80: ; preds = %76
%81 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
br label %86
82: ; preds = %76
%83 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.12, i64 0, i64 0))
br label %86
84: ; preds = %76
%85 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
br label %86
86: ; preds = %76, %84, %82, %80, %78
br label %87
87: ; preds = %86, %75
br label %88
88: ; preds = %87, %60
store i32 0, i32* %3
br label %89
89: ; preds = %88, %11
%90 = load i32, i32* %3
ret i32 %90
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"Usage: %s <filename>\0A\00"
@.str.1 = [17 x i8] c"_cachedmulti.elf\00"
@.str.2 = [11 x i8] c"_multi.elf\00"
@.str.3 = [12 x i8] c"_cached.elf\00"
@.str.4 = [13 x i8] c"test_raw_mc_\00"
@.str.7 = [10 x i8] c"test_raw_\00"
@str.13 = [27 x i8] c"-Ttest_cached.ld obj/lib.o\00"
@str.14 = [45 x i8] c"-Ttest_cached.ld obj/init_cached.o obj/lib.o\00"
@str.15 = [20 x i8] c"-Ttest.ld obj/lib.o\00"
@str.16 = [38 x i8] c"-Traw_cachedmulti.ld obj/init_multi.o\00"
@str.17 = [32 x i8] c"-Traw_multi.ld obj/init_multi.o\00"
@str.22 = [34 x i8] c"-Traw_cached.ld obj/init_cached.o\00"
@str.23 = [9 x i8] c"-Traw.ld\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %61
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @rindex(i8* %10, i8 signext 47)
%12 = icmp eq i8* %11, null
%13 = getelementptr inbounds i8, i8* %11, i64 1
%14 = select i1 %12, i8* %10, i8* %13
%15 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %24
17: ; preds = %8
%18 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i64 @strstr(i8* %14, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %20, %17, %8
%25 = phi i32 [ 3, %8 ], [ 2, %17 ], [ %23, %20 ]
%26 = tail call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
switch i32 %25, label %58 [
i32 0, label %29
i32 1, label %31
i32 2, label %33
i32 3, label %35
]
29: ; preds = %28
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.23, i64 0, i64 0))
br label %61
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.22, i64 0, i64 0))
br label %61
33: ; preds = %28
%34 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.23, i64 0, i64 0))
br label %61
35: ; preds = %28
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.22, i64 0, i64 0))
br label %61
37: ; preds = %24
%38 = tail call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 9)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %49
40: ; preds = %37
switch i32 %25, label %59 [
i32 0, label %41
i32 1, label %43
i32 2, label %45
i32 3, label %47
]
41: ; preds = %40
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.23, i64 0, i64 0))
br label %61
43: ; preds = %40
%44 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.22, i64 0, i64 0))
br label %61
45: ; preds = %40
%46 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.17, i64 0, i64 0))
br label %61
47: ; preds = %40
%48 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.16, i64 0, i64 0))
br label %61
49: ; preds = %37
switch i32 %25, label %60 [
i32 0, label %50
i32 1, label %52
i32 2, label %54
i32 3, label %56
]
50: ; preds = %49
%51 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.15, i64 0, i64 0))
br label %61
52: ; preds = %49
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.14, i64 0, i64 0))
br label %61
54: ; preds = %49
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
br label %61
56: ; preds = %49
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.14, i64 0, i64 0))
br label %61
58: ; preds = %28
unreachable
59: ; preds = %40
unreachable
60: ; preds = %49
unreachable
61: ; preds = %35, %33, %31, %29, %50, %52, %54, %56, %41, %43, %45, %47, %4
%62 = phi i32 [ -1, %4 ], [ 0, %47 ], [ 0, %45 ], [ 0, %43 ], [ 0, %41 ], [ 0, %56 ], [ 0, %54 ], [ 0, %52 ], [ 0, %50 ], [ 0, %29 ], [ 0, %31 ], [ 0, %33 ], [ 0, %35 ]
ret i32 %62
}