#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 rangecolor(int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
void numbertocolor(int n, char *s) {
  int red, blue, green;
  if (n < 0)
    n = 0;
  red = n / 100;
  blue = ((n / 10) % 10);
  green = n % 10;
  sprintf(s, "#%2.2x%2.2x%2.2x", rangecolor(red), rangecolor(blue),
          rangecolor(green));
}


x86 assembly (clang, -O0):
<numbertocolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1140 <numbertocolor+0x20>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <rangecolor@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <rangecolor@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%edi
call   1030 <rangecolor@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    %eax,%r8d
lea    0xe54(%rip),%rsi
call   1040 <sprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numbertocolor>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
xor    %eax,%eax
test   %edi,%edi
cmovs  %eax,%ebx
imul   $0x51eb851f,%rbx,%rdi
shr    $0x25,%rdi
mov    $0xcccccccd,%eax
mov    %rbx,%rcx
imul   %rax,%rcx
shr    $0x23,%rcx
imul   %rcx,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %ecx,%ebp
sub    %eax,%ebp
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
sub    %eax,%ebx
call   1030 <rangecolor@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1030 <rangecolor@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <rangecolor@plt>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %eax,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <sprintf@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"#%2.2x%2.2x%2.2x\00"
define void @numbertocolor(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %11
11: ; preds = %10, %2
%12 = load i32, i32* %3
%13 = sdiv i32 %12, 100
store i32 %13, i32* %5
%14 = load i32, i32* %3
%15 = sdiv i32 %14, 10
%16 = srem i32 %15, 10
store i32 %16, i32* %6
%17 = load i32, i32* %3
%18 = srem i32 %17, 10
store i32 %18, i32* %7
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = call i32 @rangecolor(i32 %20)
%22 = load i32, i32* %6
%23 = call i32 @rangecolor(i32 %22)
%24 = load i32, i32* %7
%25 = call i32 @rangecolor(i32 %24)
%26 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23, i32 %25)
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"#%2.2x%2.2x%2.2x\00"
define void @numbertocolor(i32 %0, i8* nocapture writeonly %1) {
%3 = icmp sgt i32 %0, 0
%4 = select i1 %3, i32 %0, i32 0
%5 = udiv i32 %4, 100
%6 = udiv i32 %4, 10
%7 = urem i32 %6, 10
%8 = urem i32 %4, 10
%9 = tail call i32 @rangecolor(i32 %5)
%10 = tail call i32 @rangecolor(i32 %7)
%11 = tail call i32 @rangecolor(i32 %8)
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i32 %11)
ret void
}