#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 */
int COLS;
int /*<<< orphan*/ EXIT_SUCCESS;
int LINES;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, char, char);
int /*<<< orphan*/ delwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ mvwaddch(int /*<<< orphan*/ *, int, int, char);
int /*<<< orphan*/ mvwprintw(int /*<<< orphan*/ *, int, int, char *, char *);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ *stdscr;
int /*<<< orphan*/ touchwin(int /*<<< orphan*/ *);
int /*<<< orphan*/ wclear(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int main() {
  WINDOW *new_window_ptr;
  WINDOW *popup_window_ptr;
  int x_loop;
  int y_loop;
  char a_letter = 'a';
  initscr();
  new_window_ptr = newwin(10, 20, 5, 5);
  mvwprintw(new_window_ptr, 2, 2, "%s", "Hello World");
  mvwprintw(new_window_ptr, 5, 2, "%s",
            "Notice how very long lines wrap inside the window");
  wrefresh(new_window_ptr);
  sleep(2);
  a_letter = '0';
  for (x_loop = 0; x_loop < COLS - 1; x_loop++) {
    for (y_loop = 0; y_loop < LINES - 1; y_loop++) {
      mvwaddch(stdscr, y_loop, x_loop, a_letter);
      a_letter++;
      if (a_letter > '9')
        a_letter = '0';
    }
  }
  refresh();
  sleep(2);
  wrefresh(new_window_ptr);
  sleep(2);
  touchwin(new_window_ptr);
  wrefresh(new_window_ptr);
  sleep(2);
  popup_window_ptr = newwin(10, 20, 8, 8);
  box(popup_window_ptr, '|', '-');
  mvwprintw(popup_window_ptr, 5, 2, "%s", "Pop Up Window!");
  wrefresh(popup_window_ptr);
  sleep(2);
  touchwin(new_window_ptr);
  wrefresh(new_window_ptr);
  sleep(2);
  wclear(new_window_ptr);
  wrefresh(new_window_ptr);
  sleep(2);
  delwin(new_window_ptr);
  touchwin(popup_window_ptr);
  wrefresh(popup_window_ptr);
  sleep(2);
  delwin(popup_window_ptr);
  touchwin(stdscr);
  refresh();
  sleep(2);
  endwin();
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x61,-0x21(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x5,%ecx
mov    %ecx,%edx
call   1060 <newwin@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2,%edx
lea    0xdec(%rip),%rcx
lea    0xde8(%rip),%r8
mov    %edx,%esi
call   10c0 <mvwprintw@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
mov    $0x2,%edx
lea    0xdc9(%rip),%rcx
lea    0xdd1(%rip),%r8
call   10c0 <mvwprintw@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
movb   $0x30,-0x21(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2d6d(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12ee <main+0x11e>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    12db <main+0x10b>
mov    0x2d43(%rip),%rax
mov    (%rax),%rdi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
movsbl -0x21(%rbp),%ecx
call   10d0 <mvwaddch@plt>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x39,%eax
jle    12c8 <main+0xf8>
movb   $0x30,-0x21(%rbp)
jmp    12cd <main+0xfd>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    127f <main+0xaf>
jmp    12e0 <main+0x110>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1261 <main+0x91>
mov    $0x0,%al
call   1090 <refresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1030 <touchwin@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x8,%ecx
mov    %ecx,%edx
call   1060 <newwin@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1070 <box@plt>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
mov    $0x2,%edx
lea    0xc90(%rip),%rcx
lea    0xcca(%rip),%r8
call   10c0 <mvwprintw@plt>
mov    -0x18(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1030 <touchwin@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <wclear@plt>
mov    -0x10(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x10(%rbp),%rdi
call   1080 <delwin@plt>
mov    -0x18(%rbp),%rdi
call   1030 <touchwin@plt>
mov    -0x18(%rbp),%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    -0x18(%rbp),%rdi
call   1080 <delwin@plt>
mov    0x2be4(%rip),%rax
mov    (%rax),%rdi
call   1030 <touchwin@plt>
mov    $0x0,%al
call   1090 <refresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    0x2ba5(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
xor    %eax,%eax
call   1050 <initscr@plt>
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x5,%edx
mov    $0x5,%ecx
call   1060 <newwin@plt>
mov    %rax,%rbp
lea    0xdf8(%rip),%rbx
lea    0xdf4(%rip),%r8
mov    %rax,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   10c0 <mvwprintw@plt>
lea    0xde4(%rip),%r8
mov    %rbp,%rdi
mov    $0x5,%esi
mov    $0x2,%edx
mov    %rbx,%rcx
call   10c0 <mvwprintw@plt>
mov    %rbp,(%rsp)
mov    %rbp,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edx
cmp    $0x2,%edx
jl     12db <main+0x10b>
mov    0x2d7d(%rip),%r13
mov    0x0(%r13),%ecx
mov    $0x30,%al
mov    0x2d68(%rip),%r14
mov    $0x30,%r12d
jmp    128c <main+0xbc>
add    $0x1,%r15d
lea    -0x1(%rdx),%esi
cmp    %esi,%r15d
jge    12db <main+0x10b>
cmp    $0x2,%ecx
jl     1280 <main+0xb0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%rdi
movsbl %al,%ebp
mov    %ebx,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
call   10d0 <mvwaddch@plt>
add    $0x1,%bpl
cmp    $0x3a,%bpl
movzbl %bpl,%eax
cmovge %r12d,%eax
add    $0x1,%ebx
mov    0x0(%r13),%ecx
lea    -0x1(%rcx),%edx
cmp    %edx,%ebx
jl     12a0 <main+0xd0>
mov    0x2d01(%rip),%rdx
mov    (%rdx),%edx
jmp    1280 <main+0xb0>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    (%rsp),%rbx
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %rbx,%rdi
call   1030 <touchwin@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    $0xa,%edi
mov    $0x14,%esi
mov    $0x8,%edx
mov    $0x8,%ecx
call   1060 <newwin@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1070 <box@plt>
lea    0xcaf(%rip),%rcx
lea    0xce9(%rip),%r8
mov    %rbp,%rdi
mov    $0x5,%esi
mov    $0x2,%edx
call   10c0 <mvwprintw@plt>
mov    %rbp,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %rbx,%rdi
call   1030 <touchwin@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %rbx,%rdi
call   10b0 <wclear@plt>
mov    %rbx,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %rbx,%rdi
call   1080 <delwin@plt>
mov    %rbp,%rdi
call   1030 <touchwin@plt>
mov    %rbp,%rdi
call   1040 <wrefresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %rbp,%rdi
call   1080 <delwin@plt>
mov    0x2bff(%rip),%rax
mov    (%rax),%rdi
call   1030 <touchwin@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
xor    %eax,%eax
call   10a0 <endwin@plt>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [12 x i8] c"Hello World\00"
@.str.2 = [50 x i8] c"Notice how very long lines wrap inside the window\00"
@COLS = global i32 0
@LINES = global i32 0
@stdscr = global i32* null
@.str.3 = [15 x i8] c"Pop Up Window!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
store i32 0, i32* %1
store i8 97, i8* %6
%7 = call i32 (...) @initscr()
%8 = call i32* @newwin(i32 10, i32 20, i32 5, i32 5)
store i32* %8, i32** %2
%9 = load i32*, i32** %2
%10 = call i32 @mvwprintw(i32* %9, i32 2, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32*, i32** %2
%12 = call i32 @mvwprintw(i32* %11, i32 5, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = call i32 @wrefresh(i32* %13)
%15 = call i32 @sleep(i32 2)
store i8 48, i8* %6
store i32 0, i32* %4
br label %16
16: ; preds = %44, %0
%17 = load i32, i32* %4
%18 = load i32, i32* @COLS
%19 = sub nsw i32 %18, 1
%20 = icmp slt i32 %17, %19
br i1 %20, label %21, label %47
21: ; preds = %16
store i32 0, i32* %5
br label %22
22: ; preds = %40, %21
%23 = load i32, i32* %5
%24 = load i32, i32* @LINES
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %43
27: ; preds = %22
%28 = load i32*, i32** @stdscr
%29 = load i32, i32* %5
%30 = load i32, i32* %4
%31 = load i8, i8* %6
%32 = call i32 @mvwaddch(i32* %28, i32 %29, i32 %30, i8 signext %31)
%33 = load i8, i8* %6
%34 = add i8 %33, 1
store i8 %34, i8* %6
%35 = load i8, i8* %6
%36 = sext i8 %35 to i32
%37 = icmp sgt i32 %36, 57
br i1 %37, label %38, label %39
38: ; preds = %27
store i8 48, i8* %6
br label %39
39: ; preds = %38, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %5
%42 = add nsw i32 %41, 1
store i32 %42, i32* %5
br label %22
43: ; preds = %22
br label %44
44: ; preds = %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %16
47: ; preds = %16
%48 = call i32 (...) @refresh()
%49 = call i32 @sleep(i32 2)
%50 = load i32*, i32** %2
%51 = call i32 @wrefresh(i32* %50)
%52 = call i32 @sleep(i32 2)
%53 = load i32*, i32** %2
%54 = call i32 @touchwin(i32* %53)
%55 = load i32*, i32** %2
%56 = call i32 @wrefresh(i32* %55)
%57 = call i32 @sleep(i32 2)
%58 = call i32* @newwin(i32 10, i32 20, i32 8, i32 8)
store i32* %58, i32** %3
%59 = load i32*, i32** %3
%60 = call i32 @box(i32* %59, i8 signext 124, i8 signext 45)
%61 = load i32*, i32** %3
%62 = call i32 @mvwprintw(i32* %61, i32 5, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%63 = load i32*, i32** %3
%64 = call i32 @wrefresh(i32* %63)
%65 = call i32 @sleep(i32 2)
%66 = load i32*, i32** %2
%67 = call i32 @touchwin(i32* %66)
%68 = load i32*, i32** %2
%69 = call i32 @wrefresh(i32* %68)
%70 = call i32 @sleep(i32 2)
%71 = load i32*, i32** %2
%72 = call i32 @wclear(i32* %71)
%73 = load i32*, i32** %2
%74 = call i32 @wrefresh(i32* %73)
%75 = call i32 @sleep(i32 2)
%76 = load i32*, i32** %2
%77 = call i32 @delwin(i32* %76)
%78 = load i32*, i32** %3
%79 = call i32 @touchwin(i32* %78)
%80 = load i32*, i32** %3
%81 = call i32 @wrefresh(i32* %80)
%82 = call i32 @sleep(i32 2)
%83 = load i32*, i32** %3
%84 = call i32 @delwin(i32* %83)
%85 = load i32*, i32** @stdscr
%86 = call i32 @touchwin(i32* %85)
%87 = call i32 (...) @refresh()
%88 = call i32 @sleep(i32 2)
%89 = call i32 (...) @endwin()
%90 = load i32, i32* @EXIT_SUCCESS
%91 = call i32 @exit(i32 %90)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [12 x i8] c"Hello World\00"
@.str.2 = [50 x i8] c"Notice how very long lines wrap inside the window\00"
@COLS = global i32 0
@LINES = global i32 0
@stdscr = global i32* null
@.str.3 = [15 x i8] c"Pop Up Window!\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32* @newwin(i32 10, i32 20, i32 5, i32 5)
%3 = tail call i32 @mvwprintw(i32* %2, i32 2, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @mvwprintw(i32* %2, i32 5, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @wrefresh(i32* %2)
%6 = tail call i32 @sleep(i32 2)
%7 = load i32, i32* @COLS
%8 = icmp sgt i32 %7, 1
br i1 %8, label %9, label %38
9: ; preds = %0
%10 = load i32, i32* @LINES
br label %11
11: ; preds = %9, %31
%12 = phi i32 [ %32, %31 ], [ %7, %9 ]
%13 = phi i32 [ %33, %31 ], [ %10, %9 ]
%14 = phi i8 [ %34, %31 ], [ 48, %9 ]
%15 = phi i32 [ %35, %31 ], [ 0, %9 ]
%16 = icmp sgt i32 %13, 1
br i1 %16, label %17, label %31
17: ; preds = %11, %17
%18 = phi i8 [ %24, %17 ], [ %14, %11 ]
%19 = phi i32 [ %25, %17 ], [ 0, %11 ]
%20 = load i32*, i32** @stdscr
%21 = tail call i32 @mvwaddch(i32* %20, i32 %19, i32 %15, i8 signext %18)
%22 = add i8 %18, 1
%23 = icmp sgt i8 %22, 57
%24 = select i1 %23, i8 48, i8 %22
%25 = add nuw nsw i32 %19, 1
%26 = load i32, i32* @LINES
%27 = add nsw i32 %26, -1
%28 = icmp slt i32 %25, %27
br i1 %28, label %17, label %29
29: ; preds = %17
%30 = load i32, i32* @COLS
br label %31
31: ; preds = %29, %11
%32 = phi i32 [ %12, %11 ], [ %30, %29 ]
%33 = phi i32 [ %13, %11 ], [ %26, %29 ]
%34 = phi i8 [ %14, %11 ], [ %24, %29 ]
%35 = add nuw nsw i32 %15, 1
%36 = add nsw i32 %32, -1
%37 = icmp slt i32 %35, %36
br i1 %37, label %11, label %38
38: ; preds = %31, %0
%39 = tail call i32 (...) @refresh()
%40 = tail call i32 @sleep(i32 2)
%41 = tail call i32 @wrefresh(i32* %2)
%42 = tail call i32 @sleep(i32 2)
%43 = tail call i32 @touchwin(i32* %2)
%44 = tail call i32 @wrefresh(i32* %2)
%45 = tail call i32 @sleep(i32 2)
%46 = tail call i32* @newwin(i32 10, i32 20, i32 8, i32 8)
%47 = tail call i32 @box(i32* %46, i8 signext 124, i8 signext 45)
%48 = tail call i32 @mvwprintw(i32* %46, i32 5, i32 2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%49 = tail call i32 @wrefresh(i32* %46)
%50 = tail call i32 @sleep(i32 2)
%51 = tail call i32 @touchwin(i32* %2)
%52 = tail call i32 @wrefresh(i32* %2)
%53 = tail call i32 @sleep(i32 2)
%54 = tail call i32 @wclear(i32* %2)
%55 = tail call i32 @wrefresh(i32* %2)
%56 = tail call i32 @sleep(i32 2)
%57 = tail call i32 @delwin(i32* %2)
%58 = tail call i32 @touchwin(i32* %46)
%59 = tail call i32 @wrefresh(i32* %46)
%60 = tail call i32 @sleep(i32 2)
%61 = tail call i32 @delwin(i32* %46)
%62 = load i32*, i32** @stdscr
%63 = tail call i32 @touchwin(i32* %62)
%64 = tail call i32 (...) @refresh()
%65 = tail call i32 @sleep(i32 2)
%66 = tail call i32 (...) @endwin()
%67 = load i32, i32* @EXIT_SUCCESS
%68 = tail call i32 @exit(i32 %67)
unreachable
}