#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 COLS;
int EXIT_SUCCESS;
int LINES;
int /*<<< orphan*/ addstr(char *);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sleep(int);
int main(void) {
  char message[] = "hello";
  char blank[] = "     ";
  initscr();
  clear();
  int dir = 1;
  int pos = 10;
  while (true) {
    move(10, pos);
    addstr(message);
    move(LINES - 1, COLS - 1);
    refresh();
    sleep(1);
    move(10, pos);
    addstr(blank);
    pos += dir;
    if (pos >= 30)
      dir = -1;
    if (pos <= 10)
      dir = 1;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8b(%rip),%eax
mov    %eax,-0xa(%rbp)
mov    0xe85(%rip),%ax
mov    %ax,-0x6(%rbp)
mov    0xe7d(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe77(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1060 <clear@plt>
movl   $0x1,-0x14(%rbp)
movl   $0xa,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
lea    -0xa(%rbp),%rdi
call   1050 <addstr@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
sub    $0x1,%esi
call   1080 <move@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    -0x18(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
lea    -0x10(%rbp),%rdi
call   1050 <addstr@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x1e,-0x18(%rbp)
jl     1227 <main+0xc7>
movl   $0xffffffff,-0x14(%rbp)
cmpl   $0xa,-0x18(%rbp)
jg     1238 <main+0xd8>
movl   $0x1,-0x14(%rbp)
jmp    11b3 <main+0x53>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x6f,0x14(%rsp)
movl   $0x6c6c6568,0x10(%rsp)
6c
movw   $0x20,0xc(%rsp)
movl   $0x20202020,0x8(%rsp)
20
xor    %eax,%eax
call   1030 <initscr@plt>
xor    %eax,%eax
call   1060 <clear@plt>
mov    $0xa,%ebx
mov    0x2e42(%rip),%r13
mov    0x2e33(%rip),%rbp
lea    0x8(%rsp),%r15
mov    $0xffffffff,%r12d
mov    $0x1,%r14d
xchg   %ax,%ax
mov    $0xa,%edi
mov    %ebx,%esi
call   1080 <move@plt>
lea    0x10(%rsp),%rdi
call   1050 <addstr@plt>
mov    0x0(%r13),%edi
add    $0xffffffff,%edi
mov    0x0(%rbp),%esi
add    $0xffffffff,%esi
call   1080 <move@plt>
xor    %eax,%eax
call   1040 <refresh@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0xa,%edi
mov    %ebx,%esi
call   1080 <move@plt>
mov    %r15,%rdi
call   1050 <addstr@plt>
add    %r14d,%ebx
cmp    $0x1e,%ebx
cmovge %r12d,%r14d
cmp    $0xb,%ebx
mov    $0x1,%eax
cmovl  %eax,%r14d
jmp    11c0 <main+0x60>

LLVM IR (-O0):
@__const.main.message = [6 x i8] c"hello\00"
@__const.main.blank = [6 x i8] c" \00"
@LINES = global i32 0
@COLS = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i8]
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [6 x i8]* %2 to i8*
%7 = bitcast [6 x i8]* %3 to i8*
%8 = call i32 (...) @initscr()
%9 = call i32 (...) @clear()
store i32 1, i32* %4
store i32 10, i32* %5
br label %10
10: ; preds = %0, %36
%11 = load i32, i32* %5
%12 = call i32 @move(i32 10, i32 %11)
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%14 = call i32 @addstr(i8* %13)
%15 = load i32, i32* @LINES
%16 = sub nsw i32 %15, 1
%17 = load i32, i32* @COLS
%18 = sub nsw i32 %17, 1
%19 = call i32 @move(i32 %16, i32 %18)
%20 = call i32 (...) @refresh()
%21 = call i32 @sleep(i32 1)
%22 = load i32, i32* %5
%23 = call i32 @move(i32 10, i32 %22)
%24 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%25 = call i32 @addstr(i8* %24)
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = add nsw i32 %27, %26
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp sge i32 %29, 30
br i1 %30, label %31, label %32
31: ; preds = %10
store i32 -1, i32* %4
br label %32
32: ; preds = %31, %10
%33 = load i32, i32* %5
%34 = icmp sle i32 %33, 10
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 1, i32* %4
br label %36
36: ; preds = %35, %32
br label %10
}

LLVM IR (-O2):
@__const.main.message = [6 x i8] c"hello\00"
@__const.main.blank = [6 x i8] c" \00"
@LINES = global i32 0
@COLS = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [6 x i8]
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @clear()
br label %7
7: ; preds = %7, %0
%8 = phi i32 [ 1, %0 ], [ %25, %7 ]
%9 = phi i32 [ 10, %0 ], [ %21, %7 ]
%10 = call i32 @move(i32 10, i32 %9)
%11 = call i32 @addstr(i8* %3)
%12 = load i32, i32* @LINES
%13 = add nsw i32 %12, -1
%14 = load i32, i32* @COLS
%15 = add nsw i32 %14, -1
%16 = call i32 @move(i32 %13, i32 %15)
%17 = call i32 (...) @refresh()
%18 = call i32 @sleep(i32 1)
%19 = call i32 @move(i32 10, i32 %9)
%20 = call i32 @addstr(i8* %4)
%21 = add nsw i32 %9, %8
%22 = icmp sgt i32 %21, 29
%23 = select i1 %22, i32 -1, i32 %8
%24 = icmp slt i32 %21, 11
%25 = select i1 %24, i32 1, i32 %23
br label %7
}