#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*/ BattleRoyaleWithCheese(char *, char *);
int /*<<< orphan*/ SortMaster3000(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ train_compare(char *, char *);
int /*<<< orphan*/ validate_compare(char *, char *);
void run_compare(int argc, char **argv) {
  if (argc < 4) {
    fprintf(stderr,
            "usage: %s %s [train/test/valid] [cfg] [weights (optional)]\n",
            argv[0], argv[1]);
    return;
  }
  char *cfg = argv[3];
  char *weights = (argc > 4) ? argv[4] : 0;
  if (0 == strcmp(argv[2], "train"))
    train_compare(cfg, weights);
  else if (0 == strcmp(argv[2], "valid"))
    validate_compare(cfg, weights);
  else if (0 == strcmp(argv[2], "sort"))
    SortMaster3000(cfg, weights);
  else if (0 == strcmp(argv[2], "battle"))
    BattleRoyaleWithCheese(cfg, weights);
}


x86 assembly (clang, -O0):
<run_compare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    11a2 <run_compare+0x42>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xe68(%rip),%rsi
call   1060 <fprintf@plt>
jmp    12b6 <run_compare+0x156>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x4,-0x4(%rbp)
jle    11c9 <run_compare+0x69>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    11d4 <run_compare+0x74>
xor    %eax,%eax
mov    %rax,-0x28(%rbp)
jmp    11d4 <run_compare+0x74>
mov    -0x28(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1210 <run_compare+0xb0>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <train_compare@plt>
jmp    12b6 <run_compare+0x156>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe23(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1244 <run_compare+0xe4>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <validate_compare@plt>
jmp    12b1 <run_compare+0x151>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdf5(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1278 <run_compare+0x118>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <SortMaster3000@plt>
jmp    12ac <run_compare+0x14c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xdc6(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12a7 <run_compare+0x147>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <BattleRoyaleWithCheese@plt>
jmp    12ac <run_compare+0x14c>
jmp    12b1 <run_compare+0x151>
jmp    12b6 <run_compare+0x156>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_compare>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     118e <run_compare+0x2e>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
mov    0x8(%rbx),%rcx
lea    0xe7c(%rip),%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <fprintf@plt>
cmp    $0x4,%edi
jne    1198 <run_compare+0x38>
xor    %r14d,%r14d
jmp    119c <run_compare+0x3c>
mov    0x20(%rbx),%r14
mov    0x18(%rbx),%r15
mov    0x10(%rbx),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11fa <run_compare+0x9a>
mov    0x10(%rbx),%rdi
lea    0xe82(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     120a <run_compare+0xaa>
mov    0x10(%rbx),%rdi
lea    0xe73(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     121a <run_compare+0xba>
mov    0x10(%rbx),%rdi
lea    0xe63(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     122a <run_compare+0xca>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <train_compare@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1070 <validate_compare@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <SortMaster3000@plt>
mov    %r15,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <BattleRoyaleWithCheese@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"usage: %s %s [train/test/valid] [cfg] [weights (optional)]\0A\00"
@.str.1 = [6 x i8] c"train\00"
@.str.2 = [6 x i8] c"valid\00"
@.str.3 = [5 x i8] c"sort\00"
@.str.4 = [7 x i8] c"battle\00"
define void @run_compare(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 4
br i1 %8, label %9, label %18
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %16)
br label %73
18: ; preds = %2
%19 = load i8**, i8*** %4
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
store i8* %21, i8** %5
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 4
br i1 %23, label %24, label %28
24: ; preds = %18
%25 = load i8**, i8*** %4
%26 = getelementptr inbounds i8*, i8** %25, i64 4
%27 = load i8*, i8** %26
br label %29
28: ; preds = %18
br label %29
29: ; preds = %28, %24
%30 = phi i8* [ %27, %24 ], [ null, %28 ]
store i8* %30, i8** %6
%31 = load i8**, i8*** %4
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 0, %34
br i1 %35, label %36, label %40
36: ; preds = %29
%37 = load i8*, i8** %5
%38 = load i8*, i8** %6
%39 = call i32 @train_compare(i8* %37, i8* %38)
br label %73
40: ; preds = %29
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%45 = icmp eq i64 0, %44
br i1 %45, label %46, label %50
46: ; preds = %40
%47 = load i8*, i8** %5
%48 = load i8*, i8** %6
%49 = call i32 @validate_compare(i8* %47, i8* %48)
br label %72
50: ; preds = %40
%51 = load i8**, i8*** %4
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%55 = icmp eq i64 0, %54
br i1 %55, label %56, label %60
56: ; preds = %50
%57 = load i8*, i8** %5
%58 = load i8*, i8** %6
%59 = call i32 @SortMaster3000(i8* %57, i8* %58)
br label %71
60: ; preds = %50
%61 = load i8**, i8*** %4
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%65 = icmp eq i64 0, %64
br i1 %65, label %66, label %70
66: ; preds = %60
%67 = load i8*, i8** %5
%68 = load i8*, i8** %6
%69 = call i32 @BattleRoyaleWithCheese(i8* %67, i8* %68)
br label %70
70: ; preds = %66, %60
br label %71
71: ; preds = %70, %56
br label %72
72: ; preds = %71, %46
br label %73
73: ; preds = %9, %72, %36
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"usage: %s %s [train/test/valid] [cfg] [weights (optional)]\0A\00"
@.str.1 = [6 x i8] c"train\00"
@.str.2 = [6 x i8] c"valid\00"
@.str.3 = [5 x i8] c"sort\00"
@.str.4 = [7 x i8] c"battle\00"
define void @run_compare(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %10
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %8)
br label %43
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = icmp eq i32 %0, 4
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
br label %17
17: ; preds = %10, %14
%18 = phi i8* [ %16, %14 ], [ null, %10 ]
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = tail call i32 @train_compare(i8* %12, i8* %18)
br label %43
25: ; preds = %17
%26 = load i8*, i8** %19
%27 = tail call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = tail call i32 @validate_compare(i8* %12, i8* %18)
br label %43
31: ; preds = %25
%32 = load i8*, i8** %19
%33 = tail call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = tail call i32 @SortMaster3000(i8* %12, i8* %18)
br label %43
37: ; preds = %31
%38 = load i8*, i8** %19
%39 = tail call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = tail call i32 @BattleRoyaleWithCheese(i8* %12, i8* %18)
br label %43
43: ; preds = %23, %35, %41, %37, %29, %4
ret void
}