#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 Sq(float);
float sqrt(float);
float RefractionIncidentAngleDerivative(float odotm, float iorIncident,
                                        float iorOutgoing) {
  float eta = iorOutgoing / iorIncident;
  float flip = (iorIncident > iorOutgoing) ? 1 : -1;
  float cosx = odotm;
  float sinxSq = 1.f - cosx * cosx;
  float sinx = sqrt(sinxSq);
  float cotx = cosx / sinx;
  float a = eta;
  float k = sqrt(1.f + Sq(a) * (Sq(odotm) - 1.f));
  float angleDev = a * odotm / k;
  return flip * 2.f * angleDev;
}


x86 assembly (clang, -O0):
<RefractionIncidentAngleDerivative>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
divss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
mov    $0xffffffff,%eax
mov    $0x1,%ecx
ucomiss %xmm1,%xmm0
cmova  %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
movss  -0x18(%rbp),%xmm1
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
mulss  %xmm1,%xmm0
movss  0xe6e(%rip),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrt@plt>
movss  %xmm0,-0x20(%rbp)
movss  -0x18(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
call   1030 <Sq@plt>
movss  %xmm0,-0x34(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <Sq@plt>
movaps %xmm0,%xmm1
movss  -0x34(%rbp),%xmm0
movss  0xe14(%rip),%xmm2
subss  %xmm2,%xmm1
mulss  %xmm1,%xmm0
movss  0xe04(%rip),%xmm1
addss  %xmm1,%xmm0
call   1040 <sqrt@plt>
movss  %xmm0,-0x2c(%rbp)
movss  -0x28(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
divss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  0xdd6(%rip),%xmm0
mulss  -0x14(%rbp),%xmm0
mulss  -0x30(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RefractionIncidentAngleDerivative>:
sub    $0x18,%rsp
movss  %xmm2,0x14(%rsp)
movss  %xmm1,0x10(%rsp)
divss  %xmm1,%xmm2
movss  %xmm0,0x8(%rsp)
movaps %xmm0,%xmm1
mulss  %xmm0,%xmm1
movss  0xeb7(%rip),%xmm0
subss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm0,%xmm1
movss  %xmm2,0x4(%rsp)
ja     11d2 <RefractionIncidentAngleDerivative+0xb2>
movaps %xmm2,%xmm0
call   1030 <Sq@plt>
movss  %xmm0,0xc(%rsp)
movss  0x8(%rsp),%xmm0
call   1030 <Sq@plt>
addss  0xe88(%rip),%xmm0
mulss  0xc(%rsp),%xmm0
addss  0xe76(%rip),%xmm0
ucomiss 0xe77(%rip),%xmm0
jb     1199 <RefractionIncidentAngleDerivative+0x79>
sqrtss %xmm0,%xmm0
jmp    119e <RefractionIncidentAngleDerivative+0x7e>
call   1040 <sqrt@plt>
xor    %eax,%eax
movss  0x10(%rsp),%xmm1
ucomiss 0x14(%rsp),%xmm1
seta   %al
movss  0x4(%rsp),%xmm1
mulss  0x8(%rsp),%xmm1
divss  %xmm0,%xmm1
lea    0xe47(%rip),%rcx
mulss  (%rcx,%rax,4),%xmm1
movaps %xmm1,%xmm0
add    $0x18,%rsp
ret
ucomiss %xmm1,%xmm0
jae    115b <RefractionIncidentAngleDerivative+0x3b>
call   1040 <sqrt@plt>
movss  0x4(%rsp),%xmm2
jmp    115b <RefractionIncidentAngleDerivative+0x3b>

LLVM IR (-O0):
define float @RefractionIncidentAngleDerivative(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
%11 = alloca float
%12 = alloca float
%13 = alloca float
%14 = alloca float
%15 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%16 = load float, float* %6
%17 = load float, float* %5
%18 = fdiv float %16, %17
store float %18, float* %7
%19 = load float, float* %5
%20 = load float, float* %6
%21 = fcmp ogt float %19, %20
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 1, i32 -1
%24 = sitofp i32 %23 to float
store float %24, float* %8
%25 = load float, float* %4
store float %25, float* %9
%26 = load float, float* %9
%27 = load float, float* %9
%28 = fneg float %26
%29 = call float @llvm.fmuladd.f32(float %28, float %27, float 1.000000e+00)
store float %29, float* %10
%30 = load float, float* %10
%31 = call float @sqrt(float %30)
store float %31, float* %11
%32 = load float, float* %9
%33 = load float, float* %11
%34 = fdiv float %32, %33
store float %34, float* %12
%35 = load float, float* %7
store float %35, float* %13
%36 = load float, float* %13
%37 = call float @Sq(float %36)
%38 = load float, float* %4
%39 = call float @Sq(float %38)
%40 = fsub float %39, 1.000000e+00
%41 = call float @llvm.fmuladd.f32(float %37, float %40, float 1.000000e+00)
%42 = call float @sqrt(float %41)
store float %42, float* %14
%43 = load float, float* %13
%44 = load float, float* %4
%45 = fmul float %43, %44
%46 = load float, float* %14
%47 = fdiv float %45, %46
store float %47, float* %15
%48 = load float, float* %8
%49 = fmul float %48, 2.000000e+00
%50 = load float, float* %15
%51 = fmul float %49, %50
ret float %51
}

LLVM IR (-O2):
define float @RefractionIncidentAngleDerivative(float %0, float %1, float %2) {
%4 = fdiv float %2, %1
%5 = fneg float %0
%6 = tail call float @llvm.fmuladd.f32(float %5, float %0, float 1.000000e+00)
%7 = fcmp olt float %6, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call float @sqrt(float %6)
br label %10
10: ; preds = %3, %8
%11 = fcmp ogt float %1, %2
%12 = tail call float @Sq(float %4)
%13 = tail call float @Sq(float %0)
%14 = fadd float %13, -1.000000e+00
%15 = tail call float @llvm.fmuladd.f32(float %12, float %14, float 1.000000e+00)
%16 = tail call float @sqrt(float %15)
%17 = fmul float %4, %0
%18 = fdiv float %17, %16
%19 = select i1 %11, float 2.000000e+00, float -2.000000e+00
%20 = fmul float %19, %18
ret float %20
}