#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*/ printf(char *, int, int, ...);
void color(int i, int j) {
  int cl[8] = {30, 31, 32, 33, 34, 35, 36, 37},
      bg[8] = {40, 41, 42, 43, 44, 45, 46, 47};
  if ((i >= 0 && i <= 7) && (j >= 0 && j <= 7)) {
    if (i == 0) {
      if (j == 0) {
        printf("%c[%dm", 27, 0);
      } else {
        printf("%c[%d;%dm", 27, 1, bg[j]);
      }
    } else {
      if (j == 0) {
        printf("%c[%d;%dm", 27, 1, cl[i]);
      } else {
        printf("%c[%d;%d;%dm", 27, 1, cl[i], bg[j]);
      }
    }
  }
}


x86 assembly (clang, -O0):
<color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed2(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xecf(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xecc(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xec9(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xec6(%rip),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1253 <color+0x143>
cmpl   $0x7,-0x4(%rbp)
jg     1253 <color+0x143>
cmpl   $0x0,-0x8(%rbp)
jl     1253 <color+0x143>
cmpl   $0x7,-0x8(%rbp)
jg     1253 <color+0x143>
cmpl   $0x0,-0x4(%rbp)
jne    11f1 <color+0xe1>
cmpl   $0x0,-0x8(%rbp)
jne    11cc <color+0xbc>
lea    0xe87(%rip),%rdi
mov    $0x1b,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <color+0xdc>
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
lea    0xe6c(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <color+0x13e>
cmpl   $0x0,-0x8(%rbp)
jne    1220 <color+0x110>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
lea    0xe3d(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1249 <color+0x139>
movslq -0x4(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%ecx
movslq -0x8(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%r8d
lea    0xe19(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124e <color+0x13e>
jmp    1253 <color+0x143>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<color>:
mov    %esi,%eax
or     %edi,%eax
cmp    $0x7,%eax
ja     1152 <color+0x42>
test   %edi,%edi
je     1153 <color+0x43>
mov    %edi,%eax
lea    0xeda(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
test   %esi,%esi
je     1163 <color+0x53>
mov    %esi,%eax
lea    0xeea(%rip),%rdx
mov    (%rdx,%rax,4),%r8d
lea    0xf10(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>
ret
test   %esi,%esi
je     117b <color+0x6b>
mov    %esi,%eax
lea    0xec0(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
lea    0xedd(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x1b,%esi
xor    %edx,%edx
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@__const.color.cl = [8 x i32] [i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37]
@__const.color.bg = [8 x i32] [i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47]
@.str = [7 x i8] c"%c[%dm\00"
@.str.1 = [10 x i8] c"%c[%d;%dm\00"
@.str.2 = [13 x i8] c"%c[%d;%d;%dm\00"
define void @color(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [8 x i32]
%6 = alloca [8 x i32]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = bitcast [8 x i32]* %5 to i8*
%8 = bitcast [8 x i32]* %6 to i8*
%9 = load i32, i32* %3
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %56
11: ; preds = %2
%12 = load i32, i32* %3
%13 = icmp sle i32 %12, 7
br i1 %13, label %14, label %56
14: ; preds = %11
%15 = load i32, i32* %4
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %56
17: ; preds = %14
%18 = load i32, i32* %4
%19 = icmp sle i32 %18, 7
br i1 %19, label %20, label %56
20: ; preds = %17
%21 = load i32, i32* %3
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %35
23: ; preds = %20
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 27, i32 0)
br label %34
28: ; preds = %23
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 1, i32 %32)
br label %34
34: ; preds = %28, %26
br label %55
35: ; preds = %20
%36 = load i32, i32* %4
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %44
38: ; preds = %35
%39 = load i32, i32* %3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 1, i32 %42)
br label %54
44: ; preds = %35
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [8 x i32], [8 x i32]* %5, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 27, i32 1, i32 %48, i32 %52)
br label %54
54: ; preds = %44, %38
br label %55
55: ; preds = %54, %34
br label %56
56: ; preds = %55, %17, %14, %11, %2
ret void
}

LLVM IR (-O2):
@__const.color.cl = [8 x i32] [i32 30, i32 31, i32 32, i32 33, i32 34, i32 35, i32 36, i32 37]
@__const.color.bg = [8 x i32] [i32 40, i32 41, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47]
@.str = [7 x i8] c"%c[%dm\00"
@.str.1 = [10 x i8] c"%c[%d;%dm\00"
@.str.2 = [13 x i8] c"%c[%d;%d;%dm\00"
define void @color(i32 %0, i32 %1) {
%3 = or i32 %1, %0
%4 = icmp ult i32 %3, 8
br i1 %4, label %5, label %27
5: ; preds = %2
%6 = icmp eq i32 %0, 0
%7 = icmp eq i32 %1, 0
br i1 %6, label %8, label %16
8: ; preds = %5
br i1 %7, label %9, label %11
9: ; preds = %8
%10 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 27, i32 0)
br label %27
11: ; preds = %8
%12 = zext i32 %1 to i64
%13 = getelementptr inbounds [8 x i32], [8 x i32]* @__const.color.bg, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 1, i32 %14)
br label %27
16: ; preds = %5
%17 = zext i32 %0 to i64
%18 = getelementptr inbounds [8 x i32], [8 x i32]* @__const.color.cl, i64 0, i64 %17
%19 = load i32, i32* %18
br i1 %7, label %20, label %22
20: ; preds = %16
%21 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 27, i32 1, i32 %19)
br label %27
22: ; preds = %16
%23 = zext i32 %1 to i64
%24 = getelementptr inbounds [8 x i32], [8 x i32]* @__const.color.bg, i64 0, i64 %23
%25 = load i32, i32* %24
%26 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 27, i32 1, i32 %19, i32 %25)
br label %27
27: ; preds = %11, %9, %22, %20, %2
ret void
}