#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*/ endwin();
int /*<<< orphan*/ erase();
scalar_t__ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ noecho();
int main() {
  int x = 2;
  int y = 2;
  char tecla;
  int salir = 0;
  initscr();
  while (salir == 0) {
    erase();
    mvprintw(y, x, " ###");
    mvprintw(y + 1, x, "#");
    mvprintw(y + 2, x, "#");
    mvprintw(y + 3, x, " ###");
    noecho();
    tecla = (char)getch();
    switch (tecla) {
    case 'w':
      y--;
      break;
    case 'a':
      x--;
      break;
    case 's':
      y++;
      break;
    case 'd':
      x++;
      break;
    case 'q':
      salir = 1;
    default:;
      break;
    }
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1278 <main+0x118>
xor    %eax,%eax
mov    %al,-0x21(%rbp)
call   1040 <erase@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xeb0(%rip),%rdx
mov    %rdx,-0x30(%rbp)
call   1080 <mvprintw@plt>
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    -0x8(%rbp),%esi
lea    0xe9a(%rip),%rdx
mov    %rdx,-0x38(%rbp)
call   1080 <mvprintw@plt>
mov    -0x38(%rbp),%rdx
mov    -0xc(%rbp),%edi
add    $0x2,%edi
mov    -0x8(%rbp),%esi
call   1080 <mvprintw@plt>
mov    -0x30(%rbp),%rdx
mov    -0xc(%rbp),%edi
add    $0x3,%edi
mov    -0x8(%rbp),%esi
call   1080 <mvprintw@plt>
mov    -0x21(%rbp),%al
call   1070 <noecho@plt>
mov    -0x21(%rbp),%al
call   1050 <getch@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x16,%eax
ja     126e <main+0x10e>
mov    -0x20(%rbp),%rax
lea    0xdda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1273 <main+0x113>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1273 <main+0x113>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1273 <main+0x113>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1273 <main+0x113>
movl   $0x1,-0x14(%rbp)
jmp    1273 <main+0x113>
jmp    118b <main+0x2b>
mov    $0x0,%al
call   1060 <endwin@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
push   %rax
xor    %eax,%eax
call   1030 <initscr@plt>
mov    $0x2,%ebx
mov    $0x2,%ebp
lea    0x1(%rbx),%eax
mov    %eax,0x4(%rsp)
lea    0x2(%rbx),%r13d
lea    0x3(%rbx),%r14d
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <erase@plt>
mov    %ebx,%edi
mov    %ebp,%esi
lea    0xeba(%rip),%r15
mov    %r15,%rdx
call   1080 <mvprintw@plt>
mov    0x4(%rsp),%edi
mov    %ebp,%esi
lea    0xea8(%rip),%r12
mov    %r12,%rdx
call   1080 <mvprintw@plt>
mov    %r13d,%edi
mov    %ebp,%esi
mov    %r12,%rdx
call   1080 <mvprintw@plt>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r15,%rdx
call   1080 <mvprintw@plt>
xor    %eax,%eax
call   1070 <noecho@plt>
xor    %eax,%eax
call   1050 <getch@plt>
movsbl %al,%eax
add    $0xffffff9f,%eax
cmp    $0x16,%eax
ja     1190 <main+0x30>
lea    0xe07(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
add    $0xffffffff,%ebp
jmp    1190 <main+0x30>
add    $0x1,%ebp
jmp    1190 <main+0x30>
nopl   0x0(%rax)
mov    0x4(%rsp),%eax
mov    %eax,%ebx
jmp    117c <main+0x1c>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
jmp    117c <main+0x1c>
xor    %eax,%eax
call   1060 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" ###\00"
@.str.1 = [2 x i8] c"#\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
store i32 2, i32* %3
store i32 0, i32* %5
%6 = call i32 (...) @initscr()
br label %7
7: ; preds = %46, %0
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %47
10: ; preds = %7
%11 = call i32 (...) @erase()
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = call i32 @mvprintw(i32 %12, i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
%17 = load i32, i32* %2
%18 = call i32 @mvprintw(i32 %16, i32 %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* %3
%20 = add nsw i32 %19, 2
%21 = load i32, i32* %2
%22 = call i32 @mvprintw(i32 %20, i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 3
%25 = load i32, i32* %2
%26 = call i32 @mvprintw(i32 %24, i32 %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = call i32 (...) @noecho()
%28 = call i64 (...) @getch()
%29 = trunc i64 %28 to i8
store i8 %29, i8* %4
%30 = load i8, i8* %4
%31 = sext i8 %30 to i32
switch i32 %31, label %45 [
i32 119, label %32
i32 97, label %35
i32 115, label %38
i32 100, label %41
i32 113, label %44
]
32: ; preds = %10
%33 = load i32, i32* %3
%34 = add nsw i32 %33, -1
store i32 %34, i32* %3
br label %46
35: ; preds = %10
%36 = load i32, i32* %2
%37 = add nsw i32 %36, -1
store i32 %37, i32* %2
br label %46
38: ; preds = %10
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %46
41: ; preds = %10
%42 = load i32, i32* %2
%43 = add nsw i32 %42, 1
store i32 %43, i32* %2
br label %46
44: ; preds = %10
store i32 1, i32* %5
br label %45
45: ; preds = %10, %44
br label %46
46: ; preds = %45, %41, %38, %35, %32
br label %7
47: ; preds = %7
%48 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c" ###\00"
@.str.1 = [2 x i8] c"#\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
br label %2
2: ; preds = %25, %0
%3 = phi i32 [ 2, %0 ], [ %26, %25 ]
%4 = phi i32 [ 2, %0 ], [ %9, %25 ]
%5 = add nsw i32 %3, 1
%6 = add nsw i32 %3, 2
%7 = add nsw i32 %3, 3
br label %8
8: ; preds = %29, %2
%9 = phi i32 [ %4, %2 ], [ %30, %29 ]
br label %10
10: ; preds = %8, %10
%11 = tail call i32 (...) @erase()
%12 = tail call i32 @mvprintw(i32 %3, i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @mvprintw(i32 %5, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32 @mvprintw(i32 %6, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @mvprintw(i32 %7, i32 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 (...) @noecho()
%17 = tail call i64 (...) @getch()
%18 = trunc i64 %17 to i32
%19 = shl i32 %18, 24
%20 = ashr exact i32 %19, 24
switch i32 %20, label %10 [
i32 119, label %21
i32 97, label %23
i32 115, label %25
i32 100, label %27
i32 113, label %31
]
21: ; preds = %10
%22 = add nsw i32 %3, -1
br label %25
23: ; preds = %10
%24 = add nsw i32 %9, -1
br label %29
25: ; preds = %10, %21
%26 = phi i32 [ %22, %21 ], [ %5, %10 ]
br label %2
27: ; preds = %10
%28 = add nsw i32 %9, 1
br label %29
29: ; preds = %27, %23
%30 = phi i32 [ %24, %23 ], [ %28, %27 ]
br label %8
31: ; preds = %10
%32 = tail call i32 (...) @endwin()
ret i32 0
}