#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 */
double distance(double *, double *, int);
size_t ind(int, int, int);
int /*<<< orphan*/ interpintv(double *, double *, int, double, double *);
double *malloc(int);
scalar_t__ sqrt(double);
double c_curvspace(double *points, int p_size, int p_dim, int N,
                   double *output) {
  double totaldist, intv, remainder, distsum, disttmp;
  double dum, R;
  int p_ind_first, kk, k0, k;
  double *ptnow = malloc(sizeof(double) * p_dim);
  double *newpt = malloc(sizeof(double) * p_dim);
  double *pttarget = malloc(sizeof(double) * p_dim);
  totaldist = 0;
  for (k0 = 0; k0 < p_size - 1; k0++) {
    R = 0;
    for (k = 0; k < p_dim; k++) {
      dum = points[ind(k0, k, p_dim)] - points[ind(k0 + 1, k, p_dim)];
      R += dum * dum;
    }
    totaldist += sqrt(R);
  }
  intv = totaldist / (N - 1);
  for (k = 0; k < p_dim; k++) {
    output[k] = points[ind(0, k, p_dim)];
    ptnow[k] = points[ind(0, k, p_dim)];
  }
  p_ind_first = 1;
  int q_ind;
  for (q_ind = 1; q_ind < N; q_ind++) {
    distsum = 0;
    remainder = intv;
    kk = 0;
    while (1) {
      for (k = 0; k < p_dim; k++)
        pttarget[k] = points[ind(p_ind_first + kk, k, p_dim)];
      disttmp = distance(ptnow, pttarget, p_dim);
      distsum += disttmp;
      if (distsum >= intv) {
        interpintv(ptnow, pttarget, p_dim, remainder, newpt);
        break;
      } else {
        remainder -= disttmp;
        kk++;
        for (k = 0; k < p_dim; k++)
          ptnow[k] = pttarget[k];
        if (p_ind_first + kk == p_size) {
          for (k = 0; k < p_dim; k++)
            newpt[k] = points[ind(p_size - 1, k, p_dim)];
          break;
        }
      }
    }
    p_ind_first += kk;
    for (k = 0; k < p_dim; k++) {
      output[ind(q_ind, k, p_dim)] = newpt[k];
      ptnow[k] = newpt[k];
    }
  }
  return totaldist;
}


