#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*/ addstr(char *);
int /*<<< orphan*/ beep();
int clear();
int game_scene(int);
char getch();
int move(int, scalar_t__);
int refresh();
void start_scene(char choice, int loop_c) {
  while (loop_c = 1, 0) {
  }
  while (loop_c) {
    while (clear(), 0) {
    }
    while (move(0 + 6 + 0, 0 + 6), addstr("Minesweeper Game!"), 0) {
    }
    while (move(0 + 6 + 2, 0 + 6), addstr("1. Easy."), 0) {
    }
    while (move(0 + 6 + 3, 0 + 6), addstr("2. Normal."), 0) {
    }
    while (move(0 + 6 + 5, 0 + 6),
           addstr("Sel: start new game or quit(1/2/q): "), 0) {
    }
    while (refresh(), 0) {
    }
    while (choice = getch(), !(choice == '1' || choice == '2' ||
                               choice == 'q' || choice == 'Q') &&
                                 (beep(), 1)) {
    }
    if (choice == '1') {
      while (game_scene(10), 0) {
      }
    } else if (choice == '2') {
      while (game_scene(15), 0) {
      }
    } else {
      while (loop_c = 0, 0) {
      }
    }
  }
}


x86 assembly (clang, -O0):
<start_scene>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x1,-0x8(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    1197 <start_scene+0x27>
jmp    119c <start_scene+0x2c>
jmp    1181 <start_scene+0x11>
jmp    11a1 <start_scene+0x31>
cmpl   $0x0,-0x8(%rbp)
je     13cc <start_scene+0x25c>
jmp    11b0 <start_scene+0x40>
mov    $0x0,%al
call   1080 <clear@plt>
xor    %eax,%eax
test   $0x1,%al
jne    11c6 <start_scene+0x56>
jmp    11cb <start_scene+0x5b>
jmp    11b0 <start_scene+0x40>
jmp    11d0 <start_scene+0x60>
mov    $0x6,%edi
mov    $0x6,%esi
call   1090 <move@plt>
lea    0xe1a(%rip),%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
test   $0x1,%al
jne    11fa <start_scene+0x8a>
jmp    11ff <start_scene+0x8f>
jmp    11d0 <start_scene+0x60>
jmp    1204 <start_scene+0x94>
mov    $0x8,%edi
mov    $0x6,%esi
call   1090 <move@plt>
lea    0xdf8(%rip),%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
test   $0x1,%al
jne    122e <start_scene+0xbe>
jmp    1233 <start_scene+0xc3>
jmp    1204 <start_scene+0x94>
jmp    1238 <start_scene+0xc8>
mov    $0x9,%edi
mov    $0x6,%esi
call   1090 <move@plt>
lea    0xdcd(%rip),%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
test   $0x1,%al
jne    1262 <start_scene+0xf2>
jmp    1267 <start_scene+0xf7>
jmp    1238 <start_scene+0xc8>
jmp    126c <start_scene+0xfc>
mov    $0xb,%edi
mov    $0x6,%esi
call   1090 <move@plt>
lea    0xda4(%rip),%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
test   $0x1,%al
jne    1296 <start_scene+0x126>
jmp    129b <start_scene+0x12b>
jmp    126c <start_scene+0xfc>
jmp    12a0 <start_scene+0x130>
mov    $0x0,%al
call   1040 <refresh@plt>
xor    %eax,%eax
test   $0x1,%al
jne    12b6 <start_scene+0x146>
jmp    12bb <start_scene+0x14b>
jmp    12a0 <start_scene+0x130>
jmp    12c0 <start_scene+0x150>
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x31,%ecx
mov    %al,-0x9(%rbp)
je     131e <start_scene+0x1ae>
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x32,%ecx
mov    %al,-0x9(%rbp)
je     131e <start_scene+0x1ae>
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x71,%ecx
mov    %al,-0x9(%rbp)
je     131e <start_scene+0x1ae>
movsbl -0x1(%rbp),%ecx
xor    %eax,%eax
cmp    $0x51,%ecx
mov    %al,-0x9(%rbp)
je     131e <start_scene+0x1ae>
mov    $0x0,%al
call   1030 <beep@plt>
mov    $0x1,%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    132e <start_scene+0x1be>
jmp    1333 <start_scene+0x1c3>
jmp    12c0 <start_scene+0x150>
movsbl -0x1(%rbp),%eax
cmp    $0x31,%eax
jne    1368 <start_scene+0x1f8>
jmp    1345 <start_scene+0x1d5>
mov    $0xa,%edi
call   1060 <game_scene@plt>
xor    %eax,%eax
test   $0x1,%al
jne    135e <start_scene+0x1ee>
jmp    1363 <start_scene+0x1f3>
jmp    1345 <start_scene+0x1d5>
jmp    13c7 <start_scene+0x257>
movsbl -0x1(%rbp),%eax
cmp    $0x32,%eax
jne    139d <start_scene+0x22d>
jmp    137a <start_scene+0x20a>
mov    $0xf,%edi
call   1060 <game_scene@plt>
xor    %eax,%eax
test   $0x1,%al
jne    1393 <start_scene+0x223>
jmp    1398 <start_scene+0x228>
jmp    137a <start_scene+0x20a>
jmp    13c2 <start_scene+0x252>
jmp    13a2 <start_scene+0x232>
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
test   $0x1,%al
jne    13b8 <start_scene+0x248>
jmp    13bd <start_scene+0x24d>
jmp    13a2 <start_scene+0x232>
jmp    13c2 <start_scene+0x252>
jmp    13c7 <start_scene+0x257>
jmp    11a1 <start_scene+0x31>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<start_scene>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xe81(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0xe8e(%rip),%r12
lea    0xe92(%rip),%rbx
xor    %eax,%eax
call   1080 <clear@plt>
mov    $0x6,%esi
mov    $0x6,%edi
call   1090 <move@plt>
mov    %r14,%rdi
call   1070 <addstr@plt>
mov    $0x6,%esi
mov    $0x8,%edi
call   1090 <move@plt>
mov    %r15,%rdi
call   1070 <addstr@plt>
mov    $0x6,%esi
mov    $0x9,%edi
call   1090 <move@plt>
mov    %r12,%rdi
call   1070 <addstr@plt>
mov    $0x6,%esi
mov    $0xb,%edi
call   1090 <move@plt>
mov    %rbx,%rdi
call   1070 <addstr@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
jmp    1207 <start_scene+0x97>
xor    %eax,%eax
call   1030 <beep@plt>
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0x50,%al
jg     1220 <start_scene+0xb0>
cmp    $0x31,%al
je     1230 <start_scene+0xc0>
cmp    $0x32,%al
jne    1200 <start_scene+0x90>
jmp    1240 <start_scene+0xd0>
nopl   0x0(%rax)
cmp    $0x51,%al
je     124f <start_scene+0xdf>
cmp    $0x71,%al
jne    1200 <start_scene+0x90>
jmp    124f <start_scene+0xdf>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1060 <game_scene@plt>
jmp    1194 <start_scene+0x24>
nop
mov    $0xf,%edi
call   1060 <game_scene@plt>
jmp    1194 <start_scene+0x24>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Minesweeper Game!\00"
@.str.1 = [9 x i8] c"1. Easy.\00"
@.str.2 = [11 x i8] c"2. Normal.\00"
@.str.3 = [37 x i8] c"Sel: start new game or quit(1/2/q): \00"
define void @start_scene(i8 signext %0, i32 %1) {
%3 = alloca i8
%4 = alloca i32
store i8 %0, i8* %3
store i32 %1, i32* %4
br label %5
5: ; preds = %6, %2
store i32 1, i32* %4
br i1 false, label %6, label %7
6: ; preds = %5
br label %5
7: ; preds = %5
br label %8
8: ; preds = %85, %7
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %86
11: ; preds = %8
br label %12
12: ; preds = %14, %11
%13 = call i32 (...) @clear()
br i1 false, label %14, label %15
14: ; preds = %12
br label %12
15: ; preds = %12
br label %16
16: ; preds = %19, %15
%17 = call i32 @move(i32 6, i64 6)
%18 = call i32 @addstr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br i1 false, label %19, label %20
19: ; preds = %16
br label %16
20: ; preds = %16
br label %21
21: ; preds = %24, %20
%22 = call i32 @move(i32 8, i64 6)
%23 = call i32 @addstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
br i1 false, label %24, label %25
24: ; preds = %21
br label %21
25: ; preds = %21
br label %26
26: ; preds = %29, %25
%27 = call i32 @move(i32 9, i64 6)
%28 = call i32 @addstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br i1 false, label %29, label %30
29: ; preds = %26
br label %26
30: ; preds = %26
br label %31
31: ; preds = %34, %30
%32 = call i32 @move(i32 11, i64 6)
%33 = call i32 @addstr(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
br i1 false, label %34, label %35
34: ; preds = %31
br label %31
35: ; preds = %31
br label %36
36: ; preds = %38, %35
%37 = call i32 (...) @refresh()
br i1 false, label %38, label %39
38: ; preds = %36
br label %36
39: ; preds = %36
br label %40
40: ; preds = %61, %39
%41 = call signext i8 (...) @getch()
store i8 %41, i8* %3
%42 = load i8, i8* %3
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 49
br i1 %44, label %59, label %45
45: ; preds = %40
%46 = load i8, i8* %3
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 50
br i1 %48, label %59, label %49
49: ; preds = %45
%50 = load i8, i8* %3
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 113
br i1 %52, label %59, label %53
53: ; preds = %49
%54 = load i8, i8* %3
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 81
br i1 %56, label %59, label %57
57: ; preds = %53
%58 = call i32 (...) @beep()
br label %59
59: ; preds = %57, %53, %49, %45, %40
%60 = phi i1 [ false, %53 ], [ false, %49 ], [ false, %45 ], [ false, %40 ], [ true, %57 ]
br i1 %60, label %61, label %62
61: ; preds = %59
br label %40
62: ; preds = %59
%63 = load i8, i8* %3
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 49
br i1 %65, label %66, label %71
66: ; preds = %62
br label %67
67: ; preds = %69, %66
%68 = call i32 @game_scene(i32 10)
br i1 false, label %69, label %70
69: ; preds = %67
br label %67
70: ; preds = %67
br label %85
71: ; preds = %62
%72 = load i8, i8* %3
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 50
br i1 %74, label %75, label %80
75: ; preds = %71
br label %76
76: ; preds = %78, %75
%77 = call i32 @game_scene(i32 15)
br i1 false, label %78, label %79
78: ; preds = %76
br label %76
79: ; preds = %76
br label %84
80: ; preds = %71
br label %81
81: ; preds = %82, %80
store i32 0, i32* %4
br i1 false, label %82, label %83
82: ; preds = %81
br label %81
83: ; preds = %81
br label %84
84: ; preds = %83, %79
br label %85
85: ; preds = %84, %70
br label %8
86: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Minesweeper Game!\00"
@.str.1 = [9 x i8] c"1. Easy.\00"
@.str.2 = [11 x i8] c"2. Normal.\00"
@.str.3 = [37 x i8] c"Sel: start new game or quit(1/2/q): \00"
define void @start_scene(i8 signext %0, i32 %1) {
br label %3
3: ; preds = %19, %2
%4 = tail call i32 (...) @clear()
%5 = tail call i32 @move(i32 6, i64 6)
%6 = tail call i32 @addstr(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @move(i32 8, i64 6)
%8 = tail call i32 @addstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @move(i32 9, i64 6)
%10 = tail call i32 @addstr(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%11 = tail call i32 @move(i32 11, i64 6)
%12 = tail call i32 @addstr(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 (...) @refresh()
br label %14
14: ; preds = %16, %3
%15 = tail call signext i8 (...) @getch()
switch i8 %15, label %16 [
i8 49, label %19
i8 50, label %18
i8 81, label %22
i8 113, label %22
]
16: ; preds = %14
%17 = tail call i32 (...) @beep()
br label %14
18: ; preds = %14
br label %19
19: ; preds = %14, %18
%20 = phi i32 [ 15, %18 ], [ 10, %14 ]
%21 = tail call i32 @game_scene(i32 %20)
br label %3
22: ; preds = %14, %14
ret void
}