#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 /*<<< orphan*/ FALSE;
int /*<<< orphan*/ TRUE;
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ clear();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ has_colors();
int /*<<< orphan*/ init_colors();
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ keypad(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdscr;
void init_screen() {
  if (!initscr()) {
    fprintf(stderr, "ERROR in init_screen() \n");
    exit(1);
  }
  if (!has_colors()) {
    endwin();
    printf("ERROR with colors! \n");
    exit(1);
  }
  start_color();
  init_colors();
  clear();
  noecho();
  keypad(stdscr, TRUE);
  cbreak();
  curs_set(FALSE);
}


x86 assembly (clang, -O0):
<init_screen>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   1070 <initscr@plt>
cmp    $0x0,%eax
jne    1203 <init_screen+0x33>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe0c(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1030 <has_colors@plt>
cmp    $0x0,%eax
jne    1230 <init_screen+0x60>
mov    $0x0,%al
call   10a0 <endwin@plt>
lea    0xdf8(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    $0x0,%al
call   10d0 <init_colors@plt>
mov    $0x0,%al
call   10e0 <clear@plt>
mov    $0x0,%al
call   10b0 <noecho@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
mov    0x2d84(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
mov    $0x0,%al
call   1040 <cbreak@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
call   10f0 <curs_set@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_screen>:
push   %rax
xor    %eax,%eax
call   1070 <initscr@plt>
test   %eax,%eax
je     1230 <init_screen+0x60>
xor    %eax,%eax
call   1040 <has_colors@plt>
test   %eax,%eax
je     124f <init_screen+0x7f>
xor    %eax,%eax
call   1080 <start_color@plt>
xor    %eax,%eax
call   10d0 <init_colors@plt>
xor    %eax,%eax
call   10e0 <clear@plt>
xor    %eax,%eax
call   10b0 <noecho@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    0x2dcd(%rip),%rax
mov    (%rax),%esi
call   1060 <keypad@plt>
xor    %eax,%eax
call   1050 <cbreak@plt>
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
pop    %rax
jmp    10f0 <curs_set@plt>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdc0(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
xor    %eax,%eax
call   10a0 <endwin@plt>
lea    0xdbc(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"ERROR in init_screen() \0A\00"
@.str.1 = [21 x i8] c"ERROR with colors! \0A\00"
@stdscr = global i32 0
@TRUE = global i32 0
@FALSE = global i32 0
define void @init_screen() {
%1 = call i32 (...) @initscr()
%2 = icmp ne i32 %1, 0
br i1 %2, label %7, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = call i32 (...) @has_colors()
%9 = icmp ne i32 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = call i32 (...) @endwin()
%12 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = call i32 (...) @start_color()
%16 = call i32 (...) @init_colors()
%17 = call i32 (...) @clear()
%18 = call i32 (...) @noecho()
%19 = load i32, i32* @stdscr
%20 = load i32, i32* @TRUE
%21 = call i32 @keypad(i32 %19, i32 %20)
%22 = call i32 (...) @cbreak()
%23 = load i32, i32* @FALSE
%24 = call i32 @curs_set(i32 %23)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"ERROR in init_screen() \0A\00"
@stdscr = global i32 0
@TRUE = global i32 0
@FALSE = global i32 0
@str = [20 x i8] c"ERROR with colors! \00"
define void @init_screen() {
%1 = tail call i32 (...) @initscr()
%2 = icmp eq i32 %1, 0
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %0
%8 = tail call i32 (...) @has_colors()
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %7
%11 = tail call i32 (...) @endwin()
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %7
%15 = tail call i32 (...) @start_color()
%16 = tail call i32 (...) @init_colors()
%17 = tail call i32 (...) @clear()
%18 = tail call i32 (...) @noecho()
%19 = load i32, i32* @stdscr
%20 = load i32, i32* @TRUE
%21 = tail call i32 @keypad(i32 %19, i32 %20)
%22 = tail call i32 (...) @cbreak()
%23 = load i32, i32* @FALSE
%24 = tail call i32 @curs_set(i32 %23)
ret void
}