#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*/ FALSE;
#define KEY_DOWN 132
#define KEY_LEFT 131
#define KEY_RESIZE 130
#define KEY_RIGHT 129
#define KEY_UP 128
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ atexit(int /*<<< orphan*/ (*)());
int /*<<< orphan*/ clear();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int main(void) {
  int x = 10, y = 10;
  initscr();
  noecho();
  curs_set(FALSE);
  keypad(stdscr, TRUE);
  atexit(endwin);
  while (1) {
    clear();
    mvprintw(y, x, "Hello World");
    refresh();
    switch (getch()) {
    case KEY_RESIZE:
      break;
    case KEY_UP:
      y--;
      break;
    case KEY_DOWN:
      y++;
      break;
    case KEY_RIGHT:
      x++;
      break;
    case KEY_LEFT:
      x--;
      break;
    case 'q':
      exit(0);
      break;
    default:
      refresh();
      break;
    }
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   1070 <noecho@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   10b0 <curs_set@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
call   1030 <keypad@plt>
mov    0x2df1(%rip),%rdi
call   12a0 <atexit>
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   10a0 <clear@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xe3d(%rip),%rdx
call   10c0 <mvprintw@plt>
mov    -0x19(%rbp),%al
call   1050 <refresh@plt>
mov    -0x19(%rbp),%al
call   1060 <getch@plt>
add    $0xffffff8f,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x13,%eax
ja     1292 <main+0xf2>
mov    -0x18(%rbp),%rax
lea    0xdbb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1299 <main+0xf9>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    1299 <main+0xf9>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1299 <main+0xf9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1299 <main+0xf9>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1299 <main+0xf9>
xor    %edi,%edi
call   1090 <exit@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    11fc <main+0x5c>
xchg   %ax,%ax

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   1070 <noecho@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   10b0 <curs_set@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
call   1030 <keypad@plt>
mov    0x2e07(%rip),%rdi
call   1260 <atexit>
mov    $0xa,%ebx
lea    0xe5e(%rip),%r14
lea    0xe07(%rip),%r15
mov    $0xa,%ebp
jmp    1207 <main+0x67>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   10a0 <clear@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r14,%rdx
call   10c0 <mvprintw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   1060 <getch@plt>
add    $0xffffff8f,%eax
cmp    $0x13,%eax
ja     1200 <main+0x60>
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
add    $0xffffffff,%ebp
jmp    1207 <main+0x67>
add    $0x1,%ebx
jmp    1207 <main+0x67>
add    $0xffffffff,%ebx
jmp    1207 <main+0x67>
add    $0x1,%ebp
jmp    1207 <main+0x67>
xor    %edi,%edi
call   1090 <exit@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax

LLVM IR (-O0):
@FALSE = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [12 x i8] c"Hello World\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %2
store i32 10, i32* %3
%4 = call i32 (...) @initscr()
%5 = call i32 (...) @noecho()
%6 = load i32, i32* @FALSE
%7 = call i32 @curs_set(i32 %6)
%8 = load i32, i32* @stdscr
%9 = load i32, i32* @TRUE
%10 = call i32 @keypad(i32 %8, i32 %9)
%11 = call i32 @atexit(i32 (...)* @endwin)
br label %12
12: ; preds = %0, %36
%13 = call i32 (...) @clear()
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = call i32 @mvprintw(i32 %14, i32 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = call i32 (...) @refresh()
%18 = call i32 (...) @getch()
switch i32 %18, label %34 [
i32 130, label %19
i32 128, label %20
i32 132, label %23
i32 129, label %26
i32 131, label %29
i32 113, label %32
]
19: ; preds = %12
br label %36
20: ; preds = %12
%21 = load i32, i32* %3
%22 = add nsw i32 %21, -1
store i32 %22, i32* %3
br label %36
23: ; preds = %12
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %36
26: ; preds = %12
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %36
29: ; preds = %12
%30 = load i32, i32* %2
%31 = add nsw i32 %30, -1
store i32 %31, i32* %2
br label %36
32: ; preds = %12
%33 = call i32 @exit(i32 0)
unreachable
34: ; preds = %12
%35 = call i32 (...) @refresh()
br label %36
36: ; preds = %34, %29, %26, %23, %20, %19
br label %12
}

LLVM IR (-O2):
@FALSE = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
@.str = [12 x i8] c"Hello World\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @noecho()
%3 = load i32, i32* @FALSE
%4 = tail call i32 @curs_set(i32 %3)
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32 %5, i32 %6)
%8 = tail call i32 @atexit(i32 (...)* @endwin)
br label %9
9: ; preds = %29, %0
%10 = phi i32 [ 10, %0 ], [ %30, %29 ]
%11 = phi i32 [ 10, %0 ], [ %13, %29 ]
br label %12
12: ; preds = %23, %9
%13 = phi i32 [ %11, %9 ], [ %24, %23 ]
br label %14
14: ; preds = %35, %12
%15 = tail call i32 (...) @clear()
%16 = tail call i32 @mvprintw(i32 %13, i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 (...) @refresh()
%18 = tail call i32 (...) @getch()
switch i32 %18, label %33 [
i32 130, label %35
i32 128, label %19
i32 132, label %21
i32 129, label %25
i32 131, label %27
i32 113, label %31
]
19: ; preds = %14
%20 = add nsw i32 %13, -1
br label %23
21: ; preds = %14
%22 = add nsw i32 %13, 1
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ %20, %19 ], [ %22, %21 ]
br label %12
25: ; preds = %14
%26 = add nsw i32 %10, 1
br label %29
27: ; preds = %14
%28 = add nsw i32 %10, -1
br label %29
29: ; preds = %27, %25
%30 = phi i32 [ %26, %25 ], [ %28, %27 ]
br label %9
31: ; preds = %14
%32 = tail call i32 @exit(i32 0)
unreachable
33: ; preds = %14
%34 = tail call i32 (...) @refresh()
br label %35
35: ; preds = %33, %14
br label %14
}