#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;
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ FALSE;
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ has_colors();
int /*<<< orphan*/ init_pair(int, int, int /*<<< orphan*/);
int /*<<< orphan*/ start_color();
int /*<<< orphan*/ stderr;
void init256color() {
  static bool inited = false;
  if (inited)
    return;
  if (has_colors() == FALSE) {
    endwin();
    fprintf(stderr, "terminal does not support colors");
    exit(EXIT_FAILURE);
  }
  start_color();
  for (int i = 0; i <= 8; i++)
    init_pair((232 + (256 - 232 - 1) * i / 8), (232 + (256 - 232 - 1) * i / 8),
              COLOR_BLACK);
  inited = true;
}


x86 assembly (clang, -O0):
<init256color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
cmpl   $0x0,0x2ee9(%rip)
je     117a <init256color+0x1a>
jmp    1221 <init256color+0xc1>
mov    $0x0,%al
call   1030 <has_colors@plt>
mov    0x2e40(%rip),%rcx
cmp    (%rcx),%rax
jne    11bb <init256color+0x5b>
mov    $0x0,%al
call   1070 <endwin@plt>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1050 <start_color@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x8,-0x4(%rbp)
jg     1217 <init256color+0xb7>
imul   $0x17,-0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0xe8,%edi
imul   $0x17,-0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
add    $0xe8,%esi
mov    0x2de6(%rip),%rax
mov    (%rax),%edx
call   1040 <init_pair@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11c9 <init256color+0x69>
movl   $0x1,0x2e37(%rip)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init256color>:
push   %rbx
cmpb   $0x0,0x2ef0(%rip)
jne    1233 <init256color+0xd3>
xor    %eax,%eax
call   1030 <has_colors@plt>
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
je     1235 <init256color+0xd5>
xor    %eax,%eax
call   1050 <start_color@plt>
mov    0x2e55(%rip),%rbx
mov    (%rbx),%edx
mov    $0xe8,%edi
mov    $0xe8,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xea,%edi
mov    $0xea,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xed,%edi
mov    $0xed,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xf0,%edi
mov    $0xf0,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xf3,%edi
mov    $0xf3,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xf6,%edi
mov    $0xf6,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xf9,%edi
mov    $0xf9,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xfc,%edi
mov    $0xfc,%esi
call   1040 <init_pair@plt>
mov    (%rbx),%edx
mov    $0xff,%edi
mov    $0xff,%esi
call   1040 <init_pair@plt>
movb   $0x1,0x2e25(%rip)
pop    %rbx
ret
xor    %eax,%eax
call   1070 <endwin@plt>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xdb4(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d78(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@init256color.inited = internal global i32 0
@FALSE = global i64 0
@stderr = global i32 0
@.str = [33 x i8] c"terminal does not support colors\00"
@EXIT_FAILURE = global i32 0
@COLOR_BLACK = global i32 0
define void @init256color() {
%1 = alloca i32
%2 = load i32, i32* @init256color.inited
%3 = icmp ne i32 %2, 0
br i1 %3, label %4, label %5
4: ; preds = %0
br label %35
5: ; preds = %0
%6 = call i64 (...) @has_colors()
%7 = load i64, i64* @FALSE
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %15
9: ; preds = %5
%10 = call i32 (...) @endwin()
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = call i32 @exit(i32 %13)
unreachable
15: ; preds = %5
%16 = call i32 (...) @start_color()
store i32 0, i32* %1
br label %17
17: ; preds = %31, %15
%18 = load i32, i32* %1
%19 = icmp sle i32 %18, 8
br i1 %19, label %20, label %34
20: ; preds = %17
%21 = load i32, i32* %1
%22 = mul nsw i32 23, %21
%23 = sdiv i32 %22, 8
%24 = add nsw i32 232, %23
%25 = load i32, i32* %1
%26 = mul nsw i32 23, %25
%27 = sdiv i32 %26, 8
%28 = add nsw i32 232, %27
%29 = load i32, i32* @COLOR_BLACK
%30 = call i32 @init_pair(i32 %24, i32 %28, i32 %29)
br label %31
31: ; preds = %20
%32 = load i32, i32* %1
%33 = add nsw i32 %32, 1
store i32 %33, i32* %1
br label %17
34: ; preds = %17
store i32 1, i32* @init256color.inited
br label %35
35: ; preds = %34, %4
ret void
}

LLVM IR (-O2):
@init256color.inited = internal unnamed_addr global i1 false
@FALSE = global i64 0
@stderr = global i32 0
@.str = [33 x i8] c"terminal does not support colors\00"
@EXIT_FAILURE = global i32 0
@COLOR_BLACK = global i32 0
define void @init256color() {
%1 = load i1, i1* @init256color.inited
br i1 %1, label %32, label %2
2: ; preds = %0
%3 = tail call i64 (...) @has_colors()
%4 = load i64, i64* @FALSE
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = tail call i32 (...) @endwin()
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = tail call i32 (...) @start_color()
%14 = load i32, i32* @COLOR_BLACK
%15 = tail call i32 @init_pair(i32 232, i32 232, i32 %14)
%16 = load i32, i32* @COLOR_BLACK
%17 = tail call i32 @init_pair(i32 234, i32 234, i32 %16)
%18 = load i32, i32* @COLOR_BLACK
%19 = tail call i32 @init_pair(i32 237, i32 237, i32 %18)
%20 = load i32, i32* @COLOR_BLACK
%21 = tail call i32 @init_pair(i32 240, i32 240, i32 %20)
%22 = load i32, i32* @COLOR_BLACK
%23 = tail call i32 @init_pair(i32 243, i32 243, i32 %22)
%24 = load i32, i32* @COLOR_BLACK
%25 = tail call i32 @init_pair(i32 246, i32 246, i32 %24)
%26 = load i32, i32* @COLOR_BLACK
%27 = tail call i32 @init_pair(i32 249, i32 249, i32 %26)
%28 = load i32, i32* @COLOR_BLACK
%29 = tail call i32 @init_pair(i32 252, i32 252, i32 %28)
%30 = load i32, i32* @COLOR_BLACK
%31 = tail call i32 @init_pair(i32 255, i32 255, i32 %30)
store i1 true, i1* @init256color.inited
br label %32
32: ; preds = %0, %12
ret void
}