#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*/ endwin();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sleep(int);
int main(int argc, char *argv[]) {
  char *msg = "Hello";
  char *blk = "     ";
  int dir = 1;
  int pos = 10;
  initscr();
  clear();
  while (1) {
    move(10, pos);
    addstr(msg);
    move(LINES - 1, COLS - 1);
    refresh();
    sleep(1);
    move(10, pos);
    addstr(blk);
    pos += dir;
    if (pos >= 30)
      dir -= 1;
    if (pos <= 10)
      dir += 1;
  }
  endwin();
  return 0;
}


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)
lea    0xe83(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe7e(%rip),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movl   $0xa,-0x28(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
mov    $0x0,%al
call   1060 <clear@plt>
mov    -0x28(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
mov    -0x18(%rbp),%rdi
call   1050 <addstr@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
mov    0x2e0f(%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    -0x28(%rbp),%esi
mov    $0xa,%edi
call   1080 <move@plt>
mov    -0x20(%rbp),%rdi
call   1050 <addstr@plt>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1e,-0x28(%rbp)
jl     121e <main+0xbe>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0xa,-0x28(%rbp)
jg     1231 <main+0xd1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a8 <main+0x48>

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    $0x1,%ebp
lea    0xe76(%rip),%r14
mov    0x2e57(%rip),%r12
mov    0x2e48(%rip),%r13
lea    0xe67(%rip),%r15
nop
mov    $0xa,%edi
mov    %ebx,%esi
call   1080 <move@plt>
mov    %r14,%rdi
call   1050 <addstr@plt>
mov    (%r12),%edi
add    $0xffffffff,%edi
mov    0x0(%r13),%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    %ebp,%ebx
xor    %eax,%eax
cmp    $0x1e,%ebx
setge  %al
sub    %eax,%ebp
xor    %eax,%eax
cmp    $0xb,%ebx
setl   %al
add    %eax,%ebp
jmp    11a0 <main+0x40>

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

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