#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 /*<<< orphan*/ addstr(char *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ printw(char *);
int /*<<< orphan*/ refresh();
int main(void) {
  initscr();
  addstr("ncurses test!  ");
  getch();
  printf("printf line");
  getch();
  printw("printw line1");
  getch();
  printw("printw line2");
  refresh();
  getch();
  endwin();
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
lea    0xe73(%rip),%rdi
call   1090 <addstr@plt>
mov    $0x0,%al
call   1070 <getch@plt>
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1070 <getch@plt>
lea    0xe69(%rip),%rdi
call   1050 <printw@plt>
mov    $0x0,%al
call   1070 <getch@plt>
lea    0xe63(%rip),%rdi
call   1050 <printw@plt>
mov    $0x0,%al
call   1060 <refresh@plt>
mov    $0x0,%al
call   1070 <getch@plt>
mov    $0x0,%al
call   1080 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
lea    0xe81(%rip),%rdi
call   1090 <addstr@plt>
xor    %eax,%eax
call   1070 <getch@plt>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
call   1070 <getch@plt>
lea    0xe77(%rip),%rdi
call   1050 <printw@plt>
xor    %eax,%eax
call   1070 <getch@plt>
lea    0xe71(%rip),%rdi
call   1050 <printw@plt>
xor    %eax,%eax
call   1060 <refresh@plt>
xor    %eax,%eax
call   1070 <getch@plt>
xor    %eax,%eax
call   1080 <endwin@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"ncurses test! \00"
@.str.1 = [12 x i8] c"printf line\00"
@.str.2 = [13 x i8] c"printw line1\00"
@.str.3 = [13 x i8] c"printw line2\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 (...) @initscr()
%3 = call i32 @addstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @getch()
%5 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 (...) @getch()
%7 = call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (...) @getch()
%9 = call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (...) @refresh()
%11 = call i32 (...) @getch()
%12 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"ncurses test! \00"
@.str.1 = [12 x i8] c"printf line\00"
@.str.2 = [13 x i8] c"printw line1\00"
@.str.3 = [13 x i8] c"printw line2\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 @addstr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 (...) @getch()
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 (...) @getch()
%6 = tail call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%7 = tail call i32 (...) @getch()
%8 = tail call i32 @printw(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%9 = tail call i32 (...) @refresh()
%10 = tail call i32 (...) @getch()
%11 = tail call i32 (...) @endwin()
ret i32 0
}