x86 assembly (clang, -O0):
<c_curvspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8,-0x20(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x70(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x78(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1299 <c_curvspace+0x149>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1272 <c_curvspace+0x122>
mov    -0x8(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <ind@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x64(%rbp),%edi
add    $0x1,%edi
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <ind@plt>
movsd  -0x98(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm2
movsd  -0x58(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    11d4 <c_curvspace+0x84>
movsd  -0x58(%rbp),%xmm0
call   1060 <sqrt@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    11b4 <c_curvspace+0x64>
movsd  -0x28(%rbp),%xmm0
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    133a <c_curvspace+0x1ea>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %edi,%edi
call   1030 <ind@plt>
mov    %rax,%rcx
mov    -0xb0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
xor    %edi,%edi
call   1030 <ind@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    12b8 <c_curvspace+0x168>
movl   $0x1,-0x5c(%rbp)
movl   $0x1,-0x84(%rbp)
mov    -0x84(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1591 <c_curvspace+0x441>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    13cc <c_curvspace+0x27c>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x5c(%rbp),%edi
add    -0x60(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <ind@plt>
mov    %rax,%rcx
mov    -0xb8(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x80(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    137a <c_curvspace+0x22a>
mov    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1070 <distance@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     141e <c_curvspace+0x2ce>
mov    -0x70(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x10(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
mov    -0x78(%rbp),%rcx
call   1050 <interpintv@plt>
jmp    14ec <c_curvspace+0x39c>
movsd  -0x48(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1475 <c_curvspace+0x325>
mov    -0x80(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1441 <c_curvspace+0x2f1>
mov    -0x5c(%rbp),%eax
add    -0x60(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    14e2 <c_curvspace+0x392>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    14dd <c_curvspace+0x38d>
mov    -0x8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0xc(%rbp),%edi
sub    $0x1,%edi
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <ind@plt>
mov    %rax,%rcx
mov    -0xc0(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x78(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    148b <c_curvspace+0x33b>
jmp    14ec <c_curvspace+0x39c>
jmp    14e7 <c_curvspace+0x397>
jmp    1373 <c_curvspace+0x223>
mov    -0x60(%rbp),%eax
add    -0x5c(%rbp),%eax
mov    %eax,-0x5c(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1578 <c_curvspace+0x428>
mov    -0x78(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
mov    -0x20(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x84(%rbp),%edi
mov    -0x68(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <ind@plt>
movsd  -0xd0(%rbp),%xmm0
ff
mov    %rax,%rcx
mov    -0xc8(%rbp),%rax
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x78(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x70(%rbp),%rax
movslq -0x68(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    14fc <c_curvspace+0x3ac>
jmp    157d <c_curvspace+0x42d>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    134b <c_curvspace+0x1fb>
movsd  -0x28(%rbp),%xmm0
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_curvspace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,0x58(%rsp)
mov    %rcx,0x38(%rsp)
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%r13
lea    0x0(,%r14,8),%ebx
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,0x48(%rsp)
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,0x40(%rsp)
mov    %ebx,%edi
mov    %r14,%rbx
call   1050 <malloc@plt>
mov    %rax,%r12
lea    -0x1(%rbp),%eax
mov    %eax,0x2c(%rsp)
mov    %ebx,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    %rbp,0x50(%rsp)
cmp    $0x2,%ebp
jl     1275 <c_curvspace+0x115>
xor    %ebp,%ebp
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
jmp    1208 <c_curvspace+0xa8>
nopl   (%rax)
call   1070 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
mov    (%rsp),%eax
mov    %eax,%ebp
cmp    0x2c(%rsp),%eax
je     1275 <c_curvspace+0x115>
lea    0x1(%rbp),%eax
mov    %eax,(%rsp)
xorpd  %xmm0,%xmm0
test   %ebx,%ebx
jle    11e0 <c_curvspace+0x80>
xorpd  %xmm0,%xmm0
xor    %r14d,%r14d
nopl   (%rax)
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <ind@plt>
movsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    (%rsp),%edi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <ind@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
subsd  0x0(%r13,%rax,8),%xmm1
mulsd  %xmm1,%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%r14d
cmp    %r14d,%ebx
jne    1220 <c_curvspace+0xc0>
jmp    11e0 <c_curvspace+0x80>
test   %ebx,%ebx
mov    0x48(%rsp),%r14
jle    12be <c_curvspace+0x15e>
xor    %ebp,%ebp
xor    %edi,%edi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <ind@plt>
movsd  0x0(%r13,%rax,8),%xmm0
mov    0x58(%rsp),%rax
movsd  %xmm0,(%rax,%rbp,8)
xor    %edi,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1030 <ind@plt>
movsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%r14,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1280 <c_curvspace+0x120>
cmpl   $0x2,0x38(%rsp)
jl     1503 <c_curvspace+0x3a3>
mov    0x38(%rsp),%rax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x20(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x68(%rsp)
lea    0x0(,%r15,8),%rax
mov    %rax,0x70(%rsp)
mov    $0x1,%ecx
mov    $0x1,%r14d
mov    %rbx,0x30(%rsp)
jmp    1322 <c_curvspace+0x1c2>
nopw   0x0(%rax,%rax,1)
mov    0x30(%rsp),%rbx
add    $0x1,%ecx
cmp    0x38(%rsp),%ecx
je     1503 <c_curvspace+0x3a3>
mov    %ecx,0x18(%rsp)
mov    0x50(%rsp),%rax
mov    %eax,%ecx
mov    %r14,%rax
mov    %r14,0x60(%rsp)
sub    %r14d,%ecx
mov    %ecx,0xc(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %r14d,%r14d
movsd  0x68(%rsp),%xmm0
movsd  %xmm0,(%rsp)
jmp    136b <c_curvspace+0x20b>
cs nopw 0x0(%rax,%rax,1)
cmp    0xc(%rsp),%r14d
je     14f5 <c_curvspace+0x395>
test   %ebx,%ebx
jle    13a2 <c_curvspace+0x242>
mov    0x60(%rsp),%rax
lea    (%r14,%rax,1),%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,%edx
call   1030 <ind@plt>
movsd  0x0(%r13,%rax,8),%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1380 <c_curvspace+0x220>
mov    0x48(%rsp),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    0x30(%rsp),%rbx
mov    %ebx,%edx
call   1080 <distance@plt>
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
ucomisd 0x68(%rsp),%xmm1
jae    1460 <c_curvspace+0x300>
movsd  %xmm1,0x10(%rsp)
add    $0x1,%r14d
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
test   %ebx,%ebx
jle    1360 <c_curvspace+0x200>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    0x70(%rsp),%rdx
call   1040 <memcpy@plt>
cmp    0xc(%rsp),%r14d
jne    136b <c_curvspace+0x20b>
xor    %ebx,%ebx
mov    0x2c(%rsp),%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebx,%esi
mov    %r15d,%edx
call   1030 <ind@plt>
movsd  0x0(%r13,%rax,8),%xmm0
mov    0x40(%rsp),%rax
movsd  %xmm0,(%rax,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1420 <c_curvspace+0x2c0>
mov    0xc(%rsp),%eax
mov    %eax,%r14d
mov    0x30(%rsp),%rbx
jmp    1477 <c_curvspace+0x317>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
movsd  (%rsp),%xmm0
mov    0x40(%rsp),%rcx
call   1060 <interpintv@plt>
add    0x60(%rsp),%r14d
test   %ebx,%ebx
mov    0x58(%rsp),%rax
mov    0x18(%rsp),%ecx
jle    1310 <c_curvspace+0x1b0>
mov    %r14,(%rsp)
xor    %ebp,%ebp
mov    0x40(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x18(%rsp),%edi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rax,%r14
call   1030 <ind@plt>
mov    0x18(%rsp),%ecx
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%r14,%rax,8)
mov    %r14,%rax
movsd  (%rbx,%rbp,8),%xmm0
mov    0x48(%rsp),%rdx
movsd  %xmm0,(%rdx,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r15
jne    14a0 <c_curvspace+0x340>
mov    0x30(%rsp),%rbx
mov    (%rsp),%r14
jmp    1315 <c_curvspace+0x1b5>
mov    0x50(%rsp),%r14
mov    0x18(%rsp),%ecx
jmp    1315 <c_curvspace+0x1b5>
movsd  0x20(%rsp),%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @c_curvspace(double* %0, i32 %1, i32 %2, i32 %3, double* %4) {
%6 = alloca double*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca double*
%23 = alloca double*
%24 = alloca double*
%25 = alloca i32
store double* %0, double** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store double* %4, double** %10
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul i64 8, %27
%29 = trunc i64 %28 to i32
%30 = call double* @malloc(i32 %29)
store double* %30, double** %22
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = mul i64 8, %32
%34 = trunc i64 %33 to i32
%35 = call double* @malloc(i32 %34)
store double* %35, double** %23
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = mul i64 8, %37
%39 = trunc i64 %38 to i32
%40 = call double* @malloc(i32 %39)
store double* %40, double** %24
store double 0.000000e+00, double* %11
store i32 0, i32* %20
br label %41
41: ; preds = %81, %5
%42 = load i32, i32* %20
%43 = load i32, i32* %7
%44 = sub nsw i32 %43, 1
%45 = icmp slt i32 %42, %44
br i1 %45, label %46, label %84
46: ; preds = %41
store double 0.000000e+00, double* %17
store i32 0, i32* %21
br label %47
47: ; preds = %72, %46
%48 = load i32, i32* %21
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %75
51: ; preds = %47
%52 = load double*, double** %6
%53 = load i32, i32* %20
%54 = load i32, i32* %21
%55 = load i32, i32* %8
%56 = call i64 @ind(i32 %53, i32 %54, i32 %55)
%57 = getelementptr inbounds double, double* %52, i64 %56
%58 = load double, double* %57
%59 = load double*, double** %6
%60 = load i32, i32* %20
%61 = add nsw i32 %60, 1
%62 = load i32, i32* %21
%63 = load i32, i32* %8
%64 = call i64 @ind(i32 %61, i32 %62, i32 %63)
%65 = getelementptr inbounds double, double* %59, i64 %64
%66 = load double, double* %65
%67 = fsub double %58, %66
store double %67, double* %16
%68 = load double, double* %16
%69 = load double, double* %16
%70 = load double, double* %17
%71 = call double @llvm.fmuladd.f64(double %68, double %69, double %70)
store double %71, double* %17
br label %72
72: ; preds = %51
%73 = load i32, i32* %21
%74 = add nsw i32 %73, 1
store i32 %74, i32* %21
br label %47
75: ; preds = %47
%76 = load double, double* %17
%77 = call i64 @sqrt(double %76)
%78 = sitofp i64 %77 to double
%79 = load double, double* %11
%80 = fadd double %79, %78
store double %80, double* %11
br label %81
81: ; preds = %75
%82 = load i32, i32* %20
%83 = add nsw i32 %82, 1
store i32 %83, i32* %20
br label %41
84: ; preds = %41
%85 = load double, double* %11
%86 = load i32, i32* %9
%87 = sub nsw i32 %86, 1
%88 = sitofp i32 %87 to double
%89 = fdiv double %85, %88
store double %89, double* %12
store i32 0, i32* %21
br label %90
90: ; preds = %115, %84
%91 = load i32, i32* %21
%92 = load i32, i32* %8
%93 = icmp slt i32 %91, %92
br i1 %93, label %94, label %118
94: ; preds = %90
%95 = load double*, double** %6
%96 = load i32, i32* %21
%97 = load i32, i32* %8
%98 = call i64 @ind(i32 0, i32 %96, i32 %97)
%99 = getelementptr inbounds double, double* %95, i64 %98
%100 = load double, double* %99
%101 = load double*, double** %10
%102 = load i32, i32* %21
%103 = sext i32 %102 to i64
%104 = getelementptr inbounds double, double* %101, i64 %103
store double %100, double* %104
%105 = load double*, double** %6
%106 = load i32, i32* %21
%107 = load i32, i32* %8
%108 = call i64 @ind(i32 0, i32 %106, i32 %107)
%109 = getelementptr inbounds double, double* %105, i64 %108
%110 = load double, double* %109
%111 = load double*, double** %22
%112 = load i32, i32* %21
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds double, double* %111, i64 %113
store double %110, double* %114
br label %115
115: ; preds = %94
%116 = load i32, i32* %21
%117 = add nsw i32 %116, 1
store i32 %117, i32* %21
br label %90
118: ; preds = %90
store i32 1, i32* %18
store i32 1, i32* %25
br label %119
119: ; preds = %251, %118
%120 = load i32, i32* %25
%121 = load i32, i32* %9
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %254
123: ; preds = %119
store double 0.000000e+00, double* %14
%124 = load double, double* %12
store double %124, double* %13
store i32 0, i32* %19
br label %125
125: ; preds = %123, %217
store i32 0, i32* %21
br label %126
126: ; preds = %144, %125
%127 = load i32, i32* %21
%128 = load i32, i32* %8
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %147
130: ; preds = %126
%131 = load double*, double** %6
%132 = load i32, i32* %18
%133 = load i32, i32* %19
%134 = add nsw i32 %132, %133
%135 = load i32, i32* %21
%136 = load i32, i32* %8
%137 = call i64 @ind(i32 %134, i32 %135, i32 %136)
%138 = getelementptr inbounds double, double* %131, i64 %137
%139 = load double, double* %138
%140 = load double*, double** %24
%141 = load i32, i32* %21
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds double, double* %140, i64 %142
store double %139, double* %143
br label %144
144: ; preds = %130
%145 = load i32, i32* %21
%146 = add nsw i32 %145, 1
store i32 %146, i32* %21
br label %126
147: ; preds = %126
%148 = load double*, double** %22
%149 = load double*, double** %24
%150 = load i32, i32* %8
%151 = call double @distance(double* %148, double* %149, i32 %150)
store double %151, double* %15
%152 = load double, double* %15
%153 = load double, double* %14
%154 = fadd double %153, %152
store double %154, double* %14
%155 = load double, double* %14
%156 = load double, double* %12
%157 = fcmp oge double %155, %156
br i1 %157, label %158, label %165
158: ; preds = %147
%159 = load double*, double** %22
%160 = load double*, double** %24
%161 = load i32, i32* %8
%162 = load double, double* %13
%163 = load double*, double** %23
%164 = call i32 @interpintv(double* %159, double* %160, i32 %161, double %162, double* %163)
br label %218
165: ; preds = %147
%166 = load double, double* %15
%167 = load double, double* %13
%168 = fsub double %167, %166
store double %168, double* %13
%169 = load i32, i32* %19
%170 = add nsw i32 %169, 1
store i32 %170, i32* %19
store i32 0, i32* %21
br label %171
171: ; preds = %185, %165
%172 = load i32, i32* %21
%173 = load i32, i32* %8
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %188
175: ; preds = %171
%176 = load double*, double** %24
%177 = load i32, i32* %21
%178 = sext i32 %177 to i64
%179 = getelementptr inbounds double, double* %176, i64 %178
%180 = load double, double* %179
%181 = load double*, double** %22
%182 = load i32, i32* %21
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds double, double* %181, i64 %183
store double %180, double* %184
br label %185
185: ; preds = %175
%186 = load i32, i32* %21
%187 = add nsw i32 %186, 1
store i32 %187, i32* %21
br label %171
188: ; preds = %171
%189 = load i32, i32* %18
%190 = load i32, i32* %19
%191 = add nsw i32 %189, %190
%192 = load i32, i32* %7
%193 = icmp eq i32 %191, %192
br i1 %193, label %194, label %216
194: ; preds = %188
store i32 0, i32* %21
br label %195
195: ; preds = %212, %194
%196 = load i32, i32* %21
%197 = load i32, i32* %8
%198 = icmp slt i32 %196, %197
br i1 %198, label %199, label %215
199: ; preds = %195
%200 = load double*, double** %6
%201 = load i32, i32* %7
%202 = sub nsw i32 %201, 1
%203 = load i32, i32* %21
%204 = load i32, i32* %8
%205 = call i64 @ind(i32 %202, i32 %203, i32 %204)
%206 = getelementptr inbounds double, double* %200, i64 %205
%207 = load double, double* %206
%208 = load double*, double** %23
%209 = load i32, i32* %21
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds double, double* %208, i64 %210
store double %207, double* %211
br label %212
212: ; preds = %199
%213 = load i32, i32* %21
%214 = add nsw i32 %213, 1
store i32 %214, i32* %21
br label %195
215: ; preds = %195
br label %218
216: ; preds = %188
br label %217
217: ; preds = %216
br label %125
218: ; preds = %215, %158
%219 = load i32, i32* %19
%220 = load i32, i32* %18
%221 = add nsw i32 %220, %219
store i32 %221, i32* %18
store i32 0, i32* %21
br label %222
222: ; preds = %247, %218
%223 = load i32, i32* %21
%224 = load i32, i32* %8
%225 = icmp slt i32 %223, %224
br i1 %225, label %226, label %250
226: ; preds = %222
%227 = load double*, double** %23
%228 = load i32, i32* %21
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds double, double* %227, i64 %229
%231 = load double, double* %230
%232 = load double*, double** %10
%233 = load i32, i32* %25
%234 = load i32, i32* %21
%235 = load i32, i32* %8
%236 = call i64 @ind(i32 %233, i32 %234, i32 %235)
%237 = getelementptr inbounds double, double* %232, i64 %236
store double %231, double* %237
%238 = load double*, double** %23
%239 = load i32, i32* %21
%240 = sext i32 %239 to i64
%241 = getelementptr inbounds double, double* %238, i64 %240
%242 = load double, double* %241
%243 = load double*, double** %22
%244 = load i32, i32* %21
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds double, double* %243, i64 %245
store double %242, double* %246
br label %247
247: ; preds = %226
%248 = load i32, i32* %21
%249 = add nsw i32 %248, 1
store i32 %249, i32* %21
br label %222
250: ; preds = %222
br label %251
251: ; preds = %250
%252 = load i32, i32* %25
%253 = add nsw i32 %252, 1
store i32 %253, i32* %25
br label %119
254: ; preds = %119
%255 = load double, double* %11
ret double %255
}

LLVM IR (-O2):
define double @c_curvspace(double* nocapture %0, i32 %1, i32 %2, i32 %3, double* nocapture writeonly %4) {
%6 = shl i32 %2, 3
%7 = tail call double* @malloc(i32 %6)
%8 = bitcast double* %7 to i8*
%9 = tail call double* @malloc(i32 %6)
%10 = tail call double* @malloc(i32 %6)
%11 = bitcast double* %10 to i8*
%12 = add i32 %1, -1
%13 = icmp sgt i32 %1, 1
br i1 %13, label %14, label %39
14: ; preds = %5
%15 = icmp sgt i32 %2, 0
br label %16
16: ; preds = %14, %33
%17 = phi double [ 0.000000e+00, %14 ], [ %37, %33 ]
%18 = phi i32 [ 0, %14 ], [ %19, %33 ]
%19 = add nuw nsw i32 %18, 1
br i1 %15, label %20, label %33
20: ; preds = %16, %20
%21 = phi i32 [ %31, %20 ], [ 0, %16 ]
%22 = phi double [ %30, %20 ], [ 0.000000e+00, %16 ]
%23 = tail call i64 @ind(i32 %18, i32 %21, i32 %2)
%24 = getelementptr inbounds double, double* %0, i64 %23
%25 = load double, double* %24
%26 = tail call i64 @ind(i32 %19, i32 %21, i32 %2)
%27 = getelementptr inbounds double, double* %0, i64 %26
%28 = load double, double* %27
%29 = fsub double %25, %28
%30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %22)
%31 = add nuw nsw i32 %21, 1
%32 = icmp eq i32 %31, %2
br i1 %32, label %33, label %20
33: ; preds = %20, %16
%34 = phi double [ 0.000000e+00, %16 ], [ %30, %20 ]
%35 = tail call i64 @sqrt(double %34)
%36 = sitofp i64 %35 to double
%37 = fadd double %17, %36
%38 = icmp eq i32 %19, %12
br i1 %38, label %39, label %16
39: ; preds = %33, %5
%40 = phi double [ 0.000000e+00, %5 ], [ %37, %33 ]
%41 = add nsw i32 %3, -1
%42 = sitofp i32 %41 to double
%43 = fdiv double %40, %42
%44 = icmp sgt i32 %2, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = zext i32 %2 to i64
br label %52
47: ; preds = %52, %39
%48 = icmp sgt i32 %3, 1
br i1 %48, label %49, label %125
49: ; preds = %47
%50 = zext i32 %2 to i64
%51 = shl nuw nsw i64 %50, 3
br label %65
52: ; preds = %45, %52
%53 = phi i64 [ 0, %45 ], [ %63, %52 ]
%54 = trunc i64 %53 to i32
%55 = tail call i64 @ind(i32 0, i32 %54, i32 %2)
%56 = getelementptr inbounds double, double* %0, i64 %55
%57 = load double, double* %56
%58 = getelementptr inbounds double, double* %4, i64 %53
store double %57, double* %58
%59 = tail call i64 @ind(i32 0, i32 %54, i32 %2)
%60 = getelementptr inbounds double, double* %0, i64 %59
%61 = load double, double* %60
%62 = getelementptr inbounds double, double* %7, i64 %53
store double %61, double* %62
%63 = add nuw nsw i64 %53, 1
%64 = icmp eq i64 %63, %46
br i1 %64, label %47, label %52
65: ; preds = %49, %121
%66 = phi i32 [ 1, %49 ], [ %123, %121 ]
%67 = phi i32 [ 1, %49 ], [ %122, %121 ]
%68 = sub i32 %1, %67
br label %69
69: ; preds = %95, %65
%70 = phi i32 [ 0, %65 ], [ %92, %95 ]
%71 = phi double [ 0.000000e+00, %65 ], [ %86, %95 ]
%72 = phi double [ %43, %65 ], [ %91, %95 ]
br i1 %44, label %73, label %84
73: ; preds = %69
%74 = add nsw i32 %70, %67
br label %75
75: ; preds = %73, %75
%76 = phi i64 [ 0, %73 ], [ %82, %75 ]
%77 = trunc i64 %76 to i32
%78 = tail call i64 @ind(i32 %74, i32 %77, i32 %2)
%79 = getelementptr inbounds double, double* %0, i64 %78
%80 = load double, double* %79
%81 = getelementptr inbounds double, double* %10, i64 %76
store double %80, double* %81
%82 = add nuw nsw i64 %76, 1
%83 = icmp eq i64 %82, %50
br i1 %83, label %84, label %75
84: ; preds = %75, %69
%85 = tail call double @distance(double* %7, double* %10, i32 %2)
%86 = fadd double %71, %85
%87 = fcmp ult double %86, %43
br i1 %87, label %90, label %88
88: ; preds = %84
%89 = tail call i32 @interpintv(double* %7, double* %10, i32 %2, double %72, double* %9)
br label %107
90: ; preds = %84
%91 = fsub double %72, %85
%92 = add nuw i32 %70, 1
br i1 %44, label %93, label %96
93: ; preds = %90
%94 = icmp eq i32 %92, %68
br i1 %94, label %98, label %95
95: ; preds = %93, %96
br label %69
96: ; preds = %90
%97 = icmp eq i32 %92, %68
br i1 %97, label %121, label %95
98: ; preds = %93, %98
%99 = phi i64 [ %105, %98 ], [ 0, %93 ]
%100 = trunc i64 %99 to i32
%101 = tail call i64 @ind(i32 %12, i32 %100, i32 %2)
%102 = getelementptr inbounds double, double* %0, i64 %101
%103 = load double, double* %102
%104 = getelementptr inbounds double, double* %9, i64 %99
store double %103, double* %104
%105 = add nuw nsw i64 %99, 1
%106 = icmp eq i64 %105, %50
br i1 %106, label %107, label %98
107: ; preds = %98, %88
%108 = phi i32 [ %70, %88 ], [ %68, %98 ]
%109 = add nsw i32 %108, %67
br i1 %44, label %110, label %121
110: ; preds = %107, %110
%111 = phi i64 [ %119, %110 ], [ 0, %107 ]
%112 = getelementptr inbounds double, double* %9, i64 %111
%113 = load double, double* %112
%114 = trunc i64 %111 to i32
%115 = tail call i64 @ind(i32 %66, i32 %114, i32 %2)
%116 = getelementptr inbounds double, double* %4, i64 %115
store double %113, double* %116
%117 = load double, double* %112
%118 = getelementptr inbounds double, double* %7, i64 %111
store double %117, double* %118
%119 = add nuw nsw i64 %111, 1
%120 = icmp eq i64 %119, %50
br i1 %120, label %121, label %110
121: ; preds = %96, %110, %107
%122 = phi i32 [ %109, %107 ], [ %109, %110 ], [ %1, %96 ]
%123 = add nuw nsw i32 %66, 1
%124 = icmp eq i32 %123, %3
br i1 %124, label %125, label %65
125: ; preds = %121, %47
ret double %40
}