#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*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printw(char *, int /*<<< orphan*/);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int main() {
  int i = 150;
  int ch;
  int *p_coord;
  int row;
  int col;
  int player_x;
  int player_y;
  initscr();
  getmaxyx(stdscr, row, col);
  row = row / 2;
  col = col / 2;
  col = row = 0;
  mvprintw(0, col, "pres cursor key");
  mvprintw(row, col, "@");
  noecho();
  do {
    printw("ch:%d ", getch());
    refresh();
  } while (i--);
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x96,-0x8(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <getmaxyx@plt>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%esi
xor    %edi,%edi
lea    0xe19(%rip),%rdx
call   10a0 <mvprintw@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    0xe17(%rip),%rdx
call   10a0 <mvprintw@plt>
mov    $0x0,%al
call   1090 <noecho@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    %eax,%esi
lea    0xdfd(%rip),%rdi
call   1050 <printw@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jne    1205 <main+0x85>
mov    $0x0,%al
call   1070 <getch@plt>
mov    $0x0,%al
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <initscr@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1040 <getmaxyx@plt>
lea    0xe61(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10a0 <mvprintw@plt>
lea    0xe61(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
call   10a0 <mvprintw@plt>
xor    %eax,%eax
call   1090 <noecho@plt>
mov    $0xffffff69,%ebp
lea    0xe47(%rip),%rbx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <getch@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <printw@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
inc    %ebp
jne    11d0 <main+0x50>
xor    %eax,%eax
call   1070 <getch@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@.str = [16 x i8] c"pres cursor key\00"
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [7 x i8] c"ch:%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 150, i32* %2
%9 = call i32 (...) @initscr()
%10 = load i32, i32* @stdscr
%11 = load i32, i32* %5
%12 = load i32, i32* %6
%13 = call i32 @getmaxyx(i32 %10, i32 %11, i32 %12)
%14 = load i32, i32* %5
%15 = sdiv i32 %14, 2
store i32 %15, i32* %5
%16 = load i32, i32* %6
%17 = sdiv i32 %16, 2
store i32 %17, i32* %6
store i32 0, i32* %5
store i32 0, i32* %6
%18 = load i32, i32* %6
%19 = call i32 @mvprintw(i32 0, i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call i32 @mvprintw(i32 %20, i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%23 = call i32 (...) @noecho()
br label %24
24: ; preds = %28, %0
%25 = call i32 (...) @getch()
%26 = call i32 @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = call i32 (...) @refresh()
br label %28
28: ; preds = %24
%29 = load i32, i32* %2
%30 = add nsw i32 %29, -1
store i32 %30, i32* %2
%31 = icmp ne i32 %29, 0
br i1 %31, label %24, label %32
32: ; preds = %28
%33 = call i32 (...) @getch()
%34 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@.str = [16 x i8] c"pres cursor key\00"
@.str.1 = [2 x i8] c"@\00"
@.str.2 = [7 x i8] c"ch:%d \00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getmaxyx(i32 %2, i32 undef, i32 undef)
%4 = tail call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 (...) @noecho()
br label %7
7: ; preds = %7, %0
%8 = phi i32 [ 150, %0 ], [ %12, %7 ]
%9 = tail call i32 (...) @getch()
%10 = tail call i32 @printw(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = tail call i32 (...) @refresh()
%12 = add nsw i32 %8, -1
%13 = icmp eq i32 %8, 0
br i1 %13, label %14, label %7
14: ; preds = %7
%15 = tail call i32 (...) @getch()
%16 = tail call i32 (...) @endwin()
ret i32 0
}