#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*/ addch(char);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ napms(int);
int /*<<< orphan*/ refresh();
int main(void) {
  char text[] = "Greetings from Ncurses!";
  char *t = NULL;
  initscr();
  t = text;
  while (*t) {
    addch(*t);
    t++;
    refresh();
    napms(100);
  }
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe84(%rip),%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1030 <initscr@plt>
lea    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e2 <main+0x82>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <addch@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <refresh@plt>
mov    $0x64,%edi
call   1080 <napms@plt>
jmp    11a7 <main+0x47>
mov    $0x0,%al
call   1060 <getch@plt>
mov    $0x0,%al
call   1070 <endwin@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0xe94(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x21736573727563,%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1030 <initscr@plt>
lea    0x1(%rsp),%rbx
mov    $0x47,%al
nopl   (%rax)
movsbl %al,%edi
call   1040 <addch@plt>
xor    %eax,%eax
call   1050 <refresh@plt>
mov    $0x64,%edi
call   1080 <napms@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <main+0x30>
xor    %eax,%eax
call   1060 <getch@plt>
xor    %eax,%eax
call   1070 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.text = [24 x i8] c"Greetings from Ncurses!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [24 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = bitcast [24 x i8]* %2 to i8*
store i8* null, i8** %3
%5 = call i32 (...) @initscr()
%6 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
store i8* %6, i8** %3
br label %7
7: ; preds = %11, %0
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = call i32 @addch(i8 signext %13)
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
%17 = call i32 (...) @refresh()
%18 = call i32 @napms(i32 100)
br label %7
19: ; preds = %7
%20 = call i32 (...) @getch()
%21 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@__const.main.text = [24 x i8] c"Greetings from Ncurses!\00"
define i32 @main() {
%1 = alloca [24 x i8]
%2 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @initscr()
br label %4
4: ; preds = %0, %4
%5 = phi i8 [ %11, %4 ], [ 71, %0 ]
%6 = phi i8* [ %8, %4 ], [ %2, %0 ]
%7 = tail call i32 @addch(i8 signext %5)
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = tail call i32 (...) @refresh()
%10 = tail call i32 @napms(i32 100)
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4
%14 = tail call i32 (...) @getch()
%15 = tail call i32 (...) @endwin()
ret i32 0
}