#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 argc, char *argv[]) {
  int x = 0, y = 0, max_x = 0, max_y = 0, next_x = 0, direction = 1;
  initscr();
  noecho();
  curs_set(FALSE);
  getmaxyx(stdscr, max_y, max_x);
  while (1) {
    clear();
    getmaxyx(stdscr, max_y, max_x);
    mvprintw(y, x, "o");
    refresh();
    usleep(30000);
    next_x = x + direction;
    if (next_x >= max_x || next_x < 0) {
      direction *= -1;
    } else {
      x += direction;
    }
  }
  endwin();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1060 <noecho@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
call   1080 <curs_set@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <getmaxyx@plt>
mov    $0x0,%al
call   1070 <clear@plt>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1040 <getmaxyx@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    0xde8(%rip),%rdx
call   1090 <mvprintw@plt>
mov    $0x0,%al
call   1050 <refresh@plt>
mov    $0x7530,%edi
call   10a0 <usleep@plt>
mov    -0x14(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    124d <main+0xcd>
cmpl   $0x0,-0x24(%rbp)
jge    1259 <main+0xd9>
imul   $0xffffffff,-0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1262 <main+0xe2>
mov    -0x28(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11f0 <main+0x70>

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
mov    (%r14),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getmaxyx@plt>
lea    0xe46(%rip),%rbx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1070 <clear@plt>
mov    (%r14),%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getmaxyx@plt>
xor    %edi,%edi
xor    %esi,%esi
mov    %rbx,%rdx
call   1090 <mvprintw@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    $0x7530,%edi
call   10a0 <usleep@plt>
jmp    11c0 <main+0x40>

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

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