#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 *, unsigned int, unsigned int, unsigned int);
void print_color(unsigned short c, unsigned short c2) {
  unsigned int r, g, b, level;
  r = ((c >> 11) & 0x1f) << 3;
  g = ((c >> 5) & 0x3f) << 2;
  b = (c & 0x1f) << 3;
  printf("\033[48;2;%d;%d;%d;", r, g, b);
  r = ((c2 >> 11) & 0x1f) << 3;
  g = ((c2 >> 5) & 0x3f) << 2;
  b = (c2 & 0x1f) << 3;
  printf("38;2;%d;%d;%dm\xe2\x96\x84", r, g, b);
}


x86 assembly (clang, -O0):
<print_color>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
movzwl -0x2(%rbp),%eax
sar    $0xb,%eax
and    $0x1f,%eax
shl    $0x3,%eax
mov    %eax,-0x8(%rbp)
movzwl -0x2(%rbp),%eax
sar    $0x5,%eax
and    $0x3f,%eax
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
movzwl -0x2(%rbp),%eax
and    $0x1f,%eax
shl    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
movzwl -0x4(%rbp),%eax
sar    $0xb,%eax
and    $0x1f,%eax
shl    $0x3,%eax
mov    %eax,-0x8(%rbp)
movzwl -0x4(%rbp),%eax
sar    $0x5,%eax
and    $0x3f,%eax
shl    $0x2,%eax
mov    %eax,-0xc(%rbp)
movzwl -0x4(%rbp),%eax
and    $0x1f,%eax
shl    $0x3,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_color>:
push   %rbx
mov    %esi,%ebx
mov    %edi,%esi
shr    $0x8,%esi
and    $0xfffffff8,%esi
mov    %edi,%edx
shr    $0x3,%edx
and    $0xfc,%edx
shl    $0x3,%edi
movzbl %dil,%ecx
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%esi
shr    $0x8,%esi
and    $0xfffffff8,%esi
mov    %ebx,%edx
shr    $0x3,%edx
and    $0xfc,%edx
shl    $0x3,%ebx
movzbl %bl,%ecx
lea    0xeb8(%rip),%rdi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"\1B[48;2;%d;%d;%d;\00"
@.str.1 = [18 x i8] c"38;2;%d;%d;%dm\E2\96\84\00"
define void @print_color(i16 zeroext %0, i16 zeroext %1) {
%3 = alloca i16
%4 = alloca i16
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i16 %0, i16* %3
store i16 %1, i16* %4
%9 = load i16, i16* %3
%10 = zext i16 %9 to i32
%11 = ashr i32 %10, 11
%12 = and i32 %11, 31
%13 = shl i32 %12, 3
store i32 %13, i32* %5
%14 = load i16, i16* %3
%15 = zext i16 %14 to i32
%16 = ashr i32 %15, 5
%17 = and i32 %16, 63
%18 = shl i32 %17, 2
store i32 %18, i32* %6
%19 = load i16, i16* %3
%20 = zext i16 %19 to i32
%21 = and i32 %20, 31
%22 = shl i32 %21, 3
store i32 %22, i32* %7
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %23, i32 %24, i32 %25)
%27 = load i16, i16* %4
%28 = zext i16 %27 to i32
%29 = ashr i32 %28, 11
%30 = and i32 %29, 31
%31 = shl i32 %30, 3
store i32 %31, i32* %5
%32 = load i16, i16* %4
%33 = zext i16 %32 to i32
%34 = ashr i32 %33, 5
%35 = and i32 %34, 63
%36 = shl i32 %35, 2
store i32 %36, i32* %6
%37 = load i16, i16* %4
%38 = zext i16 %37 to i32
%39 = and i32 %38, 31
%40 = shl i32 %39, 3
store i32 %40, i32* %7
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %41, i32 %42, i32 %43)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"\1B[48;2;%d;%d;%d;\00"
@.str.1 = [18 x i8] c"38;2;%d;%d;%dm\E2\96\84\00"
define void @print_color(i16 zeroext %0, i16 zeroext %1) {
%3 = zext i16 %0 to i32
%4 = lshr i32 %3, 8
%5 = and i32 %4, 248
%6 = lshr i32 %3, 3
%7 = and i32 %6, 252
%8 = shl nuw nsw i32 %3, 3
%9 = and i32 %8, 248
%10 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %5, i32 %7, i32 %9)
%11 = zext i16 %1 to i32
%12 = lshr i32 %11, 8
%13 = and i32 %12, 248
%14 = lshr i32 %11, 3
%15 = and i32 %14, 252
%16 = shl nuw nsw i32 %11, 3
%17 = and i32 %16, 248
%18 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %15, i32 %17)
ret void
}