#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 */
int /*<<< orphan*/ calc_interpolation_params(double *, int *, double *,
                                             double *, double *, double, double,
                                             double, double, double);
double ellipse(double, double, double);
double floor(double);
double interp_lin(double *, double *, int);
double sin(double);
void calc_3d_angles(int *nangles, double *theta, double *phi, double *kmax,
                    double *dcf, double fov1, double fov2, double fov3,
                    double res12, double res3) {
  int ncones, count;
  double t[4096];
  double theta_cones[4096], kmax_cones[4096], dcf_cones[4096];
  double del_phi_est, del_phi, fov12;
  fov12 = (fov1 > fov2) ? fov1 : fov2;
  calc_interpolation_params(t, &ncones, theta_cones, kmax_cones, dcf_cones,
                            fov1, fov2, fov3, res12, res3);
  *nangles = (int)floor(t[ncones - 1]) + 1;
  for (count = 0; count < *nangles; count++) {
    theta[count] = interp_lin(t, theta_cones, count);
    kmax[count] = interp_lin(t, kmax_cones, count);
    if (count == 0)
      phi[count] = 0;
    else {
      del_phi_est =
          1.0 / (kmax[count] * sin(theta[count]) *
                 ellipse(phi[count - 1] +
                             3.1415926535897932384626433832795028841971 / 2.0,
                         fov1, fov2));
      del_phi =
          1.0 / (kmax[count] * sin(theta[count]) *
                 ellipse(phi[count - 1] +
                             3.1415926535897932384626433832795028841971 / 2.0 +
                             del_phi_est / 2.0,
                         fov1, fov2));
      phi[count] = phi[count - 1] + del_phi;
      phi[count] -= floor(phi[count] /
                          (2.0 * 3.1415926535897932384626433832795028841971)) *
                    2.0 * 3.1415926535897932384626433832795028841971;
    }
    dcf[count] =
        kmax[count] /
        (ellipse(theta[count] +
                     3.1415926535897932384626433832795028841971 / 2.0,
                 fov3, fov12) *
         ellipse(phi[count] + 3.1415926535897932384626433832795028841971 / 2.0,
                 fov1, fov2));
  }
  return;
}


