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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *const);
void ct_startcolor(FILE *stream, size_t color_index) {
  static const char *const colors[] = {"\033[0;32m", "\033[0;31m", "\033[0;36m",
                                       "\033[0;35m"};
  static const size_t color_count = sizeof colors / sizeof colors[0];
  if (color_index < color_count) {
    fprintf(stream, "%s", colors[color_index]);
  }
}


x86 assembly (clang, -O0):
<ct_startcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x4,-0x10(%rbp)
jae    114a <ct_startcolor+0x3a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rcx
lea    0x2cc6(%rip),%rax
mov    (%rax,%rcx,8),%rdx
lea    0xedb(%rip),%rsi
call   1030 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ct_startcolor>:
cmp    $0x3,%rsi
ja     112f <ct_startcolor+0x1f>
mov    %rdi,%rax
lea    0xee0(%rip),%rcx
movslq (%rcx,%rsi,4),%rdi
add    %rcx,%rdi
mov    %rax,%rsi
jmp    1030 <fputs@plt>
ret

LLVM IR (-O0):
@ct_startcolor.colors = internal constant [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0)]
@.str = [8 x i8] c"\1B[0;32m\00"
@.str.1 = [8 x i8] c"\1B[0;31m\00"
@.str.2 = [8 x i8] c"\1B[0;36m\00"
@.str.3 = [8 x i8] c"\1B[0;35m\00"
@ct_startcolor.color_count = internal constant i64 4
@.str.4 = [3 x i8] c"%s\00"
define void @ct_startcolor(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = icmp ult i64 %5, 4
br i1 %6, label %7, label %13
7: ; preds = %2
%8 = load i32*, i32** %3
%9 = load i64, i64* %4
%10 = getelementptr inbounds [4 x i8*], [4 x i8*]* @ct_startcolor.colors, i64 0, i64 %9
%11 = load i8*, i8** %10
%12 = call i32 @fprintf(i32* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %7, %2
ret void
}

LLVM IR (-O2):
@reltable.ct_startcolor = internal unnamed_addr constant [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.ct_startcolor to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.ct_startcolor to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.ct_startcolor to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.ct_startcolor to i64)) to i32)]
@.str = [8 x i8] c"\1B[0;32m\00"
@.str.1 = [8 x i8] c"\1B[0;31m\00"
@.str.2 = [8 x i8] c"\1B[0;36m\00"
@.str.3 = [8 x i8] c"\1B[0;35m\00"
define void @ct_startcolor(i32* nocapture %0, i64 %1) {
%3 = icmp ult i64 %1, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = shl i64 %1, 2
%6 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.ct_startcolor to i8*), i64 %5)
%7 = tail call i32 @fputs(i8* %6, i32* %0)
br label %8
8: ; preds = %4, %2
ret void
}