#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 M_PI;
scalar_t__ RAND_MAX;
int /*<<< orphan*/ csp2d_close(double **);
double csp2d_eval(double *, double **, int *, double *, double **, int *);
double **csp2d_open(double **, int *, double *);
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
double sin(double);
int sqrt(double);
int testmain2d(void) {
  double *f;
  int nx, ny, nf;
  int i, j;
  double xx, yy;
  double *x, *y;
  double r;
  double **splines;
  int interval[2];
  double *xv[2];
  int nv[2];
  double p[2];
  nx = 12;
  ny = 12;
  x = (double *)malloc(nx * sizeof(double));
  y = (double *)malloc(ny * sizeof(double));
  xv[0] = x;
  xv[1] = y;
  x[0] = 0.;
  y[0] = 0.;
  x[1] = 0.1;
  y[1] = 0.1;
  for (i = 2; i < nx; i++) {
    x[i] = i - 1.;
    y[i] = i - 1.;
  }
  nf = nx * ny;
  nv[0] = nx;
  nv[1] = ny;
  f = (double *)malloc(nf * sizeof(double));
  nf = 0;
  for (i = 0; i < nx; i++) {
    for (j = 0; j < ny; j++) {
      r = M_PI * sqrt(x[i] * x[i] + y[j] * y[j]) / 2.;
      yy = (r != 0.) ? sin(r) / r : 1.;
      int m = i * ny + j;
      if (m != nf) {
        printf("Mismatch\n");
        return 1;
      }
      f[m] = yy;
      nf++;
    }
  }
  splines = csp2d_open(xv, nv, f);
  for (i = 0; i < 2; i++)
    interval[i] = 0;
  for (i = 0; i < 50; i++) {
    double e, spl;
    double ex[2];
    if (i == 0) {
      ex[0] = 1.;
      ex[1] = 0.;
    } else if (i == 1) {
      ex[0] = 1.;
      ex[1] = 1.;
    } else {
      for (j = 0; j < 2; j++) {
        ex[j] = rand() / (double)RAND_MAX;
      }
      ex[rand() % 2] = 1.;
    }
    for (j = 0; j < 201; j++) {
      xx = j * ex[0] / 20.;
      yy = j * ex[1] / 20.;
      p[0] = xx;
      p[1] = yy;
      spl = csp2d_eval(p, xv, nv, f, splines, interval);
      r = M_PI * sqrt(xx * xx + yy * yy) / 2.;
      e = (r != 0.) ? sin(r) / r : 1.;
      printf("%8.5f %9.6f %9.6f %8.5f %8.5f\n", r, spl, e, xx, yy);
    }
  }
  free(f);
  csp2d_close(splines);
  return 0;
}


