#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 atoi(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int getopt(int, char **, char *);
int /*<<< orphan*/ load_idx();
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ start_predict(int, int, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int c;
  int thread = 1;
  int fold = 5;
  int dataset = 10000;
  while ((c = getopt(argc, argv, "t:f:d:")) != -1) {
    switch (c) {
    case 't':
      thread = atoi(optarg);
      break;
    case 'f':
      fold = atoi(optarg);
      break;
    case 'd':
      dataset = atoi(optarg);
      break;
    default:
      fprintf(stderr, "Usage: %s <-t> thread <-f> fold <-d> dataset per fold\n",
              argv[0]);
      return 1;
    }
  }
  load_idx();
  printf("thread = %d\n", thread);
  start_predict(thread, fold, dataset);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
movl   $0x2710,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe67(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     124f <main+0xef>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x64,%eax
je     120c <main+0xac>
jmp    11be <main+0x5e>
mov    -0x24(%rbp),%eax
sub    $0x66,%eax
je     11f6 <main+0x96>
jmp    11cf <main+0x6f>
mov    -0x24(%rbp),%eax
sub    $0x74,%eax
jne    1222 <main+0xc2>
jmp    11e0 <main+0x80>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
jmp    124a <main+0xea>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
jmp    124a <main+0xea>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
call   1070 <atoi@plt>
mov    %eax,-0x20(%rbp)
jmp    124a <main+0xea>
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdce(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    127a <main+0x11a>
jmp    118b <main+0x2b>
mov    $0x0,%al
call   1080 <load_idx@plt>
mov    -0x18(%rbp),%esi
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1030 <start_predict@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x2710,%r12d
movl   $0x5,0x4(%rsp)
mov    $0x1,%r15d
lea    0xe75(%rip),%r13
mov    0x2e66(%rip),%r14
jmp    11ab <main+0x4b>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r14),%edi
call   1070 <atoi@plt>
mov    %eax,%r12d
mov    %ebx,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1060 <getopt@plt>
cmp    $0x64,%eax
je     11a0 <main+0x40>
cmp    $0xffffffff,%eax
je     11e7 <main+0x87>
cmp    $0x66,%eax
je     11d9 <main+0x79>
cmp    $0x74,%eax
jne    1210 <main+0xb0>
mov    (%r14),%edi
call   1070 <atoi@plt>
mov    %eax,%r15d
jmp    11ab <main+0x4b>
mov    (%r14),%edi
call   1070 <atoi@plt>
mov    %eax,0x4(%rsp)
jmp    11ab <main+0x4b>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <load_idx@plt>
lea    0xe47(%rip),%rdi
mov    %r15d,%esi
call   1040 <printf@plt>
mov    %r15d,%edi
mov    0x4(%rsp),%esi
mov    %r12d,%edx
call   1030 <start_predict@plt>
jmp    122e <main+0xce>
mov    0x2dc1(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xde3(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"t:f:d:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [55 x i8] c"Usage: %s <-t> thread <-f> fold <-d> dataset per fold\0A\00"
@.str.2 = [13 x i8] c"thread = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
store i32 5, i32* %8
store i32 10000, i32* %9
br label %10
10: ; preds = %32, %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %6
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %33
15: ; preds = %10
%16 = load i32, i32* %6
switch i32 %16, label %26 [
i32 116, label %17
i32 102, label %20
i32 100, label %23
]
17: ; preds = %15
%18 = load i32, i32* @optarg
%19 = call i32 @atoi(i32 %18)
store i32 %19, i32* %7
br label %32
20: ; preds = %15
%21 = load i32, i32* @optarg
%22 = call i32 @atoi(i32 %21)
store i32 %22, i32* %8
br label %32
23: ; preds = %15
%24 = load i32, i32* @optarg
%25 = call i32 @atoi(i32 %24)
store i32 %25, i32* %9
br label %32
26: ; preds = %15
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %30)
store i32 1, i32* %3
br label %41
32: ; preds = %23, %20, %17
br label %10
33: ; preds = %10
%34 = call i32 (...) @load_idx()
%35 = load i32, i32* %7
%36 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %7
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = call i32 @start_predict(i32 %37, i32 %38, i32 %39)
store i32 0, i32* %3
br label %41
41: ; preds = %33, %26
%42 = load i32, i32* %3
ret i32 %42
}

LLVM IR (-O2):
@.str = [7 x i8] c"t:f:d:\00"
@optarg = global i32 0
@stderr = global i32 0
@.str.1 = [55 x i8] c"Usage: %s <-t> thread <-f> fold <-d> dataset per fold\0A\00"
@.str.2 = [13 x i8] c"thread = %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i32 [ %15, %13 ], [ 1, %2 ]
%5 = phi i32 [ %8, %13 ], [ 5, %2 ]
%6 = phi i32 [ %11, %13 ], [ 10000, %2 ]
br label %7
7: ; preds = %3, %16
%8 = phi i32 [ %5, %3 ], [ %18, %16 ]
%9 = phi i32 [ %6, %3 ], [ %11, %16 ]
br label %10
10: ; preds = %7, %19
%11 = phi i32 [ %21, %19 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %22 [
i32 -1, label %26
i32 116, label %13
i32 102, label %16
i32 100, label %19
]
13: ; preds = %10
%14 = load i32, i32* @optarg
%15 = tail call i32 @atoi(i32 %14)
br label %3
16: ; preds = %10
%17 = load i32, i32* @optarg
%18 = tail call i32 @atoi(i32 %17)
br label %7
19: ; preds = %10
%20 = load i32, i32* @optarg
%21 = tail call i32 @atoi(i32 %20)
br label %10
22: ; preds = %10
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %1
%25 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %30
26: ; preds = %10
%27 = tail call i32 (...) @load_idx()
%28 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%29 = tail call i32 @start_predict(i32 %4, i32 %8, i32 %11)
br label %30
30: ; preds = %26, %22
%31 = phi i32 [ 1, %22 ], [ 0, %26 ]
ret i32 %31
}