void residual_null(double *param, double *fixed, int *lev, int *fact,
                   int *sumlev, int *spos_first, int *in_st, double *observed,
                   int *dimdata, int *model, double *RSS) {
  int i, j;
  int lentot = (dimdata[0]) * (dimdata[1]);
  double resid;
  double estimated[dimdata[1]];
  double parameters[sumlev[2]];
  if (*in_st == 0 || *model == 0) {
    parameters[0] = fixed[0];
    parameters[1] = fixed[1];
  } else {
    parameters[0] = param[0];
    parameters[1] = 0;
  }
  if (*model == 1) {
    for (i = 2; i < sumlev[1]; i++)
      parameters[i] = param[*in_st];
  }
  if (*model == 2) {
    for (i = 0; i < *fact; i++) {
      for (j = 0; j < lev[i]; j++)
        parameters[spos_first[i] + j] = param[i + *in_st];
    }
  }
  if (*model == 3) {
    for (i = 2; i < sumlev[1]; i++) {
      if (!isnan(fixed[i]))
        parameters[i] = fixed[i];
      else
        parameters[i] = param[i - 2 + *in_st];
    }
  }
  for (i = sumlev[1]; i < sumlev[2]; i++)
    parameters[i] = 0;
  averaging(parameters, lev, fact, sumlev, estimated);
  j = 0;
  for (i = 0; i < lentot; i++) {
    if (!isnan(observed[i])) {
      resid = estimated[j] - observed[i];
      *RSS += resid * resid;
    }
    if (i == ((dimdata[0]) * (j + 1) - 1))
      j++;
  }
}


