#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*/ TRUE;
int /*<<< orphan*/ clear();
int /*<<< orphan*/ draw_border(int, int);
int /*<<< orphan*/ draw_target(int, int, int, int, char, char, char);
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ raw();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int main() {
  int ch;
  int x;
  int y;
  int posx;
  int posy;
  initscr();
  getmaxyx(stdscr, y, x);
  raw();
  keypad(stdscr, TRUE);
  noecho();
  posx = (x / 2);
  posy = (y / 2);
  draw_border(x, y);
  draw_target(x, y, posx, posy, '|', '-', '+');
  ch = 0;
  while ((ch != 'q') && (ch != 'Q')) {
    ch = getch();
    getmaxyx(stdscr, y, x);
    if (posx > (x - 1))
      posx = x - 1;
    if (posy > (y - 1))
      posy = y - 1;
    switch (ch) {
    case 's':
    case 'j':
    case 0x102:
      if ((posy + 1) < (y - 1))
        posy++;
      break;
    case 'w':
    case 'k':
    case 0x103:
      if ((posy - 1) > 0)
        posy--;
      break;
    case 'h':
    case 'a':
    case 0x104:
      if ((posx - 1) > 0)
        posx--;
      break;
    case 'l':
    case 'd':
    case 0x105:
      if ((posx + 1) < (x - 1))
        posx++;
      break;
    default:
      break;
    };
    clear();
    draw_border(x, y);
    draw_target(x, y, posx, posy, '|', '-', '+');
    refresh();
  };
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    $0x0,%al
call   1050 <raw@plt>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
mov    0x2def(%rip),%rax
mov    (%rax),%esi
call   1030 <keypad@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <draw_border@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x7c,%r8d
mov    $0x2d,%r9d
movl   $0x2b,(%rsp)
call   10c0 <draw_target@plt>
movl   $0x0,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x71,-0x8(%rbp)
mov    %al,-0x19(%rbp)
je     126a <main+0xba>
cmpl   $0x51,-0x8(%rbp)
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    127a <main+0xca>
jmp    1468 <main+0x2b8>
mov    $0x0,%al
call   1090 <getch@plt>
mov    %eax,-0x8(%rbp)
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1060 <getmaxyx@plt>
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    12b2 <main+0x102>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    12cc <main+0x11c>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x61,%eax
je     13e2 <main+0x232>
jmp    12e0 <main+0x130>
mov    -0x20(%rbp),%eax
sub    $0x64,%eax
je     13ff <main+0x24f>
jmp    12f1 <main+0x141>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
je     13e2 <main+0x232>
jmp    1302 <main+0x152>
mov    -0x20(%rbp),%eax
sub    $0x6a,%eax
je     13a3 <main+0x1f3>
jmp    1313 <main+0x163>
mov    -0x20(%rbp),%eax
sub    $0x6b,%eax
je     13c5 <main+0x215>
jmp    1324 <main+0x174>
mov    -0x20(%rbp),%eax
sub    $0x6c,%eax
je     13ff <main+0x24f>
jmp    1335 <main+0x185>
mov    -0x20(%rbp),%eax
sub    $0x73,%eax
je     13a3 <main+0x1f3>
jmp    1346 <main+0x196>
mov    -0x20(%rbp),%eax
sub    $0x77,%eax
je     13c5 <main+0x215>
jmp    1357 <main+0x1a7>
mov    -0x20(%rbp),%eax
sub    $0x102,%eax
je     13a3 <main+0x1f3>
jmp    136a <main+0x1ba>
mov    -0x20(%rbp),%eax
sub    $0x103,%eax
je     13c5 <main+0x215>
jmp    137d <main+0x1cd>
mov    -0x20(%rbp),%eax
sub    $0x104,%eax
je     13e2 <main+0x232>
jmp    1390 <main+0x1e0>
mov    -0x20(%rbp),%eax
sub    $0x105,%eax
je     13ff <main+0x24f>
jmp    1421 <main+0x271>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    13c0 <main+0x210>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1426 <main+0x276>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jle    13dd <main+0x22d>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1426 <main+0x276>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jle    13fa <main+0x24a>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1426 <main+0x276>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    141c <main+0x26c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1426 <main+0x276>
jmp    1426 <main+0x276>
mov    $0x0,%al
call   10d0 <clear@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1070 <draw_border@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    $0x7c,%r8d
mov    $0x2d,%r9d
movl   $0x2b,(%rsp)
call   10c0 <draw_target@plt>
mov    $0x0,%al
call   1080 <refresh@plt>
jmp    1251 <main+0xa1>
mov    $0x0,%al
call   10a0 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
mov    0x2e26(%rip),%r14
mov    (%r14),%edi
call   1060 <getmaxyx@plt>
xor    %eax,%eax
call   1050 <raw@plt>
mov    (%r14),%edi
mov    0x2e05(%rip),%rax
mov    (%rax),%esi
call   1030 <keypad@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
call   1070 <draw_border@plt>
movl   $0x2b,(%rsp)
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x7c,%r8d
mov    $0x2d,%r9d
call   10c0 <draw_target@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <getch@plt>
mov    %eax,%ebx
mov    (%r14),%edi
call   1060 <getmaxyx@plt>
xor    %eax,%eax
call   10d0 <clear@plt>
call   1070 <draw_border@plt>
movl   $0x2b,(%rsp)
xor    %edx,%edx
xor    %ecx,%ecx
mov    $0x7c,%r8d
mov    $0x2d,%r9d
call   10c0 <draw_target@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
and    $0xffffffdf,%ebx
cmp    $0x51,%ebx
jne    1210 <main+0x60>
xor    %eax,%eax
call   10a0 <endwin@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (...) @initscr()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = call i32 @getmaxyx(i32 %8, i32 %9, i32 %10)
%12 = call i32 (...) @raw()
%13 = load i32, i32* @stdscr
%14 = load i32, i32* @TRUE
%15 = call i32 @keypad(i32 %13, i32 %14)
%16 = call i32 (...) @noecho()
%17 = load i32, i32* %3
%18 = sdiv i32 %17, 2
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = sdiv i32 %19, 2
store i32 %20, i32* %6
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @draw_border(i32 %21, i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @draw_target(i32 %24, i32 %25, i32 %26, i32 %27, i8 signext 124, i8 signext 45, i8 signext 43)
store i32 0, i32* %2
br label %29
29: ; preds = %97, %0
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 113
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %2
%34 = icmp ne i32 %33, 81
br label %35
35: ; preds = %32, %29
%36 = phi i1 [ false, %29 ], [ %34, %32 ]
br i1 %36, label %37, label %108
37: ; preds = %35
%38 = call i32 (...) @getch()
store i32 %38, i32* %2
%39 = load i32, i32* @stdscr
%40 = load i32, i32* %4
%41 = load i32, i32* %3
%42 = call i32 @getmaxyx(i32 %39, i32 %40, i32 %41)
%43 = load i32, i32* %5
%44 = load i32, i32* %3
%45 = sub nsw i32 %44, 1
%46 = icmp sgt i32 %43, %45
br i1 %46, label %47, label %50
47: ; preds = %37
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 1
store i32 %49, i32* %5
br label %50
50: ; preds = %47, %37
%51 = load i32, i32* %6
%52 = load i32, i32* %4
%53 = sub nsw i32 %52, 1
%54 = icmp sgt i32 %51, %53
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load i32, i32* %4
%57 = sub nsw i32 %56, 1
store i32 %57, i32* %6
br label %58
58: ; preds = %55, %50
%59 = load i32, i32* %2
switch i32 %59, label %96 [
i32 115, label %60
i32 106, label %60
i32 258, label %60
i32 119, label %70
i32 107, label %70
i32 259, label %70
i32 104, label %78
i32 97, label %78
i32 260, label %78
i32 108, label %86
i32 100, label %86
i32 261, label %86
]
60: ; preds = %58, %58, %58
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %4
%64 = sub nsw i32 %63, 1
%65 = icmp slt i32 %62, %64
br i1 %65, label %66, label %69
66: ; preds = %60
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %69
69: ; preds = %66, %60
br label %97
70: ; preds = %58, %58, %58
%71 = load i32, i32* %6
%72 = sub nsw i32 %71, 1
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i32, i32* %6
%76 = add nsw i32 %75, -1
store i32 %76, i32* %6
br label %77
77: ; preds = %74, %70
br label %97
78: ; preds = %58, %58, %58
%79 = load i32, i32* %5
%80 = sub nsw i32 %79, 1
%81 = icmp sgt i32 %80, 0
br i1 %81, label %82, label %85
82: ; preds = %78
%83 = load i32, i32* %5
%84 = add nsw i32 %83, -1
store i32 %84, i32* %5
br label %85
85: ; preds = %82, %78
br label %97
86: ; preds = %58, %58, %58
%87 = load i32, i32* %5
%88 = add nsw i32 %87, 1
%89 = load i32, i32* %3
%90 = sub nsw i32 %89, 1
%91 = icmp slt i32 %88, %90
br i1 %91, label %92, label %95
92: ; preds = %86
%93 = load i32, i32* %5
%94 = add nsw i32 %93, 1
store i32 %94, i32* %5
br label %95
95: ; preds = %92, %86
br label %97
96: ; preds = %58
br label %97
97: ; preds = %96, %95, %85, %77, %69
%98 = call i32 (...) @clear()
%99 = load i32, i32* %3
%100 = load i32, i32* %4
%101 = call i32 @draw_border(i32 %99, i32 %100)
%102 = load i32, i32* %3
%103 = load i32, i32* %4
%104 = load i32, i32* %5
%105 = load i32, i32* %6
%106 = call i32 @draw_target(i32 %102, i32 %103, i32 %104, i32 %105, i8 signext 124, i8 signext 45, i8 signext 43)
%107 = call i32 (...) @refresh()
br label %29
108: ; preds = %35
%109 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
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 (...) @raw()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* @TRUE
%7 = tail call i32 @keypad(i32 %5, i32 %6)
%8 = tail call i32 (...) @noecho()
%9 = tail call i32 @draw_border(i32 undef, i32 undef)
%10 = tail call i32 @draw_target(i32 undef, i32 undef, i32 0, i32 0, i8 signext 124, i8 signext 45, i8 signext 43)
br label %11
11: ; preds = %0, %11
%12 = tail call i32 (...) @getch()
%13 = load i32, i32* @stdscr
%14 = tail call i32 @getmaxyx(i32 %13, i32 undef, i32 undef)
%15 = tail call i32 (...) @clear()
%16 = tail call i32 @draw_border(i32 undef, i32 undef)
%17 = tail call i32 @draw_target(i32 undef, i32 undef, i32 0, i32 0, i8 signext 124, i8 signext 45, i8 signext 43)
%18 = tail call i32 (...) @refresh()
%19 = and i32 %12, -33
%20 = icmp eq i32 %19, 81
br i1 %20, label %21, label %11
21: ; preds = %11
%22 = tail call i32 (...) @endwin()
ret i32 0
}