#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*/ init_color(int, unsigned short, unsigned short,
                              unsigned short);
unsigned short round(unsigned int);
void mkcolor(int n, unsigned color) {
  float scale = 1000.0 / 256.0;
  unsigned short r = round((((color) >> 16) & 0xFF) * scale);
  unsigned short g = round((((color) >> 8) & 0xFF) * scale);
  unsigned short b = round((((color) >> 0) & 0xFF) * scale);
  init_color(n, r, g, b);
}


x86 assembly (clang, -O0):
<mkcolor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x407a0000,-0xc(%rbp)
movzbl -0x6(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %eax,%edi
call   1040 <round@plt>
mov    %ax,-0xe(%rbp)
movzbl -0x7(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %eax,%edi
call   1040 <round@plt>
mov    %ax,-0x10(%rbp)
movzbl -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%rax
mov    %eax,%edi
call   1040 <round@plt>
mov    %ax,-0x12(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xe(%rbp),%cx
mov    -0x10(%rbp),%ax
movzwl %cx,%esi
movzwl %ax,%edx
movzwl -0x12(%rbp),%ecx
call   1030 <init_color@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mkcolor>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebx
mov    %edi,%r14d
mov    %esi,%eax
shr    $0x10,%eax
movzbl %al,%eax
cvtsi2ss %eax,%xmm0
mulss  0xec3(%rip),%xmm0
cvttss2si %xmm0,%rdi
call   1040 <round@plt>
movzbl %bh,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mov    %eax,%ebp
mulss  0xea5(%rip),%xmm0
cvttss2si %xmm0,%rdi
call   1040 <round@plt>
movzbl %bl,%ecx
xorps  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm0
mov    %eax,%ebx
mulss  0xe87(%rip),%xmm0
cvttss2si %xmm0,%rdi
call   1040 <round@plt>
movzwl %bp,%esi
movzwl %bx,%edx
movzwl %ax,%ecx
mov    %r14d,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <init_color@plt>

LLVM IR (-O0):
define void @mkcolor(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i32 %0, i32* %3
store i32 %1, i32* %4
store float 3.906250e+00, float* %5
%9 = load i32, i32* %4
%10 = lshr i32 %9, 16
%11 = and i32 %10, 255
%12 = uitofp i32 %11 to float
%13 = load float, float* %5
%14 = fmul float %12, %13
%15 = fptoui float %14 to i32
%16 = call zeroext i16 @round(i32 %15)
store i16 %16, i16* %6
%17 = load i32, i32* %4
%18 = lshr i32 %17, 8
%19 = and i32 %18, 255
%20 = uitofp i32 %19 to float
%21 = load float, float* %5
%22 = fmul float %20, %21
%23 = fptoui float %22 to i32
%24 = call zeroext i16 @round(i32 %23)
store i16 %24, i16* %7
%25 = load i32, i32* %4
%26 = lshr i32 %25, 0
%27 = and i32 %26, 255
%28 = uitofp i32 %27 to float
%29 = load float, float* %5
%30 = fmul float %28, %29
%31 = fptoui float %30 to i32
%32 = call zeroext i16 @round(i32 %31)
store i16 %32, i16* %8
%33 = load i32, i32* %3
%34 = load i16, i16* %6
%35 = load i16, i16* %7
%36 = load i16, i16* %8
%37 = call i32 @init_color(i32 %33, i16 zeroext %34, i16 zeroext %35, i16 zeroext %36)
ret void
}

LLVM IR (-O2):
define void @mkcolor(i32 %0, i32 %1) {
%3 = lshr i32 %1, 16
%4 = and i32 %3, 255
%5 = uitofp i32 %4 to float
%6 = fmul float %5, 3.906250e+00
%7 = fptoui float %6 to i32
%8 = tail call zeroext i16 @round(i32 %7)
%9 = lshr i32 %1, 8
%10 = and i32 %9, 255
%11 = uitofp i32 %10 to float
%12 = fmul float %11, 3.906250e+00
%13 = fptoui float %12 to i32
%14 = tail call zeroext i16 @round(i32 %13)
%15 = and i32 %1, 255
%16 = uitofp i32 %15 to float
%17 = fmul float %16, 3.906250e+00
%18 = fptoui float %17 to i32
%19 = tail call zeroext i16 @round(i32 %18)
%20 = tail call i32 @init_color(i32 %0, i16 zeroext %8, i16 zeroext %14, i16 zeroext %19)
ret void
}