#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*/ gcol;

/* Variables and functions */
int /*<<< orphan*/ COLOR_BLACK;
int COLOR_BLUE;
int COLOR_CYAN;
int COLOR_GREEN;
int COLOR_MAGENTA;
int COLOR_RED;
int COLOR_WHITE;
int COLOR_YELLOW;
scalar_t__ can_change_color();
int /*<<< orphan*/ cbreak();
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ has_colors();
int /*<<< orphan*/ init_color(int, int, int, int);
int /*<<< orphan*/ init_pair(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ initscr();
int /*<<< orphan*/ nodelay(int /*<<< orphan*/, int);
int /*<<< orphan*/ noecho();
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdscr;
void *Pac_InitRender(void) {
  int gcol[] = {
      COLOR_RED,
      COLOR_GREEN,
      COLOR_MAGENTA,
      COLOR_CYAN,
  };
  int i;
  initscr();
  cbreak();
  noecho();
  nodelay(stdscr, 1);
  curs_set(0);
  if (has_colors()) {
    fprintf(stderr, "Color console in use\n");
    start_color();
    init_pair(1, COLOR_YELLOW, COLOR_BLACK);
    init_pair(2, COLOR_BLUE, COLOR_BLACK);
    init_pair(6, COLOR_MAGENTA, COLOR_BLACK);
    init_pair(3, COLOR_CYAN, COLOR_BLACK);
    init_pair(4, COLOR_WHITE, COLOR_BLACK);
    init_pair(5, COLOR_WHITE, COLOR_BLACK);
    if (can_change_color()) {
      init_color(COLOR_GREEN, 1000, 644, 888);
      init_color(COLOR_MAGENTA, 1000, 888, 970);
      init_color(COLOR_CYAN, 1000, 644, 285);
    } else {
      fprintf(stderr, "Ghosts colors will not be accurate because TTY doesn't "
                      "support init_color\n");
    }
    for (i = 0; i < 4; i++)
      init_pair(20 + i, gcol[i % sizeof(gcol)], COLOR_BLACK);
  } else {
    fprintf(stderr, "Black and white console in use\n");
  }
  return NULL;
}


x86 assembly (clang, -O0):
<Pac_InitRender>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    0x2df5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1070 <initscr@plt>
mov    $0x0,%al
call   1050 <cbreak@plt>
mov    $0x0,%al
call   10c0 <noecho@plt>
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   10a0 <nodelay@plt>
xor    %edi,%edi
call   10d0 <curs_set@plt>
mov    $0x0,%al
call   1030 <has_colors@plt>
cmp    $0x0,%rax
je     13b2 <Pac_InitRender+0x202>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdc8(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x0,%al
call   1080 <start_color@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%esi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
mov    0x2d70(%rip),%rax
mov    (%rax),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
mov    0x2d54(%rip),%rax
mov    (%rax),%edx
mov    $0x6,%edi
call   1060 <init_pair@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%esi
mov    0x2d38(%rip),%rax
mov    (%rax),%edx
mov    $0x3,%edi
call   1060 <init_pair@plt>
mov    0x2cfd(%rip),%rax
mov    (%rax),%esi
mov    0x2d1c(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%edi
call   1060 <init_pair@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%esi
mov    0x2d00(%rip),%rax
mov    (%rax),%edx
mov    $0x5,%edi
call   1060 <init_pair@plt>
mov    $0x0,%al
call   10b0 <can_change_color@plt>
cmp    $0x0,%rax
je     1359 <Pac_InitRender+0x1a9>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
mov    $0x3e8,%esi
mov    $0x284,%edx
mov    $0x378,%ecx
call   1040 <init_color@plt>
mov    0x2c9f(%rip),%rax
mov    (%rax),%edi
mov    $0x3e8,%esi
mov    $0x378,%edx
mov    $0x3ca,%ecx
call   1040 <init_color@plt>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
mov    $0x3e8,%esi
mov    $0x284,%edx
mov    $0x11d,%ecx
call   1040 <init_color@plt>
jmp    136e <Pac_InitRender+0x1be>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
lea    0xcad(%rip),%rsi
call   1090 <fprintf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    13ad <Pac_InitRender+0x1fd>
mov    -0x14(%rbp),%edi
add    $0x14,%edi
movslq -0x14(%rbp),%rax
and    $0xf,%rax
mov    -0x10(%rbp,%rax,4),%esi
mov    0x2c48(%rip),%rax
mov    (%rax),%edx
call   1060 <init_pair@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1375 <Pac_InitRender+0x1c5>
jmp    13c7 <Pac_InitRender+0x217>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xc9f(%rip),%rsi
call   1090 <fprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Pac_InitRender>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2dd3(%rip),%rax
mov    (%rax),%r12d
mov    0x2e01(%rip),%rax
mov    (%rax),%r14d
mov    0x2de7(%rip),%r13
mov    0x0(%r13),%ebp
mov    0x2df4(%rip),%rax
mov    (%rax),%ebx
xor    %eax,%eax
call   1070 <initscr@plt>
xor    %eax,%eax
call   1050 <cbreak@plt>
xor    %eax,%eax
call   10c0 <noecho@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    $0x1,%esi
call   10a0 <nodelay@plt>
xor    %edi,%edi
call   10d0 <curs_set@plt>
xor    %eax,%eax
call   1030 <has_colors@plt>
mov    0x2d8d(%rip),%r15
mov    (%r15),%edi
test   %rax,%rax
je     1330 <Pac_InitRender+0x180>
mov    %r12d,0x8(%rsp)
mov    %r14d,0xc(%rsp)
mov    %ebp,0x10(%rsp)
mov    %ebx,0x14(%rsp)
lea    0xdb8(%rip),%rsi
call   1090 <fprintf@plt>
xor    %eax,%eax
call   1080 <start_color@plt>
mov    0x2d4d(%rip),%rax
mov    (%rax),%esi
mov    0x2d7c(%rip),%r14
mov    (%r14),%edx
mov    $0x1,%edi
call   1060 <init_pair@plt>
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
mov    (%r14),%edx
mov    $0x2,%edi
call   1060 <init_pair@plt>
mov    0x0(%r13),%esi
mov    (%r14),%edx
mov    $0x6,%edi
call   1060 <init_pair@plt>
mov    0x2d39(%rip),%rbx
mov    (%rbx),%esi
mov    (%r14),%edx
mov    $0x3,%edi
call   1060 <init_pair@plt>
mov    0x2d03(%rip),%r12
mov    (%r12),%esi
mov    (%r14),%edx
mov    $0x4,%edi
call   1060 <init_pair@plt>
mov    (%r12),%esi
mov    (%r14),%edx
mov    $0x5,%edi
call   1060 <init_pair@plt>
xor    %eax,%eax
call   10b0 <can_change_color@plt>
test   %rax,%rax
je     133e <Pac_InitRender+0x18e>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    $0x3e8,%esi
mov    $0x284,%edx
mov    $0x378,%ecx
call   1040 <init_color@plt>
mov    0x0(%r13),%edi
mov    $0x3e8,%esi
mov    $0x378,%edx
mov    $0x3ca,%ecx
call   1040 <init_color@plt>
mov    (%rbx),%edi
mov    $0x3e8,%esi
mov    $0x284,%edx
mov    $0x11d,%ecx
call   1040 <init_color@plt>
jmp    134d <Pac_InitRender+0x19d>
lea    0xd2a(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1391 <Pac_InitRender+0x1e1>
mov    (%r15),%edi
lea    0xcce(%rip),%rsi
call   1090 <fprintf@plt>
mov    0x8(%rsp),%esi
mov    (%r14),%edx
mov    $0x14,%edi
call   1060 <init_pair@plt>
mov    (%r14),%edx
mov    $0x15,%edi
mov    0xc(%rsp),%esi
call   1060 <init_pair@plt>
mov    (%r14),%edx
mov    $0x16,%edi
mov    0x10(%rsp),%esi
call   1060 <init_pair@plt>
mov    (%r14),%edx
mov    $0x17,%edi
mov    0x14(%rsp),%esi
call   1060 <init_pair@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@COLOR_RED = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@stdscr = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"Color console in use\0A\00"
@COLOR_YELLOW = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_WHITE = global i32 0
@.str.1 = [75 x i8] c"Ghosts colors will not be accurate because TTY doesn't support init_color\0A\00"
@.str.2 = [32 x i8] c"Black and white console in use\0A\00"
define i8* @Pac_InitRender() {
%1 = alloca [4 x i32]
%2 = alloca i32
%3 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 0
%4 = load i32, i32* @COLOR_RED
store i32 %4, i32* %3
%5 = getelementptr inbounds i32, i32* %3, i64 1
%6 = load i32, i32* @COLOR_GREEN
store i32 %6, i32* %5
%7 = getelementptr inbounds i32, i32* %5, i64 1
%8 = load i32, i32* @COLOR_MAGENTA
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
%10 = load i32, i32* @COLOR_CYAN
store i32 %10, i32* %9
%11 = call i32 (...) @initscr()
%12 = call i32 (...) @cbreak()
%13 = call i32 (...) @noecho()
%14 = load i32, i32* @stdscr
%15 = call i32 @nodelay(i32 %14, i32 1)
%16 = call i32 @curs_set(i32 0)
%17 = call i64 (...) @has_colors()
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %71
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (...) @start_color()
%23 = load i32, i32* @COLOR_YELLOW
%24 = load i32, i32* @COLOR_BLACK
%25 = call i32 @init_pair(i32 1, i32 %23, i32 %24)
%26 = load i32, i32* @COLOR_BLUE
%27 = load i32, i32* @COLOR_BLACK
%28 = call i32 @init_pair(i32 2, i32 %26, i32 %27)
%29 = load i32, i32* @COLOR_MAGENTA
%30 = load i32, i32* @COLOR_BLACK
%31 = call i32 @init_pair(i32 6, i32 %29, i32 %30)
%32 = load i32, i32* @COLOR_CYAN
%33 = load i32, i32* @COLOR_BLACK
%34 = call i32 @init_pair(i32 3, i32 %32, i32 %33)
%35 = load i32, i32* @COLOR_WHITE
%36 = load i32, i32* @COLOR_BLACK
%37 = call i32 @init_pair(i32 4, i32 %35, i32 %36)
%38 = load i32, i32* @COLOR_WHITE
%39 = load i32, i32* @COLOR_BLACK
%40 = call i32 @init_pair(i32 5, i32 %38, i32 %39)
%41 = call i64 (...) @can_change_color()
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %50
43: ; preds = %19
%44 = load i32, i32* @COLOR_GREEN
%45 = call i32 @init_color(i32 %44, i32 1000, i32 644, i32 888)
%46 = load i32, i32* @COLOR_MAGENTA
%47 = call i32 @init_color(i32 %46, i32 1000, i32 888, i32 970)
%48 = load i32, i32* @COLOR_CYAN
%49 = call i32 @init_color(i32 %48, i32 1000, i32 644, i32 285)
br label %53
50: ; preds = %19
%51 = load i32, i32* @stderr
%52 = call i32 @fprintf(i32 %51, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
br label %53
53: ; preds = %50, %43
store i32 0, i32* %2
br label %54
54: ; preds = %67, %53
%55 = load i32, i32* %2
%56 = icmp slt i32 %55, 4
br i1 %56, label %57, label %70
57: ; preds = %54
%58 = load i32, i32* %2
%59 = add nsw i32 20, %58
%60 = load i32, i32* %2
%61 = sext i32 %60 to i64
%62 = urem i64 %61, 16
%63 = getelementptr inbounds [4 x i32], [4 x i32]* %1, i64 0, i64 %62
%64 = load i32, i32* %63
%65 = load i32, i32* @COLOR_BLACK
%66 = call i32 @init_pair(i32 %59, i32 %64, i32 %65)
br label %67
67: ; preds = %57
%68 = load i32, i32* %2
%69 = add nsw i32 %68, 1
store i32 %69, i32* %2
br label %54
70: ; preds = %54
br label %74
71: ; preds = %0
%72 = load i32, i32* @stderr
%73 = call i32 @fprintf(i32 %72, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %74
74: ; preds = %71, %70
ret i8* null
}

LLVM IR (-O2):
@COLOR_RED = global i32 0
@COLOR_GREEN = global i32 0
@COLOR_MAGENTA = global i32 0
@COLOR_CYAN = global i32 0
@stdscr = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"Color console in use\0A\00"
@COLOR_YELLOW = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_BLUE = global i32 0
@COLOR_WHITE = global i32 0
@.str.1 = [75 x i8] c"Ghosts colors will not be accurate because TTY doesn't support init_color\0A\00"
@.str.2 = [32 x i8] c"Black and white console in use\0A\00"
define noalias i8* @Pac_InitRender() {
%1 = load i32, i32* @COLOR_RED
%2 = load i32, i32* @COLOR_GREEN
%3 = load i32, i32* @COLOR_MAGENTA
%4 = load i32, i32* @COLOR_CYAN
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @cbreak()
%7 = tail call i32 (...) @noecho()
%8 = load i32, i32* @stdscr
%9 = tail call i32 @nodelay(i32 %8, i32 1)
%10 = tail call i32 @curs_set(i32 0)
%11 = tail call i64 (...) @has_colors()
%12 = icmp eq i64 %11, 0
%13 = load i32, i32* @stderr
br i1 %12, label %56, label %14
14: ; preds = %0
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 (...) @start_color()
%17 = load i32, i32* @COLOR_YELLOW
%18 = load i32, i32* @COLOR_BLACK
%19 = tail call i32 @init_pair(i32 1, i32 %17, i32 %18)
%20 = load i32, i32* @COLOR_BLUE
%21 = load i32, i32* @COLOR_BLACK
%22 = tail call i32 @init_pair(i32 2, i32 %20, i32 %21)
%23 = load i32, i32* @COLOR_MAGENTA
%24 = load i32, i32* @COLOR_BLACK
%25 = tail call i32 @init_pair(i32 6, i32 %23, i32 %24)
%26 = load i32, i32* @COLOR_CYAN
%27 = load i32, i32* @COLOR_BLACK
%28 = tail call i32 @init_pair(i32 3, i32 %26, i32 %27)
%29 = load i32, i32* @COLOR_WHITE
%30 = load i32, i32* @COLOR_BLACK
%31 = tail call i32 @init_pair(i32 4, i32 %29, i32 %30)
%32 = load i32, i32* @COLOR_WHITE
%33 = load i32, i32* @COLOR_BLACK
%34 = tail call i32 @init_pair(i32 5, i32 %32, i32 %33)
%35 = tail call i64 (...) @can_change_color()
%36 = icmp eq i64 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %14
%38 = load i32, i32* @COLOR_GREEN
%39 = tail call i32 @init_color(i32 %38, i32 1000, i32 644, i32 888)
%40 = load i32, i32* @COLOR_MAGENTA
%41 = tail call i32 @init_color(i32 %40, i32 1000, i32 888, i32 970)
%42 = load i32, i32* @COLOR_CYAN
%43 = tail call i32 @init_color(i32 %42, i32 1000, i32 644, i32 285)
br label %47
44: ; preds = %14
%45 = load i32, i32* @stderr
%46 = tail call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.1, i64 0, i64 0))
br label %47
47: ; preds = %44, %37
%48 = load i32, i32* @COLOR_BLACK
%49 = tail call i32 @init_pair(i32 20, i32 %1, i32 %48)
%50 = load i32, i32* @COLOR_BLACK
%51 = tail call i32 @init_pair(i32 21, i32 %2, i32 %50)
%52 = load i32, i32* @COLOR_BLACK
%53 = tail call i32 @init_pair(i32 22, i32 %3, i32 %52)
%54 = load i32, i32* @COLOR_BLACK
%55 = tail call i32 @init_pair(i32 23, i32 %4, i32 %54)
br label %58
56: ; preds = %0
%57 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %47, %56
ret i8* null
}