#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 EXIT_SUCCESS;
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 /*<<< orphan*/ standend();
int /*<<< orphan*/ standout();
int main(void) {
  initscr();
  clear();
  for (int i = 0; i < LINES; ++i) {
    move(i, i + i);
    if (i % 2 == 1)
      standout();
    addstr("Hello, world");
    if (i % 2 == 1)
      standend();
    refresh();
    sleep(1);
  }
  endwin();
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    $0x0,%al
call   1090 <clear@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%eax
jge    1235 <main+0xa5>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
add    -0x8(%rbp),%esi
call   10b0 <move@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    11ef <main+0x5f>
mov    $0x0,%al
call   1050 <standout@plt>
lea    0xe0a(%rip),%rdi
call   1080 <addstr@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x1,%edx
jne    1216 <main+0x86>
mov    $0x0,%al
call   1030 <standend@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x24>
mov    $0x0,%al
call   1070 <endwin@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
xor    %eax,%eax
call   1090 <clear@plt>
mov    0x2e3c(%rip),%r15
cmpl   $0x0,(%r15)
jle    120a <main+0x7a>
lea    0xe47(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11e4 <main+0x54>
nop
mov    %r14,%rdi
call   1080 <addstr@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
mov    $0x1,%edi
call   10a0 <sleep@plt>
add    $0x1,%ebx
add    $0x2,%ebp
cmp    (%r15),%ebx
jge    120a <main+0x7a>
mov    %ebx,%edi
mov    %ebp,%esi
call   10b0 <move@plt>
test   $0x1,%bl
je     11c0 <main+0x30>
xor    %eax,%eax
call   1050 <standout@plt>
mov    %r14,%rdi
call   1080 <addstr@plt>
xor    %eax,%eax
call   1030 <standend@plt>
jmp    11c8 <main+0x38>
xor    %eax,%eax
call   1070 <endwin@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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