#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*/ assert(int);
int fabs(float);
void luma_coeffs(float m[3][4], float lr, float lg, float lb) {
  assert(fabs(lr + lg + lb - 1) < 1e-6);
  m[0][0] = m[1][0] = m[2][0] = 1;
  m[0][1] = 0;
  m[1][1] = -2 * (1 - lb) * lb / lg;
  m[2][1] = 2 * (1 - lb);
  m[0][2] = 2 * (1 - lr);
  m[1][2] = -2 * (1 - lr) * lr / lg;
  m[2][2] = 0;
}


x86 assembly (clang, -O0):
<luma_coeffs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
movss  %xmm1,-0x10(%rbp)
movss  %xmm2,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  0xeb2(%rip),%xmm1
subss  %xmm1,%xmm0
call   1030 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xea9(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
movss  0xe80(%rip),%xmm0
movss  %xmm0,0x20(%rax)
mov    -0x8(%rbp),%rax
movss  0xe6f(%rip),%xmm0
movss  %xmm0,0x10(%rax)
mov    -0x8(%rbp),%rax
movss  0xe5e(%rip),%xmm0
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rax)
movss  0xe46(%rip),%xmm1
subss  -0x14(%rbp),%xmm1
movss  0xe35(%rip),%xmm0
mulss  %xmm1,%xmm0
mulss  -0x14(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x14(%rax)
movss  0xe1a(%rip),%xmm1
subss  -0x14(%rbp),%xmm1
movss  0xe11(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x24(%rax)
movss  0xdf8(%rip),%xmm1
subss  -0xc(%rbp),%xmm1
movss  0xdef(%rip),%xmm0
mulss  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
movss  0xdd6(%rip),%xmm1
subss  -0xc(%rbp),%xmm1
movss  0xdc5(%rip),%xmm0
mulss  %xmm1,%xmm0
mulss  -0xc(%rbp),%xmm0
divss  -0x10(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,0x18(%rax)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,0x28(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<luma_coeffs>:
push   %rbx
sub    $0x10,%rsp
movss  %xmm2,0x4(%rsp)
movss  %xmm1,0x8(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %rdi,%rbx
addss  %xmm1,%xmm0
addss  %xmm2,%xmm0
addss  0xeb6(%rip),%xmm0
call   1030 <fabs@plt>
xor    %edi,%edi
test   %eax,%eax
setle  %dil
call   1040 <assert@plt>
movl   $0x3f800000,0x20(%rbx)
movl   $0x3f800000,0x10(%rbx)
movq   $0x3f800000,(%rbx)
movss  0xe8b(%rip),%xmm0
movaps %xmm0,%xmm1
movss  0x4(%rsp),%xmm4
subss  %xmm4,%xmm1
movss  0xe7a(%rip),%xmm2
movaps %xmm1,%xmm3
mulss  %xmm2,%xmm3
mulss  %xmm4,%xmm3
movss  0x8(%rsp),%xmm4
divss  %xmm4,%xmm3
movss  %xmm3,0x14(%rbx)
addss  %xmm1,%xmm1
movss  %xmm1,0x24(%rbx)
movss  0xc(%rsp),%xmm3
subss  %xmm3,%xmm0
movaps %xmm0,%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0x8(%rbx)
mulss  %xmm2,%xmm0
mulss  %xmm3,%xmm0
divss  %xmm4,%xmm0
movss  %xmm0,0x18(%rbx)
movl   $0x0,0x28(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @luma_coeffs([4 x float]* %0, float %1, float %2, float %3) {
%5 = alloca [4 x float]*
%6 = alloca float
%7 = alloca float
%8 = alloca float
store [4 x float]* %0, [4 x float]** %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
%9 = load float, float* %6
%10 = load float, float* %7
%11 = fadd float %9, %10
%12 = load float, float* %8
%13 = fadd float %11, %12
%14 = fsub float %13, 1.000000e+00
%15 = call i32 @fabs(float %14)
%16 = sitofp i32 %15 to double
%17 = fcmp olt double %16, 0x3EB0C6F7A0B5ED8D
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load [4 x float]*, [4 x float]** %5
%21 = getelementptr inbounds [4 x float], [4 x float]* %20, i64 2
%22 = getelementptr inbounds [4 x float], [4 x float]* %21, i64 0, i64 0
store float 1.000000e+00, float* %22
%23 = load [4 x float]*, [4 x float]** %5
%24 = getelementptr inbounds [4 x float], [4 x float]* %23, i64 1
%25 = getelementptr inbounds [4 x float], [4 x float]* %24, i64 0, i64 0
store float 1.000000e+00, float* %25
%26 = load [4 x float]*, [4 x float]** %5
%27 = getelementptr inbounds [4 x float], [4 x float]* %26, i64 0
%28 = getelementptr inbounds [4 x float], [4 x float]* %27, i64 0, i64 0
store float 1.000000e+00, float* %28
%29 = load [4 x float]*, [4 x float]** %5
%30 = getelementptr inbounds [4 x float], [4 x float]* %29, i64 0
%31 = getelementptr inbounds [4 x float], [4 x float]* %30, i64 0, i64 1
store float 0.000000e+00, float* %31
%32 = load float, float* %8
%33 = fsub float 1.000000e+00, %32
%34 = fmul float -2.000000e+00, %33
%35 = load float, float* %8
%36 = fmul float %34, %35
%37 = load float, float* %7
%38 = fdiv float %36, %37
%39 = load [4 x float]*, [4 x float]** %5
%40 = getelementptr inbounds [4 x float], [4 x float]* %39, i64 1
%41 = getelementptr inbounds [4 x float], [4 x float]* %40, i64 0, i64 1
store float %38, float* %41
%42 = load float, float* %8
%43 = fsub float 1.000000e+00, %42
%44 = fmul float 2.000000e+00, %43
%45 = load [4 x float]*, [4 x float]** %5
%46 = getelementptr inbounds [4 x float], [4 x float]* %45, i64 2
%47 = getelementptr inbounds [4 x float], [4 x float]* %46, i64 0, i64 1
store float %44, float* %47
%48 = load float, float* %6
%49 = fsub float 1.000000e+00, %48
%50 = fmul float 2.000000e+00, %49
%51 = load [4 x float]*, [4 x float]** %5
%52 = getelementptr inbounds [4 x float], [4 x float]* %51, i64 0
%53 = getelementptr inbounds [4 x float], [4 x float]* %52, i64 0, i64 2
store float %50, float* %53
%54 = load float, float* %6
%55 = fsub float 1.000000e+00, %54
%56 = fmul float -2.000000e+00, %55
%57 = load float, float* %6
%58 = fmul float %56, %57
%59 = load float, float* %7
%60 = fdiv float %58, %59
%61 = load [4 x float]*, [4 x float]** %5
%62 = getelementptr inbounds [4 x float], [4 x float]* %61, i64 1
%63 = getelementptr inbounds [4 x float], [4 x float]* %62, i64 0, i64 2
store float %60, float* %63
%64 = load [4 x float]*, [4 x float]** %5
%65 = getelementptr inbounds [4 x float], [4 x float]* %64, i64 2
%66 = getelementptr inbounds [4 x float], [4 x float]* %65, i64 0, i64 2
store float 0.000000e+00, float* %66
ret void
}

LLVM IR (-O2):
define void @luma_coeffs([4 x float]* nocapture writeonly %0, float %1, float %2, float %3) {
%5 = fadd float %1, %2
%6 = fadd float %5, %3
%7 = fadd float %6, -1.000000e+00
%8 = tail call i32 @fabs(float %7)
%9 = icmp slt i32 %8, 1
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
%12 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 2, i64 0
store float 1.000000e+00, float* %12
%13 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 1, i64 0
store float 1.000000e+00, float* %13
%14 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 0, i64 0
store float 1.000000e+00, float* %14
%15 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 0, i64 1
store float 0.000000e+00, float* %15
%16 = fsub float 1.000000e+00, %3
%17 = fmul float %16, -2.000000e+00
%18 = fmul float %17, %3
%19 = fdiv float %18, %2
%20 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 1, i64 1
store float %19, float* %20
%21 = fmul float %16, 2.000000e+00
%22 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 2, i64 1
store float %21, float* %22
%23 = fsub float 1.000000e+00, %1
%24 = fmul float %23, 2.000000e+00
%25 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 0, i64 2
store float %24, float* %25
%26 = fmul float %23, -2.000000e+00
%27 = fmul float %26, %1
%28 = fdiv float %27, %2
%29 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 1, i64 2
store float %28, float* %29
%30 = getelementptr inbounds [4 x float], [4 x float]* %0, i64 2, i64 2
store float 0.000000e+00, float* %30
ret void
}