#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*/ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ refresh();
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();
  getch();
  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   10a0 <clear@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2e2a(%rip),%rcx
cmp    (%rcx),%eax
jge    1229 <main+0x99>
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   1090 <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>
jmp    121b <main+0x8b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x24>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    $0x0,%al
call   1080 <endwin@plt>
mov    0x2d93(%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   10a0 <clear@plt>
mov    0x2e3c(%rip),%r15
cmpl   $0x0,(%r15)
jle    11f9 <main+0x69>
lea    0xe47(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
jmp    11d3 <main+0x43>
nop
mov    %r14,%rdi
call   1090 <addstr@plt>
add    $0x1,%ebx
add    $0x2,%ebp
cmp    (%r15),%ebx
jge    11f9 <main+0x69>
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   1090 <addstr@plt>
xor    %eax,%eax
call   1030 <standend@plt>
jmp    11c8 <main+0x38>
xor    %eax,%eax
call   1060 <refresh@plt>
xor    %eax,%eax
call   1070 <getch@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
mov    0x2dc3(%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 = %28, %0
%6 = load i32, i32* %2
%7 = load i32, i32* @LINES
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %31
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
br label %28
28: ; preds = %27
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
br label %5
31: ; preds = %5
%32 = call i32 (...) @refresh()
%33 = call i32 (...) @getch()
%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 %10, label %5
5: ; preds = %22, %0
%6 = tail call i32 (...) @refresh()
%7 = tail call i32 (...) @getch()
%8 = tail call i32 (...) @endwin()
%9 = load i32, i32* @EXIT_SUCCESS
ret i32 %9
10: ; preds = %0, %22
%11 = phi i32 [ %23, %22 ], [ 0, %0 ]
%12 = shl nuw nsw i32 %11, 1
%13 = tail call i32 @move(i32 %11, i32 %12)
%14 = and i32 %11, 1
%15 = icmp eq i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = tail call i32 (...) @standout()
%18 = tail call i32 @addstr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = tail call i32 (...) @standend()
br label %22
20: ; preds = %10
%21 = tail call i32 @addstr(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = add nuw nsw i32 %11, 1
%24 = load i32, i32* @LINES
%25 = icmp slt i32 %23, %24
br i1 %25, label %10, label %5
}