#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 */
typedef int /*<<< orphan*/ WINDOW;

/* Variables and functions */
short COLS;
char EOF;
short LINES;
int /*<<< orphan*/ SIGINT;
short TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, char, char);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ *newwin(short, short, short, short);
int /*<<< orphan*/ scrollok(int /*<<< orphan*/ *, short);
int /*<<< orphan*/ signal(int /*<<< orphan*/, void (*)());
int /*<<< orphan*/ touchwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ wgetstr(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ wmove(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
main() {
  WINDOW *win;
  short nl, nc, br, bc;
  char inbuf[100];
  short flag;
  void done();
  initscr();
  signal(SIGINT, done);
  br = 0;
  bc = 0;
  nc = COLS;
  nl = LINES;
  win = newwin(nl, nc, br, bc);
  box(win, '|', '-');
  touchwin(win);
  wrefresh(win);
  scrollok(win, TRUE);
  *inbuf = !EOF;
  flag = TRUE;
  while (*inbuf != EOF)
    ;
  {
    wmove(win, 1, 1);
    wgetstr(win, inbuf);
    wrefresh(win);
  }
  endwin();
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    0x2ddf(%rip),%rsi
call   1080 <signal@plt>
movw   $0x0,-0x16(%rbp)
movw   $0x0,-0x18(%rbp)
mov    0x2dd7(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x14(%rbp)
mov    0x2de1(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x12(%rbp)
mov    -0x12(%rbp),%dx
mov    -0x14(%rbp),%cx
mov    -0x16(%rbp),%ax
movswl %dx,%edi
movswl %cx,%esi
movswl %ax,%edx
movswl -0x18(%rbp),%ecx
call   1070 <newwin@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1090 <box@plt>
mov    -0x10(%rbp),%rdi
call   1040 <touchwin@plt>
mov    -0x10(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    -0x10(%rbp),%rdi
mov    0x2d78(%rip),%rax
movswl (%rax),%esi
call   10a0 <scrollok@plt>
mov    0x2d71(%rip),%rax
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x80(%rbp)
mov    0x2d52(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x82(%rbp)
movsbl -0x80(%rbp),%eax
mov    0x2d45(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12a3 <main+0xf3>
jmp    1288 <main+0xd8>
mov    -0x10(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10d0 <wmove@plt>
mov    -0x10(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1030 <wgetstr@plt>
mov    -0x10(%rbp),%rdi
call   1050 <wrefresh@plt>
mov    $0x0,%al
call   10b0 <endwin@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
xor    %eax,%eax
call   1060 <initscr@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    0x2dec(%rip),%rsi
call   1080 <signal@plt>
mov    0x2df0(%rip),%rax
movswl (%rax),%esi
mov    0x2dfe(%rip),%rax
movswl (%rax),%edi
xor    %edx,%edx
xor    %ecx,%ecx
call   1070 <newwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1090 <box@plt>
mov    %rbx,%rdi
call   1040 <touchwin@plt>
mov    %rbx,%rdi
call   1050 <wrefresh@plt>
mov    0x2db6(%rip),%rax
movswl (%rax),%esi
mov    %rbx,%rdi
call   10a0 <scrollok@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%al
test   %al,%al
sete   %cl
sete   (%rsp)
cmp    %cl,%al
je     1242 <main+0x92>
nopl   0x0(%rax,%rax,1)
jmp    1240 <main+0x90>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   10d0 <wmove@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <wgetstr@plt>
mov    %rbx,%rdi
call   1050 <wrefresh@plt>
xor    %eax,%eax
call   10b0 <endwin@plt>
xor    %edi,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@SIGINT = global i32 0
@COLS = global i16 0
@LINES = global i16 0
@TRUE = global i16 0
@EOF = global i8 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
%6 = alloca i16
%7 = alloca [100 x i8]
%8 = alloca i16
store i32 0, i32* %1
%9 = call i32 (...) @initscr()
%10 = load i32, i32* @SIGINT
%11 = call i32 @signal(i32 %10, void (...)* @done)
store i16 0, i16* %5
store i16 0, i16* %6
%12 = load i16, i16* @COLS
store i16 %12, i16* %4
%13 = load i16, i16* @LINES
store i16 %13, i16* %3
%14 = load i16, i16* %3
%15 = load i16, i16* %4
%16 = load i16, i16* %5
%17 = load i16, i16* %6
%18 = call i32* @newwin(i16 signext %14, i16 signext %15, i16 signext %16, i16 signext %17)
store i32* %18, i32** %2
%19 = load i32*, i32** %2
%20 = call i32 @box(i32* %19, i8 signext 124, i8 signext 45)
%21 = load i32*, i32** %2
%22 = call i32 @touchwin(i32* %21)
%23 = load i32*, i32** %2
%24 = call i32 @wrefresh(i32* %23)
%25 = load i32*, i32** %2
%26 = load i16, i16* @TRUE
%27 = call i32 @scrollok(i32* %25, i16 signext %26)
%28 = load i8, i8* @EOF
%29 = icmp ne i8 %28, 0
%30 = xor i1 %29, true
%31 = zext i1 %30 to i32
%32 = trunc i32 %31 to i8
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
store i8 %32, i8* %33
%34 = load i16, i16* @TRUE
store i16 %34, i16* %8
br label %35
35: ; preds = %42, %0
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = load i8, i8* @EOF
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %38, %40
br i1 %41, label %42, label %43
42: ; preds = %35
br label %35
43: ; preds = %35
%44 = load i32*, i32** %2
%45 = call i32 @wmove(i32* %44, i32 1, i32 1)
%46 = load i32*, i32** %2
%47 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%48 = call i32 @wgetstr(i32* %46, i8* %47)
%49 = load i32*, i32** %2
%50 = call i32 @wrefresh(i32* %49)
%51 = call i32 (...) @endwin()
%52 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@SIGINT = global i32 0
@COLS = global i16 0
@LINES = global i16 0
@TRUE = global i16 0
@EOF = global i8 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @initscr()
%4 = load i32, i32* @SIGINT
%5 = tail call i32 @signal(i32 %4, void (...)* @done)
%6 = load i16, i16* @COLS
%7 = load i16, i16* @LINES
%8 = tail call i32* @newwin(i16 signext %7, i16 signext %6, i16 signext 0, i16 signext 0)
%9 = tail call i32 @box(i32* %8, i8 signext 124, i8 signext 45)
%10 = tail call i32 @touchwin(i32* %8)
%11 = tail call i32 @wrefresh(i32* %8)
%12 = load i16, i16* @TRUE
%13 = tail call i32 @scrollok(i32* %8, i16 signext %12)
%14 = load i8, i8* @EOF
%15 = icmp eq i8 %14, 0
%16 = zext i1 %15 to i8
store i8 %16, i8* %2
%17 = icmp eq i8 %14, %16
br i1 %17, label %19, label %18
18: ; preds = %0, %18
br label %18
19: ; preds = %0
%20 = tail call i32 @wmove(i32* %8, i32 1, i32 1)
%21 = call i32 @wgetstr(i32* %8, i8* %2)
%22 = call i32 @wrefresh(i32* %8)
%23 = call i32 (...) @endwin()
%24 = call i32 @exit(i32 0)
unreachable
}