#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;
int /*<<< orphan*/ clear();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *, char, ...);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int axe_x = 0, axe_y = 2;
  int axe_max_x = 0, axe_max_y = 0;
  int next_x = 0;
  int direction = 1;
  char letter = 'O';
  int c;
  initscr();
  noecho();
  curs_set(FALSE);
  while (1) {
    getmaxyx(stdscr, axe_max_y, axe_max_x);
    clear();
    mvprintw(0, 0, "My: %d - y: %d - Mx: %d - x: %d", axe_max_y, axe_y,
             axe_max_x, axe_x);
    mvprintw(axe_y, axe_x, "%c", letter);
    refresh();
    int char_number;
    switch (char_number = getch()) {
    case 105:
      axe_y -= direction;
      break;
    case 106:
      axe_x -= direction;
      break;
    case 107:
      axe_y += direction;
      break;
    case 108:
      axe_x += direction;
      break;
    default:
      break;
    }
    usleep(30000);
    if (axe_x < 0) {
      axe_x = 0;
    } else if (axe_x > axe_max_x) {
      axe_x = axe_max_x - 1;
    } else if (axe_y < 1) {
      axe_y = 1;
    } else if (axe_y > axe_max_y) {
      axe_y = axe_max_y - 1;
    }
    mvprintw(axe_y, axe_x, "%c", letter);
    refresh();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
movb   $0x4f,-0x29(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1070 <noecho@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
call   1090 <curs_set@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <getmaxyx@plt>
xor    %eax,%eax
mov    %eax,-0x48(%rbp)
mov    %al,-0x41(%rbp)
call   1080 <clear@plt>
mov    -0x48(%rbp),%esi
mov    -0x41(%rbp),%al
movsbl -0x20(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x1c(%rbp),%r9d
mov    -0x14(%rbp),%edi
mov    %rsp,%rdx
mov    %edi,(%rdx)
lea    0xdde(%rip),%rdx
mov    %esi,%edi
call   10a0 <mvprintw@plt>
mov    -0x41(%rbp),%al
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
movsbl -0x29(%rbp),%ecx
lea    0xde3(%rip),%rdx
call   10a0 <mvprintw@plt>
mov    -0x41(%rbp),%al
call   1050 <refresh@plt>
mov    -0x41(%rbp),%al
call   1060 <getch@plt>
mov    %eax,-0x34(%rbp)
add    $0xffffff97,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x3,%eax
ja     12c7 <main+0x137>
mov    -0x40(%rbp),%rax
lea    0xd7e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
jmp    12cc <main+0x13c>
mov    -0x28(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
jmp    12cc <main+0x13c>
mov    -0x28(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    12cc <main+0x13c>
mov    -0x28(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    12cc <main+0x13c>
jmp    12cc <main+0x13c>
mov    $0x7530,%edi
call   10b0 <usleep@plt>
cmpl   $0x0,-0x14(%rbp)
jge    12ec <main+0x15c>
movl   $0x0,-0x14(%rbp)
jmp    1340 <main+0x1b0>
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    1306 <main+0x176>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    133b <main+0x1ab>
cmpl   $0x1,-0x18(%rbp)
jge    131c <main+0x18c>
movl   $0x1,-0x18(%rbp)
jmp    1336 <main+0x1a6>
mov    -0x18(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    1331 <main+0x1a1>
mov    -0x20(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1336 <main+0x1a6>
jmp    133b <main+0x1ab>
jmp    1340 <main+0x1b0>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    0xce3(%rip),%rdx
movsbl -0x29(%rbp),%ecx
mov    $0x0,%al
call   10a0 <mvprintw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
jmp    11f0 <main+0x60>

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>
xor    %eax,%eax
call   1070 <noecho@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
call   1090 <curs_set@plt>
mov    $0x2,%ebp
mov    0x2e25(%rip),%r12
lea    0xe46(%rip),%r14
lea    0xe5f(%rip),%r15
lea    0xe28(%rip),%r13
xor    %ebx,%ebx
jmp    1206 <main+0x76>
nopl   0x0(%rax)
mov    $0x7530,%edi
call   10b0 <usleep@plt>
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15,%rdx
mov    $0x4f,%ecx
xor    %eax,%eax
call   10a0 <mvprintw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    (%r12),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getmaxyx@plt>
xor    %eax,%eax
call   1080 <clear@plt>
mov    %ebx,(%rsp)
xor    %edi,%edi
xor    %esi,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %ebp,%r8d
xor    %r9d,%r9d
xor    %eax,%eax
call   10a0 <mvprintw@plt>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15,%rdx
mov    $0x4f,%ecx
xor    %eax,%eax
call   10a0 <mvprintw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
xor    %eax,%eax
call   1060 <getch@plt>
add    $0xffffff97,%eax
cmp    $0x3,%eax
ja     1273 <main+0xe3>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
add    $0xffffffff,%ebp
jmp    1273 <main+0xe3>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    $0x7530,%edi
call   10b0 <usleep@plt>
test   %ebx,%ebx
js     11ea <main+0x5a>
xor    %eax,%eax
test   %ebp,%ebp
setle  %al
lea    (%rax,%rax,1),%ebp
add    $0xffffffff,%ebp
jmp    11ea <main+0x5a>
nopw   0x0(%rax,%rax,1)
mov    $0x7530,%edi
call   10b0 <usleep@plt>
cmp    $0xffffffff,%ebx
mov    $0xffffffff,%ebx
jne    11ec <main+0x5c>
jmp    1285 <main+0xf5>

LLVM IR (-O0):
@FALSE = global i32 0
@stdscr = global i32 0
@.str = [32 x i8] c"My: %d - y: %d - Mx: %d - x: %d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 1, i32* %11
store i8 79, i8* %12
%15 = call i32 (...) @initscr()
%16 = call i32 (...) @noecho()
%17 = load i32, i32* @FALSE
%18 = call i32 @curs_set(i32 %17)
br label %19
19: ; preds = %2, %80
%20 = load i32, i32* @stdscr
%21 = load i32, i32* %9
%22 = load i32, i32* %8
%23 = call i32 @getmaxyx(i32 %20, i32 %21, i32 %22)
%24 = call i32 (...) @clear()
%25 = load i32, i32* %9
%26 = trunc i32 %25 to i8
%27 = load i32, i32* %7
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext %26, i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %7
%32 = load i32, i32* %6
%33 = load i8, i8* %12
%34 = call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 %31, i32 %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %33)
%35 = call i32 (...) @refresh()
%36 = call i32 (...) @getch()
store i32 %36, i32* %14
switch i32 %36, label %53 [
i32 105, label %37
i32 106, label %41
i32 107, label %45
i32 108, label %49
]
37: ; preds = %19
%38 = load i32, i32* %11
%39 = load i32, i32* %7
%40 = sub nsw i32 %39, %38
store i32 %40, i32* %7
br label %54
41: ; preds = %19
%42 = load i32, i32* %11
%43 = load i32, i32* %6
%44 = sub nsw i32 %43, %42
store i32 %44, i32* %6
br label %54
45: ; preds = %19
%46 = load i32, i32* %11
%47 = load i32, i32* %7
%48 = add nsw i32 %47, %46
store i32 %48, i32* %7
br label %54
49: ; preds = %19
%50 = load i32, i32* %11
%51 = load i32, i32* %6
%52 = add nsw i32 %51, %50
store i32 %52, i32* %6
br label %54
53: ; preds = %19
br label %54
54: ; preds = %53, %49, %45, %41, %37
%55 = call i32 @usleep(i32 30000)
%56 = load i32, i32* %6
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %54
store i32 0, i32* %6
br label %80
59: ; preds = %54
%60 = load i32, i32* %6
%61 = load i32, i32* %8
%62 = icmp sgt i32 %60, %61
br i1 %62, label %63, label %66
63: ; preds = %59
%64 = load i32, i32* %8
%65 = sub nsw i32 %64, 1
store i32 %65, i32* %6
br label %79
66: ; preds = %59
%67 = load i32, i32* %7
%68 = icmp slt i32 %67, 1
br i1 %68, label %69, label %70
69: ; preds = %66
store i32 1, i32* %7
br label %78
70: ; preds = %66
%71 = load i32, i32* %7
%72 = load i32, i32* %9
%73 = icmp sgt i32 %71, %72
br i1 %73, label %74, label %77
74: ; preds = %70
%75 = load i32, i32* %9
%76 = sub nsw i32 %75, 1
store i32 %76, i32* %7
br label %77
77: ; preds = %74, %70
br label %78
78: ; preds = %77, %69
br label %79
79: ; preds = %78, %63
br label %80
80: ; preds = %79, %58
%81 = load i32, i32* %7
%82 = load i32, i32* %6
%83 = load i8, i8* %12
%84 = call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 %81, i32 %82, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext %83)
%85 = call i32 (...) @refresh()
br label %19
}

LLVM IR (-O2):
@FALSE = global i32 0
@stdscr = global i32 0
@.str = [32 x i8] c"My: %d - y: %d - Mx: %d - x: %d\00"
@.str.1 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @initscr()
%4 = tail call i32 (...) @noecho()
%5 = load i32, i32* @FALSE
%6 = tail call i32 @curs_set(i32 %5)
br label %7
7: ; preds = %34, %2
%8 = phi i32 [ 2, %2 ], [ %35, %34 ]
%9 = phi i32 [ 0, %2 ], [ %36, %34 ]
%10 = load i32, i32* @stdscr
%11 = tail call i32 @getmaxyx(i32 %10, i32 0, i32 0)
%12 = tail call i32 (...) @clear()
%13 = tail call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext 0, i32 %8, i32 0, i32 %9)
%14 = tail call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 %8, i32 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext 79)
%15 = tail call i32 (...) @refresh()
%16 = tail call i32 (...) @getch()
switch i32 %16, label %23 [
i32 105, label %17
i32 106, label %19
i32 107, label %21
i32 108, label %27
]
17: ; preds = %7
%18 = add nsw i32 %8, -1
br label %23
19: ; preds = %7
%20 = tail call i32 @usleep(i32 30000)
br label %34
21: ; preds = %7
%22 = add nsw i32 %8, 1
br label %23
23: ; preds = %7, %21, %17
%24 = phi i32 [ %8, %7 ], [ %22, %21 ], [ %18, %17 ]
%25 = tail call i32 @usleep(i32 30000)
%26 = icmp slt i32 %9, 0
br i1 %26, label %34, label %30
27: ; preds = %7
%28 = tail call i32 @usleep(i32 30000)
%29 = icmp eq i32 %9, -1
br i1 %29, label %30, label %34
30: ; preds = %23, %27
%31 = phi i32 [ %8, %27 ], [ %24, %23 ]
%32 = icmp slt i32 %31, 1
%33 = select i1 %32, i32 1, i32 -1
br label %34
34: ; preds = %19, %30, %27, %23
%35 = phi i32 [ %24, %23 ], [ %8, %27 ], [ %33, %30 ], [ %8, %19 ]
%36 = phi i32 [ 0, %23 ], [ -1, %27 ], [ 0, %30 ], [ 0, %19 ]
%37 = tail call i32 (i32, i32, i8*, i8, ...) @mvprintw(i32 %35, i32 %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8 signext 79)
%38 = tail call i32 (...) @refresh()
br label %7
}