#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 /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, char, char);
int /*<<< orphan*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ *newwin(int, int, int, int);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ wgetnstr(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ wprintw(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  int WX = 15;
  int WY = 55;
  int SUBX = 3;
  int SUBY = 40;
  int SUFX = 10;
  int SUFY = 18;
  int ZERO = 0;
  char buf[5012];
  WINDOW *wnd;
  WINDOW *send;
  initscr();
  setlocale(LC_ALL, "");
  clear();
  for (;;) {
    memset(buf, 0, sizeof(char));
    wnd = newwin(WX, WY, ZERO, ZERO);
    send = newwin(SUBX, SUBY, SUFY, SUFX);
    move(10, 25);
    box(wnd, '|', '-');
    box(send, '|', '-');
    wrefresh(wnd);
    wrefresh(send);
    move(10, 42);
    clear();
    wgetnstr(wnd, buf, 5000);
    refresh();
    wgetnstr(wnd, buf, 1028);
    wprintw(wnd, buf);
    if (!strcmp(buf, "quit")) {
      break;
    }
    wprintw(wnd, "%s", buf);
    refresh();
    wrefresh(wnd);
    wrefresh(send);
    refresh();
  }
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x13d0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf,-0x14(%rbp)
movl   $0x37,-0x18(%rbp)
movl   $0x3,-0x1c(%rbp)
movl   $0x28,-0x20(%rbp)
movl   $0xa,-0x24(%rbp)
movl   $0x12,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
lea    0xdd6(%rip),%rsi
call   10b0 <setlocale@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
lea    -0x13c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x2c(%rbp),%ecx
call   1050 <newwin@plt>
mov    %rax,-0x13c8(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
call   1050 <newwin@plt>
mov    %rax,-0x13d0(%rbp)
mov    $0xa,%edi
mov    $0x19,%esi
call   10f0 <move@plt>
mov    -0x13c8(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1080 <box@plt>
mov    -0x13d0(%rbp),%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1080 <box@plt>
mov    -0x13c8(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    -0x13d0(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    $0xa,%edi
mov    $0x2a,%esi
call   10f0 <move@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
mov    -0x13c8(%rbp),%rdi
lea    -0x13c0(%rbp),%rsi
mov    $0x1388,%edx
call   10d0 <wgetnstr@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    -0x13c8(%rbp),%rdi
lea    -0x13c0(%rbp),%rsi
mov    $0x404,%edx
call   10d0 <wgetnstr@plt>
mov    -0x13c8(%rbp),%rdi
lea    -0x13c0(%rbp),%rsi
mov    $0x0,%al
call   1090 <wprintw@plt>
lea    -0x13c0(%rbp),%rdi
lea    0xcbd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1356 <main+0x186>
jmp    139d <main+0x1cd>
mov    -0x13c8(%rbp),%rdi
lea    -0x13c0(%rbp),%rdx
lea    0xc9a(%rip),%rsi
mov    $0x0,%al
call   1090 <wprintw@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
mov    -0x13c8(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    -0x13d0(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    $0x0,%al
call   10a0 <refresh@plt>
jmp    123d <main+0x6d>
mov    $0x0,%al
call   10c0 <endwin@plt>
xor    %eax,%eax
add    $0x13d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x13a0,%rsp
xor    %eax,%eax
call   1040 <initscr@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe21(%rip),%rsi
call   10a0 <setlocale@plt>
xor    %eax,%eax
call   10d0 <clear@plt>
mov    %rsp,%r15
mov    $0x74697571,%ebp
lea    0xe04(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1060 <memset@plt>
mov    $0xf,%edi
mov    $0x37,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <newwin@plt>
mov    %rax,%rbx
mov    $0x3,%edi
mov    $0x28,%esi
mov    $0x12,%edx
mov    $0xa,%ecx
call   1050 <newwin@plt>
mov    %rax,%r12
mov    $0xa,%edi
mov    $0x19,%esi
call   10e0 <move@plt>
mov    %rbx,%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1070 <box@plt>
mov    %r12,%rdi
mov    $0x7c,%esi
mov    $0x2d,%edx
call   1070 <box@plt>
mov    %rbx,%rdi
call   1030 <wrefresh@plt>
mov    %r12,%rdi
call   1030 <wrefresh@plt>
mov    $0xa,%edi
mov    $0x2a,%esi
call   10e0 <move@plt>
xor    %eax,%eax
call   10d0 <clear@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1388,%edx
call   10c0 <wgetnstr@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x404,%edx
call   10c0 <wgetnstr@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1080 <wprintw@plt>
mov    (%rsp),%eax
xor    %ebp,%eax
movzbl 0x4(%rsp),%ecx
or     %eax,%ecx
je     131f <main+0x15f>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1080 <wprintw@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
mov    %rbx,%rdi
call   1030 <wrefresh@plt>
mov    %r12,%rdi
call   1030 <wrefresh@plt>
xor    %eax,%eax
call   1090 <refresh@plt>
jmp    1210 <main+0x50>
xor    %eax,%eax
call   10b0 <endwin@plt>
xor    %eax,%eax
add    $0x13a0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [5012 x i8]
%14 = alloca i32*
%15 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 15, i32* %6
store i32 55, i32* %7
store i32 3, i32* %8
store i32 40, i32* %9
store i32 10, i32* %10
store i32 18, i32* %11
store i32 0, i32* %12
%16 = call i32 (...) @initscr()
%17 = load i32, i32* @LC_ALL
%18 = call i32 @setlocale(i32 %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%19 = call i32 (...) @clear()
br label %20
20: ; preds = %58, %2
%21 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 1)
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = load i32, i32* %12
%26 = load i32, i32* %12
%27 = call i32* @newwin(i32 %23, i32 %24, i32 %25, i32 %26)
store i32* %27, i32** %14
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = load i32, i32* %11
%31 = load i32, i32* %10
%32 = call i32* @newwin(i32 %28, i32 %29, i32 %30, i32 %31)
store i32* %32, i32** %15
%33 = call i32 @move(i32 10, i32 25)
%34 = load i32*, i32** %14
%35 = call i32 @box(i32* %34, i8 signext 124, i8 signext 45)
%36 = load i32*, i32** %15
%37 = call i32 @box(i32* %36, i8 signext 124, i8 signext 45)
%38 = load i32*, i32** %14
%39 = call i32 @wrefresh(i32* %38)
%40 = load i32*, i32** %15
%41 = call i32 @wrefresh(i32* %40)
%42 = call i32 @move(i32 10, i32 42)
%43 = call i32 (...) @clear()
%44 = load i32*, i32** %14
%45 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%46 = call i32 @wgetnstr(i32* %44, i8* %45, i32 5000)
%47 = call i32 (...) @refresh()
%48 = load i32*, i32** %14
%49 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%50 = call i32 @wgetnstr(i32* %48, i8* %49, i32 1028)
%51 = load i32*, i32** %14
%52 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%53 = call i32 (i32*, i8*, ...) @wprintw(i32* %51, i8* %52)
%54 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%55 = call i32 @strcmp(i8* %54, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%56 = icmp ne i32 %55, 0
br i1 %56, label %58, label %57
57: ; preds = %20
br label %68
58: ; preds = %20
%59 = load i32*, i32** %14
%60 = getelementptr inbounds [5012 x i8], [5012 x i8]* %13, i64 0, i64 0
%61 = call i32 (i32*, i8*, ...) @wprintw(i32* %59, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %60)
%62 = call i32 (...) @refresh()
%63 = load i32*, i32** %14
%64 = call i32 @wrefresh(i32* %63)
%65 = load i32*, i32** %15
%66 = call i32 @wrefresh(i32* %65)
%67 = call i32 (...) @refresh()
br label %20
68: ; preds = %57
%69 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [5 x i8] c"quit\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [5012 x i8]
%4 = getelementptr inbounds [5012 x i8], [5012 x i8]* %3, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = load i32, i32* @LC_ALL
%7 = tail call i32 @setlocale(i32 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 (...) @clear()
br label %9
9: ; preds = %26, %2
%10 = call i32 @memset(i8* %4, i32 0, i32 1)
%11 = call i32* @newwin(i32 15, i32 55, i32 0, i32 0)
%12 = call i32* @newwin(i32 3, i32 40, i32 18, i32 10)
%13 = call i32 @move(i32 10, i32 25)
%14 = call i32 @box(i32* %11, i8 signext 124, i8 signext 45)
%15 = call i32 @box(i32* %12, i8 signext 124, i8 signext 45)
%16 = call i32 @wrefresh(i32* %11)
%17 = call i32 @wrefresh(i32* %12)
%18 = call i32 @move(i32 10, i32 42)
%19 = call i32 (...) @clear()
%20 = call i32 @wgetnstr(i32* %11, i8* %4, i32 5000)
%21 = call i32 (...) @refresh()
%22 = call i32 @wgetnstr(i32* %11, i8* %4, i32 1028)
%23 = call i32 (i32*, i8*, ...) @wprintw(i32* %11, i8* %4)
%24 = call i32 @bcmp(i8* dereferenceable(5) %4, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 5)
%25 = icmp eq i32 %24, 0
br i1 %25, label %32, label %26
26: ; preds = %9
%27 = call i32 (i32*, i8*, ...) @wprintw(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%28 = call i32 (...) @refresh()
%29 = call i32 @wrefresh(i32* %11)
%30 = call i32 @wrefresh(i32* %12)
%31 = call i32 (...) @refresh()
br label %9
32: ; preds = %9
%33 = call i32 (...) @endwin()
ret i32 0
}