#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*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ isWallSouth();
int /*<<< orphan*/ isWallWest();
int /*<<< orphan*/ movePlayerDown();
int /*<<< orphan*/ movePlayerRight();
int /*<<< orphan*/ movePlayerUp();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ win();
void parseChar() {
  int key = getch();
  switch (key) {
  case 97:
    printf("[a]ttack\n");
    break;
  case 104:
    printf("[h]elp\n");
    break;
  case 113:
    clear();
    endwin();
    printf("[q]uit\n");
    exit(0);
    break;
  case 258:
    switch (isWallSouth()) {
    case 0:
      printf("You can't go this way !");
      break;
    case 1:
      movePlayerDown();
      break;
    case 2:
      win();
      break;
    }
    break;
  case 259:
    switch (isWallSouth()) {
    case 0:
      printf("You can't go this way !");
      break;
    case 1:
      movePlayerUp();
      break;
    }
    break;
  case 260:
    switch (isWallWest()) {
    case 0:
      printf("You can't go this way !");
      break;
    case 1:
      movePlayerDown();
      break;
    }
    break;
  case 261:
    switch (isWallSouth()) {
    case 0:
      printf("You can't go this way !");
      break;
    case 1:
      movePlayerRight();
      break;
    case 2:
      win();
      break;
    }
    break;
  default:
    printf("keystroke : %d\n", key);
    break;
  }
}


