#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 const rcp(float const);
float fresnelDielectric(const float cosi, const float cost, const float eta) {
  const float Rper = (eta * cosi - cost) * rcp(eta * cosi + cost);
  const float Rpar = (cosi - eta * cost) * rcp(cosi + eta * cost);
  return 0.5f * (Rpar * Rpar + Rper * Rper);
}


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

x86 assembly (clang, -O2):
<fresnelDielectric>:
sub    $0x18,%rsp
movss  %xmm2,0x8(%rsp)
movaps %xmm0,%xmm3
movss  %xmm0,0x14(%rsp)
movaps %xmm2,%xmm0
mulss  %xmm3,%xmm0
movaps %xmm0,%xmm2
movss  %xmm1,0x10(%rsp)
subss  %xmm1,%xmm2
movss  %xmm2,0xc(%rsp)
addss  %xmm1,%xmm0
call   1030 <rcp@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
movaps %xmm1,%xmm2
subss  %xmm0,%xmm2
movss  %xmm2,0x8(%rsp)
addss  %xmm1,%xmm0
call   1030 <rcp@plt>
mulss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
mulss  %xmm1,%xmm1
mulss  %xmm0,%xmm0
addss  %xmm1,%xmm0
mulss  0xe66(%rip),%xmm0
add    $0x18,%rsp
ret

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

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