#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 */
scalar_t__ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ draw_menu();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
scalar_t__ has_colors();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ raw();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
int main(void) {
  int row, col;
  initscr();
  getmaxyx(stdscr, row, col);
  if (has_colors() == FALSE) {
    endwin();
    printf("No terminal color support\n");
    exit(1);
  } else if (row < 20 || col < 80) {
    endwin();
    printf("Too small terminal window, please restart with a larger window (x: "
           "%d, y: %d\n",
           col, row);
    exit(1);
  }
  start_color();
  raw();
  keypad(stdscr, TRUE);
  noecho();
  curs_set(0);
  draw_menu();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1090 <getmaxyx@plt>
mov    $0x0,%al
call   1030 <has_colors@plt>
mov    0x2dd8(%rip),%rcx
cmp    (%rcx),%rax
jne    1220 <main+0x60>
mov    $0x0,%al
call   10a0 <endwin@plt>
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x14,-0x8(%rbp)
jl     1234 <main+0x74>
cmpl   $0x50,-0xc(%rbp)
jge    1259 <main+0x99>
mov    $0x0,%al
call   10a0 <endwin@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xdd3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    125e <main+0x9e>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    $0x0,%al
call   1070 <raw@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
mov    $0x0,%al
call   10c0 <draw_menu@plt>
mov    $0x0,%al
call   10a0 <endwin@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <initscr@plt>
mov    0x2e19(%rip),%rbx
mov    (%rbx),%edi
call   1090 <getmaxyx@plt>
xor    %eax,%eax
call   1040 <has_colors@plt>
mov    0x2dec(%rip),%rcx
cmp    (%rcx),%rax
je     1227 <main+0x67>
xor    %eax,%eax
call   1080 <start_color@plt>
xor    %eax,%eax
call   1070 <raw@plt>
mov    (%rbx),%edi
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
xor    %eax,%eax
call   10c0 <draw_menu@plt>
xor    %eax,%eax
call   10a0 <endwin@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   10a0 <endwin@plt>
lea    0xdcb(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
@stdscr = global i32 0
@FALSE = global i64 0
@.str = [27 x i8] c"No terminal color support\0A\00"
@.str.1 = [78 x i8] c"Too small terminal window, please restart with a larger window (x: %d, y: %d\0A\00"
@TRUE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @initscr()
%5 = load i32, i32* @stdscr
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 @getmaxyx(i32 %5, i32 %6, i32 %7)
%9 = call i64 (...) @has_colors()
%10 = load i64, i64* @FALSE
%11 = icmp eq i64 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %0
%13 = call i32 (...) @endwin()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %0
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 20
br i1 %18, label %22, label %19
19: ; preds = %16
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 80
br i1 %21, label %22, label %28
22: ; preds = %19, %16
%23 = call i32 (...) @endwin()
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
br label %29
29: ; preds = %28
%30 = call i32 (...) @start_color()
%31 = call i32 (...) @raw()
%32 = load i32, i32* @stdscr
%33 = load i32, i32* @TRUE
%34 = call i32 @keypad(i32 %32, i32 %33)
%35 = call i32 (...) @noecho()
%36 = call i32 @curs_set(i32 0)
%37 = call i32 (...) @draw_menu()
%38 = call i32 (...) @endwin()
ret i32 0
}

LLVM IR (-O2):
@stdscr = global i32 0
@FALSE = global i64 0
@TRUE = global i32 0
@str = [26 x i8] c"No terminal color support\00"
define i32 @main() {
%1 = tail call i32 (...) @initscr()
%2 = load i32, i32* @stdscr
%3 = tail call i32 @getmaxyx(i32 %2, i32 undef, i32 undef)
%4 = tail call i64 (...) @has_colors()
%5 = load i64, i64* @FALSE
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %11
7: ; preds = %0
%8 = tail call i32 (...) @endwin()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = tail call i32 (...) @start_color()
%13 = tail call i32 (...) @raw()
%14 = load i32, i32* @stdscr
%15 = load i32, i32* @TRUE
%16 = tail call i32 @keypad(i32 %14, i32 %15)
%17 = tail call i32 (...) @noecho()
%18 = tail call i32 @curs_set(i32 0)
%19 = tail call i32 (...) @draw_menu()
%20 = tail call i32 (...) @endwin()
ret i32 0
}