x86 assembly (clang, -O0):
<calc_3d_angles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x200b0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm0,-0x30(%rbp)
movsd  %xmm1,-0x38(%rbp)
movsd  %xmm2,-0x40(%rbp)
movsd  %xmm3,-0x48(%rbp)
movsd  %xmm4,-0x50(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11aa <calc_3d_angles+0x5a>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x20080(%rbp)
ff
jmp    11b7 <calc_3d_angles+0x67>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x20080(%rbp)
ff
movsd  -0x20080(%rbp),%xmm0
ff
movsd  %xmm0,-0x20078(%rbp)
ff
lea    -0x8060(%rbp),%rdi
lea    -0x10060(%rbp),%rdx
lea    -0x18060(%rbp),%rcx
lea    -0x20060(%rbp),%r8
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm3
movsd  -0x50(%rbp),%xmm4
lea    -0x54(%rbp),%rsi
call   1030 <calc_interpolation_params@plt>
mov    -0x54(%rbp),%eax
sub    $0x1,%eax
cltq
movsd  -0x8060(%rbp,%rax,8),%xmm0
ff ff
call   1070 <floor@plt>
cvttsd2si %xmm0,%ecx
add    $0x1,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    14f1 <calc_3d_angles+0x3a1>
lea    -0x8060(%rbp),%rdi
lea    -0x10060(%rbp),%rsi
mov    -0x58(%rbp),%edx
call   1040 <interp_lin@plt>
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
lea    -0x8060(%rbp),%rdi
lea    -0x18060(%rbp),%rsi
mov    -0x58(%rbp),%edx
call   1040 <interp_lin@plt>
mov    -0x20(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cmpl   $0x0,-0x58(%rbp)
jne    12a3 <calc_3d_angles+0x153>
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1453 <calc_3d_angles+0x303>
mov    -0x20(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x200a0(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x200a0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20098(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xd2a(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1060 <ellipse@plt>
movsd  -0x20098(%rbp),%xmm1
ff
mulsd  %xmm0,%xmm1
movsd  0xcfa(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20068(%rbp)
ff
mov    -0x20(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x20090(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x20090(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20088(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  0xca3(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x20068(%rbp),%xmm1
ff
movsd  0xc76(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1060 <ellipse@plt>
movsd  -0x20088(%rbp),%xmm1
ff
mulsd  %xmm0,%xmm1
movsd  0xc5b(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20070(%rbp)
ff
mov    -0x18(%rbp),%rax
mov    -0x58(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
addsd  -0x20070(%rbp),%xmm0
ff
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  0xc0b(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <floor@plt>
movsd  0xbf2(%rip),%xmm1
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm0,%rdx
movabs $0x8000000000000000,%rsi
xor    %rsi,%rdx
movq   %rdx,%xmm0
movsd  0xbba(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x200a8(%rbp)
ff
mov    -0x10(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  0xba8(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x20078(%rbp),%xmm2
ff
call   1060 <ellipse@plt>
movsd  %xmm0,-0x200b0(%rbp)
ff
mov    -0x18(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  0xb79(%rip),%xmm0
addsd  (%rax,%rcx,8),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
call   1060 <ellipse@plt>
movsd  -0x200b0(%rbp),%xmm1
ff
movaps %xmm0,%xmm2
movsd  -0x200a8(%rbp),%xmm0
ff
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    122f <calc_3d_angles+0xdf>
add    $0x200b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_3d_angles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20048,%rsp
mov    %r8,0x30(%rsp)
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%r13
lea    0x40(%rsp),%rdi
lea    0x24(%rsp),%rsi
lea    0x10040(%rsp),%rdx
lea    0x8040(%rsp),%rcx
lea    0x18040(%rsp),%r8
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
movsd  %xmm2,0x38(%rsp)
call   1030 <calc_interpolation_params@plt>
movslq 0x24(%rsp),%rax
movsd  0x38(%rsp,%rax,8),%xmm0
call   1070 <floor@plt>
cvttsd2si %xmm0,%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x0(%r13)
test   %eax,%eax
js     13a6 <calc_3d_angles+0x256>
movsd  0x8(%rsp),%xmm0
maxsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
xor    %ebp,%ebp
lea    0x40(%rsp),%r14
jmp    135c <calc_3d_angles+0x20c>
nopl   0x0(%rax)
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbp,8),%xmm0
call   1050 <sin@plt>
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  -0x8(%rbx,%rbp,8),%xmm0
movsd  0xde4(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1060 <ellipse@plt>
mulsd  (%rsp),%xmm0
movsd  0xdca(%rip),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbp,8),%xmm0
call   1050 <sin@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  -0x8(%rbx,%rbp,8),%xmm0
addsd  0xd8a(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0xd8c(%rip),%xmm1
addsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1060 <ellipse@plt>
mulsd  (%rsp),%xmm0
movsd  0xd5e(%rip),%xmm1
divsd  %xmm0,%xmm1
addsd  -0x8(%rbx,%rbp,8),%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
divsd  0xd53(%rip),%xmm0
call   1070 <floor@plt>
movsd  0xd2e(%rip),%xmm1
mulsd  0xd46(%rip),%xmm0
mulsd  0xd46(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx,%rbp,8)
movsd  (%r15,%rbp,8),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%r12,%rbp,8),%xmm0
addsd  %xmm1,%xmm0
movsd  0x38(%rsp),%xmm1
movsd  0x28(%rsp),%xmm2
call   1060 <ellipse@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rbx,%rbp,8),%xmm0
addsd  0xcdb(%rip),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1060 <ellipse@plt>
mulsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
divsd  %xmm0,%xmm1
mov    0x30(%rsp),%rax
movsd  %xmm1,(%rax,%rbp,8)
add    $0x1,%rbp
movslq 0x0(%r13),%rax
cmp    %rax,%rbp
jge    13a6 <calc_3d_angles+0x256>
mov    %r14,%rdi
lea    0x10040(%rsp),%rsi
mov    %ebp,%edx
call   1040 <interp_lin@plt>
movsd  %xmm0,(%r12,%rbp,8)
mov    %r14,%rdi
lea    0x8040(%rsp),%rsi
mov    %ebp,%edx
call   1040 <interp_lin@plt>
movsd  %xmm0,(%r15,%rbp,8)
test   %rbp,%rbp
jne    11f0 <calc_3d_angles+0xa0>
xorpd  %xmm0,%xmm0
movsd  0xc5f(%rip),%xmm1
jmp    12e7 <calc_3d_angles+0x197>
add    $0x20048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @calc_3d_angles(i32* %0, double* %1, double* %2, double* %3, double* %4, double %5, double %6, double %7, double %8, double %9) {
%11 = alloca i32*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double*
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca i32
%22 = alloca i32
%23 = alloca [4096 x double]
%24 = alloca [4096 x double]
%25 = alloca [4096 x double]
%26 = alloca [4096 x double]
%27 = alloca double
%28 = alloca double
%29 = alloca double
store i32* %0, i32** %11
store double* %1, double** %12
store double* %2, double** %13
store double* %3, double** %14
store double* %4, double** %15
store double %5, double* %16
store double %6, double* %17
store double %7, double* %18
store double %8, double* %19
store double %9, double* %20
%30 = load double, double* %16
%31 = load double, double* %17
%32 = fcmp ogt double %30, %31
br i1 %32, label %33, label %35
33: ; preds = %10
%34 = load double, double* %16
br label %37
35: ; preds = %10
%36 = load double, double* %17
br label %37
37: ; preds = %35, %33
%38 = phi double [ %34, %33 ], [ %36, %35 ]
store double %38, double* %29
%39 = getelementptr inbounds [4096 x double], [4096 x double]* %23, i64 0, i64 0
%40 = getelementptr inbounds [4096 x double], [4096 x double]* %24, i64 0, i64 0
%41 = getelementptr inbounds [4096 x double], [4096 x double]* %25, i64 0, i64 0
%42 = getelementptr inbounds [4096 x double], [4096 x double]* %26, i64 0, i64 0
%43 = load double, double* %16
%44 = load double, double* %17
%45 = load double, double* %18
%46 = load double, double* %19
%47 = load double, double* %20
%48 = call i32 @calc_interpolation_params(double* %39, i32* %21, double* %40, double* %41, double* %42, double %43, double %44, double %45, double %46, double %47)
%49 = load i32, i32* %21
%50 = sub nsw i32 %49, 1
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [4096 x double], [4096 x double]* %23, i64 0, i64 %51
%53 = load double, double* %52
%54 = call double @llvm.floor.f64(double %53)
%55 = fptosi double %54 to i32
%56 = add nsw i32 %55, 1
%57 = load i32*, i32** %11
store i32 %56, i32* %57
store i32 0, i32* %22
br label %58
58: ; preds = %196, %37
%59 = load i32, i32* %22
%60 = load i32*, i32** %11
%61 = load i32, i32* %60
%62 = icmp slt i32 %59, %61
br i1 %62, label %63, label %199
63: ; preds = %58
%64 = getelementptr inbounds [4096 x double], [4096 x double]* %23, i64 0, i64 0
%65 = getelementptr inbounds [4096 x double], [4096 x double]* %24, i64 0, i64 0
%66 = load i32, i32* %22
%67 = call double @interp_lin(double* %64, double* %65, i32 %66)
%68 = load double*, double** %12
%69 = load i32, i32* %22
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds double, double* %68, i64 %70
store double %67, double* %71
%72 = getelementptr inbounds [4096 x double], [4096 x double]* %23, i64 0, i64 0
%73 = getelementptr inbounds [4096 x double], [4096 x double]* %25, i64 0, i64 0
%74 = load i32, i32* %22
%75 = call double @interp_lin(double* %72, double* %73, i32 %74)
%76 = load double*, double** %14
%77 = load i32, i32* %22
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
store double %75, double* %79
%80 = load i32, i32* %22
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %87
82: ; preds = %63
%83 = load double*, double** %13
%84 = load i32, i32* %22
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double 0.000000e+00, double* %86
br label %166
87: ; preds = %63
%88 = load double*, double** %14
%89 = load i32, i32* %22
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %88, i64 %90
%92 = load double, double* %91
%93 = load double*, double** %12
%94 = load i32, i32* %22
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds double, double* %93, i64 %95
%97 = load double, double* %96
%98 = call double @sin(double %97)
%99 = fmul double %92, %98
%100 = load double*, double** %13
%101 = load i32, i32* %22
%102 = sub nsw i32 %101, 1
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %100, i64 %103
%105 = load double, double* %104
%106 = fadd double %105, 0x3FF921FB54442D18
%107 = load double, double* %16
%108 = load double, double* %17
%109 = call double @ellipse(double %106, double %107, double %108)
%110 = fmul double %99, %109
%111 = fdiv double 1.000000e+00, %110
store double %111, double* %27
%112 = load double*, double** %14
%113 = load i32, i32* %22
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %112, i64 %114
%116 = load double, double* %115
%117 = load double*, double** %12
%118 = load i32, i32* %22
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds double, double* %117, i64 %119
%121 = load double, double* %120
%122 = call double @sin(double %121)
%123 = fmul double %116, %122
%124 = load double*, double** %13
%125 = load i32, i32* %22
%126 = sub nsw i32 %125, 1
%127 = sext i32 %126 to i64
%128 = getelementptr inbounds double, double* %124, i64 %127
%129 = load double, double* %128
%130 = fadd double %129, 0x3FF921FB54442D18
%131 = load double, double* %27
%132 = fdiv double %131, 2.000000e+00
%133 = fadd double %130, %132
%134 = load double, double* %16
%135 = load double, double* %17
%136 = call double @ellipse(double %133, double %134, double %135)
%137 = fmul double %123, %136
%138 = fdiv double 1.000000e+00, %137
store double %138, double* %28
%139 = load double*, double** %13
%140 = load i32, i32* %22
%141 = sub nsw i32 %140, 1
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %139, i64 %142
%144 = load double, double* %143
%145 = load double, double* %28
%146 = fadd double %144, %145
%147 = load double*, double** %13
%148 = load i32, i32* %22
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %147, i64 %149
store double %146, double* %150
%151 = load double*, double** %13
%152 = load i32, i32* %22
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds double, double* %151, i64 %153
%155 = load double, double* %154
%156 = fdiv double %155, 0x401921FB54442D18
%157 = call double @llvm.floor.f64(double %156)
%158 = fmul double %157, 2.000000e+00
%159 = load double*, double** %13
%160 = load i32, i32* %22
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds double, double* %159, i64 %161
%163 = load double, double* %162
%164 = fneg double %158
%165 = call double @llvm.fmuladd.f64(double %164, double 0x400921FB54442D18, double %163)
store double %165, double* %162
br label %166
166: ; preds = %87, %82
%167 = load double*, double** %14
%168 = load i32, i32* %22
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %167, i64 %169
%171 = load double, double* %170
%172 = load double*, double** %12
%173 = load i32, i32* %22
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds double, double* %172, i64 %174
%176 = load double, double* %175
%177 = fadd double %176, 0x3FF921FB54442D18
%178 = load double, double* %18
%179 = load double, double* %29
%180 = call double @ellipse(double %177, double %178, double %179)
%181 = load double*, double** %13
%182 = load i32, i32* %22
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
%185 = load double, double* %184
%186 = fadd double %185, 0x3FF921FB54442D18
%187 = load double, double* %16
%188 = load double, double* %17
%189 = call double @ellipse(double %186, double %187, double %188)
%190 = fmul double %180, %189
%191 = fdiv double %171, %190
%192 = load double*, double** %15
%193 = load i32, i32* %22
%194 = sext i32 %193 to i64
%195 = getelementptr inbounds double, double* %192, i64 %194
store double %191, double* %195
br label %196
196: ; preds = %166
%197 = load i32, i32* %22
%198 = add nsw i32 %197, 1
store i32 %198, i32* %22
br label %58
199: ; preds = %58
ret void
}

LLVM IR (-O2):
define void @calc_3d_angles(i32* nocapture %0, double* nocapture %1, double* nocapture %2, double* nocapture %3, double* nocapture writeonly %4, double %5, double %6, double %7, double %8, double %9) {
%11 = alloca i32
%12 = alloca [4096 x double]
%13 = alloca [4096 x double]
%14 = alloca [4096 x double]
%15 = alloca [4096 x double]
%16 = bitcast i32* %11 to i8*
%17 = bitcast [4096 x double]* %12 to i8*
%18 = bitcast [4096 x double]* %13 to i8*
%19 = bitcast [4096 x double]* %14 to i8*
%20 = bitcast [4096 x double]* %15 to i8*
%21 = fcmp ogt double %5, %6
%22 = select i1 %21, double %5, double %6
%23 = getelementptr inbounds [4096 x double], [4096 x double]* %12, i64 0, i64 0
%24 = getelementptr inbounds [4096 x double], [4096 x double]* %13, i64 0, i64 0
%25 = getelementptr inbounds [4096 x double], [4096 x double]* %14, i64 0, i64 0
%26 = getelementptr inbounds [4096 x double], [4096 x double]* %15, i64 0, i64 0
%27 = call i32 @calc_interpolation_params(double* %23, i32* %11, double* %24, double* %25, double* %26, double %5, double %6, double %7, double %8, double %9)
%28 = load i32, i32* %11
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4096 x double], [4096 x double]* %12, i64 0, i64 %30
%32 = load double, double* %31
%33 = call double @llvm.floor.f64(double %32)
%34 = fptosi double %33 to i32
%35 = add nsw i32 %34, 1
store i32 %35, i32* %0
%36 = icmp sgt i32 %34, -1
br i1 %36, label %37, label %90
37: ; preds = %10, %73
%38 = phi i64 [ %86, %73 ], [ 0, %10 ]
%39 = trunc i64 %38 to i32
%40 = call double @interp_lin(double* %23, double* %24, i32 %39)
%41 = getelementptr inbounds double, double* %1, i64 %38
store double %40, double* %41
%42 = call double @interp_lin(double* %23, double* %25, i32 %39)
%43 = getelementptr inbounds double, double* %3, i64 %38
store double %42, double* %43
%44 = icmp eq i64 %38, 0
br i1 %44, label %73, label %45
45: ; preds = %37
%46 = load double, double* %41
%47 = call double @sin(double %46)
%48 = fmul double %42, %47
%49 = add nsw i64 %38, -1
%50 = getelementptr inbounds double, double* %2, i64 %49
%51 = load double, double* %50
%52 = fadd double %51, 0x3FF921FB54442D18
%53 = call double @ellipse(double %52, double %5, double %6)
%54 = fmul double %48, %53
%55 = fdiv double 1.000000e+00, %54
%56 = load double, double* %43
%57 = load double, double* %41
%58 = call double @sin(double %57)
%59 = fmul double %56, %58
%60 = load double, double* %50
%61 = fadd double %60, 0x3FF921FB54442D18
%62 = fmul double %55, 5.000000e-01
%63 = fadd double %62, %61
%64 = call double @ellipse(double %63, double %5, double %6)
%65 = fmul double %59, %64
%66 = fdiv double 1.000000e+00, %65
%67 = load double, double* %50
%68 = fadd double %67, %66
%69 = fdiv double %68, 0x401921FB54442D18
%70 = call double @llvm.floor.f64(double %69)
%71 = fmul double %70, -2.000000e+00
%72 = call double @llvm.fmuladd.f64(double %71, double 0x400921FB54442D18, double %68)
br label %73
73: ; preds = %37, %45
%74 = phi double [ %72, %45 ], [ 0.000000e+00, %37 ]
%75 = getelementptr inbounds double, double* %2, i64 %38
store double %74, double* %75
%76 = load double, double* %43
%77 = load double, double* %41
%78 = fadd double %77, 0x3FF921FB54442D18
%79 = call double @ellipse(double %78, double %7, double %22)
%80 = load double, double* %75
%81 = fadd double %80, 0x3FF921FB54442D18
%82 = call double @ellipse(double %81, double %5, double %6)
%83 = fmul double %79, %82
%84 = fdiv double %76, %83
%85 = getelementptr inbounds double, double* %4, i64 %38
store double %84, double* %85
%86 = add nuw nsw i64 %38, 1
%87 = load i32, i32* %0
%88 = sext i32 %87 to i64
%89 = icmp slt i64 %86, %88
br i1 %89, label %37, label %90
90: ; preds = %73, %10
ret void
}