#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 */
double linear(unsigned long);
double pow(double, double);
__attribute__((const)) unsigned long join(unsigned long fg, unsigned long bg,
                                          unsigned long alpha) {
  double t = (double)alpha * linear(fg) + (double)(255 - alpha) * linear(bg);
  t /= 255.;
  if (t <= 0.00304)
    t *= 12.92;
  else
    t = 1.055 * pow(t, 1.0 / 2.4) - 0.055;
  return (unsigned long)(255. * t + 0.5);
}


x86 assembly (clang, -O0):
<join>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   -0x18(%rbp),%xmm0
movaps 0xf00(%rip),%xmm1
movaps %xmm1,-0x60(%rbp)
punpckldq %xmm1,%xmm0
movapd 0xf00(%rip),%xmm1
movaps %xmm1,-0x50(%rbp)
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <linear@plt>
movaps -0x60(%rbp),%xmm2
movaps -0x50(%rbp),%xmm1
movsd  %xmm0,-0x30(%rbp)
mov    -0x18(%rbp),%rcx
mov    $0xff,%eax
sub    %rcx,%rax
movq   %rax,%xmm0
punpckldq %xmm2,%xmm0
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <linear@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x28(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe28(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe0f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1213 <join+0xf3>
movsd  0xe24(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1242 <join+0x122>
movsd  -0x20(%rbp),%xmm0
movsd  0xe00(%rip),%xmm1
call   1040 <pow@plt>
movsd  0xde3(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xddf(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xdb9(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdd5(%rip),%xmm1
addsd  %xmm1,%xmm0
movaps %xmm0,%xmm1
cvttsd2si %xmm1,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
movsd  0xdc2(%rip),%xmm1
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rcx
and    %rdx,%rcx
or     %rcx,%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<join>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
movq   %rdx,%xmm0
punpckldq 0xec6(%rip),%xmm0
subpd  0xece(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,0x20(%rsp)
call   1030 <linear@plt>
movapd %xmm0,0x10(%rsp)
mov    $0xff,%eax
sub    %rbx,%rax
movq   %rax,%xmm0
punpckldq 0xe8c(%rip),%xmm0
subpd  0xe94(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,(%rsp)
mov    %r14,%rdi
call   1030 <linear@plt>
mulsd  (%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
divsd  0xe6e(%rip),%xmm1
movsd  0xe6e(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm1,%xmm0
jae    11e3 <join+0xc3>
movsd  0xe6c(%rip),%xmm1
call   1040 <pow@plt>
mulsd  0xe67(%rip),%xmm0
addsd  0xe67(%rip),%xmm0
jmp    11eb <join+0xcb>
mulsd  0xe45(%rip),%xmm0
mulsd  0xe2d(%rip),%xmm0
addsd  0xe55(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
subsd  0xe49(%rip),%xmm0
cvttsd2si %xmm0,%rax
and    %rdx,%rax
or     %rcx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @join(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca double
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%8 = load i64, i64* %6
%9 = uitofp i64 %8 to double
%10 = load i64, i64* %4
%11 = call double @linear(i64 %10)
%12 = load i64, i64* %6
%13 = sub i64 255, %12
%14 = uitofp i64 %13 to double
%15 = load i64, i64* %5
%16 = call double @linear(i64 %15)
%17 = fmul double %14, %16
%18 = call double @llvm.fmuladd.f64(double %9, double %11, double %17)
store double %18, double* %7
%19 = load double, double* %7
%20 = fdiv double %19, 2.550000e+02
store double %20, double* %7
%21 = load double, double* %7
%22 = fcmp ole double %21, 3.040000e-03
br i1 %22, label %23, label %26
23: ; preds = %3
%24 = load double, double* %7
%25 = fmul double %24, 1.292000e+01
store double %25, double* %7
br label %30
26: ; preds = %3
%27 = load double, double* %7
%28 = call double @pow(double %27, double 0x3FDAAAAAAAAAAAAB)
%29 = call double @llvm.fmuladd.f64(double 1.055000e+00, double %28, double -5.500000e-02)
store double %29, double* %7
br label %30
30: ; preds = %26, %23
%31 = load double, double* %7
%32 = call double @llvm.fmuladd.f64(double 2.550000e+02, double %31, double 5.000000e-01)
%33 = fptoui double %32 to i64
ret i64 %33
}

LLVM IR (-O2):
define i64 @join(i64 %0, i64 %1, i64 %2) {
%4 = uitofp i64 %2 to double
%5 = tail call double @linear(i64 %0)
%6 = sub i64 255, %2
%7 = uitofp i64 %6 to double
%8 = tail call double @linear(i64 %1)
%9 = fmul double %8, %7
%10 = tail call double @llvm.fmuladd.f64(double %4, double %5, double %9)
%11 = fdiv double %10, 2.550000e+02
%12 = fcmp ugt double %11, 3.040000e-03
br i1 %12, label %15, label %13
13: ; preds = %3
%14 = fmul double %11, 1.292000e+01
br label %18
15: ; preds = %3
%16 = tail call double @pow(double %11, double 0x3FDAAAAAAAAAAAAB)
%17 = tail call double @llvm.fmuladd.f64(double %16, double 1.055000e+00, double -5.500000e-02)
br label %18
18: ; preds = %15, %13
%19 = phi double [ %14, %13 ], [ %17, %15 ]
%20 = tail call double @llvm.fmuladd.f64(double %19, double 2.550000e+02, double 5.000000e-01)
%21 = fptoui double %20 to i64
ret i64 %21
}