#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 char_color(int);
int /*<<< orphan*/ printf(char *, int);
int rubix_color(int);
void printf_colored(int side) {
  switch (rubix_color(side)) {
  case 5:
    printf("\x1b[43m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  case 0:
    printf("\x1b[47m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  case 1:
    printf("\x1b[41m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  case 2:
    printf("\x1b[44m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  case 3:
    printf("\x1b[45m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  case 4:
    printf("\x1b[42m"
           "%2c "
           "\x1b[0m",
           char_color(side));
    break;
  }
}


x86 assembly (clang, -O0):
<printf_colored>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <rubix_color@plt>
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x5,%eax
ja     1203 <printf_colored+0xd3>
mov    -0x10(%rbp),%rax
lea    0xea3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printf_colored+0xd3>
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printf_colored+0xd3>
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printf_colored+0xd3>
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printf_colored+0xd3>
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xe6d(%rip),%rdi
call   1040 <printf@plt>
jmp    1203 <printf_colored+0xd3>
mov    -0x4(%rbp),%edi
call   1050 <char_color@plt>
mov    %eax,%esi
lea    0xe60(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printf_colored>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
call   1030 <rubix_color@plt>
cmp    $0x5,%eax
ja     1168 <printf_colored+0x38>
cltq
lea    0xf0b(%rip),%rcx
movslq (%rcx,%rax,4),%r14
add    %rcx,%r14
mov    %ebx,%edi
call   1050 <char_color@plt>
mov    %r14,%rdi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"\1B[43m%2c \1B[0m\00"
@.str.1 = [14 x i8] c"\1B[47m%2c \1B[0m\00"
@.str.2 = [14 x i8] c"\1B[41m%2c \1B[0m\00"
@.str.3 = [14 x i8] c"\1B[44m%2c \1B[0m\00"
@.str.4 = [14 x i8] c"\1B[45m%2c \1B[0m\00"
@.str.5 = [14 x i8] c"\1B[42m%2c \1B[0m\00"
define void @printf_colored(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 @rubix_color(i32 %3)
switch i32 %4, label %29 [
i32 5, label %5
i32 0, label %9
i32 1, label %13
i32 2, label %17
i32 3, label %21
i32 4, label %25
]
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 @char_color(i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %29
9: ; preds = %1
%10 = load i32, i32* %2
%11 = call i32 @char_color(i32 %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %29
13: ; preds = %1
%14 = load i32, i32* %2
%15 = call i32 @char_color(i32 %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %29
17: ; preds = %1
%18 = load i32, i32* %2
%19 = call i32 @char_color(i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %29
21: ; preds = %1
%22 = load i32, i32* %2
%23 = call i32 @char_color(i32 %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i32 %23)
br label %29
25: ; preds = %1
%26 = load i32, i32* %2
%27 = call i32 @char_color(i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %1, %25, %21, %17, %13, %9, %5
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"\1B[43m%2c \1B[0m\00"
@.str.1 = [14 x i8] c"\1B[47m%2c \1B[0m\00"
@.str.2 = [14 x i8] c"\1B[41m%2c \1B[0m\00"
@.str.3 = [14 x i8] c"\1B[44m%2c \1B[0m\00"
@.str.4 = [14 x i8] c"\1B[45m%2c \1B[0m\00"
@.str.5 = [14 x i8] c"\1B[42m%2c \1B[0m\00"
@reltable.printf_colored = [6 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.1 to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.2 to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.3 to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.4 to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str.5 to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str to i64), i64 ptrtoint ([6 x i32]* @reltable.printf_colored to i64)) to i32)]
define void @printf_colored(i32 %0) {
%2 = tail call i32 @rubix_color(i32 %0)
%3 = icmp ult i32 %2, 6
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = sext i32 %2 to i64
%6 = shl i64 %5, 2
%7 = call i8* @llvm.load.relative.i64(i8* bitcast ([6 x i32]* @reltable.printf_colored to i8*), i64 %6)
%8 = tail call i32 @char_color(i32 %0)
%9 = tail call i32 @printf(i8* %7, i32 %8)
br label %10
10: ; preds = %1, %4
ret void
}