#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int const);
int /*<<< orphan*/ memoryError();
int mod(int, int const);
void trapz_threeCell(double *Q, double *K, const int N, double *strength,
                     const double dx, double *result) {
  int i, j, k, i12, i13, k12, k13, N2 = N * N;
  double F1, sum12, sum13;
  double *F12, *F13;
  if ((F12 = (double *)malloc(N * N2 * sizeof(double))) == NULL)
    memoryError();
  if ((F13 = (double *)malloc(N * N2 * sizeof(double))) == NULL)
    memoryError();
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      for (k = 0; k < N; k++) {
        F1 = Q[i] * (strength[0] * K[N * i + j] + strength[1] * K[N * i + k]);
        F12[i * N2 + j * N + k] = F1 - Q[j] * (strength[2] * K[N * j + i] +
                                               strength[3] * K[N * j + k]);
        F13[i * N2 + j * N + k] = F1 - Q[k] * (strength[4] * K[N * k + i] +
                                               strength[5] * K[N * k + j]);
      }
    }
  }
  for (i12 = 0; i12 < N; i12++) {
    for (i13 = 0; i13 < N; i13++) {
      for (k = 0; k < N; k++) {
        k12 = mod(k - i12, N);
        k13 = mod(k - i13, N);
        sum12 =
            ((double)k * sum12 + F12[k * N2 + k12 * N + k13]) / (double)(k + 1);
        sum13 =
            ((double)k * sum13 + F13[k * N2 + k12 * N + k13]) / (double)(k + 1);
      }
      result[i12 * N + i13] = dx * sum12;
      result[i12 * N + i13 + N2] = dx * sum13;
    }
  }
  free(F12);
  free(F13);
}


