#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 EXIT_FAILURE;
int /*<<< orphan*/ cleanup_window(int /*<<< orphan*/ *);
int /*<<< orphan*/ execlp(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ init_title_screen(int /*<<< orphan*/ *);
int /*<<< orphan*/ *initscr();
scalar_t__ start_color();
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  WINDOW *titlescr;
  if ((titlescr = initscr()) == NULL) {
    fprintf(stderr, "Failed to initialize ncurses.\n");
    return EXIT_FAILURE;
  }
  if (start_color() < 0) {
    fprintf(stderr, "Failed to initialize colors.\n");
    return EXIT_FAILURE;
  }
  init_title_screen(titlescr);
  cleanup_window(titlescr);
  execlp("./main", "main", NULL);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <initscr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b1 <main+0x51>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
lea    0xe65(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1211 <main+0xb1>
mov    $0x0,%al
call   1050 <start_color@plt>
cmp    $0x0,%rax
jge    11e8 <main+0x88>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2dfa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1211 <main+0xb1>
mov    -0x18(%rbp),%rdi
call   1030 <init_title_screen@plt>
mov    -0x18(%rbp),%rdi
call   1070 <cleanup_window@plt>
lea    0xe3c(%rip),%rdi
lea    0xe37(%rip),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <execlp@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <initscr@plt>
test   %rax,%rax
je     11a9 <main+0x49>
mov    %rax,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <start_color@plt>
test   %rax,%rax
js     11bb <main+0x5b>
mov    %rbx,%rdi
call   1030 <init_title_screen@plt>
mov    %rbx,%rdi
call   1070 <cleanup_window@plt>
lea    0xea4(%rip),%rdi
lea    0xe9f(%rip),%rsi
xor    %edx,%edx
call   1080 <execlp@plt>
jmp    11da <main+0x7a>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
jmp    11cb <main+0x6b>
mov    0x2e1e(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"Failed to initialize ncurses.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Failed to initialize colors.\0A\00"
@.str.2 = [7 x i8] c"./main\00"
@.str.3 = [5 x i8] c"main\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* (...) @initscr()
store i32* %7, i32** %6
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %3
br label %26
13: ; preds = %2
%14 = call i64 (...) @start_color()
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
store i32 %19, i32* %3
br label %26
20: ; preds = %13
%21 = load i32*, i32** %6
%22 = call i32 @init_title_screen(i32* %21)
%23 = load i32*, i32** %6
%24 = call i32 @cleanup_window(i32* %23)
%25 = call i32 @execlp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %26
26: ; preds = %20, %16, %9
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"Failed to initialize ncurses.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Failed to initialize colors.\0A\00"
@.str.2 = [7 x i8] c"./main\00"
@.str.3 = [5 x i8] c"main\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* (...) @initscr()
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
br label %20
9: ; preds = %2
%10 = tail call i64 (...) @start_color()
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
br label %20
16: ; preds = %9
%17 = tail call i32 @init_title_screen(i32* %3)
%18 = tail call i32 @cleanup_window(i32* %3)
%19 = tail call i32 @execlp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* null)
br label %20
20: ; preds = %16, %12, %5
%21 = phi i32 [ %8, %5 ], [ %15, %12 ], [ 0, %16 ]
ret i32 %21
}