#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 rcp(float);
float sqrt(float);
float V_Smith(float roughness, float NoV, float NoL) {
  float a = roughness * roughness;
  float a2 = a * a;
  float Vis_SmithV = NoV + sqrt(NoV * (NoV - NoV * a2) + a2);
  float Vis_SmithL = NoL + sqrt(NoL * (NoL - NoL * a2) + a2);
  return rcp(Vis_SmithV * Vis_SmithL);
}


x86 assembly (clang, -O0):
<V_Smith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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  -0x10(%rbp),%xmm0
mulss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0x8(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
movss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x24(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  -0xc(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
movss  -0x14(%rbp),%xmm3
movd   %xmm2,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm2
mulss  %xmm3,%xmm2
addss  %xmm1,%xmm2
movss  -0x14(%rbp),%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movss  -0x20(%rbp),%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
call   1030 <rcp@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<V_Smith>:
sub    $0x18,%rsp
movaps %xmm0,%xmm3
mulss  %xmm0,%xmm3
mulss  %xmm3,%xmm3
movaps %xmm1,%xmm4
mulss  %xmm3,%xmm4
movaps %xmm1,%xmm0
subss  %xmm4,%xmm0
mulss  %xmm1,%xmm0
addss  %xmm3,%xmm0
xorps  %xmm5,%xmm5
ucomiss %xmm5,%xmm0
movss  %xmm2,0x10(%rsp)
jb     115c <V_Smith+0x3c>
xorps  %xmm4,%xmm4
sqrtss %xmm0,%xmm4
jmp    1185 <V_Smith+0x65>
movss  %xmm3,0xc(%rsp)
movss  %xmm1,0x14(%rsp)
call   1040 <sqrt@plt>
xorps  %xmm5,%xmm5
movss  0x14(%rsp),%xmm1
movss  0xc(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
movaps %xmm0,%xmm4
addss  %xmm1,%xmm4
movaps %xmm2,%xmm1
mulss  %xmm3,%xmm1
movaps %xmm2,%xmm0
subss  %xmm1,%xmm0
mulss  %xmm2,%xmm0
addss  %xmm3,%xmm0
ucomiss %xmm5,%xmm0
jb     11aa <V_Smith+0x8a>
sqrtss %xmm0,%xmm0
jmp    11c1 <V_Smith+0xa1>
movss  %xmm4,0xc(%rsp)
call   1040 <sqrt@plt>
movss  0xc(%rsp),%xmm4
movss  0x10(%rsp),%xmm2
addss  %xmm2,%xmm0
mulss  %xmm0,%xmm4
movaps %xmm4,%xmm0
add    $0x18,%rsp
jmp    1030 <rcp@plt>

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

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