#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 *movePoint(int, int);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
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;
  mvprintw(0, col, "pres cursor key");
  mvprintw(row, col, "@");
  noecho();
  do {
    int *p_new_coord = movePoint(col, row);
    mvprintw(row, col, " ");
    col = p_new_coord[0];
    row = p_new_coord[1];
    mvprintw(0, 0, "r:%d c:%d  ", row, col);
    mvprintw(row, col, "@");
    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   1050 <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)
mov    -0x20(%rbp),%esi
xor    %edi,%edi
lea    0xe27(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    0xe23(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    $0x0,%al
call   1090 <noecho@plt>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1040 <movePoint@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    0xe05(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
xor    %esi,%esi
lea    0xdd1(%rip),%rdx
mov    %esi,%edi
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    0xdb9(%rip),%rdx
mov    $0x0,%al
call   10a0 <mvprintw@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    11fb <main+0x7b>
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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <initscr@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1050 <getmaxyx@plt>
lea    0xe59(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <mvprintw@plt>
lea    0xe57(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   10a0 <mvprintw@plt>
xor    %eax,%eax
call   1090 <noecho@plt>
mov    $0xffffff69,%r14d
lea    0xe44(%rip),%r15
lea    0xe33(%rip),%r12
xor    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
mov    %ebx,%esi
call   1040 <movePoint@plt>
mov    %rax,%r13
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r15,%rdx
xor    %eax,%eax
call   10a0 <mvprintw@plt>
mov    0x0(%r13),%ebp
mov    0x4(%r13),%ebx
xor    %edi,%edi
xor    %esi,%esi
mov    %r12,%rdx
mov    %ebx,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   10a0 <mvprintw@plt>
mov    %ebx,%edi
mov    %ebp,%esi
lea    0xde0(%rip),%rdx
xor    %eax,%eax
call   10a0 <mvprintw@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
inc    %r14d
jne    11f0 <main+0x70>
xor    %eax,%eax
call   1070 <getch@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
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 = [2 x i8] c" \00"
@.str.3 = [12 x i8] c"r:%d c:%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
%9 = alloca i32*
store i32 0, i32* %1
store i32 150, i32* %2
%10 = call i32 (...) @initscr()
%11 = load i32, i32* @stdscr
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @getmaxyx(i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %5
%16 = sdiv i32 %15, 2
store i32 %16, i32* %5
%17 = load i32, i32* %6
%18 = sdiv i32 %17, 2
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 %19, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %5
%22 = load i32, i32* %6
%23 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %21, i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (...) @noecho()
br label %25
25: ; preds = %45, %0
%26 = load i32, i32* %6
%27 = load i32, i32* %5
%28 = call i32* @movePoint(i32 %26, i32 %27)
store i32* %28, i32** %9
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %29, i32 %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32*, i32** %9
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
store i32 %34, i32* %6
%35 = load i32*, i32** %9
%36 = getelementptr inbounds i32, i32* %35, i64 1
%37 = load i32, i32* %36
store i32 %37, i32* %5
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39)
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %41, i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 (...) @refresh()
br label %45
45: ; preds = %25
%46 = load i32, i32* %2
%47 = add nsw i32 %46, -1
store i32 %47, i32* %2
%48 = icmp ne i32 %46, 0
br i1 %48, label %25, label %49
49: ; preds = %45
%50 = call i32 (...) @getch()
%51 = 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 = [2 x i8] c" \00"
@.str.3 = [12 x i8] c"r:%d c:%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 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (i32, i32, i8*, ...) @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 [ 0, %0 ], [ %13, %7 ]
%9 = phi i32 [ 0, %0 ], [ %15, %7 ]
%10 = phi i32 [ 150, %0 ], [ %19, %7 ]
%11 = tail call i32* @movePoint(i32 %8, i32 %9)
%12 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %9, i32 %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* %11
%14 = getelementptr inbounds i32, i32* %11, i64 1
%15 = load i32, i32* %14
%16 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 %15, i32 %13)
%17 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 %15, i32 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 (...) @refresh()
%19 = add nsw i32 %10, -1
%20 = icmp eq i32 %10, 0
br i1 %20, label %21, label %7
21: ; preds = %7
%22 = tail call i32 (...) @getch()
%23 = tail call i32 (...) @endwin()
ret i32 0
}