#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 sqrt(float);
float GeometricSmith(float a, float NoV, float NoL) {
  float a2 = a * a;
  float GL = NoV * sqrt((-NoL * a2 + NoL) * NoL + a2);
  float GV = NoL * sqrt((-NoV * a2 + NoV) * NoV + a2);
  return 0.5 / (GV + GL);
}


x86 assembly (clang, -O0):
<GeometricSmith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x4(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0xc(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0xc(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x8(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  -0x10(%rbp),%xmm2
movss  -0x8(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  -0x8(%rbp),%xmm2
movss  -0x10(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x1c(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe08(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GeometricSmith>:
sub    $0x18,%rsp
movaps %xmm0,%xmm3
mulss  %xmm0,%xmm3
movaps %xmm2,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm2,%xmm0
subss  %xmm4,%xmm0
movss  %xmm2,0x14(%rsp)
mulss  %xmm2,%xmm0
addss  %xmm3,%xmm0
xorps  %xmm5,%xmm5
ucomiss %xmm5,%xmm0
jb     1148 <GeometricSmith+0x38>
xorps  %xmm2,%xmm2
sqrtss %xmm0,%xmm2
jmp    116b <GeometricSmith+0x5b>
movss  %xmm3,0xc(%rsp)
movss  %xmm1,0x10(%rsp)
call   1030 <sqrt@plt>
xorps  %xmm5,%xmm5
movss  0x10(%rsp),%xmm1
movss  0xc(%rsp),%xmm3
movaps %xmm0,%xmm2
mulss  %xmm1,%xmm2
movaps %xmm1,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm1,%xmm0
subss  %xmm4,%xmm0
mulss  %xmm1,%xmm0
addss  %xmm3,%xmm0
ucomiss %xmm5,%xmm0
jb     1190 <GeometricSmith+0x80>
sqrtss %xmm0,%xmm0
jmp    11a1 <GeometricSmith+0x91>
movss  %xmm2,0xc(%rsp)
call   1030 <sqrt@plt>
movss  0xc(%rsp),%xmm2
mulss  0x14(%rsp),%xmm0
addss  %xmm0,%xmm2
movss  0xe4d(%rip),%xmm0
divss  %xmm2,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @GeometricSmith(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%10 = load float, float* %4
%11 = load float, float* %4
%12 = fmul float %10, %11
store float %12, float* %7
%13 = load float, float* %5
%14 = load float, float* %6
%15 = fneg float %14
%16 = load float, float* %7
%17 = load float, float* %6
%18 = call float @llvm.fmuladd.f32(float %15, float %16, float %17)
%19 = load float, float* %6
%20 = load float, float* %7
%21 = call float @llvm.fmuladd.f32(float %18, float %19, float %20)
%22 = call float @sqrt(float %21)
%23 = fmul float %13, %22
store float %23, float* %8
%24 = load float, float* %6
%25 = load float, float* %5
%26 = fneg float %25
%27 = load float, float* %7
%28 = load float, float* %5
%29 = call float @llvm.fmuladd.f32(float %26, float %27, float %28)
%30 = load float, float* %5
%31 = load float, float* %7
%32 = call float @llvm.fmuladd.f32(float %29, float %30, float %31)
%33 = call float @sqrt(float %32)
%34 = fmul float %24, %33
store float %34, float* %9
%35 = load float, float* %9
%36 = load float, float* %8
%37 = fadd float %35, %36
%38 = fpext float %37 to double
%39 = fdiv double 5.000000e-01, %38
%40 = fptrunc double %39 to float
ret float %40
}

LLVM IR (-O2):
define float @GeometricSmith(float %0, float %1, float %2) {
%4 = fmul float %0, %0
%5 = fneg float %2
%6 = tail call float @llvm.fmuladd.f32(float %5, float %4, float %2)
%7 = tail call float @llvm.fmuladd.f32(float %6, float %2, float %4)
%8 = tail call float @sqrt(float %7)
%9 = fmul float %8, %1
%10 = fneg float %1
%11 = tail call float @llvm.fmuladd.f32(float %10, float %4, float %1)
%12 = tail call float @llvm.fmuladd.f32(float %11, float %1, float %4)
%13 = tail call float @sqrt(float %12)
%14 = fmul float %13, %2
%15 = fadd float %9, %14
%16 = fdiv float 5.000000e-01, %15
ret float %16
}