void p3dCartesian2polar_16(unsigned short *in_im, unsigned short **out_im,
                           const int dimx, const int dimy, const double centerX,
                           const double centerY, const double precision,
                           int *polarX) {
  int i, j;
  double r, phi;
  double x, y;
  double r1, r2, r3, r4;
  r1 = sqrt((centerX - 0) * (centerX - 0) + (centerY - 0) * (centerY - 0));
  r2 =
      sqrt((centerX - dimx) * (centerX - dimx) + (centerY - 0) * (centerY - 0));
  r3 =
      sqrt((centerX - 0) * (centerX - 0) + (centerY - dimy) * (centerY - dimy));
  r4 = sqrt((centerX - dimx) * (centerX - dimx) +
            (centerY - dimy) * (centerY - dimy));
  *polarX = (int)(precision * ((((((((((r1) > (r2)) ? (r1) : (r2))) > (r3))
                                       ? ((((r1) > (r2)) ? (r1) : (r2)))
                                       : (r3))) > (r4))
                                    ? (((((((r1) > (r2)) ? (r1) : (r2))) > (r3))
                                            ? ((((r1) > (r2)) ? (r1) : (r2)))
                                            : (r3)))
                                    : (r4)) +
                               0.5));
  (*out_im) =
      (unsigned short *)calloc((*polarX) * (*polarX), sizeof(unsigned short));
#pragma omp parallel for private(i, r, phi, x, y)
  for (j = 0; j < (*polarX); j++)
    for (i = 0; i < (*polarX); i++) {
      r = (double)(i);
      phi = ((double)(j) / (*polarX)) * 3.1415926535897932384626433 * 2;
      x = r * cos(phi) + centerX;
      y = r * sin(phi) + centerY;
      (*out_im)[((j) * ((*polarX)) + (i))] =
          p3dBicubicInterpolation_16(in_im, dimx, dimy, x, y);
    }
}


