#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*/ free(int *);
int /*<<< orphan*/ initscr();
int *malloc(int);
int movement(int *, int *);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ print_grid(int *, int *);
int /*<<< orphan*/ printw(char *, int, int);
int /*<<< orphan*/ refresh();
int main() {
  initscr();
  noecho();
  int *ptr_x;
  int *ptr_y;
  ptr_x = malloc(sizeof(int));
  ptr_y = malloc(sizeof(int));
  *ptr_x = *ptr_y = 0;
  int moved = 1;
  while (moved != 'q') {
    clear();
    printw("Location is: (%d,%d)\n", *ptr_x, *ptr_y);
    print_grid(ptr_x, ptr_y);
    refresh();
    moved = movement(ptr_x, ptr_y);
  }
  free(ptr_x);
  free(ptr_y);
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   10a0 <noecho@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x1,-0x1c(%rbp)
cmpl   $0x71,-0x1c(%rbp)
je     1246 <main+0xa6>
mov    $0x0,%al
call   10c0 <clear@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xde8(%rip),%rdi
call   1060 <printw@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <print_grid@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <movement@plt>
mov    %eax,-0x1c(%rbp)
jmp    11f4 <main+0x54>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   10a0 <noecho@plt>
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
movl   $0x0,(%rax)
movl   $0x0,(%r14)
lea    0xe1f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10c0 <clear@plt>
mov    (%r14),%esi
mov    (%rbx),%edx
mov    %r15,%rdi
call   1060 <printw@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <print_grid@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <movement@plt>
cmp    $0x71,%eax
jne    11f0 <main+0x50>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   1090 <endwin@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Location is: (%d,%d)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (...) @initscr()
%6 = call i32 (...) @noecho()
%7 = call i32* @malloc(i32 4)
store i32* %7, i32** %2
%8 = call i32* @malloc(i32 4)
store i32* %8, i32** %3
%9 = load i32*, i32** %3
store i32 0, i32* %9
%10 = load i32*, i32** %2
store i32 0, i32* %10
store i32 1, i32* %4
br label %11
11: ; preds = %14, %0
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 113
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = call i32 (...) @clear()
%16 = load i32*, i32** %2
%17 = load i32, i32* %16
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = call i32 @printw(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %19)
%21 = load i32*, i32** %2
%22 = load i32*, i32** %3
%23 = call i32 @print_grid(i32* %21, i32* %22)
%24 = call i32 (...) @refresh()
%25 = load i32*, i32** %2
%26 = load i32*, i32** %3
%27 = call i32 @movement(i32* %25, i32* %26)
store i32 %27, i32* %4
br label %11
28: ; preds = %11
%29 = load i32*, i32** %2
%30 = call i32 @free(i32* %29)
%31 = load i32*, i32** %3
%32 = call i32 @free(i32* %31)
%33 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Location is: (%d,%d)\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @noecho()
%3 = tail call i32* @malloc(i32 4)
%4 = tail call i32* @malloc(i32 4)
store i32 0, i32* %4
store i32 0, i32* %3
br label %5
5: ; preds = %0, %5
%6 = tail call i32 (...) @clear()
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = tail call i32 @printw(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8)
%10 = tail call i32 @print_grid(i32* %3, i32* %4)
%11 = tail call i32 (...) @refresh()
%12 = tail call i32 @movement(i32* %3, i32* %4)
%13 = icmp eq i32 %12, 113
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = tail call i32 @free(i32* %3)
%16 = tail call i32 @free(i32* %4)
%17 = tail call i32 (...) @endwin()
ret i32 0
}