#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*/ HlsToRgb(float, float, float, int *, int *, int *);
int /*<<< orphan*/ RgbToHls(int, int, int, float *, float *, float *);
int /*<<< orphan*/ printf(char *, float, float, float);
int ColourBlend(int base, int top) {
  int result;
  float hue, lumination, saturation;
  int red = ((top >> 16) & 0xff), green = ((top >> 8) & 0xff),
      blue = (top & 0xff);
  RgbToHls(red, green, blue, &hue, &lumination, &saturation);
  printf("+++ %3.0f %3.0f %3.0f\n", hue * 255, saturation * 255,
         lumination * 255);
  lumination = (((base >> 16) & 0xff) * 0.3 + ((base >> 8) & 0xff) * 0.59 +
                (base & 0xff) * 0.11) /
               255.f;
  HlsToRgb(hue, lumination, saturation, &red, &green, &blue);
  result = ((red << 16) + (green << 8) + blue);
  return result;
}


x86 assembly (clang, -O0):
<ColourBlend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r8
lea    -0x18(%rbp),%r9
call   1050 <RgbToHls@plt>
movss  0xe99(%rip),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  0xe8c(%rip),%xmm1
mulss  -0x18(%rbp),%xmm1
movss  0xe7f(%rip),%xmm2
mulss  -0x14(%rbp),%xmm2
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm1
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe40(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe2c(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe08(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf0(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
movss  -0x14(%rbp),%xmm1
movss  -0x18(%rbp),%xmm2
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1040 <HlsToRgb@plt>
mov    -0x1c(%rbp),%eax
shl    $0x10,%eax
mov    -0x20(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ColourBlend>:
push   %rbx
sub    $0x20,%rsp
mov    %esi,%eax
mov    %edi,%ebx
movzbl %ah,%esi
movzbl %al,%edx
shr    $0x10,%eax
movzbl %al,%edi
mov    %edi,0x10(%rsp)
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
lea    0x1c(%rsp),%rcx
lea    0x18(%rsp),%r8
lea    0x14(%rsp),%r9
call   1050 <RgbToHls@plt>
movss  0xe93(%rip),%xmm2
movss  0x1c(%rsp),%xmm0
mulss  %xmm2,%xmm0
movss  0x14(%rsp),%xmm1
mulss  %xmm2,%xmm1
mulss  0x18(%rsp),%xmm2
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movzbl %bh,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe54(%rip),%xmm1
mulsd  0xe54(%rip),%xmm0
movzbl %bl,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
addsd  %xmm1,%xmm0
mulsd  0xe46(%rip),%xmm2
addsd  %xmm0,%xmm2
divsd  0xe42(%rip),%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movss  %xmm1,0x18(%rsp)
movss  0x1c(%rsp),%xmm0
movss  0x14(%rsp),%xmm2
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1040 <HlsToRgb@plt>
mov    0x10(%rsp),%ecx
shl    $0x10,%ecx
mov    0xc(%rsp),%eax
shl    $0x8,%eax
add    %ecx,%eax
add    0x8(%rsp),%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [23 x i8] c"+++ %3.0f %3.0f %3.0f\0A\00"
define i32 @ColourBlend(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%12 = load i32, i32* %4
%13 = ashr i32 %12, 16
%14 = and i32 %13, 255
store i32 %14, i32* %9
%15 = load i32, i32* %4
%16 = ashr i32 %15, 8
%17 = and i32 %16, 255
store i32 %17, i32* %10
%18 = load i32, i32* %4
%19 = and i32 %18, 255
store i32 %19, i32* %11
%20 = load i32, i32* %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = call i32 @RgbToHls(i32 %20, i32 %21, i32 %22, float* %6, float* %7, float* %8)
%24 = load float, float* %6
%25 = fmul float %24, 2.550000e+02
%26 = load float, float* %8
%27 = fmul float %26, 2.550000e+02
%28 = load float, float* %7
%29 = fmul float %28, 2.550000e+02
%30 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %25, float %27, float %29)
%31 = load i32, i32* %3
%32 = ashr i32 %31, 16
%33 = and i32 %32, 255
%34 = sitofp i32 %33 to double
%35 = load i32, i32* %3
%36 = ashr i32 %35, 8
%37 = and i32 %36, 255
%38 = sitofp i32 %37 to double
%39 = fmul double %38, 5.900000e-01
%40 = call double @llvm.fmuladd.f64(double %34, double 3.000000e-01, double %39)
%41 = load i32, i32* %3
%42 = and i32 %41, 255
%43 = sitofp i32 %42 to double
%44 = call double @llvm.fmuladd.f64(double %43, double 1.100000e-01, double %40)
%45 = fdiv double %44, 2.550000e+02
%46 = fptrunc double %45 to float
store float %46, float* %7
%47 = load float, float* %6
%48 = load float, float* %7
%49 = load float, float* %8
%50 = call i32 @HlsToRgb(float %47, float %48, float %49, i32* %9, i32* %10, i32* %11)
%51 = load i32, i32* %9
%52 = shl i32 %51, 16
%53 = load i32, i32* %10
%54 = shl i32 %53, 8
%55 = add nsw i32 %52, %54
%56 = load i32, i32* %11
%57 = add nsw i32 %55, %56
store i32 %57, i32* %5
%58 = load i32, i32* %5
ret i32 %58
}

LLVM IR (-O2):
@.str = [23 x i8] c"+++ %3.0f %3.0f %3.0f\0A\00"
define i32 @ColourBlend(i32 %0, i32 %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = bitcast float* %3 to i8*
%10 = bitcast float* %4 to i8*
%11 = bitcast float* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = lshr i32 %1, 16
%14 = and i32 %13, 255
store i32 %14, i32* %6
%15 = bitcast i32* %7 to i8*
%16 = lshr i32 %1, 8
%17 = and i32 %16, 255
store i32 %17, i32* %7
%18 = bitcast i32* %8 to i8*
%19 = and i32 %1, 255
store i32 %19, i32* %8
%20 = call i32 @RgbToHls(i32 %14, i32 %17, i32 %19, float* %3, float* %4, float* %5)
%21 = load float, float* %3
%22 = fmul float %21, 2.550000e+02
%23 = load float, float* %5
%24 = fmul float %23, 2.550000e+02
%25 = load float, float* %4
%26 = fmul float %25, 2.550000e+02
%27 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), float %22, float %24, float %26)
%28 = lshr i32 %0, 16
%29 = and i32 %28, 255
%30 = sitofp i32 %29 to double
%31 = lshr i32 %0, 8
%32 = and i32 %31, 255
%33 = sitofp i32 %32 to double
%34 = fmul double %33, 5.900000e-01
%35 = call double @llvm.fmuladd.f64(double %30, double 3.000000e-01, double %34)
%36 = and i32 %0, 255
%37 = sitofp i32 %36 to double
%38 = call double @llvm.fmuladd.f64(double %37, double 1.100000e-01, double %35)
%39 = fdiv double %38, 2.550000e+02
%40 = fptrunc double %39 to float
store float %40, float* %4
%41 = load float, float* %3
%42 = load float, float* %5
%43 = call i32 @HlsToRgb(float %41, float %40, float %42, i32* %6, i32* %7, i32* %8)
%44 = load i32, i32* %6
%45 = shl i32 %44, 16
%46 = load i32, i32* %7
%47 = shl i32 %46, 8
%48 = add nsw i32 %47, %45
%49 = load i32, i32* %8
%50 = add nsw i32 %48, %49
ret i32 %50
}