#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 cos(double);
int /*<<< orphan*/ deriv_prod(double *, double *, double *, double *, double *,
                              double *, int, int);
double exp(int /*<<< orphan*/);
double exppart(double *, double *, double *, double *, int);
int /*<<< orphan*/ normpart(double *, double *, double *, int);
double round(double);
double sin(double);
void finite_sum_with_derivatives(double *fsum_real, double *fsum_imag,
                                 double *X, double *Yinv, double *T, double *x,
                                 double *y, double *S, double *deriv_real,
                                 double *deriv_imag, int nderivs, int g,
                                 int N) {
  int k, j;
  double shift[g];
  double intshift[g];
  double fracshift[g];
  double sum;
  for (k = 0; k < g; k++) {
    sum = 0;
    for (j = 0; j < g; j++)
      sum += Yinv[k * g + j] * y[j];
    shift[k] = sum;
  }
  for (k = 0; k < g; k++) {
    intshift[k] = round(shift[k]);
    fracshift[k] = shift[k] - intshift[k];
  }
  double real_total = 0, imag_total = 0;
  double ept, npt, cpt, spt;
  double dpr[1];
  double dpi[1];
  double *n;
  dpr[0] = 0;
  dpi[0] = 0;
  for (k = 0; k < N; k++) {
    n = S + k * g;
    ept = exppart(n, X, x, intshift, g);
    npt = exp(normpart(n, T, fracshift, g));
    cpt = npt * cos(ept);
    spt = npt * sin(ept);
    deriv_prod(dpr, dpi, n, intshift, deriv_real, deriv_imag, nderivs, g);
    real_total += dpr[0] * cpt - dpi[0] * spt;
    imag_total += dpr[0] * spt + dpi[0] * cpt;
  }
  fsum_real[0] = real_total;
  fsum_imag[0] = imag_total;
}


