#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*/ hsl2rgb(int *, int *, int *);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ rgb2hsl(int *, int *, int *);
int blend_color(int base, int top) {
  int result;
  float hue, lumination, saturation;
  int red = ((top >> 16) & 0xff), green = ((top >> 8) & 0xff),
      blue = (top & 0xff);
  rgb2hsl(&red, &green, &blue);
  printf("--- %3i %3i %3i\n", red, green, blue);
  blue = (((base >> 16) & 0xff) * 0.3 + ((base >> 8) & 0xff) * 0.59 +
          (base & 0xff) * 0.11);
  hsl2rgb(&red, &green, &blue);
  result = ((red << 16) + (green << 8) + blue);
  return result;
}


x86 assembly (clang, -O0):
<blend_color>:
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)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <rgb2hsl@plt>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe92(%rip),%rdi
call   1040 <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  0xe5f(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xe4b(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe27(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x24(%rbp)
lea    -0x1c(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
call   1030 <hsl2rgb@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):
<blend_color>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%eax
mov    %edi,%ebx
movzbl %ah,%ecx
movzbl %al,%edx
shr    $0x10,%eax
movzbl %al,%eax
mov    %eax,0x14(%rsp)
mov    %ecx,0x10(%rsp)
mov    %edx,0xc(%rsp)
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r14
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1050 <rgb2hsl@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%eax
cvtsi2sd %eax,%xmm0
movzbl %bh,%eax
cvtsi2sd %eax,%xmm1
mulsd  0xe59(%rip),%xmm1
mulsd  0xe59(%rip),%xmm0
addsd  %xmm1,%xmm0
movzbl %bl,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe4b(%rip),%xmm1
addsd  %xmm0,%xmm1
cvttsd2si %xmm1,%eax
mov    %eax,0xc(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <hsl2rgb@plt>
mov    0x14(%rsp),%ecx
shl    $0x10,%ecx
mov    0x10(%rsp),%eax
shl    $0x8,%eax
add    %ecx,%eax
add    0xc(%rsp),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"--- %3i %3i %3i\0A\00"
define i32 @blend_color(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 = call i32 @rgb2hsl(i32* %9, i32* %10, i32* %11)
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load i32, i32* %11
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %3
%26 = ashr i32 %25, 16
%27 = and i32 %26, 255
%28 = sitofp i32 %27 to double
%29 = load i32, i32* %3
%30 = ashr i32 %29, 8
%31 = and i32 %30, 255
%32 = sitofp i32 %31 to double
%33 = fmul double %32, 5.900000e-01
%34 = call double @llvm.fmuladd.f64(double %28, double 3.000000e-01, double %33)
%35 = load i32, i32* %3
%36 = and i32 %35, 255
%37 = sitofp i32 %36 to double
%38 = call double @llvm.fmuladd.f64(double %37, double 1.100000e-01, double %34)
%39 = fptosi double %38 to i32
store i32 %39, i32* %11
%40 = call i32 @hsl2rgb(i32* %9, i32* %10, i32* %11)
%41 = load i32, i32* %9
%42 = shl i32 %41, 16
%43 = load i32, i32* %10
%44 = shl i32 %43, 8
%45 = add nsw i32 %42, %44
%46 = load i32, i32* %11
%47 = add nsw i32 %45, %46
store i32 %47, i32* %5
%48 = load i32, i32* %5
ret i32 %48
}

LLVM IR (-O2):
@.str = [17 x i8] c"--- %3i %3i %3i\0A\00"
define i32 @blend_color(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = lshr i32 %1, 16
%8 = and i32 %7, 255
store i32 %8, i32* %3
%9 = bitcast i32* %4 to i8*
%10 = lshr i32 %1, 8
%11 = and i32 %10, 255
store i32 %11, i32* %4
%12 = bitcast i32* %5 to i8*
%13 = and i32 %1, 255
store i32 %13, i32* %5
%14 = call i32 @rgb2hsl(i32* %3, i32* %4, i32* %5)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
%19 = lshr i32 %0, 16
%20 = and i32 %19, 255
%21 = sitofp i32 %20 to double
%22 = lshr i32 %0, 8
%23 = and i32 %22, 255
%24 = sitofp i32 %23 to double
%25 = fmul double %24, 5.900000e-01
%26 = call double @llvm.fmuladd.f64(double %21, double 3.000000e-01, double %25)
%27 = and i32 %0, 255
%28 = sitofp i32 %27 to double
%29 = call double @llvm.fmuladd.f64(double %28, double 1.100000e-01, double %26)
%30 = fptosi double %29 to i32
store i32 %30, i32* %5
%31 = call i32 @hsl2rgb(i32* %3, i32* %4, i32* %5)
%32 = load i32, i32* %3
%33 = shl i32 %32, 16
%34 = load i32, i32* %4
%35 = shl i32 %34, 8
%36 = add nsw i32 %35, %33
%37 = load i32, i32* %5
%38 = add nsw i32 %36, %37
ret i32 %38
}