x86 assembly (clang, -O0):
<p3dCartesian2polar_16>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm1,-0x28(%rbp)
movsd  %xmm2,-0x30(%rbp)
mov    %r8,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
xorps  %xmm3,%xmm3
subsd  %xmm3,%xmm1
movsd  -0x28(%rbp),%xmm3
xorps  %xmm4,%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
cvtsi2sdl -0x14(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
xorps  %xmm3,%xmm3
subsd  %xmm3,%xmm1
movsd  -0x28(%rbp),%xmm3
xorps  %xmm4,%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
cvtsi2sdl -0x18(%rbp),%xmm3
subsd  %xmm3,%xmm1
movsd  -0x28(%rbp),%xmm3
cvtsi2sdl -0x18(%rbp),%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x78(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  -0x20(%rbp),%xmm2
cvtsi2sdl -0x14(%rbp),%xmm1
subsd  %xmm1,%xmm2
movsd  -0x28(%rbp),%xmm1
cvtsi2sdl -0x18(%rbp),%xmm3
subsd  %xmm3,%xmm1
movsd  -0x28(%rbp),%xmm3
cvtsi2sdl -0x18(%rbp),%xmm4
subsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    12d3 <p3dCartesian2polar_16+0x183>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    12e0 <p3dCartesian2polar_16+0x190>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
ucomisd -0x78(%rbp),%xmm0
jbe    1337 <p3dCartesian2polar_16+0x1e7>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    1315 <p3dCartesian2polar_16+0x1c5>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
jmp    1322 <p3dCartesian2polar_16+0x1d2>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x98(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
jmp    1344 <p3dCartesian2polar_16+0x1f4>
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
ucomisd -0x80(%rbp),%xmm0
jbe    13ff <p3dCartesian2polar_16+0x2af>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    1379 <p3dCartesian2polar_16+0x229>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
jmp    1386 <p3dCartesian2polar_16+0x236>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
ucomisd -0x78(%rbp),%xmm0
jbe    13dd <p3dCartesian2polar_16+0x28d>
movsd  -0x68(%rbp),%xmm0
ucomisd -0x70(%rbp),%xmm0
jbe    13bb <p3dCartesian2polar_16+0x26b>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
jmp    13c8 <p3dCartesian2polar_16+0x278>
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    13ea <p3dCartesian2polar_16+0x29a>
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  -0xb8(%rbp),%xmm0
ff
movsd  %xmm0,-0xc0(%rbp)
ff
jmp    140c <p3dCartesian2polar_16+0x2bc>
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x88(%rbp),%xmm0
ff
movsd  -0xc0(%rbp),%xmm1
ff
movsd  0xbdc(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    -0x38(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    -0x38(%rbp),%rcx
imul   (%rcx),%eax
movslq %eax,%rdi
mov    $0x2,%esi
call   1030 <calloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%eax
jge    1580 <p3dCartesian2polar_16+0x430>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%eax
jge    156d <p3dCartesian2polar_16+0x41d>
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
cvtsi2sdl -0x40(%rbp),%xmm0
mov    -0x38(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0xb67(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xb53(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm2
movsd  -0xd0(%rbp),%xmm0
ff
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm2
movsd  -0xc8(%rbp),%xmm0
ff
movsd  -0x28(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
mov    $0x2,%al
call   1060 <p3dBicubicInterpolation_16@plt>
mov    %ax,%dx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x40(%rbp),%ecx
mov    -0x38(%rbp),%rsi
imul   (%rsi),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dx,(%rax,%rcx,2)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1477 <p3dCartesian2polar_16+0x327>
jmp    1572 <p3dCartesian2polar_16+0x422>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1461 <p3dCartesian2polar_16+0x311>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p3dCartesian2polar_16>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r8,%r15
movsd  %xmm2,0x28(%rsp)
movsd  %xmm1,0x30(%rsp)
movapd %xmm0,%xmm2
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %rsi,0x48(%rsp)
mov    %rdi,0x50(%rsp)
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
addsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
movsd  %xmm2,0x40(%rsp)
jb     11a8 <p3dCartesian2polar_16+0x58>
sqrtsd %xmm0,%xmm0
jmp    11c3 <p3dCartesian2polar_16+0x73>
movsd  %xmm1,0x10(%rsp)
call   1070 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x10(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
movsd  %xmm0,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
subsd  %xmm0,%xmm2
mulsd  %xmm2,%xmm2
movsd  %xmm2,0x10(%rsp)
addsd  %xmm2,%xmm1
ucomisd %xmm3,%xmm1
jb     11f1 <p3dCartesian2polar_16+0xa1>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    11fa <p3dCartesian2polar_16+0xaa>
movapd %xmm1,%xmm0
call   1070 <sqrt@plt>
movsd  %xmm0,0x18(%rsp)
movsd  0x30(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
subsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm3,%xmm0
jb     1233 <p3dCartesian2polar_16+0xe3>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
jmp    124c <p3dCartesian2polar_16+0xfc>
movsd  %xmm1,0x8(%rsp)
call   1070 <sqrt@plt>
xorpd  %xmm3,%xmm3
movsd  0x8(%rsp),%xmm1
movapd %xmm0,%xmm2
movsd  0x10(%rsp),%xmm0
addsd  %xmm1,%xmm0
ucomisd %xmm3,%xmm0
mov    %r14d,0x3c(%rsp)
mov    %ebp,0x38(%rsp)
jb     126b <p3dCartesian2polar_16+0x11b>
sqrtsd %xmm0,%xmm0
jmp    127c <p3dCartesian2polar_16+0x12c>
movsd  %xmm2,0x8(%rsp)
call   1070 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
maxsd  0x18(%rsp),%xmm1
maxsd  %xmm2,%xmm1
maxsd  %xmm0,%xmm1
addsd  0xd68(%rip),%xmm1
mulsd  0x28(%rsp),%xmm1
cvttsd2si %xmm1,%r14d
mov    %r15,0x18(%rsp)
mov    %r14d,(%r15)
mov    %r14d,%edi
imul   %edi,%edi
mov    $0x2,%esi
call   1030 <calloc@plt>
mov    0x48(%rsp),%rcx
mov    %rax,(%rcx)
test   %r14d,%r14d
jle    13cf <p3dCartesian2polar_16+0x27f>
xor    %ebp,%ebp
movsd  0xd32(%rip),%xmm1
mov    0x3c(%rsp),%r13d
mov    0x38(%rsp),%ebx
mov    0x50(%rsp),%r12
jmp    12fc <p3dCartesian2polar_16+0x1ac>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    %r14d,%ebp
jge    13cf <p3dCartesian2polar_16+0x27f>
test   %r14d,%r14d
jle    12f0 <p3dCartesian2polar_16+0x1a0>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x28(%rsp)
xorps  %xmm2,%xmm2
cvtsi2sd %r14d,%xmm2
movsd  0x10(%rsp),%xmm0
divsd  %xmm2,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
call   1050 <cos@plt>
mulsd  0x28(%rsp),%xmm0
addsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <sin@plt>
movsd  0x28(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x30(%rsp),%xmm1
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
movsd  0x20(%rsp),%xmm0
mov    $0x2,%al
call   1060 <p3dBicubicInterpolation_16@plt>
movsd  0xc6b(%rip),%xmm1
mov    0x48(%rsp),%rcx
mov    (%rcx),%rcx
mov    0x18(%rsp),%rdx
mov    (%rdx),%r14d
mov    %ebp,%edx
imul   %r14d,%edx
movslq %edx,%rdx
add    %r15,%rdx
mov    %ax,(%rcx,%rdx,2)
add    $0x1,%r15
cmp    %r14d,%r15d
jl     1320 <p3dCartesian2polar_16+0x1d0>
jmp    12f0 <p3dCartesian2polar_16+0x1a0>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @p3dCartesian2polar_16(i16* %0, i16** nocapture %1, i32 %2, i32 %3, double %4, double %5, double %6, i32* nocapture %7) {
%9 = fmul double %5, %5
%10 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %9)
%11 = tail call double @sqrt(double %10)
%12 = sitofp i32 %2 to double
%13 = fsub double %4, %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %9)
%15 = tail call double @sqrt(double %14)
%16 = sitofp i32 %3 to double
%17 = fsub double %5, %16
%18 = fmul double %17, %17
%19 = tail call double @llvm.fmuladd.f64(double %4, double %4, double %18)
%20 = tail call double @sqrt(double %19)
%21 = tail call double @llvm.fmuladd.f64(double %13, double %13, double %18)
%22 = tail call double @sqrt(double %21)
%23 = fcmp ogt double %11, %15
%24 = select i1 %23, double %11, double %15
%25 = fcmp ogt double %24, %20
%26 = select i1 %25, double %24, double %20
%27 = fcmp ogt double %26, %22
%28 = select i1 %27, double %26, double %22
%29 = fadd double %28, 5.000000e-01
%30 = fmul double %29, %6
%31 = fptosi double %30 to i32
store i32 %31, i32* %7
%32 = mul nsw i32 %31, %31
%33 = zext i32 %32 to i64
%34 = tail call i8* @calloc(i64 %33, i64 2)
%35 = bitcast i16** %1 to i8**
store i8* %34, i8** %35
%36 = icmp sgt i32 %31, 0
br i1 %36, label %37, label %69
37: ; preds = %8, %65
%38 = phi i32 [ %66, %65 ], [ %31, %8 ]
%39 = phi i32 [ %67, %65 ], [ 0, %8 ]
%40 = icmp sgt i32 %38, 0
br i1 %40, label %41, label %65
41: ; preds = %37
%42 = sitofp i32 %39 to double
br label %43
43: ; preds = %41, %43
%44 = phi i32 [ %38, %41 ], [ %58, %43 ]
%45 = phi i32 [ 0, %41 ], [ %63, %43 ]
%46 = sitofp i32 %45 to double
%47 = sitofp i32 %44 to double
%48 = fdiv double %42, %47
%49 = fmul double %48, 0x400921FB54442D18
%50 = fmul double %49, 2.000000e+00
%51 = tail call double @cos(double %50)
%52 = tail call double @llvm.fmuladd.f64(double %46, double %51, double %4)
%53 = tail call double @sin(double %50)
%54 = tail call double @llvm.fmuladd.f64(double %46, double %53, double %5)
%55 = tail call i32 (i16*, i32, i32, double, double, ...) bitcast (i32 (...)* @p3dBicubicInterpolation_16 to i32 (i16*, i32, i32, double, double, ...)*)(i16* %0, i32 %2, i32 %3, double %52, double %54)
%56 = trunc i32 %55 to i16
%57 = load i16*, i16** %1
%58 = load i32, i32* %7
%59 = mul nsw i32 %58, %39
%60 = add nsw i32 %59, %45
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i16, i16* %57, i64 %61
store i16 %56, i16* %62
%63 = add nuw nsw i32 %45, 1
%64 = icmp slt i32 %63, %58
br i1 %64, label %43, label %65
65: ; preds = %43, %37
%66 = phi i32 [ %38, %37 ], [ %58, %43 ]
%67 = add nuw nsw i32 %39, 1
%68 = icmp slt i32 %67, %66
br i1 %68, label %37, label %69
69: ; preds = %65, %8
ret void
}