#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*/ exit(int /*<<< orphan*/);
int getchar();
int /*<<< orphan*/ make_corner();
int /*<<< orphan*/ make_edge(int);
int /*<<< orphan*/ printf(char *);
int scanf(char *, ...);
int /*<<< orphan*/ solve(char *);
int main(int argc, char **argv) {
  int number;
  char cube_raw[121];
  if (argc == 2) {
    solve(argv[1]);
    exit(0);
  }
menu_top:
  printf("What would you like to do?\n");
  printf("1) Solve a cube\n");
  printf("2) Generate the corner table\n");
  printf("3) Generate the first edge table\n");
  printf("4) Generate the second edge table\n");
  printf("Choose: ");
  while (scanf("%d", &number) != 1 || number > 4 || number < 1) {
    printf("\n");
    printf("Please enter a valid choice.\n");
    printf("Choose: ");
    number = getchar();
  }
  printf("\n");
  switch (number) {
  case 1:
    printf("\nPlease enter a raw cube string.\n"
           "Raw cube strings are 120 characters long and designate\n"
           "the colors on each side of all 20 cubies.\n"
           "You can generate this with the cube_convert.py script\n");
    int result = scanf("%120s", cube_raw);
    if (result < 1) {
      printf("Cube string error");
      goto menu_top;
    }
    printf("\n");
    solve(cube_raw);
    break;
  case 2:
    printf("Generating corner cube table\n");
    printf("This can take upwards of 40 minutes.  Ctrl-C to cancel\n");
    printf("\n");
    make_corner();
    break;
  case 3:
    printf("Generating edge cube table\n");
    printf("This can take upwards of 20 minutes.  Ctrl-C to cancel\n");
    printf("\n");
    make_edge(1);
    break;
  case 4:
    printf("Generating edge cube table\n");
    printf("This can take upwards of 20 minutes.  Ctrl-C to cancel\n");
    printf("\n");
    make_edge(2);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11a7 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <solve@plt>
xor    %edi,%edi
call   1090 <exit@plt>
jmp    11ac <main+0x3c>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
call   1040 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x1,%ecx
mov    %al,-0x95(%rbp)
jne    1238 <main+0xc8>
mov    $0x1,%al
cmpl   $0x4,-0x14(%rbp)
mov    %al,-0x95(%rbp)
jg     1238 <main+0xc8>
cmpl   $0x1,-0x14(%rbp)
setl   %al
mov    %al,-0x95(%rbp)
mov    -0x95(%rbp),%al
test   $0x1,%al
jne    124b <main+0xdb>
jmp    127e <main+0x10e>
lea    0xe76(%rip),%rdi
call   1040 <printf@plt>
lea    0xe4e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %eax,-0x14(%rbp)
jmp    11f4 <main+0x84>
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0xa0(%rbp)
sub    $0x3,%eax
ja     13ac <main+0x23c>
mov    -0xa0(%rbp),%rax
lea    0xd50(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe0a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    %eax,-0x94(%rbp)
cmpl   $0x1,-0x94(%rbp)
jge    12fe <main+0x18e>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
jmp    11ac <main+0x3c>
lea    0xdc3(%rip),%rdi
call   1040 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1030 <solve@plt>
jmp    13ac <main+0x23c>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8b(%rip),%rdi
call   1040 <printf@plt>
lea    0xd8e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1070 <make_corner@plt>
jmp    13ac <main+0x23c>
lea    0xe9f(%rip),%rdi
call   1040 <printf@plt>
lea    0xeaf(%rip),%rdi
call   1040 <printf@plt>
lea    0xd5e(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <make_edge@plt>
jmp    13ac <main+0x23c>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
lea    0xd2b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x2,%edi
call   1060 <make_edge@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
cmp    $0x2,%edi
je     136c <main+0x1dc>
lea    0xebb(%rip),%r13
lea    0xed5(%rip),%rbx
lea    0xe41(%rip),%rbp
lea    0xe43(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x103b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe3d(%rip),%rdi
call   1050 <puts@plt>
lea    0xe4c(%rip),%rdi
call   1050 <puts@plt>
lea    0xe50(%rip),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   1050 <puts@plt>
mov    %rbx,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
jmp    1245 <main+0xb5>
xchg   %ax,%ax
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12,%rdi
call   1050 <puts@plt>
mov    %rbp,%rdi
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
cmp    $0x1,%eax
jne    1220 <main+0x90>
mov    0xc(%rsp),%eax
cmp    $0x4,%eax
jg     1220 <main+0x90>
test   %eax,%eax
jle    1220 <main+0x90>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0xc(%rsp),%eax
cmp    $0x1,%eax
jne    12af <main+0x11f>
lea    0xed7(%rip),%rdi
call   1050 <puts@plt>
lea    0xd82(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
test   %eax,%eax
jg     1344 <main+0x1b4>
lea    0xd6d(%rip),%rdi
call   1060 <printf@plt>
jmp    11e0 <main+0x50>
cmp    $0x2,%eax
je     12eb <main+0x15b>
cmp    $0x3,%eax
je     1316 <main+0x186>
cmp    $0x4,%eax
jne    1358 <main+0x1c8>
lea    0xde6(%rip),%rdi
call   1050 <puts@plt>
lea    0xdf5(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x2,%edi
jmp    133d <main+0x1ad>
lea    0xe0f(%rip),%rdi
call   1050 <puts@plt>
lea    0xe20(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
call   1090 <make_corner@plt>
jmp    1358 <main+0x1c8>
lea    0xd92(%rip),%rdi
call   1050 <puts@plt>
lea    0xda1(%rip),%rdi
call   1050 <puts@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    $0x1,%edi
call   1080 <make_edge@plt>
jmp    1358 <main+0x1c8>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0x10(%rsp),%rdi
call   1030 <solve@plt>
xor    %eax,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsi),%rdi
call   1030 <solve@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"What would you like to do?\0A\00"
@.str.1 = [17 x i8] c"1) Solve a cube\0A\00"
@.str.2 = [30 x i8] c"2) Generate the corner table\0A\00"
@.str.3 = [34 x i8] c"3) Generate the first edge table\0A\00"
@.str.4 = [35 x i8] c"4) Generate the second edge table\0A\00"
@.str.5 = [9 x i8] c"Choose: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [2 x i8] c"\0A\00"
@.str.8 = [30 x i8] c"Please enter a valid choice.\0A\00"
@.str.9 = [185 x i8] c"\0APlease enter a raw cube string.\0ARaw cube strings are 120 characters long and designate\0Athe colors on each side of all 20 cubies.\0AYou can generate this with the cube_convert.py script\0A\00"
@.str.10 = [6 x i8] c"%120s\00"
@.str.11 = [18 x i8] c"Cube string error\00"
@.str.12 = [30 x i8] c"Generating corner cube table\0A\00"
@.str.13 = [56 x i8] c"This can take upwards of 40 minutes. Ctrl-C to cancel\0A\00"
@.str.14 = [28 x i8] c"Generating edge cube table\0A\00"
@.str.15 = [56 x i8] c"This can take upwards of 20 minutes. Ctrl-C to cancel\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [121 x 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 eq i32 %9, 2
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @solve(i8* %14)
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %2
br label %18
18: ; preds = %50, %17
%19 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %25
25: ; preds = %36, %18
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %6)
%27 = icmp ne i32 %26, 1
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = load i32, i32* %6
%30 = icmp sgt i32 %29, 4
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 1
br label %34
34: ; preds = %31, %28, %25
%35 = phi i1 [ true, %28 ], [ true, %25 ], [ %33, %31 ]
br i1 %35, label %36, label %41
36: ; preds = %34
%37 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%40 = call i32 (...) @getchar()
store i32 %40, i32* %6
br label %25
41: ; preds = %34
%42 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%43 = load i32, i32* %6
switch i32 %43, label %71 [
i32 1, label %44
i32 2, label %56
i32 3, label %61
i32 4, label %66
]
44: ; preds = %41
%45 = call i32 @printf(i8* getelementptr inbounds ([185 x i8], [185 x i8]* @.str.9, i64 0, i64 0))
%46 = getelementptr inbounds [121 x i8], [121 x i8]* %7, i64 0, i64 0
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %46)
store i32 %47, i32* %8
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 1
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %18
52: ; preds = %44
%53 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%54 = getelementptr inbounds [121 x i8], [121 x i8]* %7, i64 0, i64 0
%55 = call i32 @solve(i8* %54)
br label %71
56: ; preds = %41
%57 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%58 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.13, i64 0, i64 0))
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%60 = call i32 (...) @make_corner()
br label %71
61: ; preds = %41
%62 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%63 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.15, i64 0, i64 0))
%64 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%65 = call i32 @make_edge(i32 1)
br label %71
66: ; preds = %41
%67 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%68 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.15, i64 0, i64 0))
%69 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%70 = call i32 @make_edge(i32 2)
br label %71
71: ; preds = %41, %66, %61, %56, %52
ret i32 0
}

