#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*/ COLOR_BLACK;
scalar_t__ COLOR_PAIRS;
int /*<<< orphan*/ COLOR_RED;
int /*<<< orphan*/ COLOR_WHITE;
int /*<<< orphan*/ COLOR_YELLOW;
scalar_t__ OK;
int /*<<< orphan*/ curs_set(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int has_colors();
int /*<<< orphan*/ init_pair(scalar_t__, int /*<<< orphan*/,
                             int /*<<< orphan*/);
scalar_t__ start_color();
int /*<<< orphan*/ stderr;
void init_colors(void) {
  bool color = has_colors();
  if (start_color() != OK) {
    fprintf(stderr, "Could not initialize colors, exiting.\n");
    exit(2);
  }
  if (color) {
    init_pair((COLOR_PAIRS - 1), COLOR_RED, COLOR_BLACK);
    init_pair((COLOR_PAIRS - 2), COLOR_YELLOW, COLOR_BLACK);
  } else {
    init_pair((COLOR_PAIRS - 1), COLOR_WHITE, COLOR_BLACK);
    init_pair((COLOR_PAIRS - 2), COLOR_WHITE, COLOR_BLACK);
  }
  init_pair((COLOR_PAIRS - 3), COLOR_BLACK, COLOR_BLACK);
  curs_set(0);
}


x86 assembly (clang, -O0):
<init_colors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <has_colors@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1050 <start_color@plt>
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%rax
je     11a8 <init_colors+0x48>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>
cmpl   $0x0,-0x4(%rbp)
je     1201 <init_colors+0xa1>
mov    0x2e27(%rip),%rax
mov    (%rax),%rdi
sub    $0x1,%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
mov    0x2e18(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
mov    0x2df3(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
jmp    124b <init_colors+0xeb>
mov    0x2dd8(%rip),%rax
mov    (%rax),%rdi
sub    $0x1,%rdi
mov    0x2dba(%rip),%rax
mov    (%rax),%esi
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
mov    0x2da4(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
mov    0x2d8e(%rip),%rax
mov    (%rax),%rdi
sub    $0x3,%rdi
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
mov    0x2d7f(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
xor    %edi,%edi
call   1080 <curs_set@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_colors>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1030 <has_colors@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1050 <start_color@plt>
mov    0x2e3c(%rip),%rcx
cmp    (%rcx),%rax
jne    11ea <init_colors+0x8a>
mov    0x2e58(%rip),%r14
mov    (%r14),%rdi
add    $0xffffffffffffffff,%rdi
test   %ebx,%ebx
mov    0x2e38(%rip),%rbx
mov    0x2e11(%rip),%rax
cmove  %rbx,%rax
mov    (%rax),%esi
mov    0x2e3c(%rip),%r15
mov    (%r15),%edx
cmovne 0x2e09(%rip),%rbx
call   1040 <init_pair@plt>
mov    (%r14),%rdi
add    $0xfffffffffffffffe,%rdi
mov    (%rbx),%esi
mov    (%r15),%edx
call   1040 <init_pair@plt>
mov    (%r14),%rdi
add    $0xfffffffffffffffd,%rdi
mov    (%r15),%edx
mov    %edx,%esi
call   1040 <init_pair@plt>
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <curs_set@plt>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe06(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x2,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@OK = global i64 0
@stderr = global i32 0
@.str = [39 x i8] c"Could not initialize colors, exiting.\0A\00"
@COLOR_PAIRS = global i64 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
define void @init_colors() {
%1 = alloca i32
%2 = call i32 (...) @has_colors()
store i32 %2, i32* %1
%3 = call i64 (...) @start_color()
%4 = load i64, i64* @OK
%5 = icmp ne i64 %3, %4
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @exit(i32 2)
unreachable
10: ; preds = %0
%11 = load i32, i32* %1
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %10
%14 = load i64, i64* @COLOR_PAIRS
%15 = sub nsw i64 %14, 1
%16 = load i32, i32* @COLOR_RED
%17 = load i32, i32* @COLOR_BLACK
%18 = call i32 @init_pair(i64 %15, i32 %16, i32 %17)
%19 = load i64, i64* @COLOR_PAIRS
%20 = sub nsw i64 %19, 2
%21 = load i32, i32* @COLOR_YELLOW
%22 = load i32, i32* @COLOR_BLACK
%23 = call i32 @init_pair(i64 %20, i32 %21, i32 %22)
br label %35
24: ; preds = %10
%25 = load i64, i64* @COLOR_PAIRS
%26 = sub nsw i64 %25, 1
%27 = load i32, i32* @COLOR_WHITE
%28 = load i32, i32* @COLOR_BLACK
%29 = call i32 @init_pair(i64 %26, i32 %27, i32 %28)
%30 = load i64, i64* @COLOR_PAIRS
%31 = sub nsw i64 %30, 2
%32 = load i32, i32* @COLOR_WHITE
%33 = load i32, i32* @COLOR_BLACK
%34 = call i32 @init_pair(i64 %31, i32 %32, i32 %33)
br label %35
35: ; preds = %24, %13
%36 = load i64, i64* @COLOR_PAIRS
%37 = sub nsw i64 %36, 3
%38 = load i32, i32* @COLOR_BLACK
%39 = load i32, i32* @COLOR_BLACK
%40 = call i32 @init_pair(i64 %37, i32 %38, i32 %39)
%41 = call i32 @curs_set(i32 0)
ret void
}

LLVM IR (-O2):
@OK = global i64 0
@stderr = global i32 0
@.str = [39 x i8] c"Could not initialize colors, exiting.\0A\00"
@COLOR_PAIRS = global i64 0
@COLOR_RED = global i32 0
@COLOR_BLACK = global i32 0
@COLOR_YELLOW = global i32 0
@COLOR_WHITE = global i32 0
define void @init_colors() {
%1 = tail call i32 (...) @has_colors()
%2 = tail call i64 (...) @start_color()
%3 = load i64, i64* @OK
%4 = icmp eq i64 %2, %3
br i1 %4, label %9, label %5
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 2)
unreachable
9: ; preds = %0
%10 = icmp eq i32 %1, 0
%11 = load i64, i64* @COLOR_PAIRS
%12 = add nsw i64 %11, -1
%13 = load i32, i32* @COLOR_WHITE
%14 = load i32, i32* @COLOR_RED
%15 = select i1 %10, i32 %13, i32 %14
%16 = load i32, i32* @COLOR_BLACK
%17 = tail call i32 @init_pair(i64 %12, i32 %15, i32 %16)
%18 = load i64, i64* @COLOR_PAIRS
%19 = add nsw i64 %18, -2
%20 = load i32, i32* @COLOR_WHITE
%21 = load i32, i32* @COLOR_YELLOW
%22 = select i1 %10, i32 %20, i32 %21
%23 = load i32, i32* @COLOR_BLACK
%24 = tail call i32 @init_pair(i64 %19, i32 %22, i32 %23)
%25 = load i64, i64* @COLOR_PAIRS
%26 = add nsw i64 %25, -3
%27 = load i32, i32* @COLOR_BLACK
%28 = tail call i32 @init_pair(i64 %26, i32 %27, i32 %27)
%29 = tail call i32 @curs_set(i32 0)
ret void
}