#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, void const *);
void printColor(const void *ptr) {
  int color;
  if (ptr == NULL)
    color = 0;
  else
    color = *(const int *)ptr % 15;
  if (color == 0)
    color = 0;
  else if (color == 1)
    color = 7;
  else if (color < 8)
    color = 31 + color - 2;
  else
    color = 41 + color - 8;
  printf("\x1B[%dm%p\x1B[0m ", color, ptr);
}


x86 assembly (clang, -O0):
<printColor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1133 <printColor+0x23>
movl   $0x0,-0xc(%rbp)
jmp    1144 <printColor+0x34>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    $0xf,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    115a <printColor+0x4a>
movl   $0x0,-0xc(%rbp)
jmp    11a1 <printColor+0x91>
cmpl   $0x1,-0xc(%rbp)
jne    1170 <printColor+0x60>
movl   $0x7,-0xc(%rbp)
jmp    119c <printColor+0x8c>
cmpl   $0x8,-0xc(%rbp)
jge    118b <printColor+0x7b>
mov    -0xc(%rbp),%eax
add    $0x1f,%eax
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1197 <printColor+0x87>
mov    -0xc(%rbp),%eax
add    $0x29,%eax
sub    $0x8,%eax
mov    %eax,-0xc(%rbp)
jmp    119c <printColor+0x8c>
jmp    11a1 <printColor+0x91>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%rdx
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printColor>:
mov    %rdi,%rdx
test   %rdi,%rdi
je     1152 <printColor+0x42>
movslq (%rdx),%rsi
imul   $0xffffffff88888889,%rsi,%rax
shr    $0x20,%rax
add    %esi,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
sar    $0x3,%eax
add    %ecx,%eax
lea    (%rax,%rax,4),%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%esi
je     1146 <printColor+0x36>
cmp    $0x1,%esi
jne    1160 <printColor+0x50>
mov    $0x7,%esi
lea    0xeb3(%rip),%rdi
jmp    1030 <printf@plt>
xor    %esi,%esi
lea    0xea5(%rip),%rdi
jmp    1030 <printf@plt>
cmp    $0x7,%esi
jg     1174 <printColor+0x64>
add    $0x1d,%esi
lea    0xe91(%rip),%rdi
jmp    1030 <printf@plt>
add    $0x21,%esi
lea    0xe82(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"\1B[%dm%p\1B[0m \00"
define void @printColor(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %3
br label %12
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = srem i32 %10, 15
store i32 %11, i32* %3
br label %12
12: ; preds = %7, %6
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %3
br label %33
16: ; preds = %12
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 7, i32* %3
br label %32
20: ; preds = %16
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 8
br i1 %22, label %23, label %27
23: ; preds = %20
%24 = load i32, i32* %3
%25 = add nsw i32 31, %24
%26 = sub nsw i32 %25, 2
store i32 %26, i32* %3
br label %31
27: ; preds = %20
%28 = load i32, i32* %3
%29 = add nsw i32 41, %28
%30 = sub nsw i32 %29, 8
store i32 %30, i32* %3
br label %31
31: ; preds = %27, %23
br label %32
32: ; preds = %31, %19
br label %33
33: ; preds = %32, %15
%34 = load i32, i32* %3
%35 = load i8*, i8** %2
%36 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %34, i8* %35)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\1B[%dm%p\1B[0m \00"
define void @printColor(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %14, label %3
3: ; preds = %1
%4 = bitcast i8* %0 to i32*
%5 = load i32, i32* %4
%6 = srem i32 %5, 15
switch i32 %6, label %8 [
i32 0, label %14
i32 1, label %7
]
7: ; preds = %3
br label %14
8: ; preds = %3
%9 = icmp slt i32 %6, 8
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = add nsw i32 %6, 29
br label %14
12: ; preds = %8
%13 = add nuw nsw i32 %6, 33
br label %14
14: ; preds = %1, %3, %7, %12, %10
%15 = phi i32 [ 7, %7 ], [ %11, %10 ], [ %13, %12 ], [ %6, %3 ], [ 0, %1 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %15, i8* %0)
ret void
}