#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 LINES;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ box(int /*<<< orphan*/ *, int /*<<< orphan*/,
                       int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ raw();
int /*<<< orphan*/ stdscr;
int /*<<< orphan*/ *subwin(int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ wrefresh(int /*<<< orphan*/ *);
WINDOW *setup_terminal(void) {
  WINDOW *lcd;
  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();
  int rows = 4 + 2, cols = 20 + 2;
  int lcdoriginy = (LINES - rows) / 2, lcdoriginx = (COLS - cols) / 2;
  lcd = subwin(stdscr, rows, cols, lcdoriginy, lcdoriginx);
  box(lcd, 0, 0);
  wrefresh(lcd);
  return lcd;
}


x86 assembly (clang, -O0):
<setup_terminal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   1060 <raw@plt>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
mov    $0x0,%al
call   1090 <noecho@plt>
movl   $0x6,-0xc(%rbp)
movl   $0x16,-0x10(%rbp)
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
sub    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    0x2e00(%rip),%rax
mov    (%rax),%eax
sub    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1070 <subwin@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
xor    %edx,%edx
mov    %edx,%esi
call   1080 <box@plt>
mov    -0x8(%rbp),%rdi
call   1030 <wrefresh@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_terminal>:
push   %rbx
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   1060 <raw@plt>
mov    0x2e5a(%rip),%rbx
mov    (%rbx),%edi
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
call   1040 <keypad@plt>
xor    %eax,%eax
call   1090 <noecho@plt>
mov    0x2e44(%rip),%rax
mov    (%rax),%eax
mov    %eax,%ecx
add    $0xfffffffa,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
add    $0xfffffffa,%ecx
sar    %ecx
mov    0x2e14(%rip),%rax
mov    (%rax),%eax
mov    %eax,%edx
add    $0xffffffea,%edx
shr    $0x1f,%edx
lea    (%rax,%rdx,1),%r8d
add    $0xffffffea,%r8d
sar    %r8d
mov    (%rbx),%edi
mov    $0x6,%esi
mov    $0x16,%edx
call   1070 <subwin@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1080 <box@plt>
mov    %rbx,%rdi
call   1030 <wrefresh@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@stdscr = global i32 0
@TRUE = global i32 0
@LINES = global i32 0
@COLS = global i32 0
define i32* @setup_terminal() {
%1 = alloca i32*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @raw()
%8 = load i32, i32* @stdscr
%9 = load i32, i32* @TRUE
%10 = call i32 @keypad(i32 %8, i32 %9)
%11 = call i32 (...) @noecho()
store i32 6, i32* %2
store i32 22, i32* %3
%12 = load i32, i32* @LINES
%13 = load i32, i32* %2
%14 = sub nsw i32 %12, %13
%15 = sdiv i32 %14, 2
store i32 %15, i32* %4
%16 = load i32, i32* @COLS
%17 = load i32, i32* %3
%18 = sub nsw i32 %16, %17
%19 = sdiv i32 %18, 2
store i32 %19, i32* %5
%20 = load i32, i32* @stdscr
%21 = load i32, i32* %2
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = call i32* @subwin(i32 %20, i32 %21, i32 %22, i32 %23, i32 %24)
store i32* %25, i32** %1
%26 = load i32*, i32** %1
%27 = call i32 @box(i32* %26, i32 0, i32 0)
%28 = load i32*, i32** %1
%29 = call i32 @wrefresh(i32* %28)
%30 = load i32*, i32** %1
ret i32* %30
}

LLVM IR (-O2):
@stdscr = global i32 0
@TRUE = global i32 0
@LINES = global i32 0
@COLS = global i32 0
define i32* @setup_terminal() {
%1 = tail call i32 (...) @initscr()
%2 = tail call i32 (...) @raw()
%3 = load i32, i32* @stdscr
%4 = load i32, i32* @TRUE
%5 = tail call i32 @keypad(i32 %3, i32 %4)
%6 = tail call i32 (...) @noecho()
%7 = load i32, i32* @LINES
%8 = add nsw i32 %7, -6
%9 = sdiv i32 %8, 2
%10 = load i32, i32* @COLS
%11 = add nsw i32 %10, -22
%12 = sdiv i32 %11, 2
%13 = load i32, i32* @stdscr
%14 = tail call i32* @subwin(i32 %13, i32 6, i32 22, i32 %9, i32 %12)
%15 = tail call i32 @box(i32* %14, i32 0, i32 0)
%16 = tail call i32 @wrefresh(i32* %14)
ret i32* %14
}