#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 /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvprintw(int, int, char *);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ usleep(int);
int main() {
  int x = 0, y = 2;
  int maxX = 0, maxY = 0;
  int nextX = 0;
  int direction = 1;
  initscr();
  noecho();
  curs_set(FALSE);
  while (1) {
    getmaxyx(stdscr, maxY, maxX);
    clear();
    mvprintw(y, x, "o");
    refresh();
    usleep(25000);
    nextX = x + direction;
    if (nextX >= maxX || nextX < 0)
      direction *= -1;
    else
      x += direction;
  }
  endwin();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1060 <noecho@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1080 <curs_set@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <getmaxyx@plt>
mov    $0x0,%al
call   1070 <clear@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xe03(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    $0x61a8,%edi
call   10a0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1232 <main+0xb2>
cmpl   $0x0,-0x18(%rbp)
jge    123e <main+0xbe>
imul   $0xffffffff,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1247 <main+0xc7>
mov    -0x1c(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11d5 <main+0x55>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <initscr@plt>
xor    %eax,%eax
call   1060 <noecho@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1080 <curs_set@plt>
mov    0x2e41(%rip),%r14
lea    0xe52(%rip),%rbx
xchg   %ax,%ax
mov    (%r14),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getmaxyx@plt>
xor    %eax,%eax
call   1070 <clear@plt>
mov    $0x2,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    $0x61a8,%edi
call   10a0 <usleep@plt>
jmp    11b0 <main+0x30>

LLVM IR (-O0):
@FALSE = global i32 0
@stdscr = global i32 0
@.str = [2 x i8] c"o\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
store i32 0, i32* %1
store i32 0, i32* %2
store i32 2, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %7
%8 = call i32 (...) @initscr()
%9 = call i32 (...) @noecho()
%10 = load i32, i32* @FALSE
%11 = call i32 @curs_set(i32 %10)
br label %12
12: ; preds = %0, %39
%13 = load i32, i32* @stdscr
%14 = load i32, i32* %5
%15 = load i32, i32* %4
%16 = call i32 @getmaxyx(i32 %13, i32 %14, i32 %15)
%17 = call i32 (...) @clear()
%18 = load i32, i32* %3
%19 = load i32, i32* %2
%20 = call i32 @mvprintw(i32 %18, i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = call i32 (...) @refresh()
%22 = call i32 @usleep(i32 25000)
%23 = load i32, i32* %2
%24 = load i32, i32* %7
%25 = add nsw i32 %23, %24
store i32 %25, i32* %6
%26 = load i32, i32* %6
%27 = load i32, i32* %4
%28 = icmp sge i32 %26, %27
br i1 %28, label %32, label %29
29: ; preds = %12
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %29, %12
%33 = load i32, i32* %7
%34 = mul nsw i32 %33, -1
store i32 %34, i32* %7
br label %39
35: ; preds = %29
%36 = load i32, i32* %7
%37 = load i32, i32* %2
%38 = add nsw i32 %37, %36
store i32 %38, i32* %2
br label %39
39: ; preds = %35, %32
br label %12
}

LLVM IR (-O2):
@FALSE = global i32 0
@stdscr = global i32 0
@.str = [2 x i8] c"o\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)
br label %5
5: ; preds = %5, %0
%6 = load i32, i32* @stdscr
%7 = tail call i32 @getmaxyx(i32 %6, i32 0, i32 0)
%8 = tail call i32 (...) @clear()
%9 = tail call i32 @mvprintw(i32 2, i32 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 (...) @refresh()
%11 = tail call i32 @usleep(i32 25000)
br label %5
}