extern int filter(double *x, double *P, const double *H, const double *v,
                  const double *R, int n, int m) {
  double *x_, *xp_, *P_, *Pp_, *H_;
  int i, j, k, info, *ix;
  ix = imat(n, 1);
  for (i = k = 0; i < n; i++)
    if (x[i] != 0.0 && P[i + i * n] > 0.0)
      ix[k++] = i;
  x_ = mat(k, 1);
  xp_ = mat(k, 1);
  P_ = mat(k, k);
  Pp_ = mat(k, k);
  H_ = mat(k, m);
  for (i = 0; i < k; i++) {
    x_[i] = x[ix[i]];
    for (j = 0; j < k; j++)
      P_[i + j * k] = P[ix[i] + ix[j] * n];
    for (j = 0; j < m; j++)
      H_[i + j * k] = H[ix[i] + j * n];
  }
  info = filter_(x_, P_, H_, v, R, k, m, xp_, Pp_);
  for (i = 0; i < k; i++) {
    x[ix[i]] = xp_[i];
    for (j = 0; j < k; j++)
      P[ix[i] + ix[j] * n] = Pp_[i + j * k];
  }
  free(ix);
  free(x_);
  free(xp_);
  free(P_);
  free(Pp_);
  free(H_);
  return info;
}


x86 assembly (clang, -O0):
<filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <imat@plt>
cltq
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    120a <filter+0xca>
mov    -0x8(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ba <filter+0x7a>
jp     11ba <filter+0x7a>
jmp    11f7 <filter+0xb7>
mov    -0x10(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    -0x5c(%rbp),%edx
imul   -0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11f7 <filter+0xb7>
mov    -0x5c(%rbp),%edx
mov    -0x70(%rbp),%rax
mov    -0x64(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x64(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11fc <filter+0xbc>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1189 <filter+0x49>
mov    -0x64(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <mat@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x64(%rbp),%edi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <mat@plt>
cltq
mov    %rax,-0x40(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    $0x0,%al
call   1040 <mat@plt>
cltq
mov    %rax,-0x48(%rbp)
mov    -0x64(%rbp),%edi
mov    -0x64(%rbp),%esi
mov    $0x0,%al
call   1040 <mat@plt>
cltq
mov    %rax,-0x50(%rbp)
mov    -0x64(%rbp),%edi
mov    0x10(%rbp),%esi
mov    $0x0,%al
call   1040 <mat@plt>
cltq
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    136f <filter+0x22f>
mov    -0x8(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x38(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1303 <filter+0x1c3>
mov    -0x10(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
mov    -0x70(%rbp),%rdx
movslq -0x60(%rbp),%rsi
mov    (%rdx,%rsi,4),%edx
imul   -0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    -0x60(%rbp),%edx
imul   -0x64(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    12a9 <filter+0x169>
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    0x10(%rbp),%eax
jge    135c <filter+0x21c>
mov    -0x18(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
mov    -0x60(%rbp),%edx
imul   -0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x58(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    -0x60(%rbp),%edx
imul   -0x64(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    130a <filter+0x1ca>
jmp    1361 <filter+0x221>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1274 <filter+0x134>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x64(%rbp),%r9d
mov    0x10(%rbp),%r11d
mov    -0x40(%rbp),%r10
mov    -0x50(%rbp),%rax
mov    %r11d,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1060 <filter_@plt>
mov    %eax,-0x68(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1454 <filter+0x314>
mov    -0x40(%rbp),%rax
movslq -0x5c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x0,-0x60(%rbp)
mov    -0x60(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    1441 <filter+0x301>
mov    -0x50(%rbp),%rax
mov    -0x5c(%rbp),%ecx
mov    -0x60(%rbp),%edx
imul   -0x64(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
mov    -0x70(%rbp),%rcx
movslq -0x5c(%rbp),%rdx
mov    (%rcx,%rdx,4),%ecx
mov    -0x70(%rbp),%rdx
movslq -0x60(%rbp),%rsi
mov    (%rdx,%rsi,4),%edx
imul   -0x2c(%rbp),%edx
add    %edx,%ecx
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    13e7 <filter+0x2a7>
jmp    1446 <filter+0x306>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    13b2 <filter+0x272>
mov    -0x70(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
mov    -0x68(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9d,%ebp
mov    %r8,0x48(%rsp)
mov    %rcx,0x40(%rsp)
mov    %rdx,0x50(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r13
xor    %r15d,%r15d
mov    %r9d,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <imat@plt>
movslq %eax,%r14
test   %ebp,%ebp
jle    11d8 <filter+0x98>
mov    %ebp,%eax
xor    %ecx,%ecx
xorpd  %xmm0,%xmm0
xor    %edx,%edx
xor    %r15d,%r15d
jmp    11ab <filter+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rdx
add    %ebp,%ecx
cmp    %rdx,%rax
je     11d8 <filter+0x98>
movsd  0x0(%r13,%rdx,8),%xmm1
ucomisd %xmm0,%xmm1
jne    11ba <filter+0x7a>
jnp    11a0 <filter+0x60>
movslq %ecx,%rsi
add    %rdx,%rsi
movsd  (%rbx,%rsi,8),%xmm1
ucomisd %xmm0,%xmm1
jbe    11a0 <filter+0x60>
movslq %r15d,%rsi
add    $0x1,%r15d
mov    %edx,(%r14,%rsi,4)
jmp    11a0 <filter+0x60>
mov    %r15d,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <mat@plt>
cltq
mov    %rax,0x18(%rsp)
mov    %r15d,%edi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <mat@plt>
movslq %eax,%r12
mov    %r15d,%edi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <mat@plt>
cltq
mov    %rax,0x10(%rsp)
mov    %r15d,%edi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <mat@plt>
cltq
mov    %rax,0x8(%rsp)
mov    %r15d,%edi
mov    0xc0(%rsp),%eax
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <mat@plt>
movslq %eax,%rdx
test   %r15d,%r15d
jle    1541 <filter+0x401>
mov    %r12,0x68(%rsp)
mov    %r15d,0x24(%rsp)
mov    %r15d,%r15d
movslq %ebp,%r10
mov    0xc0(%rsp),%eax
mov    %eax,%esi
lea    -0x1(%r15),%rcx
mov    %rcx,0x60(%rsp)
mov    %r15d,%r11d
and    $0xfffffffe,%r11d
mov    %rsi,0x78(%rsp)
and    $0xfffffffe,%esi
mov    %rsi,0x70(%rsp)
mov    %r15,%r12
shl    $0x4,%r12
mov    %r10,0x38(%rsp)
shl    $0x4,%r10
xor    %r9d,%r9d
mov    %rdx,0x28(%rsp)
mov    0x10(%rsp),%rsi
mov    %r13,0x80(%rsp)
mov    0x18(%rsp),%rdi
mov    %rax,%rcx
jmp    12ca <filter+0x18a>
nopl   (%rax)
add    $0x1,%r9
mov    0x30(%rsp),%rsi
add    $0x8,%rsi
add    $0x8,%rdx
cmp    %r15,%r9
je     1421 <filter+0x2e1>
movslq (%r14,%r9,4),%r8
movsd  0x0(%r13,%r8,8),%xmm0
movsd  %xmm0,(%rdi,%r9,8)
cmpq   $0x0,0x60(%rsp)
mov    %rsi,0x30(%rsp)
je     1380 <filter+0x240>
xor    %r13d,%r13d
nop
mov    (%r14,%r13,4),%eax
imul   %ebp,%eax
add    %r8d,%eax
cltq
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rsi)
mov    0x4(%r14,%r13,4),%eax
imul   %ebp,%eax
add    %r8d,%eax
cltq
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,(%rsi,%r15,8)
add    $0x2,%r13
add    %r12,%rsi
cmp    %r13,%r11
jne    12f0 <filter+0x1b0>
test   $0x1,%r15b
je     1353 <filter+0x213>
movslq (%r14,%r13,4),%rax
imul   0x38(%rsp),%rax
add    %r8,%rax
movsd  (%rbx,%rax,8),%xmm0
imul   %r15,%r13
add    %r9,%r13
mov    0x10(%rsp),%rax
movsd  %xmm0,(%rax,%r13,8)
test   %ecx,%ecx
mov    0x80(%rsp),%r13
jle    12b0 <filter+0x170>
cmp    $0x1,%ecx
mov    %rdx,0x58(%rsp)
jne    1390 <filter+0x250>
xor    %esi,%esi
jmp    13d4 <filter+0x294>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %r13d,%r13d
test   $0x1,%r15b
jne    132f <filter+0x1ef>
jmp    1353 <filter+0x213>
nopl   0x0(%rax,%rax,1)
mov    0x38(%rsp),%rax
lea    (%rax,%r8,1),%rcx
mov    %rdx,%rax
mov    0x50(%rsp),%rdx
xor    %esi,%esi
mov    0x70(%rsp),%rdi
nopl   0x0(%rax,%rax,1)
movsd  (%rdx,%r8,8),%xmm0
movsd  %xmm0,(%rax)
movsd  (%rdx,%rcx,8),%xmm0
movsd  %xmm0,(%rax,%r15,8)
add    $0x2,%rsi
add    %r10,%rdx
add    %r12,%rax
cmp    %rsi,%rdi
jne    13b0 <filter+0x270>
testb  $0x1,0x78(%rsp)
mov    0x18(%rsp),%rdi
mov    0xc0(%rsp),%ecx
mov    0x58(%rsp),%rdx
je     12b0 <filter+0x170>
mov    %rsi,%rax
imul   0x38(%rsp),%rax
add    %r8,%rax
mov    0x50(%rsp),%rdx
movsd  (%rdx,%rax,8),%xmm0
mov    0x58(%rsp),%rdx
imul   %r15,%rsi
add    %r9,%rsi
mov    0x28(%rsp),%rax
movsd  %xmm0,(%rax,%rsi,8)
jmp    12b0 <filter+0x170>
sub    $0x8,%rsp
mov    0x18(%rsp),%rsi
mov    0x30(%rsp),%rdx
mov    %rcx,%r10
mov    0x48(%rsp),%rcx
mov    0x50(%rsp),%r8
mov    0x2c(%rsp),%r9d
xor    %eax,%eax
push   0x10(%rsp)
mov    0x78(%rsp),%r12
push   %r12
push   %r10
call   1060 <filter_@plt>
add    $0x20,%rsp
mov    %eax,0x30(%rsp)
cmpl   $0x0,0x24(%rsp)
jle    1580 <filter+0x440>
mov    %r15d,%r10d
and    $0xfffffffe,%r10d
mov    %r15,%rcx
shl    $0x4,%rcx
xor    %r9d,%r9d
mov    0x8(%rsp),%r11
mov    %r11,%r8
jmp    14a1 <filter+0x361>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r9
add    $0x8,%r8
cmp    %r15,%r9
je     152d <filter+0x3ed>
movsd  (%r12,%r9,8),%xmm0
movslq (%r14,%r9,4),%rdi
movsd  %xmm0,0x0(%r13,%rdi,8)
cmpq   $0x0,0x60(%rsp)
je     1500 <filter+0x3c0>
mov    %r8,%rdx
xor    %esi,%esi
nop
movsd  (%rdx),%xmm0
mov    (%r14,%rsi,4),%eax
imul   %ebp,%eax
add    %edi,%eax
cltq
movsd  %xmm0,(%rbx,%rax,8)
movsd  (%rdx,%r15,8),%xmm0
mov    0x4(%r14,%rsi,4),%eax
imul   %ebp,%eax
add    %edi,%eax
cltq
movsd  %xmm0,(%rbx,%rax,8)
add    $0x2,%rsi
add    %rcx,%rdx
cmp    %rsi,%r10
jne    14c0 <filter+0x380>
test   $0x1,%r15b
je     1490 <filter+0x350>
jmp    1508 <filter+0x3c8>
nop
xor    %esi,%esi
test   $0x1,%r15b
je     1490 <filter+0x350>
mov    %rsi,%rax
imul   %r15,%rax
add    %r9,%rax
movsd  (%r11,%rax,8),%xmm0
mov    (%r14,%rsi,4),%eax
imul   %ebp,%eax
add    %edi,%eax
cltq
movsd  %xmm0,(%rbx,%rax,8)
jmp    1490 <filter+0x350>
mov    0x18(%rsp),%rbx
mov    %r11,%rbp
mov    0x28(%rsp),%r13
mov    0x30(%rsp),%r15d
jmp    1594 <filter+0x454>
sub    $0x8,%rsp
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    0x48(%rsp),%rcx
mov    %rdx,%r13
mov    0x50(%rsp),%r8
mov    %r15d,%r9d
xor    %eax,%eax
push   0x10(%rsp)
push   %r12
mov    0xd8(%rsp),%ebp
push   %rbp
call   1060 <filter_@plt>
add    $0x20,%rsp
mov    %eax,%r15d
jmp    158f <filter+0x44f>
mov    0x18(%rsp),%rbx
mov    0x28(%rsp),%r13
mov    0x30(%rsp),%r15d
mov    0x8(%rsp),%rbp
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %r15d,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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