x86 assembly (clang, -O0):
<trapz_threeCell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x50(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    1196 <trapz_threeCell+0x56>
mov    $0x0,%al
call   1060 <memoryError@plt>
mov    -0x14(%rbp),%eax
imul   -0x50(%rbp),%eax
cltq
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    11bf <trapz_threeCell+0x7f>
mov    $0x0,%al
call   1060 <memoryError@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13b3 <trapz_threeCell+0x273>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    13a0 <trapz_threeCell+0x260>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    138d <trapz_threeCell+0x24d>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm3
mov    -0x20(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x34(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm2
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  0x10(%rax),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm4
mov    -0x20(%rbp),%rax
movsd  0x18(%rax),%xmm3
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x38(%rbp),%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x70(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x50(%rbp),%ecx
mov    -0x38(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x58(%rbp),%xmm1
mov    -0x8(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  0x20(%rax),%xmm2
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x34(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm4
mov    -0x20(%rbp),%rax
movsd  0x28(%rax),%xmm3
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
imul   -0x3c(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mulsd  (%rax,%rcx,8),%xmm3
mulsd  %xmm4,%xmm2
addsd  %xmm3,%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x78(%rbp),%rax
mov    -0x34(%rbp),%ecx
imul   -0x50(%rbp),%ecx
mov    -0x38(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
add    -0x3c(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11ec <trapz_threeCell+0xac>
jmp    1392 <trapz_threeCell+0x252>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    11d9 <trapz_threeCell+0x99>
jmp    13a5 <trapz_threeCell+0x265>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c6 <trapz_threeCell+0x86>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1508 <trapz_threeCell+0x3c8>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    14f5 <trapz_threeCell+0x3b5>
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    14a4 <trapz_threeCell+0x364>
mov    -0x3c(%rbp),%edi
sub    -0x40(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <mod@plt>
mov    %eax,-0x48(%rbp)
mov    -0x3c(%rbp),%edi
sub    -0x44(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1040 <mod@plt>
mov    %eax,-0x4c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm2
mov    -0x70(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x50(%rbp),%ecx
mov    -0x48(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
mov    -0x78(%rbp),%rax
mov    -0x3c(%rbp),%ecx
imul   -0x50(%rbp),%ecx
mov    -0x48(%rbp),%edx
imul   -0x14(%rbp),%edx
add    %edx,%ecx
add    -0x4c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    13e0 <trapz_threeCell+0x2a0>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x60(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
movsd  -0x28(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
mov    -0x30(%rbp),%rax
mov    -0x40(%rbp),%ecx
imul   -0x14(%rbp),%ecx
add    -0x44(%rbp),%ecx
add    -0x50(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    13cd <trapz_threeCell+0x28d>
jmp    14fa <trapz_threeCell+0x3ba>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    13ba <trapz_threeCell+0x27a>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x78(%rbp),%rdi
call   1030 <free@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trapz_threeCell>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %r8,%r15
movsd  %xmm0,0x90(%rsp)
mov    %rcx,%r12
mov    %edx,%ebp
mov    %rsi,0x60(%rsp)
mov    %rdi,%r14
mov    %edx,%r13d
imul   %edx,%r13d
mov    %edx,0x4(%rsp)
imul   %r13d,%ebp
shl    $0x3,%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x38(%rsp)
test   %rax,%rax
jne    1194 <trapz_threeCell+0x54>
xor    %eax,%eax
call   1060 <memoryError@plt>
mov    %r13d,0x14(%rsp)
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,0x30(%rsp)
test   %rax,%rax
jne    11b1 <trapz_threeCell+0x71>
xor    %eax,%eax
call   1060 <memoryError@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
mov    0x38(%rsp),%rdi
jle    14b9 <trapz_threeCell+0x379>
mov    %r15,0x88(%rsp)
mov    %eax,%r15d
lea    0x0(,%r15,8),%rax
mov    %rax,0x18(%rsp)
mov    0x14(%rsp),%eax
mov    %rax,0x58(%rsp)
xor    %eax,%eax
mov    0x60(%rsp),%r11
mov    %r11,0x8(%rsp)
mov    %r11,%rbp
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rdx,%rdi
imul   %r15,%rdi
mov    %rdi,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %r11,%rcx
mov    %r11,%rbx
xor    %esi,%esi
mov    %rsi,0x40(%rsp)
xchg   %ax,%ax
mov    0x28(%rsp),%rdi
mov    0x40(%rsp),%r9
lea    (%r9,%rdi,1),%rsi
mov    %rsi,0x70(%rsp)
imul   %r15,%r9
add    %rdx,%r9
xor    %r10d,%r10d
xor    %r13d,%r13d
mov    0x8(%rsp),%r8
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%r12),%xmm0
movsd  0x8(%r12),%xmm1
mulsd  (%r8,%r13,8),%xmm1
mov    0x70(%rsp),%rsi
mulsd  (%r11,%rsi,8),%xmm0
addsd  %xmm1,%xmm0
mulsd  (%r14,%rdx,8),%xmm0
movsd  0x18(%r12),%xmm1
mulsd  (%rcx,%r13,8),%xmm1
movsd  0x10(%r12),%xmm2
mulsd  (%r11,%r9,8),%xmm2
addsd  %xmm1,%xmm2
mov    0x40(%rsp),%rsi
mulsd  (%r14,%rsi,8),%xmm2
movapd %xmm0,%xmm1
subsd  %xmm2,%xmm1
lea    (%rax,%r13,1),%r11d
movslq %r11d,%r11
mov    0x38(%rsp),%rdi
movsd  %xmm1,(%rdi,%r11,8)
movsd  0x20(%r12),%xmm1
movsd  0x28(%r12),%xmm2
mulsd  (%rbx,%r10,8),%xmm2
mulsd  0x0(%rbp,%r10,8),%xmm1
addsd  %xmm2,%xmm1
mulsd  (%r14,%r13,8),%xmm1
subsd  %xmm1,%xmm0
mov    0x30(%rsp),%rsi
movsd  %xmm0,(%rsi,%r11,8)
mov    0x60(%rsp),%r11
add    $0x1,%r13
add    %r15,%r10
cmp    %r13,%r15
jne    1250 <trapz_threeCell+0x110>
mov    0x40(%rsp),%r8
add    $0x1,%r8
add    $0x8,%rbx
add    0x18(%rsp),%rcx
add    %r15,%rax
mov    %r8,%rsi
mov    %r8,0x40(%rsp)
cmp    %r15,%r8
jne    1220 <trapz_threeCell+0xe0>
add    $0x1,%rdx
add    $0x8,%rbp
mov    0x8(%rsp),%rax
add    0x18(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0x20(%rsp),%rax
add    0x58(%rsp),%rax
cmp    %r15,%rdx
jne    1200 <trapz_threeCell+0xc0>
cmpl   $0x0,0x4(%rsp)
jle    14b9 <trapz_threeCell+0x379>
xor    %r13d,%r13d
xor    %eax,%eax
mov    0x30(%rsp),%r14
nopl   0x0(%rax)
mov    %rax,0x20(%rsp)
imul   %r15,%rax
mov    %rax,0x28(%rsp)
xor    %eax,%eax
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rax,0x8(%rsp)
mov    %rbp,0x18(%rsp)
xorpd  %xmm0,%xmm0
xor    %ebp,%ebp
xor    %r12d,%r12d
xorpd  %xmm1,%xmm1
nopw   0x0(%rax,%rax,1)
movapd %xmm0,0x60(%rsp)
movaps %xmm2,0x70(%rsp)
movapd %xmm1,0x40(%rsp)
lea    (%r12,%r13,1),%edi
mov    0x4(%rsp),%esi
call   1040 <mod@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rax
lea    (%rax,%r12,1),%edi
mov    0x4(%rsp),%esi
call   1040 <mod@plt>
movapd 0x40(%rsp),%xmm1
movsd  0xc10(%rip),%xmm0
mov    0x38(%rsp),%rdi
imul   0x4(%rsp),%ebx
add    %eax,%ebx
add    %ebp,%ebx
movslq %ebx,%rax
addsd  %xmm0,%xmm1
add    $0x1,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %r12d,%xmm0
movapd 0x60(%rsp),%xmm2
unpcklpd %xmm2,%xmm2
mulpd  0x70(%rsp),%xmm2
movapd %xmm2,%xmm3
movsd  (%r14,%rax,8),%xmm2
movhpd (%rdi,%rax,8),%xmm2
addpd  %xmm3,%xmm2
unpcklpd %xmm0,%xmm0
divpd  %xmm0,%xmm2
add    0x14(%rsp),%ebp
movapd %xmm1,%xmm0
cmp    %r12d,%r15d
jne    13b0 <trapz_threeCell+0x270>
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
movsd  0x90(%rsp),%xmm1
mulsd  %xmm1,%xmm0
mov    0x28(%rsp),%rax
mov    0x18(%rsp),%rbp
add    %rbp,%rax
mov    0x88(%rsp),%rsi
movsd  %xmm0,(%rsi,%rax,8)
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
add    0x58(%rsp),%rax
movsd  %xmm0,(%rsi,%rax,8)
add    $0x1,%rbp
mov    0x8(%rsp),%rax
add    $0xffffffff,%eax
cmp    %r15,%rbp
jne    1390 <trapz_threeCell+0x250>
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    $0xffffffff,%r13d
cmp    %r15,%rax
jne    1370 <trapz_threeCell+0x230>
call   1030 <free@plt>
mov    0x30(%rsp),%rdi
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

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

LLVM IR (-O2):
define void @trapz_threeCell(double* nocapture %0, double* nocapture %1, i32 %2, double* nocapture %3, double %4, double* nocapture writeonly %5) {
%7 = mul nsw i32 %2, %2
%8 = shl i32 %2, 3
%9 = mul i32 %8, %7
%10 = tail call i64 @malloc(i32 %9)
%11 = inttoptr i64 %10 to double*
%12 = icmp eq i64 %10, 0
br i1 %12, label %13, label %15
13: ; preds = %6
%14 = tail call i32 (...) @memoryError()
br label %15
15: ; preds = %13, %6
%16 = tail call i64 @malloc(i32 %9)
%17 = inttoptr i64 %16 to double*
%18 = icmp eq i64 %16, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 (...) @memoryError()
br label %21
21: ; preds = %19, %15
%22 = icmp sgt i32 %2, 0
br i1 %22, label %23, label %154
23: ; preds = %21
%24 = getelementptr inbounds double, double* %3, i64 1
%25 = getelementptr inbounds double, double* %3, i64 2
%26 = getelementptr inbounds double, double* %3, i64 3
%27 = getelementptr inbounds double, double* %3, i64 4
%28 = getelementptr inbounds double, double* %3, i64 5
%29 = zext i32 %2 to i64
%30 = zext i32 %2 to i64
br label %31
31: ; preds = %100, %23
%32 = phi i64 [ 0, %23 ], [ %101, %100 ]
%33 = getelementptr inbounds double, double* %0, i64 %32
%34 = mul nsw i64 %32, %29
%35 = trunc i64 %32 to i32
%36 = mul i32 %7, %35
br label %42
37: ; preds = %100
br i1 %22, label %38, label %154
38: ; preds = %37
%39 = zext i32 %7 to i64
%40 = zext i32 %2 to i64
%41 = zext i32 %2 to i64
br label %103
42: ; preds = %97, %31
%43 = phi i64 [ 0, %31 ], [ %98, %97 ]
%44 = add nuw nsw i64 %43, %34
%45 = getelementptr inbounds double, double* %1, i64 %44
%46 = getelementptr inbounds double, double* %0, i64 %43
%47 = mul nsw i64 %43, %29
%48 = add nuw nsw i64 %47, %32
%49 = getelementptr inbounds double, double* %1, i64 %48
%50 = trunc i64 %47 to i32
br label %51
51: ; preds = %42, %51
%52 = phi i64 [ 0, %42 ], [ %95, %51 ]
%53 = load double, double* %33
%54 = load double, double* %3
%55 = load double, double* %45
%56 = load double, double* %24
%57 = add nuw nsw i64 %52, %34
%58 = getelementptr inbounds double, double* %1, i64 %57
%59 = load double, double* %58
%60 = fmul double %56, %59
%61 = tail call double @llvm.fmuladd.f64(double %54, double %55, double %60)
%62 = fmul double %53, %61
%63 = load double, double* %46
%64 = load double, double* %25
%65 = load double, double* %49
%66 = load double, double* %26
%67 = add nuw nsw i64 %52, %47
%68 = getelementptr inbounds double, double* %1, i64 %67
%69 = load double, double* %68
%70 = fmul double %66, %69
%71 = tail call double @llvm.fmuladd.f64(double %64, double %65, double %70)
%72 = fneg double %63
%73 = tail call double @llvm.fmuladd.f64(double %72, double %71, double %62)
%74 = trunc i64 %52 to i32
%75 = add i32 %74, %50
%76 = add i32 %75, %36
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %11, i64 %77
store double %73, double* %78
%79 = getelementptr inbounds double, double* %0, i64 %52
%80 = load double, double* %79
%81 = load double, double* %27
%82 = mul nsw i64 %52, %29
%83 = add nuw nsw i64 %82, %32
%84 = getelementptr inbounds double, double* %1, i64 %83
%85 = load double, double* %84
%86 = load double, double* %28
%87 = add nuw nsw i64 %82, %43
%88 = getelementptr inbounds double, double* %1, i64 %87
%89 = load double, double* %88
%90 = fmul double %86, %89
%91 = tail call double @llvm.fmuladd.f64(double %81, double %85, double %90)
%92 = fneg double %80
%93 = tail call double @llvm.fmuladd.f64(double %92, double %91, double %62)
%94 = getelementptr inbounds double, double* %17, i64 %77
store double %93, double* %94
%95 = add nuw nsw i64 %52, 1
%96 = icmp eq i64 %95, %30
br i1 %96, label %97, label %51
97: ; preds = %51
%98 = add nuw nsw i64 %43, 1
%99 = icmp eq i64 %98, %30
br i1 %99, label %100, label %42
100: ; preds = %97
%101 = add nuw nsw i64 %32, 1
%102 = icmp eq i64 %101, %30
br i1 %102, label %37, label %31
103: ; preds = %151, %38
%104 = phi i64 [ 0, %38 ], [ %152, %151 ]
%105 = phi <2 x double> [ undef, %38 ], [ %138, %151 ]
%106 = mul nsw i64 %104, %40
%107 = trunc i64 %104 to i32
br label %108
108: ; preds = %140, %103
%109 = phi i64 [ 0, %103 ], [ %149, %140 ]
%110 = phi <2 x double> [ %105, %103 ], [ %138, %140 ]
%111 = trunc i64 %109 to i32
br label %112
112: ; preds = %108, %112
%113 = phi i32 [ %127, %112 ], [ 0, %108 ]
%114 = phi <2 x double> [ %138, %112 ], [ %110, %108 ]
%115 = sub nsw i32 %113, %107
%116 = tail call i32 @mod(i32 %115, i32 %2)
%117 = sub nsw i32 %113, %111
%118 = tail call i32 @mod(i32 %117, i32 %2)
%119 = sitofp i32 %113 to double
%120 = mul nsw i32 %113, %7
%121 = mul nsw i32 %116, %2
%122 = add nsw i32 %121, %120
%123 = add nsw i32 %122, %118
%124 = sext i32 %123 to i64
%125 = getelementptr inbounds double, double* %11, i64 %124
%126 = load double, double* %125
%127 = add nuw nsw i32 %113, 1
%128 = sitofp i32 %127 to double
%129 = getelementptr inbounds double, double* %17, i64 %124
%130 = load double, double* %129
%131 = insertelement <2 x double> poison, double %119, i64 0
%132 = shufflevector <2 x double> %131, <2 x double> poison, <2 x i32> zeroinitializer
%133 = insertelement <2 x double> poison, double %130, i64 0
%134 = insertelement <2 x double> %133, double %126, i64 1
%135 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %132, <2 x double> %114, <2 x double> %134)
%136 = insertelement <2 x double> poison, double %128, i64 0
%137 = shufflevector <2 x double> %136, <2 x double> poison, <2 x i32> zeroinitializer
%138 = fdiv <2 x double> %135, %137
%139 = icmp eq i32 %127, %2
br i1 %139, label %140, label %112
140: ; preds = %112
%141 = extractelement <2 x double> %138, i64 1
%142 = fmul double %141, %4
%143 = add nuw nsw i64 %109, %106
%144 = getelementptr inbounds double, double* %5, i64 %143
store double %142, double* %144
%145 = extractelement <2 x double> %138, i64 0
%146 = fmul double %145, %4
%147 = add nuw nsw i64 %143, %39
%148 = getelementptr inbounds double, double* %5, i64 %147
store double %146, double* %148
%149 = add nuw nsw i64 %109, 1
%150 = icmp eq i64 %149, %41
br i1 %150, label %151, label %108
151: ; preds = %140
%152 = add nuw nsw i64 %104, 1
%153 = icmp eq i64 %152, %41
br i1 %153, label %154, label %103
154: ; preds = %151, %21, %37
%155 = tail call i32 @free(double* %11)
%156 = tail call i32 @free(double* %17)
ret void
}