#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 uint16_t;

/* Variables and functions */
scalar_t__ FALSE;
int /*<<< orphan*/ colorsInit();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ gameLoop();
int /*<<< orphan*/ gfxEnd();
scalar_t__ has_colors();
int /*<<< orphan*/ *initscr();
int /*<<< orphan*/ mapDraw();
int /*<<< orphan*/ mapInit();
int mapLoad(char *);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stderr;
main(int argc, char **argv) {
  uint16_t ec = 0;
  if (initscr() == NULL) {
    return 1;
  }
  if (has_colors() == FALSE) {
    return 1;
  }
  start_color();
  curs_set(0);
  noecho();
  colorsInit();
  mapInit();
  mapDraw();
  if ((ec = mapLoad(argv[1])) != 0) {
    gfxEnd();
    switch (ec) {
    case 4:
      fprintf(stderr, "err %d: wrong player count!\n", ec);
      break;
    case 2:
      fprintf(stderr, "err %d: cannot open level file!\n", ec);
      break;
    case 3:
      fprintf(stderr, "err %d: wrong map size!\n", ec);
    }
    return 1;
  }
  gameLoop();
  gfxEnd();
  return 0;
}


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)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
cmp    $0x0,%rax
jne    11fa <main+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1050 <has_colors@plt>
mov    0x2dd0(%rip),%rcx
cmp    (%rcx),%rax
jne    121d <main+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1070 <start_color@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
mov    $0x0,%al
call   10d0 <noecho@plt>
mov    $0x0,%al
call   10c0 <colorsInit@plt>
mov    $0x0,%al
call   1080 <mapInit@plt>
mov    $0x0,%al
call   1030 <mapDraw@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <mapLoad@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     12fb <main+0x13b>
xor    %eax,%eax
call   1090 <gfxEnd@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x2,%eax
je     12ba <main+0xfa>
jmp    127b <main+0xbb>
mov    -0x18(%rbp),%eax
sub    $0x3,%eax
je     12d7 <main+0x117>
jmp    128c <main+0xcc>
mov    -0x18(%rbp),%eax
sub    $0x4,%eax
jne    12ef <main+0x12f>
jmp    129d <main+0xdd>
mov    0x2d3c(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd50(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    12ef <main+0x12f>
mov    0x2d1f(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd50(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    12ef <main+0x12f>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd54(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1310 <main+0x150>
mov    $0x0,%al
call   1040 <gameLoop@plt>
mov    $0x0,%al
call   1090 <gfxEnd@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
xor    %eax,%eax
call   1060 <initscr@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     129b <main+0xdb>
xor    %eax,%eax
call   1050 <has_colors@plt>
mov    0x2def(%rip),%rcx
cmp    (%rcx),%rax
je     129b <main+0xdb>
xor    %eax,%eax
call   1070 <start_color@plt>
xor    %edi,%edi
call   10e0 <curs_set@plt>
xor    %eax,%eax
call   10d0 <noecho@plt>
xor    %eax,%eax
call   10c0 <colorsInit@plt>
xor    %eax,%eax
call   1080 <mapInit@plt>
xor    %eax,%eax
call   1030 <mapDraw@plt>
mov    0x8(%rbx),%rdi
call   10b0 <mapLoad@plt>
test   %eax,%eax
je     1258 <main+0x98>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <gfxEnd@plt>
cmp    $0x2,%ebx
je     126a <main+0xaa>
cmp    $0x3,%ebx
je     1281 <main+0xc1>
cmp    $0x4,%ebx
jne    129b <main+0xdb>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
lea    0xdaf(%rip),%rsi
mov    $0x4,%edx
jmp    1296 <main+0xd6>
xor    %eax,%eax
call   1040 <gameLoop@plt>
xor    %eax,%eax
call   1090 <gfxEnd@plt>
xor    %ebp,%ebp
jmp    129b <main+0xdb>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xda3(%rip),%rsi
mov    $0x2,%edx
jmp    1296 <main+0xd6>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    $0x3,%edx
call   10a0 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@FALSE = global i64 0
@stderr = global i32 0
@.str = [29 x i8] c"err %d: wrong player count!\0A\00"
@.str.1 = [33 x i8] c"err %d: cannot open level file!\0A\00"
@.str.2 = [25 x i8] c"err %d: wrong map size!\0A\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
store i32 0, i32* %6
%7 = call i32* (...) @initscr()
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %46
10: ; preds = %2
%11 = call i64 (...) @has_colors()
%12 = load i64, i64* @FALSE
%13 = icmp eq i64 %11, %12
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %3
br label %46
15: ; preds = %10
%16 = call i32 (...) @start_color()
%17 = call i32 @curs_set(i32 0)
%18 = call i32 (...) @noecho()
%19 = call i32 (...) @colorsInit()
%20 = call i32 (...) @mapInit()
%21 = call i32 (...) @mapDraw()
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @mapLoad(i8* %24)
store i32 %25, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %43
27: ; preds = %15
%28 = call i32 (...) @gfxEnd()
%29 = load i32, i32* %6
switch i32 %29, label %42 [
i32 4, label %30
i32 2, label %34
i32 3, label %38
]
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = load i32, i32* %6
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %32)
br label %42
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = load i32, i32* %6
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %36)
br label %42
38: ; preds = %27
%39 = load i32, i32* @stderr
%40 = load i32, i32* %6
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %27, %34, %30
store i32 1, i32* %3
br label %46
43: ; preds = %15
%44 = call i32 (...) @gameLoop()
%45 = call i32 (...) @gfxEnd()
store i32 0, i32* %3
br label %46
46: ; preds = %43, %42, %14, %9
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@FALSE = global i64 0
@stderr = global i32 0
@.str = [29 x i8] c"err %d: wrong player count!\0A\00"
@.str.1 = [33 x i8] c"err %d: cannot open level file!\0A\00"
@.str.2 = [25 x i8] c"err %d: wrong map size!\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32* (...) @initscr()
%4 = icmp eq i32* %3, null
br i1 %4, label %34, label %5
5: ; preds = %2
%6 = tail call i64 (...) @has_colors()
%7 = load i64, i64* @FALSE
%8 = icmp eq i64 %6, %7
br i1 %8, label %34, label %9
9: ; preds = %5
%10 = tail call i32 (...) @start_color()
%11 = tail call i32 @curs_set(i32 0)
%12 = tail call i32 (...) @noecho()
%13 = tail call i32 (...) @colorsInit()
%14 = tail call i32 (...) @mapInit()
%15 = tail call i32 (...) @mapDraw()
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32 @mapLoad(i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %31, label %20
20: ; preds = %9
%21 = tail call i32 (...) @gfxEnd()
switch i32 %18, label %34 [
i32 4, label %22
i32 2, label %25
i32 3, label %28
]
22: ; preds = %20
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 4)
br label %34
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %34
28: ; preds = %20
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 3)
br label %34
31: ; preds = %9
%32 = tail call i32 (...) @gameLoop()
%33 = tail call i32 (...) @gfxEnd()
br label %34
34: ; preds = %22, %25, %20, %28, %5, %2, %31
%35 = phi i32 [ 0, %31 ], [ 1, %2 ], [ 1, %5 ], [ 1, %28 ], [ 1, %20 ], [ 1, %25 ], [ 1, %22 ]
ret i32 %35
}