double planar_rho_inv(double X, double cos_theta, double *a, double *b,
                      double *c, double *t, double *hl) {
  double res = 0.0;
  double x_v = X * cos_theta;
  int layer = 0;
  int i;
  for (i = 0; i < 5; ++i)
    if (!(x_v >= t[i]))
      layer = i;
  if (layer == 4)
    res = c[4] / b[4];
  else
    res = c[layer] / (x_v - a[layer]);
  return res;
}


x86 assembly (clang, -O0):
<planar_rho_inv>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
cmpl   $0x5,-0x50(%rbp)
jge    1182 <planar_rho_inv+0x82>
movsd  -0x48(%rbp),%xmm0
mov    -0x30(%rbp),%rax
movslq -0x50(%rbp),%rcx
ucomisd (%rax,%rcx,8),%xmm0
jae    116f <planar_rho_inv+0x6f>
mov    -0x50(%rbp),%eax
mov    %eax,-0x4c(%rbp)
jmp    1174 <planar_rho_inv+0x74>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1147 <planar_rho_inv+0x47>
cmpl   $0x4,-0x4c(%rbp)
jne    11a8 <planar_rho_inv+0xa8>
mov    -0x28(%rbp),%rax
movsd  0x20(%rax),%xmm0
mov    -0x20(%rbp),%rax
divsd  0x20(%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    11d0 <planar_rho_inv+0xd0>
mov    -0x28(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  -0x48(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movslq -0x4c(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<planar_rho_inv>:
mulsd  %xmm1,%xmm0
ucomisd 0x20(%rcx),%xmm0
jae    111a <planar_rho_inv+0x1a>
movsd  0x20(%rdx),%xmm1
divsd  0x20(%rsi),%xmm1
movapd %xmm1,%xmm0
ret
xor    %eax,%eax
ucomisd 0x8(%rcx),%xmm0
setb   %al
ucomisd 0x10(%rcx),%xmm0
mov    $0x2,%esi
cmovae %rax,%rsi
ucomisd 0x18(%rcx),%xmm0
mov    $0x3,%eax
cmovae %rsi,%rax
movsd  (%rdx,%rax,8),%xmm1
subsd  (%rdi,%rax,8),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @planar_rho_inv(double %0, double %1, double* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca i32
%18 = alloca i32
store double %0, double* %8
store double %1, double* %9
store double* %2, double** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
store double 0.000000e+00, double* %15
%19 = load double, double* %8
%20 = load double, double* %9
%21 = fmul double %19, %20
store double %21, double* %16
store i32 0, i32* %17
store i32 0, i32* %18
br label %22
22: ; preds = %36, %7
%23 = load i32, i32* %18
%24 = icmp slt i32 %23, 5
br i1 %24, label %25, label %39
25: ; preds = %22
%26 = load double, double* %16
%27 = load double*, double** %13
%28 = load i32, i32* %18
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds double, double* %27, i64 %29
%31 = load double, double* %30
%32 = fcmp oge double %26, %31
br i1 %32, label %35, label %33
33: ; preds = %25
%34 = load i32, i32* %18
store i32 %34, i32* %17
br label %35
35: ; preds = %33, %25
br label %36
36: ; preds = %35
%37 = load i32, i32* %18
%38 = add nsw i32 %37, 1
store i32 %38, i32* %18
br label %22
39: ; preds = %22
%40 = load i32, i32* %17
%41 = icmp eq i32 %40, 4
br i1 %41, label %42, label %50
42: ; preds = %39
%43 = load double*, double** %12
%44 = getelementptr inbounds double, double* %43, i64 4
%45 = load double, double* %44
%46 = load double*, double** %11
%47 = getelementptr inbounds double, double* %46, i64 4
%48 = load double, double* %47
%49 = fdiv double %45, %48
store double %49, double* %15
br label %64
50: ; preds = %39
%51 = load double*, double** %12
%52 = load i32, i32* %17
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds double, double* %51, i64 %53
%55 = load double, double* %54
%56 = load double, double* %16
%57 = load double*, double** %10
%58 = load i32, i32* %17
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = fsub double %56, %61
%63 = fdiv double %55, %62
store double %63, double* %15
br label %64
64: ; preds = %50, %42
%65 = load double, double* %15
ret double %65
}

LLVM IR (-O2):
define double @planar_rho_inv(double %0, double %1, double* nocapture %2, double* nocapture %3, double* nocapture %4, double* nocapture %5, double* nocapture readnone %6) {
%8 = fmul double %0, %1
%9 = getelementptr inbounds double, double* %5, i64 4
%10 = load double, double* %9
%11 = fcmp ult double %8, %10
br i1 %11, label %12, label %18
12: ; preds = %7
%13 = getelementptr inbounds double, double* %4, i64 4
%14 = load double, double* %13
%15 = getelementptr inbounds double, double* %3, i64 4
%16 = load double, double* %15
%17 = fdiv double %14, %16
br label %37
18: ; preds = %7
%19 = getelementptr inbounds double, double* %5, i64 3
%20 = load double, double* %19
%21 = fcmp ult double %8, %20
%22 = getelementptr inbounds double, double* %5, i64 2
%23 = load double, double* %22
%24 = fcmp ult double %8, %23
%25 = getelementptr inbounds double, double* %5, i64 1
%26 = load double, double* %25
%27 = fcmp ult double %8, %26
%28 = zext i1 %27 to i64
%29 = select i1 %24, i64 2, i64 %28
%30 = select i1 %21, i64 3, i64 %29
%31 = getelementptr inbounds double, double* %4, i64 %30
%32 = load double, double* %31
%33 = getelementptr inbounds double, double* %2, i64 %30
%34 = load double, double* %33
%35 = fsub double %8, %34
%36 = fdiv double %32, %35
br label %37
37: ; preds = %18, %12
%38 = phi double [ %17, %12 ], [ %36, %18 ]
ret double %38
}