#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 /*<<< orphan*/ game(int, int);
char getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main(void) {
  char choice, choose;
  int num, max;
  system("clear");
  while (1) {
    printf("\t1.Start\n\t2.How to play\n\t3.Quit\n");
    printf("Please choose what to do: ");
    choose = getchar();
    getchar();
    switch (choose) {
    case '1':
      printf("Start the game?(y/n): ");
      choice = getchar();
      getchar();
      if (choice == 'y' || choice == 'Y') {
        printf("\nPlease input the number of digits(max9): ");
        scanf("%d", &num);
        getchar();
        printf("\nPlease input the max number will appear: ");
        scanf("%d", &max);
        getchar();
        if (max >= num) {
          game(num, max);
        } else {
          printf("Invalid input");
        }
      }
      break;
    case '2':
      printf("This game is the same as the game mastermind\n");
      break;
    case '3':
      printf("exiting\n");
      exit(0);
      break;
    default:
      printf("Invalid argument\n");
    }
    printf("Press enter to continue: ");
    getchar();
    system("clear");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1030 <system@plt>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
mov    %al,-0x15(%rbp)
call   1050 <getchar@plt>
mov    %al,%cl
mov    -0x15(%rbp),%al
mov    %cl,-0x6(%rbp)
call   1050 <getchar@plt>
movsbl -0x6(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x31,%eax
je     11e1 <main+0x81>
jmp    11bf <main+0x5f>
mov    -0x14(%rbp),%eax
sub    $0x32,%eax
je     1290 <main+0x130>
jmp    11d0 <main+0x70>
mov    -0x14(%rbp),%eax
sub    $0x33,%eax
je     12a1 <main+0x141>
jmp    12b4 <main+0x154>
lea    0xe5a(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x79,%eax
je     1218 <main+0xb8>
movsbl -0x5(%rbp),%eax
cmp    $0x59,%eax
jne    128b <main+0x12b>
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xe45(%rip),%rdi
call   1040 <printf@plt>
lea    0xe36(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     127a <main+0x11a>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <game@plt>
jmp    1286 <main+0x126>
lea    0xe31(%rip),%rdi
call   1040 <printf@plt>
jmp    128b <main+0x12b>
jmp    12c0 <main+0x160>
lea    0xe29(%rip),%rdi
call   1040 <printf@plt>
jmp    12c0 <main+0x160>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
lea    0xe3c(%rip),%rdi
call   1040 <printf@plt>
lea    0xe42(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xd26(%rip),%rdi
call   1030 <system@plt>
jmp    117b <main+0x1b>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe7e(%rip),%r14
mov    %r14,%rdi
call   1040 <system@plt>
lea    0xf28(%rip),%r15
lea    0xe6e(%rip),%rbp
lea    0xf00(%rip),%r13
jmp    11d3 <main+0x63>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1060 <getchar@plt>
movsbl %r12b,%eax
cmp    $0x31,%eax
je     1220 <main+0xb0>
cmp    $0x32,%eax
je     11b0 <main+0x40>
cmp    $0x33,%eax
je     12b3 <main+0x143>
lea    0xefc(%rip),%rdi
jmp    11b7 <main+0x47>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xdfa(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getchar@plt>
and    $0xdf,%bl
cmp    $0x59,%bl
jne    11bc <main+0x4c>
lea    0xde9(%rip),%rdi
call   1050 <printf@plt>
lea    0xe08(%rip),%rbx
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xdf0(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edi
cmp    %edi,%esi
jge    12a9 <main+0x139>
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
jmp    11bc <main+0x4c>
call   1080 <game@plt>
jmp    11bc <main+0x4c>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [33 x i8] c"\091.Start\0A\092.How to play\0A\093.Quit\0A\00"
@.str.2 = [27 x i8] c"Please choose what to do: \00"
@.str.3 = [23 x i8] c"Start the game?(y/n): \00"
@.str.4 = [43 x i8] c"\0APlease input the number of digits(max9): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [43 x i8] c"\0APlease input the max number will appear: \00"
@.str.7 = [14 x i8] c"Invalid input\00"
@.str.8 = [46 x i8] c"This game is the same as the game mastermind\0A\00"
@.str.9 = [9 x i8] c"exiting\0A\00"
@.str.10 = [18 x i8] c"Invalid argument\0A\00"
@.str.11 = [26 x i8] c"Press enter to continue: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %0, %50
%8 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%10 = call signext i8 (...) @getchar()
store i8 %10, i8* %3
%11 = call signext i8 (...) @getchar()
%12 = load i8, i8* %3
%13 = sext i8 %12 to i32
switch i32 %13, label %48 [
i32 49, label %14
i32 50, label %43
i32 51, label %45
]
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%16 = call signext i8 (...) @getchar()
store i8 %16, i8* %2
%17 = call signext i8 (...) @getchar()
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 121
br i1 %20, label %25, label %21
21: ; preds = %14
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 89
br i1 %24, label %25, label %42
25: ; preds = %21, %14
%26 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %4)
%28 = call signext i8 (...) @getchar()
%29 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%31 = call signext i8 (...) @getchar()
%32 = load i32, i32* %5
%33 = load i32, i32* %4
%34 = icmp sge i32 %32, %33
br i1 %34, label %35, label %39
35: ; preds = %25
%36 = load i32, i32* %4
%37 = load i32, i32* %5
%38 = call i32 @game(i32 %36, i32 %37)
br label %41
39: ; preds = %25
%40 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
br label %42
42: ; preds = %41, %21
br label %50
43: ; preds = %7
%44 = call i32 @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
br label %50
45: ; preds = %7
%46 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%47 = call i32 @exit(i32 0)
unreachable
48: ; preds = %7
%49 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
br label %50
50: ; preds = %48, %43, %42
%51 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%52 = call signext i8 (...) @getchar()
%53 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %7
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.2 = [27 x i8] c"Please choose what to do: \00"
@.str.3 = [23 x i8] c"Start the game?(y/n): \00"
@.str.4 = [43 x i8] c"\0APlease input the number of digits(max9): \00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [43 x i8] c"\0APlease input the max number will appear: \00"
@.str.7 = [14 x i8] c"Invalid input\00"
@.str.11 = [26 x i8] c"Press enter to continue: \00"
@str = [32 x i8] c"\091.Start\0A\092.How to play\0A\093.Quit\00"
@str.12 = [8 x i8] c"exiting\00"
@str.13 = [45 x i8] c"This game is the same as the game mastermind\00"
@str.14 = [17 x i8] c"Invalid argument\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %39, %0
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = call signext i8 (...) @getchar()
%11 = sext i8 %9 to i32
switch i32 %11, label %37 [
i32 49, label %12
i32 50, label %32
i32 51, label %34
]
12: ; preds = %6
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%14 = call signext i8 (...) @getchar()
%15 = call signext i8 (...) @getchar()
%16 = and i8 %14, -33
%17 = icmp eq i8 %16, 89
br i1 %17, label %18, label %39
18: ; preds = %12
%19 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%21 = call signext i8 (...) @getchar()
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%24 = call signext i8 (...) @getchar()
%25 = load i32, i32* %2
%26 = load i32, i32* %1
%27 = icmp slt i32 %25, %26
br i1 %27, label %30, label %28
28: ; preds = %18
%29 = call i32 @game(i32 %26, i32 %25)
br label %39
30: ; preds = %18
%31 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %39
32: ; preds = %6
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.13, i64 0, i64 0))
br label %39
34: ; preds = %6
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.12, i64 0, i64 0))
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %6
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
br label %39
39: ; preds = %12, %30, %28, %37, %32
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0))
%41 = call signext i8 (...) @getchar()
%42 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %6
}