#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 rcp(float);
float GeometrySmithJointApproximately(float NdotV, float NdotL,
                                      float roughness) {
  float a = roughness * roughness;
  float smithV = NdotL * (NdotV * (1.0f - a) + a);
  float smithL = NdotV * (NdotL * (1.0f - a) + a);
  return 0.5 * rcp(smithV + smithL);
}


x86 assembly (clang, -O0):
<GeometrySmithJointApproximately>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x4(%rbp),%xmm1
movss  0xec0(%rip),%xmm3
subss  -0x10(%rbp),%xmm3
movss  -0x10(%rbp),%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  0xe93(%rip),%xmm3
subss  -0x10(%rbp),%xmm3
movss  -0x10(%rbp),%xmm2
mulss  %xmm3,%xmm1
addss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
addss  -0x18(%rbp),%xmm0
call   1030 <rcp@plt>
movaps %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GeometrySmithJointApproximately>:
push   %rax
mulss  %xmm2,%xmm2
movss  0xee3(%rip),%xmm3
subss  %xmm2,%xmm3
movaps %xmm0,%xmm4
unpcklps %xmm1,%xmm4
shufps $0x0,%xmm3,%xmm3
mulps  %xmm4,%xmm3
shufps $0x0,%xmm2,%xmm2
addps  %xmm2,%xmm3
unpcklps %xmm0,%xmm1
mulps  %xmm1,%xmm3
movaps %xmm3,%xmm0
shufps $0x55,%xmm3,%xmm0
addss  %xmm3,%xmm0
call   1030 <rcp@plt>
mulsd  0xeb5(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @GeometrySmithJointApproximately(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* %6
%11 = load float, float* %6
%12 = fmul float %10, %11
store float %12, float* %7
%13 = load float, float* %5
%14 = load float, float* %4
%15 = load float, float* %7
%16 = fsub float 1.000000e+00, %15
%17 = load float, float* %7
%18 = call float @llvm.fmuladd.f32(float %14, float %16, float %17)
%19 = fmul float %13, %18
store float %19, float* %8
%20 = load float, float* %4
%21 = load float, float* %5
%22 = load float, float* %7
%23 = fsub float 1.000000e+00, %22
%24 = load float, float* %7
%25 = call float @llvm.fmuladd.f32(float %21, float %23, float %24)
%26 = fmul float %20, %25
store float %26, float* %9
%27 = load float, float* %8
%28 = load float, float* %9
%29 = fadd float %27, %28
%30 = call double @rcp(float %29)
%31 = fmul double 5.000000e-01, %30
%32 = fptrunc double %31 to float
ret float %32
}

LLVM IR (-O2):
define float @GeometrySmithJointApproximately(float %0, float %1, float %2) {
%4 = fmul float %2, %2
%5 = fsub float 1.000000e+00, %4
%6 = insertelement <2 x float> poison, float %0, i64 0
%7 = insertelement <2 x float> %6, float %1, i64 1
%8 = insertelement <2 x float> poison, float %5, i64 0
%9 = shufflevector <2 x float> %8, <2 x float> poison, <2 x i32> zeroinitializer
%10 = insertelement <2 x float> poison, float %4, i64 0
%11 = shufflevector <2 x float> %10, <2 x float> poison, <2 x i32> zeroinitializer
%12 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %7, <2 x float> %9, <2 x float> %11)
%13 = insertelement <2 x float> poison, float %1, i64 0
%14 = insertelement <2 x float> %13, float %0, i64 1
%15 = fmul <2 x float> %12, %14
%16 = shufflevector <2 x float> %15, <2 x float> poison, <2 x i32> <i32 1, i32 undef>
%17 = fadd <2 x float> %15, %16
%18 = extractelement <2 x float> %17, i64 0
%19 = tail call double @rcp(float %18)
%20 = fmul double %19, 5.000000e-01
%21 = fptrunc double %20 to float
ret float %21
}