#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 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() {
  char *message = "Hello";
  char *blank = "       ";
  int dir = 1;
  int pos = 10;
  initscr();
  clear();
  while (1) {
    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 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0xa,-0x20(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1060 <clear@plt>
mov    -0x20(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
mov    -0x10(%rbp),%rdi
call   1050 <addstr@plt>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    0x2e16(%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    -0x20(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
mov    -0x18(%rbp),%rdi
call   1050 <addstr@plt>
mov    -0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x1e,-0x20(%rbp)
jl     1215 <main+0xb5>
movl   $0xffffffff,-0x1c(%rbp)
cmpl   $0xa,-0x20(%rbp)
jg     1226 <main+0xc6>
movl   $0x1,-0x1c(%rbp)
jmp    11a1 <main+0x41>

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   1060 <clear@plt>
mov    $0xa,%ebx
mov    0x2e63(%rip),%r13
mov    0x2e54(%rip),%rbp
lea    0xe73(%rip),%r15
mov    $0xffffffff,%r12d
mov    $0x1,%r14d
nop
mov    $0xa,%edi
mov    %ebx,%esi
call   1080 <move@plt>
lea    0xe4d(%rip),%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    11a0 <main+0x40>

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

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