#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 exp(float);
float max(float, double);
float beckmannDistribution(float x, float roughness) {
  float NdotH = max(x, 0.0001);
  float cos2Alpha = NdotH * NdotH;
  float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;
  float roughness2 = roughness * roughness;
  float denom = 3.14159265358979323846264 * roughness2 * cos2Alpha * cos2Alpha;
  return exp(tan2Alpha / roughness2) / denom;
}


x86 assembly (clang, -O0):
<beckmannDistribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movsd  0xed1(%rip),%xmm1
call   1030 <max@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe9f(%rip),%xmm1
subsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x8(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe5d(%rip),%xmm0
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x14(%rbp),%xmm0
divss  -0x18(%rbp),%xmm0
call   1040 <exp@plt>
divss  -0x1c(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<beckmannDistribution>:
push   %rax
movss  %xmm1,0x4(%rsp)
movsd  0xed1(%rip),%xmm1
call   1030 <max@plt>
mulss  %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  0xec1(%rip),%xmm0
addsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  0x4(%rsp),%xmm3
mulss  %xmm3,%xmm3
cvtss2sd %xmm3,%xmm2
mulsd  0xea7(%rip),%xmm2
mulsd  %xmm1,%xmm2
mulsd  %xmm1,%xmm2
xorps  %xmm1,%xmm1
cvtsd2ss %xmm2,%xmm1
movss  %xmm1,0x4(%rsp)
divss  %xmm3,%xmm0
call   1040 <exp@plt>
divss  0x4(%rsp),%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @beckmannDistribution(float %0, float %1) {
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %3
store float %1, float* %4
%10 = load float, float* %3
%11 = call float @max(float %10, double 1.000000e-04)
store float %11, float* %5
%12 = load float, float* %5
%13 = load float, float* %5
%14 = fmul float %12, %13
store float %14, float* %6
%15 = load float, float* %6
%16 = fpext float %15 to double
%17 = fsub double %16, 1.000000e+00
%18 = load float, float* %6
%19 = fpext float %18 to double
%20 = fdiv double %17, %19
%21 = fptrunc double %20 to float
store float %21, float* %7
%22 = load float, float* %4
%23 = load float, float* %4
%24 = fmul float %22, %23
store float %24, float* %8
%25 = load float, float* %8
%26 = fpext float %25 to double
%27 = fmul double 0x400921FB54442D18, %26
%28 = load float, float* %6
%29 = fpext float %28 to double
%30 = fmul double %27, %29
%31 = load float, float* %6
%32 = fpext float %31 to double
%33 = fmul double %30, %32
%34 = fptrunc double %33 to float
store float %34, float* %9
%35 = load float, float* %7
%36 = load float, float* %8
%37 = fdiv float %35, %36
%38 = call float @exp(float %37)
%39 = load float, float* %9
%40 = fdiv float %38, %39
ret float %40
}

LLVM IR (-O2):
define float @beckmannDistribution(float %0, float %1) {
%3 = tail call float @max(float %0, double 1.000000e-04)
%4 = fmul float %3, %3
%5 = fpext float %4 to double
%6 = fadd double %5, -1.000000e+00
%7 = fdiv double %6, %5
%8 = fptrunc double %7 to float
%9 = fmul float %1, %1
%10 = fpext float %9 to double
%11 = fmul double %10, 0x400921FB54442D18
%12 = fmul double %11, %5
%13 = fmul double %12, %5
%14 = fptrunc double %13 to float
%15 = fdiv float %8, %9
%16 = tail call float @exp(float %15)
%17 = fdiv float %16, %14
ret float %17
}