#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*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void print_color(int color) {
  char *colors[] = {
      "\033[0;30m", "\033[0;34m", "\033[0;32m", "\033[0;36m",
      "\033[0;31m", "\033[0;35m", "\033[0;33m", "\033[0;37m",
      "\033[1;30m", "\033[1;34m", "\033[1;32m", "\033[1;36m",
      "\033[1;31m", "\033[1;35m", "\033[1;33m", "\033[1;37m",
  };
  if (color == 0) {
    fputs("\033[0m", stdout);
  } else {
    if (color >= 0x61 && color <= 0x66)
      color -= 0x57;
    else if (color >= 0x30 && color <= 0x39)
      color -= 0x30;
    else
      return;
    fputs(colors[color], stdout);
  }
}


x86 assembly (clang, -O0):
<print_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2c54(%rip),%rsi
mov    $0x80,%edx
call   1040 <memcpy@plt>
cmpl   $0x0,-0x4(%rbp)
jne    116a <print_color+0x4a>
mov    0x2e81(%rip),%rax
mov    (%rax),%esi
lea    0xf20(%rip),%rdi
call   1030 <fputs@plt>
jmp    11d2 <print_color+0xb2>
cmpl   $0x61,-0x4(%rbp)
jl     118c <print_color+0x6c>
cmpl   $0x66,-0x4(%rbp)
jg     118c <print_color+0x6c>
mov    -0x4(%rbp),%eax
sub    $0x57,%eax
mov    %eax,-0x4(%rbp)
jmp    11b8 <print_color+0x98>
cmpl   $0x30,-0x4(%rbp)
jl     11ae <print_color+0x8e>
cmpl   $0x39,-0x4(%rbp)
jg     11ae <print_color+0x8e>
mov    -0x4(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x4(%rbp)
jmp    11b3 <print_color+0x93>
jmp    11d2 <print_color+0xb2>
jmp    11b8 <print_color+0x98>
movslq -0x4(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
mov    0x2e0d(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_color>:
test   %edi,%edi
je     1121 <print_color+0x11>
lea    -0x61(%rdi),%eax
cmp    $0x5,%eax
ja     112a <print_color+0x1a>
add    $0xffffffa9,%edi
jmp    1132 <print_color+0x22>
lea    0xf58(%rip),%rdi
jmp    1142 <print_color+0x32>
add    $0xffffffd0,%edi
cmp    $0x9,%edi
ja     1150 <print_color+0x40>
mov    %edi,%eax
lea    0xf4d(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
mov    0x2e97(%rip),%rax
mov    (%rax),%esi
jmp    1030 <fputs@plt>
ret

LLVM IR (-O0):
@.str = [8 x i8] c"\1B[0;30m\00"
@.str.1 = [8 x i8] c"\1B[0;34m\00"
@.str.2 = [8 x i8] c"\1B[0;32m\00"
@.str.3 = [8 x i8] c"\1B[0;36m\00"
@.str.4 = [8 x i8] c"\1B[0;31m\00"
@.str.5 = [8 x i8] c"\1B[0;35m\00"
@.str.6 = [8 x i8] c"\1B[0;33m\00"
@.str.7 = [8 x i8] c"\1B[0;37m\00"
@.str.8 = [8 x i8] c"\1B[1;30m\00"
@.str.9 = [8 x i8] c"\1B[1;34m\00"
@.str.10 = [8 x i8] c"\1B[1;32m\00"
@.str.11 = [8 x i8] c"\1B[1;36m\00"
@.str.12 = [8 x i8] c"\1B[1;31m\00"
@.str.13 = [8 x i8] c"\1B[1;35m\00"
@.str.14 = [8 x i8] c"\1B[1;33m\00"
@.str.15 = [8 x i8] c"\1B[1;37m\00"
@__const.print_color.colors = [16 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), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.15, i32 0, i32 0)]
@.str.16 = [5 x i8] c"\1B[0m\00"
@stdout = global i32 0
define void @print_color(i32 %0) {
%2 = alloca i32
%3 = alloca [16 x i8*]
store i32 %0, i32* %2
%4 = bitcast [16 x i8*]* %3 to i8*
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = load i32, i32* @stdout
%9 = call i32 @fputs(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), i32 %8)
br label %37
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp sge i32 %11, 97
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 102
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %2
%18 = sub nsw i32 %17, 87
store i32 %18, i32* %2
br label %30
19: ; preds = %13, %10
%20 = load i32, i32* %2
%21 = icmp sge i32 %20, 48
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp sle i32 %23, 57
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load i32, i32* %2
%27 = sub nsw i32 %26, 48
store i32 %27, i32* %2
br label %29
28: ; preds = %22, %19
br label %37
29: ; preds = %25
br label %30
30: ; preds = %29, %16
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [16 x i8*], [16 x i8*]* %3, i64 0, i64 %32
%34 = load i8*, i8** %33
%35 = load i32, i32* @stdout
%36 = call i32 @fputs(i8* %34, i32 %35)
br label %37
37: ; preds = %28, %30, %7
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"\1B[0;30m\00"
@.str.1 = [8 x i8] c"\1B[0;34m\00"
@.str.2 = [8 x i8] c"\1B[0;32m\00"
@.str.3 = [8 x i8] c"\1B[0;36m\00"
@.str.4 = [8 x i8] c"\1B[0;31m\00"
@.str.5 = [8 x i8] c"\1B[0;35m\00"
@.str.6 = [8 x i8] c"\1B[0;33m\00"
@.str.7 = [8 x i8] c"\1B[0;37m\00"
@.str.8 = [8 x i8] c"\1B[1;30m\00"
@.str.9 = [8 x i8] c"\1B[1;34m\00"
@.str.10 = [8 x i8] c"\1B[1;32m\00"
@.str.11 = [8 x i8] c"\1B[1;36m\00"
@.str.12 = [8 x i8] c"\1B[1;31m\00"
@.str.13 = [8 x i8] c"\1B[1;35m\00"
@.str.14 = [8 x i8] c"\1B[1;33m\00"
@.str.15 = [8 x i8] c"\1B[1;37m\00"
@reltable.print_color = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.1 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.2 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.3 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.4 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.5 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.6 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.7 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.8 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.9 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.10 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.11 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.12 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.13 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.14 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.15 to i64), i64 ptrtoint ([16 x i32]* @reltable.print_color to i64)) to i32)]
@.str.16 = [5 x i8] c"\1B[0m\00"
@stdout = global i32 0
define void @print_color(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = add i32 %0, -97
%5 = icmp ult i32 %4, 6
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = add nsw i32 %0, -87
br label %11
8: ; preds = %3
%9 = add i32 %0, -48
%10 = icmp ult i32 %9, 10
br i1 %10, label %11, label %20
11: ; preds = %8, %6
%12 = phi i32 [ %7, %6 ], [ %9, %8 ]
%13 = zext i32 %12 to i64
%14 = shl i64 %13, 2
%15 = call i8* @llvm.load.relative.i64(i8* bitcast ([16 x i32]* @reltable.print_color to i8*), i64 %14)
br label %16
16: ; preds = %1, %11
%17 = phi i8* [ %15, %11 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.16, i64 0, i64 0), %1 ]
%18 = load i32, i32* @stdout
%19 = tail call i32 @fputs(i8* %17, i32 %18)
br label %20
20: ; preds = %16, %8
ret void
}