LLVM IR (-O2):
@.str.5 = [9 x i8] c"Choose: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.10 = [6 x i8] c"%120s\00"
@.str.11 = [18 x i8] c"Cube string error\00"
@str = [27 x i8] c"What would you like to do?\00"
@str.16 = [16 x i8] c"1) Solve a cube\00"
@str.17 = [29 x i8] c"2) Generate the corner table\00"
@str.18 = [33 x i8] c"3) Generate the first edge table\00"
@str.19 = [34 x i8] c"4) Generate the second edge table\00"
@str.22 = [27 x i8] c"Generating edge cube table\00"
@str.23 = [55 x i8] c"This can take upwards of 20 minutes. Ctrl-C to cancel\00"
@str.24 = [29 x i8] c"Generating corner cube table\00"
@str.25 = [55 x i8] c"This can take upwards of 40 minutes. Ctrl-C to cancel\00"
@str.26 = [184 x i8] c"\0APlease enter a raw cube string.\0ARaw cube strings are 120 characters long and designate\0Athe colors on each side of all 20 cubies.\0AYou can generate this with the cube_convert.py script\00"
@str.27 = [29 x i8] c"Please enter a valid choice.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca [121 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [121 x i8], [121 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 2
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @solve(i8* %10)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2, %46
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.16, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.17, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.18, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.19, i64 0, i64 0))
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%21 = icmp ne i32 %20, 1
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 4
%24 = select i1 %21, i1 true, i1 %23
%25 = icmp slt i32 %22, 1
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %27, label %39
27: ; preds = %13, %27
%28 = call i32 @putchar(i32 10)
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.27, i64 0, i64 0))
%30 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (...) @getchar()
store i32 %31, i32* %3
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%33 = icmp ne i32 %32, 1
%34 = load i32, i32* %3
%35 = icmp sgt i32 %34, 4
%36 = select i1 %33, i1 true, i1 %35
%37 = icmp slt i32 %34, 1
%38 = select i1 %36, i1 true, i1 %37
br i1 %38, label %27, label %39
39: ; preds = %27, %13
%40 = call i32 @putchar(i32 10)
%41 = load i32, i32* %3
switch i32 %41, label %66 [
i32 1, label %42
i32 2, label %51
i32 3, label %56
i32 4, label %61
]
42: ; preds = %39
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([184 x i8], [184 x i8]* @str.26, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0), i8* %6)
%45 = icmp slt i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
br label %13
48: ; preds = %42
%49 = call i32 @putchar(i32 10)
%50 = call i32 @solve(i8* %6)
br label %66
51: ; preds = %39
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.24, i64 0, i64 0))
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.25, i64 0, i64 0))
%54 = call i32 @putchar(i32 10)
%55 = call i32 (...) @make_corner()
br label %66
56: ; preds = %39
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
%58 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.23, i64 0, i64 0))
%59 = call i32 @putchar(i32 10)
%60 = call i32 @make_edge(i32 1)
br label %66
61: ; preds = %39
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.22, i64 0, i64 0))
%63 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @str.23, i64 0, i64 0))
%64 = call i32 @putchar(i32 10)
%65 = call i32 @make_edge(i32 2)
br label %66
66: ; preds = %39, %61, %56, %51, %48
ret i32 0
}