x86 assembly (clang, -O0):
<finite_sum_with_derivatives>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x38(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    0x38(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x50(%rbp)
mov    0x38(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xb0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x38(%rbp),%eax
jge    12b0 <finite_sum_with_derivatives+0x140>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x38(%rbp),%eax
jge    128d <finite_sum_with_derivatives+0x11d>
mov    -0x20(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   0x38(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x10(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm2
movsd  -0x60(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    123e <finite_sum_with_derivatives+0xce>
mov    -0xc0(%rbp),%rax
movsd  -0x60(%rbp),%xmm0
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1223 <finite_sum_with_derivatives+0xb3>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x38(%rbp),%eax
jge    131f <finite_sum_with_derivatives+0x1af>
mov    -0xc0(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1080 <round@plt>
mov    -0xc0(%rbp),%rdx
mov    -0xb8(%rbp),%rcx
mov    -0xb0(%rbp),%rax
movslq -0x34(%rbp),%rsi
movsd  %xmm0,(%rcx,%rsi,8)
movslq -0x34(%rbp),%rsi
movsd  (%rdx,%rsi,8),%xmm0
movslq -0x34(%rbp),%rdx
subsd  (%rcx,%rdx,8),%xmm0
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12b7 <finite_sum_with_derivatives+0x147>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x70(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    0x40(%rbp),%eax
jge    14e3 <finite_sum_with_derivatives+0x373>
mov    -0xb8(%rbp),%rcx
mov    0x18(%rbp),%rax
mov    -0x34(%rbp),%edx
imul   0x38(%rbp),%edx
movslq %edx,%rdx
shl    $0x3,%rdx
add    %rdx,%rax
mov    %rax,-0xa8(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    0x38(%rbp),%r8d
call   1040 <exppart@plt>
mov    -0xb0(%rbp),%rdx
movsd  %xmm0,-0x78(%rbp)
mov    -0xa8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x38(%rbp),%ecx
call   1090 <normpart@plt>
mov    %eax,%edi
call   1060 <exp@plt>
movsd  %xmm0,-0x80(%rbp)
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
call   1050 <sin@plt>
mov    -0xb8(%rbp),%rcx
movaps %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
lea    -0x98(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
mov    -0xa8(%rbp),%rdx
mov    0x20(%rbp),%r8
mov    0x28(%rbp),%r9
mov    0x30(%rbp),%r10d
mov    0x38(%rbp),%eax
sub    $0x10,%rsp
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <deriv_prod@plt>
add    $0x10,%rsp
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x88(%rbp),%xmm2
ff
movsd  -0xa0(%rbp),%xmm1
ff
mulsd  -0x90(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x98(%rbp),%xmm0
ff
movsd  -0x90(%rbp),%xmm2
ff
movsd  -0xa0(%rbp),%xmm1
ff
mulsd  -0x88(%rbp),%xmm1
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    134c <finite_sum_with_derivatives+0x1dc>
movsd  -0x68(%rbp),%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x70(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<finite_sum_with_derivatives>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r9,-0xb8(%rbp)
mov    %r8,-0xb0(%rbp)
mov    %rdx,%r12
mov    %rsi,-0xa0(%rbp)
mov    %rdi,-0x98(%rbp)
mov    0x38(%rbp),%r15d
mov    %rsp,%r13
lea    0xf(,%r15,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsp,%rdx
sub    %rax,%rdx
mov    %rdx,%rsp
test   %r15d,%r15d
mov    %r12,-0xa8(%rbp)
jle    1442 <finite_sum_with_derivatives+0x2d2>
mov    %rdx,-0x60(%rbp)
mov    %r14,-0x80(%rbp)
mov    0x10(%rbp),%rax
lea    -0x1(%r15),%r8
mov    %r15d,%r14d
and    $0x3,%r14d
mov    %r15d,%r11d
and    $0xfffffffc,%r11d
lea    0x18(%rcx),%rbx
lea    0x0(,%r15,8),%r9
xor    %r10d,%r10d
jmp    122a <finite_sum_with_derivatives+0xba>
nopl   (%rax)
movsd  %xmm0,0x0(%r13,%r10,8)
add    $0x1,%r10
add    %r9,%rbx
add    %r9,%rcx
cmp    %r15,%r10
je     12bc <finite_sum_with_derivatives+0x14c>
xorpd  %xmm0,%xmm0
xor    %edx,%edx
cmp    $0x3,%r8
jb     1287 <finite_sum_with_derivatives+0x117>
cs nopw 0x0(%rax,%rax,1)
movsd  -0x18(%rbx,%rdx,8),%xmm1
movsd  -0x10(%rbx,%rdx,8),%xmm2
mulsd  (%rax,%rdx,8),%xmm1
mulsd  0x8(%rax,%rdx,8),%xmm2
addsd  %xmm0,%xmm1
movsd  -0x8(%rbx,%rdx,8),%xmm3
mulsd  0x10(%rax,%rdx,8),%xmm3
addsd  %xmm1,%xmm2
movsd  (%rbx,%rdx,8),%xmm0
mulsd  0x18(%rax,%rdx,8),%xmm0
addsd  %xmm2,%xmm3
addsd  %xmm3,%xmm0
add    $0x4,%rdx
cmp    %rdx,%r11
jne    1240 <finite_sum_with_derivatives+0xd0>
test   %r14,%r14
je     1210 <finite_sum_with_derivatives+0xa0>
lea    (%rax,%rdx,8),%rdi
lea    (%rcx,%rdx,8),%rdx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
movsd  (%rdx,%rsi,8),%xmm1
mulsd  (%rdi,%rsi,8),%xmm1
addsd  %xmm1,%xmm0
add    $0x1,%rsi
cmp    %rsi,%r14
jne    12a0 <finite_sum_with_derivatives+0x130>
jmp    1210 <finite_sum_with_derivatives+0xa0>
test   %r15d,%r15d
mov    -0x80(%rbp),%r14
mov    -0x60(%rbp),%rdx
jle    1442 <finite_sum_with_derivatives+0x2d2>
cmp    $0x1,%r15d
jne    12da <finite_sum_with_derivatives+0x16a>
xor    %ebx,%ebx
jmp    1410 <finite_sum_with_derivatives+0x2a0>
mov    %r15d,%ebx
and    $0xfffffffe,%ebx
lea    -0x2(%rbx),%rax
mov    %rax,%r14
shr    %r14
add    $0x1,%r14
test   %rax,%rax
mov    %r14,-0x68(%rbp)
je     13a8 <finite_sum_with_derivatives+0x238>
and    $0xfffffffffffffffe,%r14
xor    %r12d,%r12d
mov    -0x80(%rbp),%r15
cs nopw 0x0(%rax,%rax,1)
movaps 0x0(%r13,%r12,8),%xmm0
movaps %xmm0,-0x40(%rbp)
call   1080 <round@plt>
movaps %xmm0,-0x50(%rbp)
movapd -0x40(%rbp),%xmm0
unpckhpd %xmm0,%xmm0
call   1080 <round@plt>
movapd -0x50(%rbp),%xmm1
unpcklpd %xmm0,%xmm1
movapd %xmm1,(%r15,%r12,8)
movapd -0x40(%rbp),%xmm0
subpd  %xmm1,%xmm0
mov    -0x60(%rbp),%rax
movapd %xmm0,(%rax,%r12,8)
movaps 0x10(%r13,%r12,8),%xmm0
movaps %xmm0,-0x40(%rbp)
call   1080 <round@plt>
movaps %xmm0,-0x50(%rbp)
movapd -0x40(%rbp),%xmm0
unpckhpd %xmm0,%xmm0
call   1080 <round@plt>
mov    -0x60(%rbp),%rdx
movapd -0x50(%rbp),%xmm1
unpcklpd %xmm0,%xmm1
movapd %xmm1,0x10(%r15,%r12,8)
movapd -0x40(%rbp),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,0x10(%rdx,%r12,8)
add    $0x4,%r12
add    $0xfffffffffffffffe,%r14
jne    1310 <finite_sum_with_derivatives+0x1a0>
jmp    13af <finite_sum_with_derivatives+0x23f>
xor    %r12d,%r12d
mov    -0x80(%rbp),%r15
testb  $0x1,-0x68(%rbp)
mov    %r15,%r14
je     13fb <finite_sum_with_derivatives+0x28b>
movaps 0x0(%r13,%r12,8),%xmm0
movaps %xmm0,-0x40(%rbp)
call   1080 <round@plt>
movaps %xmm0,-0x50(%rbp)
movapd -0x40(%rbp),%xmm0
unpckhpd %xmm0,%xmm0
call   1080 <round@plt>
mov    -0x60(%rbp),%rdx
movapd -0x50(%rbp),%xmm1
unpcklpd %xmm0,%xmm1
movapd %xmm1,(%r14,%r12,8)
movapd -0x40(%rbp),%xmm0
subpd  %xmm1,%xmm0
movapd %xmm0,(%rdx,%r12,8)
mov    0x38(%rbp),%r15d
cmp    %r15,%rbx
je     1442 <finite_sum_with_derivatives+0x2d2>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x0(%r13,%rbx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
call   1080 <round@plt>
mov    -0x60(%rbp),%rdx
movsd  %xmm0,(%r14,%rbx,8)
movsd  -0x40(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,(%rdx,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1410 <finite_sum_with_derivatives+0x2a0>
movq   $0x0,-0x90(%rbp)
movq   $0x0,-0x88(%rbp)
mov    0x40(%rbp),%eax
test   %eax,%eax
jle    1588 <finite_sum_with_derivatives+0x418>
mov    0x18(%rbp),%r13
mov    %r14,%rbx
mov    %r15,%r14
movslq %r14d,%rcx
mov    %eax,%r12d
shl    $0x3,%rcx
mov    %rcx,-0x68(%rbp)
xorpd  %xmm0,%xmm0
mov    %rdx,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movapd %xmm0,-0x60(%rbp)
mov    %r13,%rdi
mov    -0xa8(%rbp),%rsi
mov    -0xb8(%rbp),%rdx
mov    %rbx,%rcx
mov    %r14d,%r8d
call   1040 <exppart@plt>
movsd  %xmm0,-0x40(%rbp)
mov    %r13,%rdi
mov    -0xb0(%rbp),%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1090 <normpart@plt>
mov    %eax,%edi
call   1060 <exp@plt>
movapd %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1070 <cos@plt>
movaps %xmm0,-0x80(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1050 <sin@plt>
movapd -0x50(%rbp),%xmm1
unpcklpd %xmm1,%xmm1
unpcklpd -0x80(%rbp),%xmm0
mulpd  %xmm1,%xmm0
movapd %xmm0,-0x40(%rbp)
lea    -0x90(%rbp),%rdi
lea    -0x88(%rbp),%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    0x20(%rbp),%r8
mov    0x28(%rbp),%r9
push   %r14
mov    0x30(%rbp),%eax
push   %rax
call   1030 <deriv_prod@plt>
add    $0x10,%rsp
movsd  -0x88(%rbp),%xmm0
ff
movapd %xmm0,%xmm1
xorpd  0xabb(%rip),%xmm1
movapd -0x40(%rbp),%xmm3
movapd %xmm3,%xmm2
shufpd $0x1,%xmm3,%xmm2
unpcklpd %xmm1,%xmm0
mulpd  %xmm2,%xmm0
movsd  -0x90(%rbp),%xmm1
ff
unpcklpd %xmm1,%xmm1
mulpd  %xmm3,%xmm1
addpd  %xmm0,%xmm1
movapd -0x60(%rbp),%xmm0
addpd  %xmm1,%xmm0
add    -0x68(%rbp),%r13
add    $0xffffffffffffffff,%r12
jne    1490 <finite_sum_with_derivatives+0x320>
jmp    158c <finite_sum_with_derivatives+0x41c>
xorpd  %xmm0,%xmm0
mov    -0x98(%rbp),%rax
movhpd %xmm0,(%rax)
mov    -0xa0(%rbp),%rax
movlpd %xmm0,(%rax)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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