#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 EXIT_SUCCESS;
int atoi(char *);
int console_solve(char *, int);
int /*<<< orphan*/ exit(int);
int getopt(int, char **, char *);
char *optarg;
int /*<<< orphan*/ print_versioninfo();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ run_tests(int);
int main(int argc, char **argv) {
  int vflag = 0;
  int tflag = 0;
  int hflag = 0;
  int sflag = 0;
  char *tvalue = NULL;
  char *svalue = NULL;
  int puzzle_no = 0;
  int c;
  while ((c = getopt(argc, argv, "vht:s:")) != -1) {
    switch (c) {
    case 'v':
      vflag = 1;
      break;
    case 'h':
      hflag = 1;
      break;
    case 't':
      tflag = 1;
      tvalue = optarg;
      break;
    case 's':
      sflag = 1;
      svalue = optarg;
      break;
    default:
      break;
    }
  }
  if (hflag) {
    print_versioninfo();
    exit(EXIT_SUCCESS);
  }
  if (tflag) {
    puzzle_no = atoi(tvalue);
    if (0 <= puzzle_no && puzzle_no <= 2) {
      printf("testing puzzle number: %d\n", puzzle_no);
      run_tests(puzzle_no);
    }
    exit(EXIT_SUCCESS);
  }
  if (sflag) {
    exit(console_solve(svalue, vflag));
  }
  return EXIT_SUCCESS;
}


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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x38(%rbp)
cmp    $0xffffffff,%eax
je     1257 <main+0xe7>
mov    -0x38(%rbp),%eax
add    $0xffffff98,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0xe,%eax
ja     124d <main+0xdd>
mov    -0x40(%rbp),%rax
lea    0xe08(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x14(%rbp)
jmp    1252 <main+0xe2>
movl   $0x1,-0x1c(%rbp)
jmp    1252 <main+0xe2>
movl   $0x1,-0x18(%rbp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
jmp    1252 <main+0xe2>
movl   $0x1,-0x20(%rbp)
mov    0x2db7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1252 <main+0xe2>
jmp    1252 <main+0xe2>
jmp    11b9 <main+0x49>
cmpl   $0x0,-0x1c(%rbp)
je     1276 <main+0x106>
mov    $0x0,%al
call   1040 <print_versioninfo@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x0,-0x18(%rbp)
je     12c6 <main+0x156>
mov    -0x28(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmp    -0x34(%rbp),%eax
jg     12b8 <main+0x148>
cmpl   $0x2,-0x34(%rbp)
jg     12b8 <main+0x148>
mov    -0x34(%rbp),%esi
lea    0xd98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x34(%rbp),%edi
call   1080 <run_tests@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
cmpl   $0x0,-0x20(%rbp)
je     12e3 <main+0x173>
mov    -0x30(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <console_solve@plt>
mov    %eax,%edi
call   1090 <exit@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %r15d,%r15d
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xea9(%rip),%r13
lea    0xe66(%rip),%r14
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %eax,%eax
mov    %rax,0x10(%rsp)
xor    %r12d,%r12d
movl   $0x0,(%rsp)
jmp    11c5 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0xffffffff,%eax
je     1224 <main+0xb4>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1060 <getopt@plt>
lea    -0x68(%rax),%ecx
cmp    $0xe,%ecx
ja     11c0 <main+0x50>
movslq (%r14,%rcx,4),%rax
add    %r14,%rax
jmp    *%rax
mov    $0x1,%r15d
jmp    11c5 <main+0x55>
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    $0x1,%r12d
jmp    11c5 <main+0x55>
mov    0x2def(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
movl   $0x0,0x4(%rsp)
jmp    11c5 <main+0x55>
movl   $0x1,(%rsp)
jmp    11c5 <main+0x55>
test   %r15d,%r15d
jne    124d <main+0xdd>
testb  $0x1,0x4(%rsp)
je     1256 <main+0xe6>
test   %r12d,%r12d
jne    128a <main+0x11a>
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1040 <print_versioninfo@plt>
jmp    127c <main+0x10c>
mov    0x8(%rsp),%rdi
call   1070 <atoi@plt>
cmp    $0x2,%eax
ja     127c <main+0x10c>
mov    %eax,%ebx
lea    0xdd5(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebx,%edi
call   1080 <run_tests@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x10(%rsp),%rdi
mov    (%rsp),%esi
call   1050 <console_solve@plt>
mov    %eax,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"vht:s:\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@.str.1 = [27 x i8] c"testing puzzle number: %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
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i32 0, i32* %12
br label %14
14: ; preds = %28, %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @getopt(i32 %15, i8** %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %17, i32* %13
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %29
19: ; preds = %14
%20 = load i32, i32* %13
switch i32 %20, label %27 [
i32 118, label %21
i32 104, label %22
i32 116, label %23
i32 115, label %25
]
21: ; preds = %19
store i32 1, i32* %6
br label %28
22: ; preds = %19
store i32 1, i32* %8
br label %28
23: ; preds = %19
store i32 1, i32* %7
%24 = load i8*, i8** @optarg
store i8* %24, i8** %10
br label %28
25: ; preds = %19
store i32 1, i32* %9
%26 = load i8*, i8** @optarg
store i8* %26, i8** %11
br label %28
27: ; preds = %19
br label %28
28: ; preds = %27, %25, %23, %22, %21
br label %14
29: ; preds = %14
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 (...) @print_versioninfo()
%34 = load i32, i32* @EXIT_SUCCESS
%35 = call i32 @exit(i32 %34)
unreachable
36: ; preds = %29
%37 = load i32, i32* %7
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %55
39: ; preds = %36
%40 = load i8*, i8** %10
%41 = call i32 @atoi(i8* %40)
store i32 %41, i32* %12
%42 = load i32, i32* %12
%43 = icmp sle i32 0, %42
br i1 %43, label %44, label %52
44: ; preds = %39
%45 = load i32, i32* %12
%46 = icmp sle i32 %45, 2
br i1 %46, label %47, label %52
47: ; preds = %44
%48 = load i32, i32* %12
%49 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = load i32, i32* %12
%51 = call i32 @run_tests(i32 %50)
br label %52
52: ; preds = %47, %44, %39
%53 = load i32, i32* @EXIT_SUCCESS
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %36
%56 = load i32, i32* %9
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load i8*, i8** %11
%60 = load i32, i32* %6
%61 = call i32 @console_solve(i8* %59, i32 %60)
%62 = call i32 @exit(i32 %61)
unreachable
63: ; preds = %55
%64 = load i32, i32* @EXIT_SUCCESS
ret i32 %64
}

LLVM IR (-O2):
@.str = [7 x i8] c"vht:s:\00"
@optarg = global i8* null
@EXIT_SUCCESS = global i32 0
@.str.1 = [27 x i8] c"testing puzzle number: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %23, %2
%4 = phi i1 [ false, %23 ], [ true, %2 ]
%5 = phi i32 [ %11, %23 ], [ 0, %2 ]
%6 = phi i32 [ %16, %23 ], [ 0, %2 ]
%7 = phi i8* [ %24, %23 ], [ null, %2 ]
%8 = phi i8* [ %17, %23 ], [ null, %2 ]
%9 = phi i32 [ %20, %23 ], [ 0, %2 ]
br label %10
10: ; preds = %21, %3
%11 = phi i32 [ %5, %3 ], [ 1, %21 ]
%12 = phi i32 [ %6, %3 ], [ %16, %21 ]
%13 = phi i8* [ %8, %3 ], [ %17, %21 ]
%14 = phi i32 [ %9, %3 ], [ %20, %21 ]
br label %15
15: ; preds = %10, %25
%16 = phi i32 [ %12, %10 ], [ 1, %25 ]
%17 = phi i8* [ %13, %10 ], [ %26, %25 ]
%18 = phi i32 [ %14, %10 ], [ %20, %25 ]
br label %19
19: ; preds = %21, %15
%20 = phi i32 [ %18, %15 ], [ 1, %21 ]
br label %21
21: ; preds = %19, %21
%22 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
switch i32 %22, label %21 [
i32 -1, label %27
i32 118, label %19
i32 104, label %10
i32 116, label %23
i32 115, label %25
]
23: ; preds = %21
%24 = load i8*, i8** @optarg
br label %3
25: ; preds = %21
%26 = load i8*, i8** @optarg
br label %15
27: ; preds = %21
%28 = icmp eq i32 %11, 0
br i1 %28, label %33, label %29
29: ; preds = %27
%30 = tail call i32 (...) @print_versioninfo()
%31 = load i32, i32* @EXIT_SUCCESS
%32 = tail call i32 @exit(i32 %31)
unreachable
33: ; preds = %27
br i1 %4, label %43, label %34
34: ; preds = %33
%35 = tail call i32 @atoi(i8* %7)
%36 = icmp ult i32 %35, 3
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%39 = tail call i32 @run_tests(i32 %35)
br label %40
40: ; preds = %37, %34
%41 = load i32, i32* @EXIT_SUCCESS
%42 = tail call i32 @exit(i32 %41)
unreachable
43: ; preds = %33
%44 = icmp eq i32 %16, 0
br i1 %44, label %48, label %45
45: ; preds = %43
%46 = tail call i32 @console_solve(i8* %17, i32 %20)
%47 = tail call i32 @exit(i32 %46)
unreachable
48: ; preds = %43
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}