#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 COLS;
int LINES;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ erase();
int getch();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ mvaddstr(int, int, char const *);
int /*<<< orphan*/ refresh();
int strlen(char const *);
int main(void) {
  static const char msg[] = "Press Q to Quit";
  int c;
  initscr();
  cbreak();
  do {
    erase();
    mvaddch(LINES / 2, COLS / 2, 'X');
    mvaddstr(LINES - 1, (COLS - strlen(msg)) / 2, msg);
    move(LINES / 2, COLS / 2);
    refresh();
    c = getch();
  } while (c != 'Q' && c != 'q');
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1030 <cbreak@plt>
mov    $0x0,%al
call   1060 <erase@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    0x2e02(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x58,%edx
call   10a0 <mvaddch@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
lea    0xdea(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdca(%rip),%rdx
call   10b0 <mvaddstr@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
call   10c0 <move@plt>
mov    $0x0,%al
call   1070 <refresh@plt>
mov    $0x0,%al
call   1080 <getch@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0x51,-0x8(%rbp)
mov    %al,-0x11(%rbp)
je     1290 <main+0xf0>
cmpl   $0x71,-0x8(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11bd <main+0x1d>
mov    $0x0,%al
call   1090 <endwin@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1030 <cbreak@plt>
mov    0x2e2b(%rip),%r15
mov    0x2e1c(%rip),%r12
lea    0xe35(%rip),%r14
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <erase@plt>
mov    (%r15),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
mov    (%r12),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
mov    $0x58,%edx
call   10a0 <mvaddch@plt>
mov    (%r15),%ebp
add    $0xffffffff,%ebp
mov    (%r12),%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
sub    %eax,%ebx
mov    %ebx,%esi
shr    $0x1f,%esi
add    %ebx,%esi
sar    %esi
mov    %ebp,%edi
mov    %r14,%rdx
call   10b0 <mvaddstr@plt>
mov    (%r15),%eax
mov    %eax,%edi
shr    $0x1f,%edi
add    %eax,%edi
sar    %edi
mov    (%r12),%eax
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
call   10c0 <move@plt>
xor    %eax,%eax
call   1070 <refresh@plt>
xor    %eax,%eax
call   1080 <getch@plt>
and    $0xffffffdf,%eax
cmp    $0x51,%eax
jne    11d0 <main+0x30>
xor    %eax,%eax
call   1090 <endwin@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@main.msg = internal constant [16 x i8] c"Press Q to Quit\00"
@LINES = global i32 0
@COLS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @initscr()
%4 = call i32 (...) @cbreak()
br label %5
5: ; preds = %32, %0
%6 = call i32 (...) @erase()
%7 = load i32, i32* @LINES
%8 = sdiv i32 %7, 2
%9 = load i32, i32* @COLS
%10 = sdiv i32 %9, 2
%11 = call i32 @mvaddch(i32 %8, i32 %10, i8 signext 88)
%12 = load i32, i32* @LINES
%13 = sub nsw i32 %12, 1
%14 = load i32, i32* @COLS
%15 = call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @main.msg, i64 0, i64 0))
%16 = sub nsw i32 %14, %15
%17 = sdiv i32 %16, 2
%18 = call i32 @mvaddstr(i32 %13, i32 %17, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @main.msg, i64 0, i64 0))
%19 = load i32, i32* @LINES
%20 = sdiv i32 %19, 2
%21 = load i32, i32* @COLS
%22 = sdiv i32 %21, 2
%23 = call i32 @move(i32 %20, i32 %22)
%24 = call i32 (...) @refresh()
%25 = call i32 (...) @getch()
store i32 %25, i32* %2
br label %26
26: ; preds = %5
%27 = load i32, i32* %2
%28 = icmp ne i32 %27, 81
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = load i32, i32* %2
%31 = icmp ne i32 %30, 113
br label %32
32: ; preds = %29, %26
%33 = phi i1 [ false, %26 ], [ %31, %29 ]
br i1 %33, label %5, label %34
34: ; preds = %32
%35 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@main.msg = internal constant [16 x i8] c"Press Q to Quit\00"
@LINES = global i32 0
@COLS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @cbreak()
br label %3
3: ; preds = %3, %0
%4 = tail call i32 (...) @erase()
%5 = load i32, i32* @LINES
%6 = sdiv i32 %5, 2
%7 = load i32, i32* @COLS
%8 = sdiv i32 %7, 2
%9 = tail call i32 @mvaddch(i32 %6, i32 %8, i8 signext 88)
%10 = load i32, i32* @LINES
%11 = add nsw i32 %10, -1
%12 = load i32, i32* @COLS
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @main.msg, i64 0, i64 0))
%14 = sub nsw i32 %12, %13
%15 = sdiv i32 %14, 2
%16 = tail call i32 @mvaddstr(i32 %11, i32 %15, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @main.msg, i64 0, i64 0))
%17 = load i32, i32* @LINES
%18 = sdiv i32 %17, 2
%19 = load i32, i32* @COLS
%20 = sdiv i32 %19, 2
%21 = tail call i32 @move(i32 %18, i32 %20)
%22 = tail call i32 (...) @refresh()
%23 = tail call i32 (...) @getch()
%24 = and i32 %23, -33
%25 = icmp eq i32 %24, 81
br i1 %25, label %26, label %3
26: ; preds = %3
%27 = tail call i32 (...) @endwin()
ret i32 0
}