#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*/ COLOR_BLACK;
int /*<<< orphan*/ COLOR_BLUE;
int /*<<< orphan*/ COLOR_PAIR(int);
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ init_pair(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
scalar_t__ isalpha(int);
int /*<<< orphan*/ mvwaddstr(int /*<<< orphan*/ *, int /*<<< orphan*/,
                             int /*<<< orphan*/, char *);
int /*<<< orphan*/ *newwin(int, int, int /*<<< orphan*/, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
char toupper(int);
int /*<<< orphan*/ waddch(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ wbkgd(int /*<<< orphan*/ *, int /*<<< orphan*/);
int wgetch(int /*<<< orphan*/ *);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
int main(void) {
  WINDOW *left, *right;
  int maxx, maxy, halfx;
  int ch;
  initscr();
  start_color();
  init_pair(1, COLOR_BLACK, COLOR_BLUE);
  init_pair(2, COLOR_BLACK, COLOR_RED);
  getmaxyx(stdscr, maxy, maxx);
  halfx = maxx >> 1;
  if ((left = newwin(maxy, halfx, 0, 0)) == NULL) {
    endwin();
    puts("Unable to create 'left' window");
    return 1;
  }
  if ((right = newwin(maxy, halfx, 0, halfx)) == NULL) {
    endwin();
    puts("Unable to create 'right' window");
    return 1;
  }
  mvwaddstr(left, 0, 0, "Left window (type ~ to end)\n");
  wbkgd(left, COLOR_PAIR(1));
  wrefresh(left);
  mvwaddstr(right, 0, 0, "Right window\n");
  wbkgd(right, COLOR_PAIR(2));
  wrefresh(right);
  do {
    ch = wgetch(left);
    if (isalpha(ch)) {
      if (toupper(ch) >= 'A' && toupper(ch) <= 'M')
        ch += 13;
      else
        ch -= 13;
    }
    waddch(right, ch);
    wrefresh(right);
  } while (ch != '~');
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <initscr@plt>
mov    $0x0,%al
call   10a0 <start_color@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%esi
mov    0x2db3(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2db0(%rip),%rax
mov    (%rax),%esi
mov    0x2d8f(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   10c0 <getmaxyx@plt>
mov    -0x1c(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   10b0 <newwin@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    129e <main+0xae>
mov    $0x0,%al
call   10f0 <endwin@plt>
lea    0xd73(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    13de <main+0x1ee>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x24(%rbp),%ecx
xor    %edx,%edx
call   10b0 <newwin@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12db <main+0xeb>
mov    $0x0,%al
call   10f0 <endwin@plt>
lea    0xd55(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
jmp    13de <main+0x1ee>
mov    -0x10(%rbp),%rdi
xor    %edx,%edx
lea    0xd57(%rip),%rcx
mov    %edx,%esi
call   1110 <mvwaddstr@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x1,%edi
call   10d0 <COLOR_PAIR@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
call   1070 <wbkgd@plt>
mov    -0x10(%rbp),%rdi
call   1080 <wrefresh@plt>
mov    -0x18(%rbp),%rdi
xor    %edx,%edx
lea    0xd3a(%rip),%rcx
mov    %edx,%esi
call   1110 <mvwaddstr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x2,%edi
call   10d0 <COLOR_PAIR@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1070 <wbkgd@plt>
mov    -0x18(%rbp),%rdi
call   1080 <wrefresh@plt>
mov    -0x10(%rbp),%rdi
call   1100 <wgetch@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   10e0 <isalpha@plt>
cmp    $0x0,%rax
je     13b1 <main+0x1c1>
mov    -0x28(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x41,%eax
jl     13a3 <main+0x1b3>
mov    -0x28(%rbp),%edi
call   1030 <toupper@plt>
movsbl %al,%eax
cmp    $0x4d,%eax
jg     13a3 <main+0x1b3>
mov    -0x28(%rbp),%eax
add    $0xd,%eax
mov    %eax,-0x28(%rbp)
jmp    13ac <main+0x1bc>
mov    -0x28(%rbp),%eax
sub    $0xd,%eax
mov    %eax,-0x28(%rbp)
jmp    13b1 <main+0x1c1>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1050 <waddch@plt>
mov    -0x18(%rbp),%rdi
call   1080 <wrefresh@plt>
cmpl   $0x7e,-0x28(%rbp)
jne    134f <main+0x15f>
mov    $0x0,%al
call   10f0 <endwin@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1090 <initscr@plt>
xor    %eax,%eax
call   10a0 <start_color@plt>
mov    0x2dd7(%rip),%rbp
mov    0x0(%rbp),%esi
mov    0x2dbd(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%ebx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x0(%rbp),%esi
mov    0x2d9a(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
call   10c0 <getmaxyx@plt>
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <newwin@plt>
test   %rax,%rax
je     1336 <main+0x146>
mov    %rax,%r14
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <newwin@plt>
test   %rax,%rax
je     134b <main+0x15b>
mov    %rax,%rbx
lea    0xdc2(%rip),%rcx
mov    %r14,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1110 <mvwaddstr@plt>
mov    $0x1,%edi
call   10d0 <COLOR_PAIR@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1070 <wbkgd@plt>
mov    %r14,%rdi
call   1080 <wrefresh@plt>
lea    0xdb0(%rip),%rcx
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1110 <mvwaddstr@plt>
mov    $0x2,%edi
call   10d0 <COLOR_PAIR@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <wbkgd@plt>
mov    %rbx,%rdi
call   1080 <wrefresh@plt>
jmp    12fa <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
add    $0xfffffff3,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <waddch@plt>
mov    %rbx,%rdi
call   1080 <wrefresh@plt>
cmp    $0x7e,%ebp
je     132b <main+0x13b>
mov    %r14,%rdi
call   1100 <wgetch@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10e0 <isalpha@plt>
test   %rax,%rax
je     12e3 <main+0xf3>
mov    %ebp,%edi
call   1030 <toupper@plt>
cmp    $0x41,%al
jl     12e0 <main+0xf0>
mov    %ebp,%edi
call   1030 <toupper@plt>
cmp    $0x4d,%al
jg     12e0 <main+0xf0>
add    $0xd,%ebp
jmp    12e3 <main+0xf3>
xor    %ebx,%ebx
xor    %eax,%eax
call   10f0 <endwin@plt>
jmp    1363 <main+0x173>
xor    %eax,%eax
call   10f0 <endwin@plt>
lea    0xcbc(%rip),%rdi
call   1040 <puts@plt>
jmp    1363 <main+0x173>
xor    %eax,%eax
call   10f0 <endwin@plt>
lea    0xcc6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_RED = global i32 0
@stdscr = global i32 0
@.str = [31 x i8] c"Unable to create 'left' window\00"
@.str.1 = [32 x i8] c"Unable to create 'right' window\00"
@.str.2 = [29 x i8] c"Left window (type ~ to end)\0A\00"
@.str.3 = [14 x i8] c"Right window\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (...) @initscr()
%9 = call i32 (...) @start_color()
%10 = load i32, i32* @COLOR_BLACK
%11 = load i32, i32* @COLOR_BLUE
%12 = call i32 @init_pair(i32 1, i32 %10, i32 %11)
%13 = load i32, i32* @COLOR_BLACK
%14 = load i32, i32* @COLOR_RED
%15 = call i32 @init_pair(i32 2, i32 %13, i32 %14)
%16 = load i32, i32* @stdscr
%17 = load i32, i32* %5
%18 = load i32, i32* %4
%19 = call i32 @getmaxyx(i32 %16, i32 %17, i32 %18)
%20 = load i32, i32* %4
%21 = ashr i32 %20, 1
store i32 %21, i32* %6
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = call i32* @newwin(i32 %22, i32 %23, i32 0, i32 0)
store i32* %24, i32** %2
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = call i32 (...) @endwin()
%28 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %1
br label %87
29: ; preds = %0
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = load i32, i32* %6
%33 = call i32* @newwin(i32 %30, i32 %31, i32 0, i32 %32)
store i32* %33, i32** %3
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 (...) @endwin()
%37 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %87
38: ; preds = %29
%39 = load i32*, i32** %2
%40 = call i32 @mvwaddstr(i32* %39, i32 0, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%41 = load i32*, i32** %2
%42 = call i32 @COLOR_PAIR(i32 1)
%43 = call i32 @wbkgd(i32* %41, i32 %42)
%44 = load i32*, i32** %2
%45 = call i32 @wrefresh(i32* %44)
%46 = load i32*, i32** %3
%47 = call i32 @mvwaddstr(i32* %46, i32 0, i32 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32*, i32** %3
%49 = call i32 @COLOR_PAIR(i32 2)
%50 = call i32 @wbkgd(i32* %48, i32 %49)
%51 = load i32*, i32** %3
%52 = call i32 @wrefresh(i32* %51)
br label %53
53: ; preds = %82, %38
%54 = load i32*, i32** %2
%55 = call i32 @wgetch(i32* %54)
store i32 %55, i32* %7
%56 = load i32, i32* %7
%57 = call i64 @isalpha(i32 %56)
%58 = icmp ne i64 %57, 0
br i1 %58, label %59, label %76
59: ; preds = %53
%60 = load i32, i32* %7
%61 = call signext i8 @toupper(i32 %60)
%62 = sext i8 %61 to i32
%63 = icmp sge i32 %62, 65
br i1 %63, label %64, label %72
64: ; preds = %59
%65 = load i32, i32* %7
%66 = call signext i8 @toupper(i32 %65)
%67 = sext i8 %66 to i32
%68 = icmp sle i32 %67, 77
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 13
store i32 %71, i32* %7
br label %75
72: ; preds = %64, %59
%73 = load i32, i32* %7
%74 = sub nsw i32 %73, 13
store i32 %74, i32* %7
br label %75
75: ; preds = %72, %69
br label %76
76: ; preds = %75, %53
%77 = load i32*, i32** %3
%78 = load i32, i32* %7
%79 = call i32 @waddch(i32* %77, i32 %78)
%80 = load i32*, i32** %3
%81 = call i32 @wrefresh(i32* %80)
br label %82
82: ; preds = %76
%83 = load i32, i32* %7
%84 = icmp ne i32 %83, 126
br i1 %84, label %53, label %85
85: ; preds = %82
%86 = call i32 (...) @endwin()
store i32 0, i32* %1
br label %87
87: ; preds = %85, %35, %26
%88 = load i32, i32* %1
ret i32 %88
}

LLVM IR (-O2):
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_RED = global i32 0
@stdscr = global i32 0
@.str = [31 x i8] c"Unable to create 'left' window\00"
@.str.1 = [32 x i8] c"Unable to create 'right' window\00"
@.str.2 = [29 x i8] c"Left window (type ~ to end)\0A\00"
@.str.3 = [14 x i8] c"Right window\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @start_color()
%3 = load i32, i32* @COLOR_BLACK
%4 = load i32, i32* @COLOR_BLUE
%5 = tail call i32 @init_pair(i32 1, i32 %3, i32 %4)
%6 = load i32, i32* @COLOR_BLACK
%7 = load i32, i32* @COLOR_RED
%8 = tail call i32 @init_pair(i32 2, i32 %6, i32 %7)
%9 = load i32, i32* @stdscr
%10 = tail call i32 @getmaxyx(i32 %9, i32 undef, i32 undef)
%11 = tail call i32* @newwin(i32 undef, i32 0, i32 0, i32 0)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %0
%14 = tail call i32 (...) @endwin()
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %52
16: ; preds = %0
%17 = tail call i32* @newwin(i32 undef, i32 0, i32 0, i32 0)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = tail call i32 (...) @endwin()
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
br label %52
22: ; preds = %16
%23 = tail call i32 @mvwaddstr(i32* %11, i32 0, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @COLOR_PAIR(i32 1)
%25 = tail call i32 @wbkgd(i32* %11, i32 %24)
%26 = tail call i32 @wrefresh(i32* %11)
%27 = tail call i32 @mvwaddstr(i32* %17, i32 0, i32 0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @COLOR_PAIR(i32 2)
%29 = tail call i32 @wbkgd(i32* %17, i32 %28)
%30 = tail call i32 @wrefresh(i32* %17)
br label %31
31: ; preds = %45, %22
%32 = tail call i32 @wgetch(i32* %11)
%33 = tail call i64 @isalpha(i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %45, label %35
35: ; preds = %31
%36 = tail call signext i8 @toupper(i32 %32)
%37 = icmp sgt i8 %36, 64
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = tail call signext i8 @toupper(i32 %32)
%40 = icmp slt i8 %39, 78
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = add nsw i32 %32, 13
br label %45
43: ; preds = %38, %35
%44 = add nsw i32 %32, -13
br label %45
45: ; preds = %41, %43, %31
%46 = phi i32 [ %42, %41 ], [ %44, %43 ], [ %32, %31 ]
%47 = tail call i32 @waddch(i32* %17, i32 %46)
%48 = tail call i32 @wrefresh(i32* %17)
%49 = icmp eq i32 %46, 126
br i1 %49, label %50, label %31
50: ; preds = %45
%51 = tail call i32 (...) @endwin()
br label %52
52: ; preds = %50, %19, %13
%53 = phi i32 [ 1, %13 ], [ 1, %19 ], [ 0, %50 ]
ret i32 %53
}