#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 Clip_Color(int);
int Set_Lum(int base, int top) {
  int d = (((base >> 16) & 0xff) * 0.3 + ((base >> 8) & 0xff) * 0.59 +
           (base & 0xff) * 0.11) -
          (((top >> 16) & 0xff) * 0.3 + ((top >> 8) & 0xff) * 0.59 +
           (top & 0xff) * 0.11);
  int red = ((top >> 16) & 0xff), green = ((top >> 8) & 0xff),
      blue = (top & 0xff);
  red += d;
  green += d;
  blue += d;
  return Clip_Color(((red << 16) + (green << 8) + blue));
}


x86 assembly (clang, -O0):
<Set_Lum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
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  0xecc(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xeb8(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe94(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm2
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe76(%rip),%xmm3
mulsd  %xmm3,%xmm1
movsd  0xe62(%rip),%xmm3
mulsd  %xmm3,%xmm2
addsd  %xmm1,%xmm2
mov    -0x8(%rbp),%eax
and    $0xff,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe3e(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
shl    $0x10,%edi
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
add    %eax,%edi
add    -0x18(%rbp),%edi
call   1030 <Clip_Color@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Set_Lum>:
movd   %esi,%xmm1
movd   %edi,%xmm0
punpckldq %xmm1,%xmm0
movdqa %xmm0,%xmm1
psrld  $0x10,%xmm1
movdqa 0xed3(%rip),%xmm2
pand   %xmm2,%xmm1
cvtdq2pd %xmm1,%xmm3
movdqa %xmm0,%xmm4
psrld  $0x8,%xmm4
pand   %xmm2,%xmm4
cvtdq2pd %xmm4,%xmm5
mulpd  0xec2(%rip),%xmm5
mulpd  0xeca(%rip),%xmm3
addpd  %xmm5,%xmm3
pand   %xmm2,%xmm0
cvtdq2pd %xmm0,%xmm2
mulpd  0xec6(%rip),%xmm2
addpd  %xmm3,%xmm2
movapd %xmm2,%xmm3
unpckhpd %xmm2,%xmm3
subsd  %xmm3,%xmm2
cvttsd2si %xmm2,%eax
pshufd $0x55,%xmm1,%xmm1
movd   %xmm1,%ecx
add    %eax,%ecx
pshufd $0x55,%xmm4,%xmm1
movd   %xmm1,%edx
add    %eax,%edx
shl    $0x10,%ecx
shl    $0x8,%edx
pshufd $0x55,%xmm0,%xmm0
movd   %xmm0,%edi
add    %eax,%edi
add    %edx,%edi
add    %ecx,%edi
jmp    1030 <Clip_Color@plt>

LLVM IR (-O0):
define i32 @Set_Lum(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%9 = load i32, i32* %3
%10 = ashr i32 %9, 16
%11 = and i32 %10, 255
%12 = sitofp i32 %11 to double
%13 = load i32, i32* %3
%14 = ashr i32 %13, 8
%15 = and i32 %14, 255
%16 = sitofp i32 %15 to double
%17 = fmul double %16, 5.900000e-01
%18 = call double @llvm.fmuladd.f64(double %12, double 3.000000e-01, double %17)
%19 = load i32, i32* %3
%20 = and i32 %19, 255
%21 = sitofp i32 %20 to double
%22 = call double @llvm.fmuladd.f64(double %21, double 1.100000e-01, double %18)
%23 = load i32, i32* %4
%24 = ashr i32 %23, 16
%25 = and i32 %24, 255
%26 = sitofp i32 %25 to double
%27 = load i32, i32* %4
%28 = ashr i32 %27, 8
%29 = and i32 %28, 255
%30 = sitofp i32 %29 to double
%31 = fmul double %30, 5.900000e-01
%32 = call double @llvm.fmuladd.f64(double %26, double 3.000000e-01, double %31)
%33 = load i32, i32* %4
%34 = and i32 %33, 255
%35 = sitofp i32 %34 to double
%36 = call double @llvm.fmuladd.f64(double %35, double 1.100000e-01, double %32)
%37 = fsub double %22, %36
%38 = fptosi double %37 to i32
store i32 %38, i32* %5
%39 = load i32, i32* %4
%40 = ashr i32 %39, 16
%41 = and i32 %40, 255
store i32 %41, i32* %6
%42 = load i32, i32* %4
%43 = ashr i32 %42, 8
%44 = and i32 %43, 255
store i32 %44, i32* %7
%45 = load i32, i32* %4
%46 = and i32 %45, 255
store i32 %46, i32* %8
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = add nsw i32 %48, %47
store i32 %49, i32* %6
%50 = load i32, i32* %5
%51 = load i32, i32* %7
%52 = add nsw i32 %51, %50
store i32 %52, i32* %7
%53 = load i32, i32* %5
%54 = load i32, i32* %8
%55 = add nsw i32 %54, %53
store i32 %55, i32* %8
%56 = load i32, i32* %6
%57 = shl i32 %56, 16
%58 = load i32, i32* %7
%59 = shl i32 %58, 8
%60 = add nsw i32 %57, %59
%61 = load i32, i32* %8
%62 = add nsw i32 %60, %61
%63 = call i32 @Clip_Color(i32 %62)
ret i32 %63
}

LLVM IR (-O2):
define i32 @Set_Lum(i32 %0, i32 %1) {
%3 = insertelement <2 x i32> poison, i32 %0, i64 0
%4 = insertelement <2 x i32> %3, i32 %1, i64 1
%5 = lshr <2 x i32> %4, <i32 16, i32 16>
%6 = and <2 x i32> %5, <i32 255, i32 255>
%7 = sitofp <2 x i32> %6 to <2 x double>
%8 = lshr <2 x i32> %4, <i32 8, i32 8>
%9 = and <2 x i32> %8, <i32 255, i32 255>
%10 = sitofp <2 x i32> %9 to <2 x double>
%11 = fmul <2 x double> %10, <double 5.900000e-01, double 5.900000e-01>
%12 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %7, <2 x double> <double 3.000000e-01, double 3.000000e-01>, <2 x double> %11)
%13 = and <2 x i32> %4, <i32 255, i32 255>
%14 = sitofp <2 x i32> %13 to <2 x double>
%15 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %14, <2 x double> <double 1.100000e-01, double 1.100000e-01>, <2 x double> %12)
%16 = shufflevector <2 x double> %15, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%17 = fsub <2 x double> %15, %16
%18 = extractelement <2 x double> %17, i64 0
%19 = fptosi double %18 to i32
%20 = extractelement <2 x i32> %6, i64 1
%21 = add nsw i32 %20, %19
%22 = extractelement <2 x i32> %9, i64 1
%23 = add nsw i32 %22, %19
%24 = shl i32 %21, 16
%25 = shl i32 %23, 8
%26 = extractelement <2 x i32> %13, i64 1
%27 = add i32 %26, %19
%28 = add i32 %27, %25
%29 = add i32 %28, %24
%30 = tail call i32 @Clip_Color(i32 %29)
ret i32 %30
}