#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 */
float gamma_srgb(float const);
float const inv_gamma_srgb(float const);
float luminance_rgb(float const *c) {
  const float rY = 0.212655;
  const float gY = 0.715158;
  const float bY = 0.072187;
  return gamma_srgb(rY * inv_gamma_srgb(c[0]) + gY * inv_gamma_srgb(c[1]) +
                    bY * inv_gamma_srgb(c[2]));
}


x86 assembly (clang, -O0):
<luminance_rgb>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  0xed0(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xec7(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xeb2(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
call   1040 <inv_gamma_srgb@plt>
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
call   1040 <inv_gamma_srgb@plt>
movaps %xmm0,%xmm2
movss  -0x1c(%rbp),%xmm0
movss  0xe85(%rip),%xmm1
mulss  %xmm2,%xmm1
movss  0xe75(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
call   1040 <inv_gamma_srgb@plt>
movss  -0x18(%rbp),%xmm1
movss  0xe49(%rip),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <gamma_srgb@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luminance_rgb>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm0
call   1040 <inv_gamma_srgb@plt>
movss  %xmm0,0xc(%rsp)
movss  0x4(%rbx),%xmm0
call   1040 <inv_gamma_srgb@plt>
mulss  0xeb7(%rip),%xmm0
movss  0xc(%rsp),%xmm1
mulss  0xead(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rbx),%xmm0
call   1040 <inv_gamma_srgb@plt>
mulss  0xe95(%rip),%xmm0
addss  0xc(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
jmp    1030 <gamma_srgb@plt>

LLVM IR (-O0):
define float @luminance_rgb(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
store float* %0, float** %2
store float 0x3FCB384760000000, float* %3
store float 0x3FE6E29300000000, float* %4
store float 0x3FB27AD8E0000000, float* %5
%6 = load float*, float** %2
%7 = getelementptr inbounds float, float* %6, i64 0
%8 = load float, float* %7
%9 = call float @inv_gamma_srgb(float %8)
%10 = load float*, float** %2
%11 = getelementptr inbounds float, float* %10, i64 1
%12 = load float, float* %11
%13 = call float @inv_gamma_srgb(float %12)
%14 = fmul float 0x3FE6E29300000000, %13
%15 = call float @llvm.fmuladd.f32(float 0x3FCB384760000000, float %9, float %14)
%16 = load float*, float** %2
%17 = getelementptr inbounds float, float* %16, i64 2
%18 = load float, float* %17
%19 = call float @inv_gamma_srgb(float %18)
%20 = call float @llvm.fmuladd.f32(float 0x3FB27AD8E0000000, float %19, float %15)
%21 = call float @gamma_srgb(float %20)
ret float %21
}

LLVM IR (-O2):
define float @luminance_rgb(float* nocapture %0) {
%2 = load float, float* %0
%3 = tail call float @inv_gamma_srgb(float %2)
%4 = getelementptr inbounds float, float* %0, i64 1
%5 = load float, float* %4
%6 = tail call float @inv_gamma_srgb(float %5)
%7 = fmul float %6, 0x3FE6E29300000000
%8 = tail call float @llvm.fmuladd.f32(float %3, float 0x3FCB384760000000, float %7)
%9 = getelementptr inbounds float, float* %0, i64 2
%10 = load float, float* %9
%11 = tail call float @inv_gamma_srgb(float %10)
%12 = tail call float @llvm.fmuladd.f32(float %11, float 0x3FB27AD8E0000000, float %8)
%13 = tail call float @gamma_srgb(float %12)
ret float %13
}