x86 assembly (clang, -O0):
<residual_null>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    0x30(%rbp),%rax
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    0x20(%rbp),%rcx
mov    (%rcx),%eax
mov    0x4(%rcx),%ecx
imul   %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    0x20(%rbp),%rax
mov    0x4(%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
mov    0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     11cc <residual_null+0xac>
mov    0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11ef <residual_null+0xcf>
mov    -0x68(%rbp),%rax
mov    -0x10(%rbp),%rcx
movsd  (%rcx),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rcx
movsd  0x8(%rcx),%xmm0
movsd  %xmm0,0x8(%rax)
jmp    1207 <residual_null+0xe7>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
movsd  (%rcx),%xmm0
movsd  %xmm0,(%rax)
xorps  %xmm0,%xmm0
movsd  %xmm0,0x8(%rax)
mov    0x28(%rbp),%rax
cmpl   $0x1,(%rax)
jne    125b <residual_null+0x13b>
movl   $0x2,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    1256 <residual_null+0x136>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    0x10(%rbp),%rdx
movslq (%rdx),%rdx
movsd  (%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    121b <residual_null+0xfb>
jmp    125b <residual_null+0x13b>
mov    0x28(%rbp),%rax
cmpl   $0x2,(%rax)
jne    12ee <residual_null+0x1ce>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    12e9 <residual_null+0x1c9>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x34(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    12d6 <residual_null+0x1b6>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x34(%rbp),%edx
mov    0x10(%rbp),%rsi
add    (%rsi),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
mov    -0x30(%rbp),%rcx
movslq -0x34(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1285 <residual_null+0x165>
jmp    12db <residual_null+0x1bb>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    126f <residual_null+0x14f>
jmp    12ee <residual_null+0x1ce>
mov    0x28(%rbp),%rax
cmpl   $0x3,(%rax)
jne    138b <residual_null+0x26b>
movl   $0x2,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    0x4(%rcx),%eax
jge    1386 <residual_null+0x266>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x1,%al
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    134e <residual_null+0x22e>
mov    -0x68(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movsd  (%rcx,%rdx,8),%xmm0
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1373 <residual_null+0x253>
mov    -0x68(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x34(%rbp),%edx
sub    $0x2,%edx
mov    0x10(%rbp),%rsi
add    (%rsi),%edx
movslq %edx,%rdx
movsd  (%rcx,%rdx,8),%xmm0
movslq -0x34(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
jmp    1378 <residual_null+0x258>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1302 <residual_null+0x1e2>
jmp    138b <residual_null+0x26b>
mov    -0x28(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x28(%rbp),%rcx
cmp    0x8(%rcx),%eax
jge    13c3 <residual_null+0x2a3>
mov    -0x68(%rbp),%rax
movslq -0x34(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1395 <residual_null+0x275>
mov    -0x70(%rbp),%r8
mov    -0x68(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1040 <averaging@plt>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    148b <residual_null+0x36b>
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    $0x1,%al
call   1030 <isnan@plt>
cmp    $0x0,%eax
jne    1452 <residual_null+0x332>
mov    -0x70(%rbp),%rax
movslq -0x38(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
subsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mov    0x30(%rbp),%rax
movsd  (%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
mov    -0x34(%rbp),%eax
mov    0x20(%rbp),%rcx
mov    (%rcx),%ecx
mov    -0x38(%rbp),%edx
add    $0x1,%edx
imul   %edx,%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1478 <residual_null+0x358>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    147d <residual_null+0x35d>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13ec <residual_null+0x2cc>
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<residual_null>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r8,%r13
mov    %rsi,%r12
mov    %rdi,%r15
mov    0x20(%rbp),%rsi
mov    0x10(%rbp),%rax
mov    0x28(%rbp),%r8
mov    0x4(%rsi),%esi
mov    %rsp,%rbx
lea    0xf(,%rsi,8),%rdi
and    $0xfffffffffffffff0,%rdi
sub    %rdi,%rbx
mov    %rbx,-0x48(%rbp)
mov    %rbx,%rsp
mov    0x8(%r13),%r10d
mov    %rsp,%r14
lea    0xf(,%r10,8),%rdi
and    $0xfffffffffffffff0,%rdi
sub    %rdi,%r14
mov    %r14,%rsp
movslq (%rax),%rbx
mov    (%r8),%edi
test   %rbx,%rbx
je     11ac <residual_null+0x7c>
test   %edi,%edi
je     11aa <residual_null+0x7a>
movsd  (%r15),%xmm0
movsd  %xmm0,(%r14)
xorpd  %xmm0,%xmm0
jmp    11be <residual_null+0x8e>
xor    %edi,%edi
movsd  (%r12),%xmm0
movsd  %xmm0,(%r14)
movsd  0x8(%r12),%xmm0
mov    0x20(%rbp),%rax
mov    (%rax),%eax
imul   %esi,%eax
mov    %eax,-0x40(%rbp)
movsd  %xmm0,0x8(%r14)
cmp    $0x3,%edi
mov    %rdx,-0x30(%rbp)
je     13d6 <residual_null+0x2a6>
cmp    $0x2,%edi
je     1246 <residual_null+0x116>
cmp    $0x1,%edi
jne    14e3 <residual_null+0x3b3>
mov    0x4(%r13),%r9d
cmp    $0x3,%r9d
jl     14df <residual_null+0x3af>
movsd  (%r15,%rbx,8),%xmm0
lea    -0x2(%r9),%r8
mov    $0x2,%edx
cmp    $0x4,%r8
jb     14d0 <residual_null+0x3a0>
mov    %r8,%rdx
and    $0xfffffffffffffffc,%rdx
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%rdx),%rax
mov    %rax,%rdi
shr    $0x2,%rdi
add    $0x1,%rdi
mov    %edi,%esi
and    $0x3,%esi
cmp    $0xc,%rax
jae    1440 <residual_null+0x310>
xor    %ebx,%ebx
jmp    1495 <residual_null+0x365>
mov    (%rcx),%esi
test   %esi,%esi
jle    14e3 <residual_null+0x3b3>
mov    %edi,-0x3c(%rbp)
mov    %r10,-0x50(%rbp)
mov    %rcx,-0x38(%rbp)
lea    0x70(%r14),%rax
mov    %rax,-0x58(%rbp)
lea    0x10(%r14),%rax
mov    %rax,-0x60(%rbp)
xor    %edi,%edi
mov    %rbx,-0x68(%rbp)
jmp    128d <residual_null+0x15d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rdi
cmp    %rsi,%rdi
je     13c4 <residual_null+0x294>
mov    (%rdx,%rdi,4),%r10d
test   %r10d,%r10d
jle    1280 <residual_null+0x150>
lea    (%rdi,%rbx,1),%rax
movsd  (%r15,%rax,8),%xmm0
movslq (%r9,%rdi,4),%r11
cmp    $0x4,%r10d
jae    12c0 <residual_null+0x190>
xor    %r8d,%r8d
jmp    139e <residual_null+0x26e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rcx
mov    %r9,%r15
mov    %r13,%r9
mov    %r10d,%r8d
and    $0xfffffffc,%r8d
movapd %xmm0,%xmm1
unpcklpd %xmm0,%xmm1
lea    -0x4(%r8),%rdx
mov    %rdx,%rbx
shr    $0x2,%rbx
add    $0x1,%rbx
mov    %ebx,%eax
and    $0x3,%eax
cmp    $0xc,%rdx
jae    12f7 <residual_null+0x1c7>
xor    %r13d,%r13d
jmp    1351 <residual_null+0x221>
movabs $0x7ffffffffffffffc,%rdx
ff ff 7f
and    %rdx,%rbx
mov    -0x58(%rbp),%rdx
lea    (%rdx,%r11,8),%rdx
xor    %r13d,%r13d
nop
movupd %xmm1,-0x70(%rdx,%r13,8)
movupd %xmm1,-0x60(%rdx,%r13,8)
movupd %xmm1,-0x50(%rdx,%r13,8)
movupd %xmm1,-0x40(%rdx,%r13,8)
movupd %xmm1,-0x30(%rdx,%r13,8)
movupd %xmm1,-0x20(%rdx,%r13,8)
movupd %xmm1,-0x10(%rdx,%r13,8)
movupd %xmm1,(%rdx,%r13,8)
add    $0x10,%r13
add    $0xfffffffffffffffc,%rbx
jne    1310 <residual_null+0x1e0>
test   %rax,%rax
je     1384 <residual_null+0x254>
add    %r11,%r13
mov    -0x60(%rbp),%rdx
lea    (%rdx,%r13,8),%rdx
shl    $0x5,%rax
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movupd %xmm1,-0x10(%rdx,%rbx,1)
movupd %xmm1,(%rdx,%rbx,1)
add    $0x20,%rbx
cmp    %rbx,%rax
jne    1370 <residual_null+0x240>
cmp    %r10,%r8
mov    %r9,%r13
mov    -0x30(%rbp),%rdx
mov    %r15,%r9
mov    %rcx,%r15
mov    -0x68(%rbp),%rbx
je     1280 <residual_null+0x150>
lea    (%r14,%r11,8),%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,(%rax,%r8,8)
add    $0x1,%r8
cmp    %r8,%r10
jne    13b0 <residual_null+0x280>
jmp    1280 <residual_null+0x150>
cmpl   $0x3,-0x3c(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x50(%rbp),%r10
jne    14e3 <residual_null+0x3b3>
cmpl   $0x3,0x4(%r13)
jl     14e3 <residual_null+0x3b3>
mov    %rcx,-0x38(%rbp)
add    $0x10,%r12
mov    $0x2,%ebx
jmp    140b <residual_null+0x2db>
movsd  (%rcx),%xmm0
movsd  %xmm0,(%r14,%rbx,8)
add    $0x1,%rbx
movslq 0x4(%r13),%rax
add    $0x8,%r12
cmp    %rax,%rbx
jge    1433 <residual_null+0x303>
movsd  (%r12),%xmm0
mov    $0x1,%al
call   1040 <isnan@plt>
mov    %r12,%rcx
test   %eax,%eax
je     13f0 <residual_null+0x2c0>
mov    0x10(%rbp),%rax
movslq (%rax),%rax
add    %rbx,%rax
lea    (%r15,%rax,8),%rcx
add    $0xfffffffffffffff0,%rcx
jmp    13f0 <residual_null+0x2c0>
mov    0x8(%r13),%r10d
mov    -0x38(%rbp),%rcx
jmp    14df <residual_null+0x3af>
and    $0xfffffffffffffffc,%rdi
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movapd %xmm1,0x10(%r14,%rbx,8)
movapd %xmm1,0x20(%r14,%rbx,8)
movapd %xmm1,0x30(%r14,%rbx,8)
movapd %xmm1,0x40(%r14,%rbx,8)
movapd %xmm1,0x50(%r14,%rbx,8)
movapd %xmm1,0x60(%r14,%rbx,8)
movapd %xmm1,0x70(%r14,%rbx,8)
movapd %xmm1,0x80(%r14,%rbx,8)
add    $0x10,%rbx
add    $0xfffffffffffffffc,%rdi
jne    1450 <residual_null+0x320>
test   %rsi,%rsi
je     14c3 <residual_null+0x393>
nopw   0x0(%rax,%rax,1)
lea    0x0(,%rbx,8),%rax
or     $0x10,%rax
movapd %xmm1,(%r14,%rax,1)
movapd %xmm1,0x10(%r14,%rax,1)
add    $0x4,%rbx
add    $0xffffffffffffffff,%rsi
jne    14a0 <residual_null+0x370>
cmp    %rdx,%r8
je     14df <residual_null+0x3af>
or     $0x2,%rdx
nopl   0x0(%rax)
movsd  %xmm0,(%r14,%rdx,8)
add    $0x1,%rdx
cmp    %rdx,%r9
jne    14d0 <residual_null+0x3a0>
mov    -0x30(%rbp),%rdx
movslq 0x4(%r13),%rax
cmp    %r10d,%eax
jge    150e <residual_null+0x3de>
lea    (%r14,%rax,8),%rdi
not    %eax
add    %eax,%r10d
lea    0x8(,%r10,8),%rdx
xor    %esi,%esi
mov    %rcx,%rbx
call   1030 <memset@plt>
mov    -0x30(%rbp),%rdx
mov    %rbx,%rcx
xor    %ebx,%ebx
mov    %r14,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
mov    %r13,%rcx
mov    -0x48(%rbp),%r8
xor    %eax,%eax
call   1050 <averaging@plt>
mov    -0x40(%rbp),%eax
test   %eax,%eax
jle    1594 <residual_null+0x464>
mov    0x30(%rbp),%r14
mov    0x18(%rbp),%r15
mov    %eax,%r12d
xor    %r13d,%r13d
jmp    154b <residual_null+0x41b>
xchg   %ax,%ax
add    $0x1,%r13
mov    %eax,%ebx
cmp    %r13,%r12
je     1594 <residual_null+0x464>
movsd  (%r15,%r13,8),%xmm0
mov    $0x1,%al
call   1040 <isnan@plt>
test   %eax,%eax
jne    157c <residual_null+0x44c>
movslq %ebx,%rax
mov    -0x48(%rbp),%rcx
movsd  (%rcx,%rax,8),%xmm0
subsd  (%r15,%r13,8),%xmm0
mulsd  %xmm0,%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
lea    0x1(%rbx),%eax
mov    0x20(%rbp),%rcx
mov    (%rcx),%ecx
imul   %eax,%ecx
add    $0xffffffff,%ecx
cmp    %rcx,%r13
je     1540 <residual_null+0x410>
mov    %ebx,%eax
jmp    1540 <residual_null+0x410>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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