x86 assembly (clang, -O0):
<testmain2d>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0xc,-0x14(%rbp)
movl   $0xc,-0x18(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x48(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
movsd  0xdff(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
mov    -0x48(%rbp),%rax
movsd  0xdee(%rip),%xmm0
movsd  %xmm0,0x8(%rax)
movl   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1274 <testmain2d+0xe4>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xdb3(%rip),%xmm1
subsd  %xmm1,%xmm0
mov    -0x48(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121e <testmain2d+0x8e>
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x74(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    140d <testmain2d+0x27d>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    13fa <testmain2d+0x26a>
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc4(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x40(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x48(%rbp),%rax
movslq -0x24(%rbp),%rcx
mulsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
mov    %eax,%ecx
mov    -0xc4(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xcdf(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1357 <testmain2d+0x1c7>
jp     1357 <testmain2d+0x1c7>
jmp    1373 <testmain2d+0x1e3>
movsd  -0x50(%rbp),%xmm0
call   1060 <sin@plt>
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
jmp    1388 <testmain2d+0x1f8>
movsd  0xc8d(%rip),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
jmp    1388 <testmain2d+0x1f8>
movsd  -0xd0(%rbp),%xmm0
ff
movsd  %xmm0,-0x38(%rbp)
mov    -0x20(%rbp),%eax
imul   -0x18(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     13ce <testmain2d+0x23e>
lea    0xc65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    16cd <testmain2d+0x53d>
movsd  -0x38(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12be <testmain2d+0x12e>
jmp    13ff <testmain2d+0x26f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    12ab <testmain2d+0x11b>
lea    -0x70(%rbp),%rdi
lea    -0x78(%rbp),%rsi
mov    -0x10(%rbp),%rdx
call   1090 <csp2d_open@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x20(%rbp)
jge    144d <testmain2d+0x2bd>
movslq -0x20(%rbp),%rax
movl   $0x0,-0x60(%rbp,%rax,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1429 <testmain2d+0x299>
movl   $0x0,-0x20(%rbp)
cmpl   $0x32,-0x20(%rbp)
jge    16b4 <testmain2d+0x524>
cmpl   $0x0,-0x20(%rbp)
jne    1488 <testmain2d+0x2f8>
movsd  0xb98(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    1526 <testmain2d+0x396>
cmpl   $0x1,-0x20(%rbp)
jne    14b7 <testmain2d+0x327>
movsd  0xb6e(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  0xb5e(%rip),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
jmp    1521 <testmain2d+0x391>
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    14fe <testmain2d+0x36e>
mov    $0x0,%al
call   10a0 <rand@plt>
cvtsi2sd %eax,%xmm0
mov    0x2b06(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movslq -0x24(%rbp),%rax
movsd  %xmm0,-0xc0(%rbp,%rax,8)
ff ff
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    14be <testmain2d+0x32e>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movsd  0xaf0(%rip),%xmm0
movsd  %xmm0,-0xc0(%rbp,%rax,8)
ff ff
jmp    1526 <testmain2d+0x396>
movl   $0x0,-0x24(%rbp)
cmpl   $0xc9,-0x24(%rbp)
jge    16a1 <testmain2d+0x511>
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0xc0(%rbp),%xmm0
ff
movsd  0xac9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
mulsd  -0xb8(%rbp),%xmm0
ff
movsd  0xaab(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
lea    -0x90(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x78(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x58(%rbp),%r8
lea    -0x60(%rbp),%r9
call   10b0 <csp2d_eval@plt>
movsd  %xmm0,-0xa8(%rbp)
ff
mov    0x2a29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xd4(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
mov    %eax,%ecx
mov    -0xd4(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xa11(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1625 <testmain2d+0x495>
jp     1625 <testmain2d+0x495>
jmp    1641 <testmain2d+0x4b1>
movsd  -0x50(%rbp),%xmm0
call   1060 <sin@plt>
divsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
jmp    1656 <testmain2d+0x4c6>
movsd  0x9bf(%rip),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
jmp    1656 <testmain2d+0x4c6>
movsd  -0xe0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x50(%rbp),%xmm0
movsd  -0xa8(%rbp),%xmm1
ff
movsd  -0xa0(%rbp),%xmm2
ff
movsd  -0x30(%rbp),%xmm3
movsd  -0x38(%rbp),%xmm4
lea    0x99e(%rip),%rdi
mov    $0x5,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    152d <testmain2d+0x39d>
jmp    16a6 <testmain2d+0x516>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1454 <testmain2d+0x2c4>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1040 <csp2d_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testmain2d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    $0x60,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x60,%edi
call   1070 <malloc@plt>
mov    %rax,%r13
mov    %r14,0x50(%rsp)
mov    %rax,0x58(%rsp)
movq   $0x0,(%r14)
movq   $0x0,(%rax)
movabs $0x3fb999999999999a,%rax
99 b9 3f
mov    %rax,0x8(%r14)
mov    %rax,0x8(%r13)
movabs $0x3ff0000000000000,%rax
mov    %rax,0x10(%r14)
mov    %rax,0x10(%r13)
movabs $0x4000000000000000,%rax
mov    %rax,0x18(%r14)
mov    %rax,0x18(%r13)
movabs $0x4008000000000000,%rax
mov    %rax,0x20(%r14)
mov    %rax,0x20(%r13)
movabs $0x4010000000000000,%rax
mov    %rax,0x28(%r14)
mov    %rax,0x28(%r13)
movabs $0x4014000000000000,%rax
mov    %rax,0x30(%r14)
mov    %rax,0x30(%r13)
movabs $0x4018000000000000,%rax
mov    %rax,0x38(%r14)
mov    %rax,0x38(%r13)
movabs $0x401c000000000000,%rax
mov    %rax,0x40(%r14)
mov    %rax,0x40(%r13)
movabs $0x4020000000000000,%rax
mov    %rax,0x48(%r14)
mov    %rax,0x48(%r13)
movabs $0x4022000000000000,%rax
mov    %rax,0x50(%r14)
mov    %rax,0x50(%r13)
movabs $0x4024000000000000,%rax
mov    %rax,0x58(%r14)
mov    %rax,0x58(%r13)
movabs $0xc0000000c,%rax
mov    %rax,0x28(%rsp)
mov    $0x480,%edi
call   1070 <malloc@plt>
xor    %ebx,%ebx
mov    %rax,0x8(%rsp)
mov    %rax,%rbp
jmp    12d2 <testmain2d+0x142>
xchg   %ax,%ax
add    $0x1,%rbx
add    $0x60,%rbp
cmp    $0xc,%rbx
je     1357 <testmain2d+0x1c7>
xor    %r15d,%r15d
jmp    12f1 <testmain2d+0x161>
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,0x0(%rbp,%r15,8)
add    $0x1,%r15
cmp    $0xc,%r15
je     12c0 <testmain2d+0x130>
mov    0x2cf0(%rip),%rax
mov    (%rax),%r12d
movsd  (%r14,%rbx,8),%xmm0
movsd  0x0(%r13,%r15,8),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
imul   %r12d,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xcd4(%rip),%xmm1
ucomisd 0xcdc(%rip),%xmm1
movsd  0xccc(%rip),%xmm0
jne    1340 <testmain2d+0x1b0>
jnp    12e0 <testmain2d+0x150>
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
call   1060 <sin@plt>
divsd  0x10(%rsp),%xmm0
jmp    12e0 <testmain2d+0x150>
lea    0x50(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    0x8(%rsp),%rdx
call   1090 <csp2d_open@plt>
mov    %rax,%rbx
movq   $0x0,0x68(%rsp)
lea    0x68(%rsp),%r15
lea    0xcbd(%rip),%r14
xor    %eax,%eax
jmp    139f <testmain2d+0x20f>
nopw   0x0(%rax,%rax,1)
mov    %r12d,%eax
add    $0x1,%eax
cmp    $0x32,%eax
je     1587 <testmain2d+0x3f7>
test   %eax,%eax
je     13d0 <testmain2d+0x240>
mov    %eax,%r12d
cmp    $0x1,%eax
jne    13f0 <testmain2d+0x260>
movabs $0x3ff0000000000000,%rax
mov    %rax,0x30(%rsp)
movapd 0xc5e(%rip),%xmm0
jmp    146d <testmain2d+0x2dd>
nopw   0x0(%rax,%rax,1)
mov    %eax,%r12d
movabs $0x3ff0000000000000,%rax
mov    %rax,0x30(%rsp)
movsd  0xc1e(%rip),%xmm0
jmp    146d <testmain2d+0x2dd>
nop
xor    %eax,%eax
call   10a0 <rand@plt>
mov    %eax,%ebp
mov    0x2be0(%rip),%r13
xorps  %xmm0,%xmm0
cvtsi2sdq 0x0(%r13),%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
movd   %ebp,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sdq 0x0(%r13),%xmm1
movapd 0x10(%rsp),%xmm2
unpcklpd %xmm1,%xmm2
divpd  %xmm2,%xmm0
movapd %xmm0,0x30(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
and    $0xfffffffe,%ecx
sub    %ecx,%eax
cltq
movabs $0x3ff0000000000000,%rcx
mov    %rcx,0x30(%rsp,%rax,8)
movapd 0x30(%rsp),%xmm0
movapd %xmm0,0x40(%rsp)
xorpd  %xmm0,%xmm0
mov    $0xc9,%r13d
jmp    14b9 <testmain2d+0x329>
nop
mov    %r14,%rdi
movsd  0x60(%rsp),%xmm1
movaps 0x10(%rsp),%xmm3
movaps 0x70(%rsp),%xmm4
mov    $0x5,%al
call   1050 <printf@plt>
movsd  0xb66(%rip),%xmm1
movapd 0x80(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    $0xffffffff,%r13d
je     1390 <testmain2d+0x200>
movapd %xmm0,0x80(%rsp)
unpcklpd %xmm0,%xmm0
mulpd  0x40(%rsp),%xmm0
divpd  0xb5c(%rip),%xmm0
movapd %xmm0,0x10(%rsp)
movapd %xmm0,0x90(%rsp)
lea    0x90(%rsp),%rdi
lea    0x50(%rsp),%rsi
lea    0x28(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rbx,%r8
mov    %r15,%r9
call   10b0 <csp2d_eval@plt>
movsd  %xmm0,0x60(%rsp)
mov    0x2ad6(%rip),%rax
mov    (%rax),%ebp
movapd 0x10(%rsp),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
movapd %xmm1,0x70(%rsp)
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
call   1080 <sqrt@plt>
imul   %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xab5(%rip),%xmm0
ucomisd 0xabd(%rip),%xmm0
movsd  0xaad(%rip),%xmm2
jne    1563 <testmain2d+0x3d3>
jnp    1480 <testmain2d+0x2f0>
movsd  %xmm0,0x20(%rsp)
movsd  0x20(%rsp),%xmm0
call   1060 <sin@plt>
movapd %xmm0,%xmm2
movsd  0x20(%rsp),%xmm0
divsd  %xmm0,%xmm2
jmp    1480 <testmain2d+0x2f0>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1040 <csp2d_close@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@M_PI = global i32 0
@RAND_MAX = global i64 0
@.str.1 = [31 x i8] c"%8.5f %9.6f %9.6f %8.5f %8.5f\0A\00"
define i32 @testmain2d() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = alloca [2 x double*]
%4 = alloca [2 x i32]
%5 = alloca <2 x double>
%6 = alloca <2 x double>
%7 = bitcast [2 x double*]* %3 to i8*
%8 = bitcast [2 x i32]* %4 to i8*
%9 = bitcast <2 x double>* %5 to i8*
%10 = tail call i64 @malloc(i32 96)
%11 = inttoptr i64 %10 to double*
%12 = tail call i64 @malloc(i32 96)
%13 = inttoptr i64 %12 to double*
%14 = getelementptr inbounds [2 x double*], [2 x double*]* %3, i64 0, i64 0
store double* %11, double** %14
%15 = getelementptr inbounds [2 x double*], [2 x double*]* %3, i64 0, i64 1
store double* %13, double** %15
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %13
%16 = getelementptr inbounds double, double* %11, i64 1
store double 1.000000e-01, double* %16
%17 = getelementptr inbounds double, double* %13, i64 1
store double 1.000000e-01, double* %17
%18 = getelementptr inbounds double, double* %11, i64 2
store double 1.000000e+00, double* %18
%19 = getelementptr inbounds double, double* %13, i64 2
store double 1.000000e+00, double* %19
%20 = getelementptr inbounds double, double* %11, i64 3
store double 2.000000e+00, double* %20
%21 = getelementptr inbounds double, double* %13, i64 3
store double 2.000000e+00, double* %21
%22 = getelementptr inbounds double, double* %11, i64 4
store double 3.000000e+00, double* %22
%23 = getelementptr inbounds double, double* %13, i64 4
store double 3.000000e+00, double* %23
%24 = getelementptr inbounds double, double* %11, i64 5
store double 4.000000e+00, double* %24
%25 = getelementptr inbounds double, double* %13, i64 5
store double 4.000000e+00, double* %25
%26 = getelementptr inbounds double, double* %11, i64 6
store double 5.000000e+00, double* %26
%27 = getelementptr inbounds double, double* %13, i64 6
store double 5.000000e+00, double* %27
%28 = getelementptr inbounds double, double* %11, i64 7
store double 6.000000e+00, double* %28
%29 = getelementptr inbounds double, double* %13, i64 7
store double 6.000000e+00, double* %29
%30 = getelementptr inbounds double, double* %11, i64 8
store double 7.000000e+00, double* %30
%31 = getelementptr inbounds double, double* %13, i64 8
store double 7.000000e+00, double* %31
%32 = getelementptr inbounds double, double* %11, i64 9
store double 8.000000e+00, double* %32
%33 = getelementptr inbounds double, double* %13, i64 9
store double 8.000000e+00, double* %33
%34 = getelementptr inbounds double, double* %11, i64 10
store double 9.000000e+00, double* %34
%35 = getelementptr inbounds double, double* %13, i64 10
store double 9.000000e+00, double* %35
%36 = getelementptr inbounds double, double* %11, i64 11
store double 1.000000e+01, double* %36
%37 = getelementptr inbounds double, double* %13, i64 11
store double 1.000000e+01, double* %37
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 12, i32* %38
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 12, i32* %39
%40 = tail call i64 @malloc(i32 1152)
%41 = inttoptr i64 %40 to double*
br label %42
42: ; preds = %0, %68
%43 = phi i64 [ 0, %0 ], [ %69, %68 ]
%44 = getelementptr inbounds double, double* %11, i64 %43
%45 = mul nuw nsw i64 %43, 12
br label %46
46: ; preds = %42, %62
%47 = phi i64 [ 0, %42 ], [ %66, %62 ]
%48 = load i32, i32* @M_PI
%49 = load double, double* %44
%50 = getelementptr inbounds double, double* %13, i64 %47
%51 = load double, double* %50
%52 = fmul double %51, %51
%53 = tail call double @llvm.fmuladd.f64(double %49, double %49, double %52)
%54 = tail call i32 @sqrt(double %53)
%55 = mul nsw i32 %54, %48
%56 = sitofp i32 %55 to double
%57 = fmul double %56, 5.000000e-01
%58 = fcmp une double %57, 0.000000e+00
br i1 %58, label %59, label %62
59: ; preds = %46
%60 = tail call double @sin(double %57)
%61 = fdiv double %60, %57
br label %62
62: ; preds = %59, %46
%63 = phi double [ %61, %59 ], [ 1.000000e+00, %46 ]
%64 = add nuw nsw i64 %47, %45
%65 = getelementptr inbounds double, double* %41, i64 %64
store double %63, double* %65
%66 = add nuw nsw i64 %47, 1
%67 = icmp eq i64 %66, 12
br i1 %67, label %68, label %46
68: ; preds = %62
%69 = add nuw nsw i64 %43, 1
%70 = icmp eq i64 %69, 12
br i1 %70, label %71, label %42
71: ; preds = %68
%72 = call double** @csp2d_open(double** %14, i32* %38, double* %41)
store i64 0, i64* %1
%73 = bitcast <2 x double>* %6 to i8*
%74 = getelementptr inbounds <2 x double>, <2 x double>* %6, i64 0, i64 0
%75 = getelementptr inbounds <2 x double>, <2 x double>* %5, i64 0, i64 0
%76 = bitcast i64* %1 to i32*
br label %77
77: ; preds = %71, %126
%78 = phi i32 [ 0, %71 ], [ %127, %126 ]
switch i32 %78, label %79 [
i32 0, label %96
i32 1, label %97
]
79: ; preds = %77
%80 = call i32 (...) @rand()
%81 = load i64, i64* @RAND_MAX
%82 = call i32 (...) @rand()
%83 = insertelement <2 x i32> poison, i32 %80, i64 0
%84 = insertelement <2 x i32> %83, i32 %82, i64 1
%85 = sitofp <2 x i32> %84 to <2 x double>
%86 = load i64, i64* @RAND_MAX
%87 = insertelement <2 x i64> poison, i64 %81, i64 0
%88 = insertelement <2 x i64> %87, i64 %86, i64 1
%89 = sitofp <2 x i64> %88 to <2 x double>
%90 = fdiv <2 x double> %85, %89
store <2 x double> %90, <2 x double>* %6
%91 = call i32 (...) @rand()
%92 = srem i32 %91, 2
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds <2 x double>, <2 x double>* %6, i64 0, i64 %93
store double 1.000000e+00, double* %94
%95 = load <2 x double>, <2 x double>* %6
br label %98
96: ; preds = %77
store double 1.000000e+00, double* %74
br label %98
97: ; preds = %77
store double 1.000000e+00, double* %74
br label %98
98: ; preds = %97, %79, %96
%99 = phi <2 x double> [ <double 1.000000e+00, double 1.000000e+00>, %97 ], [ %95, %79 ], [ <double 1.000000e+00, double 0.000000e+00>, %96 ]
br label %100
100: ; preds = %98, %121
%101 = phi i32 [ 0, %98 ], [ %124, %121 ]
%102 = sitofp i32 %101 to double
%103 = insertelement <2 x double> poison, double %102, i64 0
%104 = shufflevector <2 x double> %103, <2 x double> poison, <2 x i32> zeroinitializer
%105 = fmul <2 x double> %99, %104
%106 = fdiv <2 x double> %105, <double 2.000000e+01, double 2.000000e+01>
store <2 x double> %106, <2 x double>* %5
%107 = call double @csp2d_eval(double* %75, double** %14, i32* %38, double* %41, double** %72, i32* %76)
%108 = load i32, i32* @M_PI
%109 = extractelement <2 x double> %106, i64 1
%110 = fmul double %109, %109
%111 = extractelement <2 x double> %106, i64 0
%112 = call double @llvm.fmuladd.f64(double %111, double %111, double %110)
%113 = call i32 @sqrt(double %112)
%114 = mul nsw i32 %113, %108
%115 = sitofp i32 %114 to double
%116 = fmul double %115, 5.000000e-01
%117 = fcmp une double %116, 0.000000e+00
br i1 %117, label %118, label %121
118: ; preds = %100
%119 = call double @sin(double %116)
%120 = fdiv double %119, %116
br label %121
121: ; preds = %100, %118
%122 = phi double [ %120, %118 ], [ 1.000000e+00, %100 ]
%123 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), double %116, double %107, double %122, double %111, double %109)
%124 = add nuw nsw i32 %101, 1
%125 = icmp eq i32 %124, 201
br i1 %125, label %126, label %100
126: ; preds = %121
%127 = add nuw nsw i32 %78, 1
%128 = icmp eq i32 %127, 50
br i1 %128, label %129, label %77
129: ; preds = %126
%130 = call i32 @free(double* %41)
%131 = call i32 @csp2d_close(double** %72)
ret i32 0
}