#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ echo();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ main_menu();
int /*<<< orphan*/ nocbreak();
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ nonl();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stdscr;
scalar_t__ viewer_init_colors();
int /*<<< orphan*/ viewer_restore_colors();
int main() {
  int ret = EXIT_SUCCESS;
  initscr();
  start_color();
  cbreak();
  nonl();
  noecho();
  keypad(stdscr, TRUE);
  if (viewer_init_colors()) {
    ret = EXIT_FAILURE;
    goto uninit;
  }
  if (main_menu())
    ret = EXIT_FAILURE;
uninit:
  viewer_restore_colors();
  keypad(stdscr, FALSE);
  echo();
  nocbreak();
  endwin();
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    $0x0,%al
call   1070 <start_color@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    $0x0,%al
call   10a0 <nonl@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
mov    0x2dd2(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x0,%al
call   1080 <viewer_init_colors@plt>
cmp    $0x0,%rax
je     1237 <main+0x77>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    1259 <main+0x99>
mov    $0x0,%al
call   10b0 <main_menu@plt>
cmp    $0x0,%rax
je     1254 <main+0x94>
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    1259 <main+0x99>
mov    $0x0,%al
call   1090 <viewer_restore_colors@plt>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
mov    $0x0,%al
call   1030 <echo@plt>
mov    $0x0,%al
call   10d0 <nocbreak@plt>
mov    $0x0,%al
call   10c0 <endwin@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2dfd(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1060 <initscr@plt>
xor    %eax,%eax
call   1070 <start_color@plt>
xor    %eax,%eax
call   1040 <cbreak@plt>
xor    %eax,%eax
call   10a0 <nonl@plt>
xor    %eax,%eax
call   10e0 <noecho@plt>
mov    0x2df1(%rip),%r14
mov    (%r14),%edi
mov    0x2ddf(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
xor    %eax,%eax
call   1080 <viewer_init_colors@plt>
test   %rax,%rax
jne    1220 <main+0x60>
xor    %eax,%eax
call   10b0 <main_menu@plt>
test   %rax,%rax
je     1229 <main+0x69>
mov    0x2da9(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1090 <viewer_restore_colors@plt>
mov    (%r14),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
call   1050 <keypad@plt>
xor    %eax,%eax
call   1030 <echo@plt>
xor    %eax,%eax
call   10d0 <nocbreak@plt>
xor    %eax,%eax
call   10c0 <endwin@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
@EXIT_FAILURE = global i32 0
@FALSE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @EXIT_SUCCESS
store i32 %3, i32* %2
%4 = call i32 (...) @initscr()
%5 = call i32 (...) @start_color()
%6 = call i32 (...) @cbreak()
%7 = call i32 (...) @nonl()
%8 = call i32 (...) @noecho()
%9 = load i32, i32* @stdscr
%10 = load i32, i32* @TRUE
%11 = call i32 @keypad(i32 %9, i32 %10)
%12 = call i64 (...) @viewer_init_colors()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = load i32, i32* @EXIT_FAILURE
store i32 %15, i32* %2
br label %22
16: ; preds = %0
%17 = call i64 (...) @main_menu()
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %2
br label %21
21: ; preds = %19, %16
br label %22
22: ; preds = %21, %14
%23 = call i32 (...) @viewer_restore_colors()
%24 = load i32, i32* @stdscr
%25 = load i32, i32* @FALSE
%26 = call i32 @keypad(i32 %24, i32 %25)
%27 = call i32 (...) @echo()
%28 = call i32 (...) @nocbreak()
%29 = call i32 (...) @endwin()
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stdscr = global i32 0
@TRUE = global i32 0
@EXIT_FAILURE = global i32 0
@FALSE = global i32 0
define i32 @main() {
%1 = load i32, i32* @EXIT_SUCCESS
%2 = tail call i32 (...) @initscr()
%3 = tail call i32 (...) @start_color()
%4 = tail call i32 (...) @cbreak()
%5 = tail call i32 (...) @nonl()
%6 = tail call i32 (...) @noecho()
%7 = load i32, i32* @stdscr
%8 = load i32, i32* @TRUE
%9 = tail call i32 @keypad(i32 %7, i32 %8)
%10 = tail call i64 (...) @viewer_init_colors()
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %0
%13 = load i32, i32* @EXIT_FAILURE
br label %19
14: ; preds = %0
%15 = tail call i64 (...) @main_menu()
%16 = icmp eq i64 %15, 0
%17 = load i32, i32* @EXIT_FAILURE
%18 = select i1 %16, i32 %1, i32 %17
br label %19
19: ; preds = %14, %12
%20 = phi i32 [ %13, %12 ], [ %18, %14 ]
%21 = tail call i32 (...) @viewer_restore_colors()
%22 = load i32, i32* @stdscr
%23 = load i32, i32* @FALSE
%24 = tail call i32 @keypad(i32 %22, i32 %23)
%25 = tail call i32 (...) @echo()
%26 = tail call i32 (...) @nocbreak()
%27 = tail call i32 (...) @endwin()
ret i32 %20
}