x86 assembly (clang, -O0):
<parseChar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
call   10a0 <getch@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0x61,%eax
je     1244 <parseChar+0x94>
jmp    11d6 <parseChar+0x26>
mov    -0x8(%rbp),%eax
sub    $0x68,%eax
je     1257 <parseChar+0xa7>
jmp    11e7 <parseChar+0x37>
mov    -0x8(%rbp),%eax
sub    $0x71,%eax
je     126a <parseChar+0xba>
jmp    11f8 <parseChar+0x48>
mov    -0x8(%rbp),%eax
sub    $0x102,%eax
je     128d <parseChar+0xdd>
jmp    120b <parseChar+0x5b>
mov    -0x8(%rbp),%eax
sub    $0x103,%eax
je     12f3 <parseChar+0x143>
jmp    121e <parseChar+0x6e>
mov    -0x8(%rbp),%eax
sub    $0x104,%eax
je     133c <parseChar+0x18c>
jmp    1231 <parseChar+0x81>
mov    -0x8(%rbp),%eax
sub    $0x105,%eax
je     1385 <parseChar+0x1d5>
jmp    13eb <parseChar+0x23b>
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13fc <parseChar+0x24c>
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13fc <parseChar+0x24c>
mov    $0x0,%al
call   10d0 <clear@plt>
mov    $0x0,%al
call   10b0 <endwin@plt>
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   1070 <isWallSouth@plt>
mov    %eax,%ecx
mov    %ecx,-0xc(%rbp)
test   %eax,%eax
je     12c8 <parseChar+0x118>
jmp    12a6 <parseChar+0xf6>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     12db <parseChar+0x12b>
jmp    12b7 <parseChar+0x107>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     12e7 <parseChar+0x137>
jmp    12ee <parseChar+0x13e>
lea    0xd4b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ee <parseChar+0x13e>
mov    $0x0,%al
call   1030 <movePlayerDown@plt>
jmp    12ee <parseChar+0x13e>
mov    $0x0,%al
call   1080 <win@plt>
jmp    13fc <parseChar+0x24c>
xor    %eax,%eax
call   1070 <isWallSouth@plt>
mov    %eax,%ecx
mov    %ecx,-0x10(%rbp)
test   %eax,%eax
je     131d <parseChar+0x16d>
jmp    130c <parseChar+0x15c>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
je     1330 <parseChar+0x180>
jmp    1337 <parseChar+0x187>
lea    0xcf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1337 <parseChar+0x187>
mov    $0x0,%al
call   1060 <movePlayerUp@plt>
jmp    13fc <parseChar+0x24c>
xor    %eax,%eax
call   1090 <isWallWest@plt>
mov    %eax,%ecx
mov    %ecx,-0x14(%rbp)
test   %eax,%eax
je     1366 <parseChar+0x1b6>
jmp    1355 <parseChar+0x1a5>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1379 <parseChar+0x1c9>
jmp    1380 <parseChar+0x1d0>
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1380 <parseChar+0x1d0>
mov    $0x0,%al
call   1030 <movePlayerDown@plt>
jmp    13fc <parseChar+0x24c>
xor    %eax,%eax
call   1070 <isWallSouth@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
test   %eax,%eax
je     13c0 <parseChar+0x210>
jmp    139e <parseChar+0x1ee>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     13d3 <parseChar+0x223>
jmp    13af <parseChar+0x1ff>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     13df <parseChar+0x22f>
jmp    13e6 <parseChar+0x236>
lea    0xc53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13e6 <parseChar+0x236>
mov    $0x0,%al
call   1040 <movePlayerRight@plt>
jmp    13e6 <parseChar+0x236>
mov    $0x0,%al
call   1080 <win@plt>
jmp    13fc <parseChar+0x24c>
mov    -0x4(%rbp),%esi
lea    0xc3d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseChar>:
push   %rax
xor    %eax,%eax
call   10b0 <getch@plt>
cmp    $0x101,%eax
jle    1205 <parseChar+0x45>
lea    -0x102(%rax),%ecx
cmp    $0x3,%ecx
ja     127c <parseChar+0xbc>
lea    0xe1b(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1080 <isWallSouth@plt>
cmp    $0x2,%eax
je     128d <parseChar+0xcd>
cmp    $0x1,%eax
jne    1255 <parseChar+0x95>
jmp    123c <parseChar+0x7c>
cmp    $0x61,%eax
je     126a <parseChar+0xaa>
cmp    $0x68,%eax
jne    1277 <parseChar+0xb7>
lea    0xe29(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
xor    %eax,%eax
call   1080 <isWallSouth@plt>
cmp    $0x1,%eax
jne    1255 <parseChar+0x95>
xor    %eax,%eax
pop    %rcx
jmp    1070 <movePlayerUp@plt>
xor    %eax,%eax
call   10a0 <isWallWest@plt>
cmp    $0x1,%eax
jne    1255 <parseChar+0x95>
xor    %eax,%eax
pop    %rcx
jmp    1030 <movePlayerDown@plt>
xor    %eax,%eax
call   1080 <isWallSouth@plt>
cmp    $0x2,%eax
je     128d <parseChar+0xcd>
cmp    $0x1,%eax
je     1295 <parseChar+0xd5>
test   %eax,%eax
jne    1268 <parseChar+0xa8>
lea    0xdb0(%rip),%rdi
xor    %eax,%eax
pop    %rcx
jmp    1060 <printf@plt>
pop    %rax
ret
lea    0xdd5(%rip),%rdi
pop    %rax
jmp    1040 <puts@plt>
cmp    $0x71,%eax
je     129d <parseChar+0xdd>
lea    0xda5(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rcx
jmp    1060 <printf@plt>
xor    %eax,%eax
pop    %rcx
jmp    1090 <win@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <movePlayerRight@plt>
xor    %eax,%eax
call   10e0 <clear@plt>
xor    %eax,%eax
call   10c0 <endwin@plt>
lea    0xd86(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"[a]ttack\0A\00"
@.str.1 = [8 x i8] c"[h]elp\0A\00"
@.str.2 = [8 x i8] c"[q]uit\0A\00"
@.str.3 = [24 x i8] c"You can't go this way !\00"
@.str.4 = [16 x i8] c"keystroke : %d\0A\00"
define void @parseChar() {
%1 = alloca i32
%2 = call i32 (...) @getch()
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %45 [
i32 97, label %4
i32 104, label %6
i32 113, label %8
i32 258, label %13
i32 259, label %22
i32 260, label %29
i32 261, label %36
]
4: ; preds = %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %48
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %48
8: ; preds = %0
%9 = call i32 (...) @clear()
%10 = call i32 (...) @endwin()
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @exit(i32 0)
unreachable
13: ; preds = %0
%14 = call i32 (...) @isWallSouth()
switch i32 %14, label %21 [
i32 0, label %15
i32 1, label %17
i32 2, label %19
]
15: ; preds = %13
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %21
17: ; preds = %13
%18 = call i32 (...) @movePlayerDown()
br label %21
19: ; preds = %13
%20 = call i32 (...) @win()
br label %21
21: ; preds = %13, %19, %17, %15
br label %48
22: ; preds = %0
%23 = call i32 (...) @isWallSouth()
switch i32 %23, label %28 [
i32 0, label %24
i32 1, label %26
]
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %28
26: ; preds = %22
%27 = call i32 (...) @movePlayerUp()
br label %28
28: ; preds = %22, %26, %24
br label %48
29: ; preds = %0
%30 = call i32 (...) @isWallWest()
switch i32 %30, label %35 [
i32 0, label %31
i32 1, label %33
]
31: ; preds = %29
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %35
33: ; preds = %29
%34 = call i32 (...) @movePlayerDown()
br label %35
35: ; preds = %29, %33, %31
br label %48
36: ; preds = %0
%37 = call i32 (...) @isWallSouth()
switch i32 %37, label %44 [
i32 0, label %38
i32 1, label %40
i32 2, label %42
]
38: ; preds = %36
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %44
40: ; preds = %36
%41 = call i32 (...) @movePlayerRight()
br label %44
42: ; preds = %36
%43 = call i32 (...) @win()
br label %44
44: ; preds = %36, %42, %40, %38
br label %48
45: ; preds = %0
%46 = load i32, i32* %1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %45, %44, %35, %28, %21, %6, %4
ret void
}

LLVM IR (-O2):
@.str.3 = [24 x i8] c"You can't go this way !\00"
@.str.4 = [16 x i8] c"keystroke : %d\0A\00"
@str = [7 x i8] c"[q]uit\00"
@str.5 = [7 x i8] c"[h]elp\00"
@str.6 = [9 x i8] c"[a]ttack\00"
define void @parseChar() {
%1 = tail call i32 (...) @getch()
switch i32 %1, label %39 [
i32 97, label %2
i32 104, label %4
i32 113, label %6
i32 258, label %11
i32 259, label %19
i32 260, label %25
i32 261, label %31
]
2: ; preds = %0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.6, i64 0, i64 0))
br label %41
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.5, i64 0, i64 0))
br label %41
6: ; preds = %0
%7 = tail call i32 (...) @clear()
%8 = tail call i32 (...) @endwin()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %0
%12 = tail call i32 (...) @isWallSouth()
switch i32 %12, label %41 [
i32 0, label %13
i32 1, label %15
i32 2, label %17
]
13: ; preds = %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %41
15: ; preds = %11
%16 = tail call i32 (...) @movePlayerDown()
br label %41
17: ; preds = %11
%18 = tail call i32 (...) @win()
br label %41
19: ; preds = %0
%20 = tail call i32 (...) @isWallSouth()
switch i32 %20, label %41 [
i32 0, label %21
i32 1, label %23
]
21: ; preds = %19
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %41
23: ; preds = %19
%24 = tail call i32 (...) @movePlayerUp()
br label %41
25: ; preds = %0
%26 = tail call i32 (...) @isWallWest()
switch i32 %26, label %41 [
i32 0, label %27
i32 1, label %29
]
27: ; preds = %25
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %41
29: ; preds = %25
%30 = tail call i32 (...) @movePlayerDown()
br label %41
31: ; preds = %0
%32 = tail call i32 (...) @isWallSouth()
switch i32 %32, label %41 [
i32 0, label %33
i32 1, label %35
i32 2, label %37
]
33: ; preds = %31
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
br label %41
35: ; preds = %31
%36 = tail call i32 (...) @movePlayerRight()
br label %41
37: ; preds = %31
%38 = tail call i32 (...) @win()
br label %41
39: ; preds = %0
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %1)
br label %41
41: ; preds = %33, %35, %37, %31, %27, %29, %25, %21, %23, %19, %13, %15, %17, %11, %39, %4, %2
ret void
}