#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(char *);
char checkInput(char, int, int);
int /*<<< orphan*/ clear();
char **createRoom(int, int);
int /*<<< orphan*/ destroyRoom(char **, int);
int /*<<< orphan*/ endwin();
char getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ movePlayer(char, int *, int *);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int main(int argc, char **argv) {
  char **room1;
  char input;
  char condition;
  int x1 = atoi(argv[1]);
  int y1 = atoi(argv[2]);
  int heroY = 5;
  int heroX = 5;
  room1 = createRoom(y1, x1);
  initscr();
  noecho();
  for (int i = 0; i < y1; i++) {
    for (int k = 0; k < x1; k++) {
      mvaddch(i, k, room1[i][k]);
    }
  }
  mvaddch(heroY, heroX, '@');
  move(heroY, heroX);
  refresh();
  while (input != 'q') {
    refresh();
    input = getch();
    condition = checkInput(input, heroY, heroX);
    if (condition == 1) {
      movePlayer(input, &heroY, &heroX);
    } else if (condition == 2) {
      move(30, 0);
      printw("hello");
    } else if (condition == 3) {
      clear();
      for (int i = 0; i < y1; i++) {
        for (int k = 0; k < x1; k++) {
          mvaddch(i, k, room1[i][k]);
        }
      }
    }
    move(heroY, heroX);
    refresh();
  }
  endwin();
  destroyRoom(room1, y1);
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    %eax,-0x24(%rbp)
movl   $0x5,-0x28(%rbp)
movl   $0x5,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <createRoom@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12a7 <main+0xc7>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1294 <main+0xb4>
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
call   10c0 <mvaddch@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    125b <main+0x7b>
jmp    1299 <main+0xb9>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1248 <main+0x68>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    $0x40,%edx
call   10c0 <mvaddch@plt>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1100 <move@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x71,%eax
je     13e8 <main+0x208>
mov    $0x0,%al
call   1080 <refresh@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
movsbl %al,%edi
call   1070 <checkInput@plt>
mov    %al,-0x1a(%rbp)
movsbl -0x1a(%rbp),%eax
cmp    $0x1,%eax
jne    131e <main+0x13e>
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
movsbl -0x19(%rbp),%edi
call   1050 <movePlayer@plt>
jmp    13d1 <main+0x1f1>
movsbl -0x1a(%rbp),%eax
cmp    $0x2,%eax
jne    1348 <main+0x168>
mov    $0x1e,%edi
xor    %esi,%esi
call   1100 <move@plt>
lea    0xcc2(%rip),%rdi
call   1060 <printw@plt>
jmp    13cc <main+0x1ec>
movsbl -0x1a(%rbp),%eax
cmp    $0x3,%eax
jne    13c7 <main+0x1e7>
mov    $0x0,%al
call   10f0 <clear@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    13c2 <main+0x1e2>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    13af <main+0x1cf>
mov    -0x38(%rbp),%edi
mov    -0x3c(%rbp),%esi
mov    -0x18(%rbp),%rax
movslq -0x38(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
call   10c0 <mvaddch@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1376 <main+0x196>
jmp    13b4 <main+0x1d4>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1363 <main+0x183>
jmp    13c7 <main+0x1e7>
jmp    13cc <main+0x1ec>
jmp    13d1 <main+0x1f1>
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1100 <move@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
jmp    12c9 <main+0xe9>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    -0x18(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   10e0 <destroyRoom@plt>
xor    %eax,%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    0x8(%rsi),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r15d
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%ebp
movl   $0x5,0x8(%rsp)
movl   $0x5,0x4(%rsp)
mov    %eax,%edi
mov    %r15d,%esi
call   1030 <createRoom@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
mov    %ebp,%eax
mov    %rax,0x10(%rsp)
mov    %r15d,%r14d
mov    %r15d,%r12d
mov    %ebp,0xc(%rsp)
test   %ebp,%ebp
jle    128d <main+0xad>
xor    %r15d,%r15d
jmp    125b <main+0x7b>
nopl   (%rax)
add    $0x1,%r15
cmp    0x10(%rsp),%r15
je     128d <main+0xad>
test   %r14d,%r14d
jle    1250 <main+0x70>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%rbx,%r15,8),%rax
movsbl (%rax,%rbp,1),%edx
mov    %r15d,%edi
mov    %ebp,%esi
call   10c0 <mvaddch@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1270 <main+0x90>
jmp    1250 <main+0x70>
mov    $0x5,%edi
mov    $0x5,%esi
mov    $0x40,%edx
call   10c0 <mvaddch@plt>
mov    $0x5,%edi
mov    $0x5,%esi
call   1100 <move@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
jmp    12f6 <main+0x116>
nopl   0x0(%rax)
mov    $0x1e,%edi
xor    %esi,%esi
call   1100 <move@plt>
lea    0xd2d(%rip),%rdi
call   1060 <printw@plt>
mov    0x8(%rsp),%edi
mov    0x4(%rsp),%esi
call   1100 <move@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
cmp    $0x71,%r15b
je     139e <main+0x1be>
xor    %eax,%eax
call   1080 <refresh@plt>
xor    %eax,%eax
call   1090 <getch@plt>
mov    %eax,%r15d
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
movsbl %al,%ebp
mov    %ebp,%edi
call   1070 <checkInput@plt>
cmp    $0x3,%al
je     1340 <main+0x160>
cmp    $0x2,%al
je     12c0 <main+0xe0>
cmp    $0x1,%al
jne    12d8 <main+0xf8>
mov    %ebp,%edi
lea    0x8(%rsp),%rsi
lea    0x4(%rsp),%rdx
call   1050 <movePlayer@plt>
jmp    12d8 <main+0xf8>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10f0 <clear@plt>
cmpl   $0x0,0xc(%rsp)
jle    12d8 <main+0xf8>
xor    %ebp,%ebp
jmp    136f <main+0x18f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
je     12d8 <main+0xf8>
test   %r14d,%r14d
jle    1360 <main+0x180>
xor    %r13d,%r13d
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%rbp,8),%rax
movsbl (%rax,%r13,1),%edx
mov    %ebp,%edi
mov    %r13d,%esi
call   10c0 <mvaddch@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    1380 <main+0x1a0>
jmp    1360 <main+0x180>
xor    %eax,%eax
call   10a0 <endwin@plt>
mov    %rbx,%rdi
mov    0xc(%rsp),%esi
call   10e0 <destroyRoom@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca i8
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %9
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %10
store i32 5, i32* %11
store i32 5, i32* %12
%25 = load i32, i32* %10
%26 = load i32, i32* %9
%27 = call i8** @createRoom(i32 %25, i32 %26)
store i8** %27, i8*** %6
%28 = call i32 (...) @initscr()
%29 = call i32 (...) @noecho()
store i32 0, i32* %13
br label %30
30: ; preds = %56, %2
%31 = load i32, i32* %13
%32 = load i32, i32* %10
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %59
34: ; preds = %30
store i32 0, i32* %14
br label %35
35: ; preds = %52, %34
%36 = load i32, i32* %14
%37 = load i32, i32* %9
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load i32, i32* %13
%41 = load i32, i32* %14
%42 = load i8**, i8*** %6
%43 = load i32, i32* %13
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8*, i8** %42, i64 %44
%46 = load i8*, i8** %45
%47 = load i32, i32* %14
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = load i8, i8* %49
%51 = call i32 @mvaddch(i32 %40, i32 %41, i8 signext %50)
br label %52
52: ; preds = %39
%53 = load i32, i32* %14
%54 = add nsw i32 %53, 1
store i32 %54, i32* %14
br label %35
55: ; preds = %35
br label %56
56: ; preds = %55
%57 = load i32, i32* %13
%58 = add nsw i32 %57, 1
store i32 %58, i32* %13
br label %30
59: ; preds = %30
%60 = load i32, i32* %11
%61 = load i32, i32* %12
%62 = call i32 @mvaddch(i32 %60, i32 %61, i8 signext 64)
%63 = load i32, i32* %11
%64 = load i32, i32* %12
%65 = call i32 @move(i32 %63, i32 %64)
%66 = call i32 (...) @refresh()
br label %67
67: ; preds = %129, %59
%68 = load i8, i8* %7
%69 = sext i8 %68 to i32
%70 = icmp ne i32 %69, 113
br i1 %70, label %71, label %134
71: ; preds = %67
%72 = call i32 (...) @refresh()
%73 = call signext i8 (...) @getch()
store i8 %73, i8* %7
%74 = load i8, i8* %7
%75 = load i32, i32* %11
%76 = load i32, i32* %12
%77 = call signext i8 @checkInput(i8 signext %74, i32 %75, i32 %76)
store i8 %77, i8* %8
%78 = load i8, i8* %8
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %84
81: ; preds = %71
%82 = load i8, i8* %7
%83 = call i32 @movePlayer(i8 signext %82, i32* %11, i32* %12)
br label %129
84: ; preds = %71
%85 = load i8, i8* %8
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 2
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = call i32 @move(i32 30, i32 0)
%90 = call i32 @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %128
91: ; preds = %84
%92 = load i8, i8* %8
%93 = sext i8 %92 to i32
%94 = icmp eq i32 %93, 3
br i1 %94, label %95, label %127
95: ; preds = %91
%96 = call i32 (...) @clear()
store i32 0, i32* %15
br label %97
97: ; preds = %123, %95
%98 = load i32, i32* %15
%99 = load i32, i32* %10
%100 = icmp slt i32 %98, %99
br i1 %100, label %101, label %126
101: ; preds = %97
store i32 0, i32* %16
br label %102
102: ; preds = %119, %101
%103 = load i32, i32* %16
%104 = load i32, i32* %9
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %122
106: ; preds = %102
%107 = load i32, i32* %15
%108 = load i32, i32* %16
%109 = load i8**, i8*** %6
%110 = load i32, i32* %15
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds i8*, i8** %109, i64 %111
%113 = load i8*, i8** %112
%114 = load i32, i32* %16
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %113, i64 %115
%117 = load i8, i8* %116
%118 = call i32 @mvaddch(i32 %107, i32 %108, i8 signext %117)
br label %119
119: ; preds = %106
%120 = load i32, i32* %16
%121 = add nsw i32 %120, 1
store i32 %121, i32* %16
br label %102
122: ; preds = %102
br label %123
123: ; preds = %122
%124 = load i32, i32* %15
%125 = add nsw i32 %124, 1
store i32 %125, i32* %15
br label %97
126: ; preds = %97
br label %127
127: ; preds = %126, %91
br label %128
128: ; preds = %127, %88
br label %129
129: ; preds = %128, %81
%130 = load i32, i32* %11
%131 = load i32, i32* %12
%132 = call i32 @move(i32 %130, i32 %131)
%133 = call i32 (...) @refresh()
br label %67
134: ; preds = %67
%135 = call i32 (...) @endwin()
%136 = load i8**, i8*** %6
%137 = load i32, i32* %10
%138 = call i32 @destroyRoom(i8** %136, i32 %137)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = bitcast i32* %3 to i8*
store i32 5, i32* %3
%12 = bitcast i32* %4 to i8*
store i32 5, i32* %4
%13 = tail call i8** @createRoom(i32 %10, i32 %7)
%14 = tail call i32 (...) @initscr()
%15 = tail call i32 (...) @noecho()
%16 = icmp sgt i32 %10, 0
br i1 %16, label %17, label %26
17: ; preds = %2
%18 = icmp sgt i32 %7, 0
%19 = zext i32 %10 to i64
%20 = zext i32 %7 to i64
br label %21
21: ; preds = %17, %33
%22 = phi i64 [ 0, %17 ], [ %34, %33 ]
br i1 %18, label %23, label %33
23: ; preds = %21
%24 = getelementptr inbounds i8*, i8** %13, i64 %22
%25 = trunc i64 %22 to i32
br label %36
26: ; preds = %33, %2
%27 = tail call i32 @mvaddch(i32 5, i32 5, i8 signext 64)
%28 = tail call i32 @move(i32 5, i32 5)
%29 = tail call i32 (...) @refresh()
%30 = icmp sgt i32 %7, 0
%31 = zext i32 %10 to i64
%32 = zext i32 %7 to i64
br label %45
33: ; preds = %36, %21
%34 = add nuw nsw i64 %22, 1
%35 = icmp eq i64 %34, %19
br i1 %35, label %26, label %21
36: ; preds = %23, %36
%37 = phi i64 [ 0, %23 ], [ %43, %36 ]
%38 = load i8*, i8** %24
%39 = getelementptr inbounds i8, i8* %38, i64 %37
%40 = load i8, i8* %39
%41 = trunc i64 %37 to i32
%42 = tail call i32 @mvaddch(i32 %25, i32 %41, i8 signext %40)
%43 = add nuw nsw i64 %37, 1
%44 = icmp eq i64 %43, %20
br i1 %44, label %33, label %36
45: ; preds = %26, %75
%46 = call i32 (...) @refresh()
%47 = call signext i8 (...) @getch()
%48 = load i32, i32* %3
%49 = load i32, i32* %4
%50 = call signext i8 @checkInput(i8 signext %47, i32 %48, i32 %49)
switch i8 %50, label %75 [
i8 1, label %51
i8 2, label %53
i8 3, label %56
]
51: ; preds = %45
%52 = call i32 @movePlayer(i8 signext %47, i32* %3, i32* %4)
br label %75
53: ; preds = %45
%54 = call i32 @move(i32 30, i32 0)
%55 = call i32 @printw(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %75
56: ; preds = %45
%57 = call i32 (...) @clear()
br i1 %16, label %58, label %75
58: ; preds = %56, %63
%59 = phi i64 [ %64, %63 ], [ 0, %56 ]
br i1 %30, label %60, label %63
60: ; preds = %58
%61 = getelementptr inbounds i8*, i8** %13, i64 %59
%62 = trunc i64 %59 to i32
br label %66
63: ; preds = %66, %58
%64 = add nuw nsw i64 %59, 1
%65 = icmp eq i64 %64, %31
br i1 %65, label %75, label %58
66: ; preds = %60, %66
%67 = phi i64 [ 0, %60 ], [ %73, %66 ]
%68 = load i8*, i8** %61
%69 = getelementptr inbounds i8, i8* %68, i64 %67
%70 = load i8, i8* %69
%71 = trunc i64 %67 to i32
%72 = call i32 @mvaddch(i32 %62, i32 %71, i8 signext %70)
%73 = add nuw nsw i64 %67, 1
%74 = icmp eq i64 %73, %32
br i1 %74, label %63, label %66
75: ; preds = %63, %56, %45, %53, %51
%76 = load i32, i32* %3
%77 = load i32, i32* %4
%78 = call i32 @move(i32 %76, i32 %77)
%79 = call i32 (...) @refresh()
%80 = icmp eq i8 %47, 113
br i1 %80, label %81, label %45
81: ; preds = %75
%82 = call i32 (...) @endwin()
%83 = call i32 @destroyRoom(i8** %13, i32 %10)
ret i32 0
}