#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*/ cp_vect(double **, double **, unsigned long);
int /*<<< orphan*/ do_vect(double **, unsigned long);
int /*<<< orphan*/ error_kernel_size(int, char *, unsigned int);
int /*<<< orphan*/ free(double *);
int gidz_cube(int, int, int, unsigned int);
int gidz_general(unsigned int, unsigned int, unsigned int, unsigned int,
                 unsigned int);
int /*<<< orphan*/ zero_vect(double *, unsigned long);
void convolve_kernel_outside(double **outmap, unsigned *out_extx,
                             unsigned *out_exty, unsigned *out_extz,
                             double *out_origx, double *out_origy,
                             double *out_origz, double *inmap, unsigned in_extx,
                             unsigned in_exty, unsigned in_extz,
                             double in_origx, double in_origy, double in_origz,
                             double widthx, double widthy, double widthz,
                             double *kernel, unsigned kernel_size) {
  double dval;
  unsigned long out_nvox;
  unsigned long in_nvox;
  unsigned indx, indy, indz, tmp_extx, tmp_exty;
  int indx2, indy2, indz2, margin;
  double *tmpmap;
  char *program = "lib_vwk";
  if (kernel_size < 1 || 2 * ((kernel_size + 1) / 2) - kernel_size - 1 != 0) {
    error_kernel_size(17160, program, kernel_size);
  }
  margin = (kernel_size - 1) / 2;
  tmp_extx = in_extx;
  tmp_exty = in_exty;
  *out_extx = kernel_size - 1 + in_extx;
  *out_exty = kernel_size - 1 + in_exty;
  *out_extz = kernel_size - 1 + in_extz;
  in_nvox = in_extx * in_exty * in_extz;
  out_nvox = (*out_extx) * (*out_exty) * (*out_extz);
  do_vect(&tmpmap, in_nvox);
  cp_vect(&tmpmap, &inmap, in_nvox);
  zero_vect(*outmap, out_nvox);
  for (indz = margin; indz < (*out_extz) - margin; indz++)
    for (indy = margin; indy < (*out_exty) - margin; indy++)
      for (indx = margin; indx < (*out_extx) - margin; indx++) {
        dval = *(tmpmap + gidz_general(indz - margin, indy - margin,
                                       indx - margin, tmp_exty, tmp_extx));
        if (dval != 0.0)
          for (indz2 = -margin; indz2 <= margin; indz2++)
            for (indy2 = -margin; indy2 <= margin; indy2++)
              for (indx2 = -margin; indx2 <= margin; indx2++) {
                *(*outmap + gidz_general(indz + indz2, indy + indy2,
                                         indx + indx2, (*out_exty),
                                         (*out_extx))) +=
                    *(kernel + gidz_cube(indz2 + margin, indy2 + margin,
                                         indx2 + margin, kernel_size)) *
                    dval;
              }
      }
  free(tmpmap);
  *out_origx = in_origx - widthx * margin;
  *out_origy = in_origy - widthy * margin;
  *out_origz = in_origz - widthz * margin;
}


x86 assembly (clang, -O0):
<convolve_kernel_outside>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
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)
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm1,-0x40(%rbp)
movsd  %xmm2,-0x48(%rbp)
movsd  %xmm3,-0x50(%rbp)
movsd  %xmm4,-0x58(%rbp)
movsd  %xmm5,-0x60(%rbp)
lea    0xe30(%rip),%rax
mov    %rax,-0xb0(%rbp)
cmpl   $0x1,0x40(%rbp)
jb     11fc <convolve_kernel_outside+0x8c>
mov    0x40(%rbp),%eax
add    $0x1,%eax
shr    $0x1,%eax
shl    $0x1,%eax
sub    0x40(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
je     1210 <convolve_kernel_outside+0xa0>
mov    -0xb0(%rbp),%rsi
mov    0x40(%rbp),%edx
mov    $0x4308,%edi
call   1040 <error_kernel_size@plt>
mov    0x40(%rbp),%eax
sub    $0x1,%eax
shr    $0x1,%eax
mov    %eax,-0x9c(%rbp)
mov    0x20(%rbp),%eax
mov    %eax,-0x88(%rbp)
mov    0x28(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    0x40(%rbp),%ecx
sub    $0x1,%ecx
add    0x20(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    0x40(%rbp),%ecx
sub    $0x1,%ecx
add    0x28(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    0x40(%rbp),%ecx
sub    $0x1,%ecx
add    0x30(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    0x20(%rbp),%eax
imul   0x28(%rbp),%eax
imul   0x30(%rbp),%eax
mov    %eax,%eax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
imul   (%rcx),%eax
mov    -0x20(%rbp),%rcx
imul   (%rcx),%eax
mov    %eax,%eax
mov    %rax,-0x70(%rbp)
mov    -0x78(%rbp),%rsi
lea    -0xa8(%rbp),%rdi
call   1070 <do_vect@plt>
mov    -0x78(%rbp),%rdx
lea    -0xa8(%rbp),%rdi
lea    0x18(%rbp),%rsi
call   1090 <cp_vect@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x70(%rbp),%rsi
call   1060 <zero_vect@plt>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    -0x20(%rbp),%rcx
mov    (%rcx),%ecx
sub    -0x9c(%rbp),%ecx
cmp    %ecx,%eax
jae    1547 <convolve_kernel_outside+0x3d7>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    -0x80(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
sub    -0x9c(%rbp),%ecx
cmp    %ecx,%eax
jae    152e <convolve_kernel_outside+0x3be>
mov    -0x9c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%ecx
sub    -0x9c(%rbp),%ecx
cmp    %ecx,%eax
jae    151b <convolve_kernel_outside+0x3ab>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x84(%rbp),%edi
sub    -0x9c(%rbp),%edi
mov    -0x80(%rbp),%esi
sub    -0x9c(%rbp),%esi
mov    -0x7c(%rbp),%edx
sub    -0x9c(%rbp),%edx
mov    -0x8c(%rbp),%ecx
mov    -0x88(%rbp),%r8d
call   1050 <gidz_general@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1394 <convolve_kernel_outside+0x224>
jp     1394 <convolve_kernel_outside+0x224>
jmp    1508 <convolve_kernel_outside+0x398>
xor    %eax,%eax
sub    -0x9c(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jg     1503 <convolve_kernel_outside+0x393>
xor    %eax,%eax
sub    -0x9c(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jg     14ea <convolve_kernel_outside+0x37a>
xor    %eax,%eax
sub    -0x9c(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0x90(%rbp),%eax
cmp    -0x9c(%rbp),%eax
jg     14d1 <convolve_kernel_outside+0x361>
mov    0x38(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    -0x98(%rbp),%edi
add    -0x9c(%rbp),%edi
mov    -0x94(%rbp),%esi
add    -0x9c(%rbp),%esi
mov    -0x90(%rbp),%edx
add    -0x9c(%rbp),%edx
mov    0x40(%rbp),%ecx
call   1080 <gidz_cube@plt>
mov    %eax,%ecx
mov    -0xd8(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x84(%rbp),%edi
add    -0x98(%rbp),%edi
mov    -0x80(%rbp),%esi
add    -0x94(%rbp),%esi
mov    -0x7c(%rbp),%edx
add    -0x90(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%r8d
call   1050 <gidz_general@plt>
movsd  -0xd0(%rbp),%xmm0
ff
movsd  -0xc8(%rbp),%xmm2
ff
mov    %eax,%ecx
mov    -0xc0(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    13e2 <convolve_kernel_outside+0x272>
jmp    14d6 <convolve_kernel_outside+0x366>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    13c2 <convolve_kernel_outside+0x252>
jmp    14ef <convolve_kernel_outside+0x37f>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    13a2 <convolve_kernel_outside+0x232>
jmp    1508 <convolve_kernel_outside+0x398>
jmp    150d <convolve_kernel_outside+0x39d>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    130c <convolve_kernel_outside+0x19c>
jmp    1520 <convolve_kernel_outside+0x3b0>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    12ec <convolve_kernel_outside+0x17c>
jmp    1533 <convolve_kernel_outside+0x3c3>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    12c9 <convolve_kernel_outside+0x159>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
movsd  -0x38(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm0
cvtsi2sdl -0x9c(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x40(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
cvtsi2sdl -0x9c(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x48(%rbp),%xmm1
movsd  -0x60(%rbp),%xmm0
cvtsi2sdl -0x9c(%rbp),%xmm2
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolve_kernel_outside>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xd8,%rsp
movsd  %xmm5,0xa8(%rsp)
movsd  %xmm4,0x98(%rsp)
movsd  %xmm3,0x80(%rsp)
movsd  %xmm2,0xa0(%rsp)
movsd  %xmm1,0x90(%rsp)
movsd  %xmm0,0x78(%rsp)
mov    %r9,0x88(%rsp)
mov    %r8,0x70(%rsp)
mov    %rcx,0x48(%rsp)
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,0x58(%rsp)
mov    0x140(%rsp),%r14d
mov    0x130(%rsp),%r12d
test   %r14d,%r14d
je     11ee <convolve_kernel_outside+0x7e>
lea    0x1(%r14),%eax
test   $0x1,%al
je     1202 <convolve_kernel_outside+0x92>
lea    0xe13(%rip),%rsi
mov    $0x4308,%edi
mov    %r14d,%edx
call   1040 <error_kernel_size@plt>
lea    -0x1(%r14),%ebp
shr    %ebp
mov    0x120(%rsp),%eax
mov    %rax,%rcx
add    %r14d,%eax
add    $0xffffffff,%eax
mov    %eax,(%rbx)
mov    0x128(%rsp),%r13d
lea    -0x1(%r14,%r13,1),%eax
mov    %eax,(%r15)
lea    -0x1(%r14,%r12,1),%r14d
mov    %r12,%rax
mov    0x48(%rsp),%r12
mov    %r14d,(%r12)
imul   %ecx,%r13d
imul   %eax,%r13d
imul   (%rbx),%r14d
imul   (%r15),%r14d
lea    0x20(%rsp),%rdi
mov    %r13,%rsi
call   1070 <do_vect@plt>
lea    0x118(%rsp),%rsi
lea    0x20(%rsp),%rdi
mov    %r13,%rdx
call   1090 <cp_vect@plt>
mov    0x58(%rsp),%rax
mov    (%rax),%rdi
mov    %r14,%rsi
call   1060 <zero_vect@plt>
mov    (%r12),%r8d
mov    %r8d,%eax
sub    %ebp,%eax
cmp    %eax,%ebp
jae    14c3 <convolve_kernel_outside+0x353>
mov    %ebp,%eax
neg    %eax
mov    %eax,0xc(%rsp)
mov    (%r15),%eax
lea    0x1(%rbp,%rbp,1),%r9d
mov    %ebp,%edx
mov    %rdx,0x10(%rsp)
mov    %r15,0x60(%rsp)
mov    %rbx,0x68(%rsp)
mov    %rbp,0xb8(%rsp)
mov    %r9d,0x38(%rsp)
jmp    12e5 <convolve_kernel_outside+0x175>
xchg   %ax,%ax
mov    0x48(%rsp),%rcx
mov    (%rcx),%r8d
mov    0x10(%rsp),%rcx
add    $0x1,%ecx
mov    %r8d,%edx
sub    %ebp,%edx
mov    %rcx,%rdi
mov    %rcx,0x10(%rsp)
cmp    %edx,%ecx
jae    14c3 <convolve_kernel_outside+0x353>
mov    %eax,%edx
sub    %ebp,%edx
cmp    %edx,%ebp
jae    12c8 <convolve_kernel_outside+0x158>
mov    0x10(%rsp),%rcx
sub    %ebp,%ecx
mov    %ecx,0x2c(%rsp)
mov    (%rbx),%ecx
mov    %ebp,%edx
mov    %rdx,0x18(%rsp)
jmp    1330 <convolve_kernel_outside+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x60(%rsp),%r15
mov    (%r15),%eax
mov    0x18(%rsp),%rsi
add    $0x1,%esi
mov    %eax,%edx
sub    %ebp,%edx
mov    %rsi,%rdi
mov    %rsi,0x18(%rsp)
cmp    %edx,%esi
jae    12c0 <convolve_kernel_outside+0x150>
mov    %ecx,%edx
sub    %ebp,%edx
cmp    %edx,%ebp
jae    1318 <convolve_kernel_outside+0x1a8>
mov    0x18(%rsp),%rax
sub    %ebp,%eax
mov    %eax,0x30(%rsp)
xor    %edx,%edx
mov    %ebp,%esi
jmp    136e <convolve_kernel_outside+0x1fe>
nopl   0x0(%rax)
mov    0x34(%rsp),%esi
add    $0x1,%esi
mov    0x68(%rsp),%rbx
mov    (%rbx),%ecx
mov    %ecx,%eax
sub    %ebp,%eax
mov    0x50(%rsp),%rdx
add    $0x1,%edx
cmp    %eax,%esi
jae    1310 <convolve_kernel_outside+0x1a0>
mov    %rdx,0x50(%rsp)
mov    0x20(%rsp),%rbx
mov    %esi,0x34(%rsp)
mov    %esi,%edx
sub    %ebp,%edx
mov    0x2c(%rsp),%edi
mov    0x30(%rsp),%esi
mov    0x128(%rsp),%ecx
mov    0x120(%rsp),%r8d
call   1050 <gidz_general@plt>
cltq
movsd  (%rbx,%rax,8),%xmm0
movsd  %xmm0,0xc8(%rsp)
ucomisd 0xc4c(%rip),%xmm0
jne    13b8 <convolve_kernel_outside+0x248>
jnp    1350 <convolve_kernel_outside+0x1e0>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
xchg   %ax,%ax
lea    (%rcx,%rbp,1),%r14d
mov    0x10(%rsp),%rax
mov    %rcx,0xb0(%rsp)
add    %ecx,%eax
mov    %eax,0x3c(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,%ecx
nopl   (%rax)
lea    (%rcx,%rbp,1),%eax
mov    %eax,0x44(%rsp)
mov    0x18(%rsp),%rax
mov    %rcx,0xc0(%rsp)
add    %ecx,%eax
mov    %eax,0x40(%rsp)
xor    %ebx,%ebx
mov    0x38(%rsp),%r15d
mov    0x50(%rsp),%r12
mov    0x3c(%rsp),%r13d
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    0x44(%rsp),%esi
mov    %ebx,%edx
mov    0x140(%rsp),%ecx
call   1080 <gidz_cube@plt>
cltq
mov    0x58(%rsp),%rcx
mov    (%rcx),%rbp
lea    (%r12,%rbx,1),%edx
mov    0x60(%rsp),%rcx
mov    (%rcx),%ecx
mov    0x68(%rsp),%rsi
mov    (%rsi),%r8d
mov    0x138(%rsp),%rsi
movsd  (%rsi,%rax,8),%xmm0
mulsd  0xc8(%rsp),%xmm0
movsd  %xmm0,0xd0(%rsp)
mov    %r13d,%edi
mov    0x40(%rsp),%esi
call   1050 <gidz_general@plt>
cltq
movsd  0xd0(%rsp),%xmm0
addsd  0x0(%rbp,%rax,8),%xmm0
movsd  %xmm0,0x0(%rbp,%rax,8)
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    1410 <convolve_kernel_outside+0x2a0>
mov    0xc0(%rsp),%rcx
lea    0x1(%rcx),%eax
mov    0xb8(%rsp),%rbp
cmp    %ebp,%ecx
mov    %eax,%ecx
jne    13e0 <convolve_kernel_outside+0x270>
mov    0xb0(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    %ebp,%ecx
mov    %eax,%ecx
jne    13c0 <convolve_kernel_outside+0x250>
jmp    1350 <convolve_kernel_outside+0x1e0>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  0x80(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x78(%rsp),%xmm2
subsd  %xmm1,%xmm2
mov    0x70(%rsp),%rax
movsd  %xmm2,(%rax)
movsd  0x98(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x90(%rsp),%xmm2
subsd  %xmm1,%xmm2
mov    0x88(%rsp),%rax
movsd  %xmm2,(%rax)
movsd  0xa8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0xa0(%rsp),%xmm0
subsd  %xmm1,%xmm0
mov    0x110(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0xd8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"lib_vwk\00"
define void @convolve_kernel_outside(double** nocapture %0, i32* nocapture %1, i32* nocapture %2, i32* nocapture %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture writeonly %6, double* %7, i32 %8, i32 %9, i32 %10, double %11, double %12, double %13, double %14, double %15, double %16, double* nocapture %17, i32 %18) {
%20 = alloca double*
%21 = alloca double*
store double* %7, double** %20
%22 = bitcast double** %21 to i8*
%23 = icmp eq i32 %18, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = add i32 %18, 1
%26 = and i32 %25, -2
%27 = icmp eq i32 %26, %25
br i1 %27, label %30, label %28
28: ; preds = %24, %19
%29 = tail call i32 @error_kernel_size(i32 17160, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %18)
br label %30
30: ; preds = %28, %24
%31 = add i32 %18, -1
%32 = lshr i32 %31, 1
%33 = add i32 %31, %8
store i32 %33, i32* %1
%34 = add i32 %31, %9
store i32 %34, i32* %2
%35 = add i32 %31, %10
store i32 %35, i32* %3
%36 = mul i32 %9, %8
%37 = mul i32 %36, %10
%38 = zext i32 %37 to i64
%39 = load i32, i32* %1
%40 = load i32, i32* %2
%41 = mul i32 %39, %35
%42 = mul i32 %41, %40
%43 = zext i32 %42 to i64
%44 = call i32 @do_vect(double** %21, i64 %38)
%45 = call i32 @cp_vect(double** %21, double** %20, i64 %38)
%46 = load double*, double** %0
%47 = call i32 @zero_vect(double* %46, i64 %43)
%48 = load i32, i32* %3
%49 = sub i32 %48, %32
%50 = icmp ult i32 %32, %49
br i1 %50, label %51, label %135
51: ; preds = %30
%52 = sub nsw i32 0, %32
%53 = load i32, i32* %2
br label %54
54: ; preds = %51, %128
%55 = phi i32 [ %48, %51 ], [ %129, %128 ]
%56 = phi i32 [ %53, %51 ], [ %130, %128 ]
%57 = phi i32 [ %53, %51 ], [ %131, %128 ]
%58 = phi i32 [ %32, %51 ], [ %132, %128 ]
%59 = sub i32 %57, %32
%60 = icmp ult i32 %32, %59
br i1 %60, label %61, label %128
61: ; preds = %54
%62 = sub nuw i32 %58, %32
%63 = load i32, i32* %1
br label %64
64: ; preds = %61, %120
%65 = phi i32 [ %56, %61 ], [ %121, %120 ]
%66 = phi i32 [ %63, %61 ], [ %122, %120 ]
%67 = phi i32 [ %32, %61 ], [ %123, %120 ]
%68 = sub i32 %66, %32
%69 = icmp ult i32 %32, %68
br i1 %69, label %70, label %120
70: ; preds = %64
%71 = sub nuw i32 %67, %32
br label %72
72: ; preds = %70, %113
%73 = phi i32 [ %32, %70 ], [ %114, %113 ]
%74 = load double*, double** %21
%75 = sub nuw i32 %73, %32
%76 = call i32 @gidz_general(i32 %62, i32 %71, i32 %75, i32 %9, i32 %8)
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds double, double* %74, i64 %77
%79 = load double, double* %78
%80 = fcmp oeq double %79, 0.000000e+00
br i1 %80, label %113, label %81
81: ; preds = %72, %110
%82 = phi i32 [ %111, %110 ], [ %52, %72 ]
%83 = add nsw i32 %82, %32
%84 = add i32 %82, %58
br label %85
85: ; preds = %107, %81
%86 = phi i32 [ %52, %81 ], [ %108, %107 ]
%87 = add nsw i32 %86, %32
%88 = add i32 %86, %67
br label %89
89: ; preds = %85, %89
%90 = phi i32 [ %52, %85 ], [ %105, %89 ]
%91 = add nsw i32 %90, %32
%92 = call i32 @gidz_cube(i32 %83, i32 %87, i32 %91, i32 %18)
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds double, double* %17, i64 %93
%95 = load double, double* %94
%96 = load double*, double** %0
%97 = add i32 %90, %73
%98 = load i32, i32* %2
%99 = load i32, i32* %1
%100 = call i32 @gidz_general(i32 %84, i32 %88, i32 %97, i32 %98, i32 %99)
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %96, i64 %101
%103 = load double, double* %102
%104 = call double @llvm.fmuladd.f64(double %95, double %79, double %103)
store double %104, double* %102
%105 = add i32 %90, 1
%106 = icmp eq i32 %90, %32
br i1 %106, label %107, label %89
107: ; preds = %89
%108 = add i32 %86, 1
%109 = icmp eq i32 %86, %32
br i1 %109, label %110, label %85
110: ; preds = %107
%111 = add i32 %82, 1
%112 = icmp eq i32 %82, %32
br i1 %112, label %113, label %81
113: ; preds = %110, %72
%114 = add nuw i32 %73, 1
%115 = load i32, i32* %1
%116 = sub i32 %115, %32
%117 = icmp ult i32 %114, %116
br i1 %117, label %72, label %118
118: ; preds = %113
%119 = load i32, i32* %2
br label %120
120: ; preds = %118, %64
%121 = phi i32 [ %119, %118 ], [ %65, %64 ]
%122 = phi i32 [ %115, %118 ], [ %66, %64 ]
%123 = add nuw i32 %67, 1
%124 = sub i32 %121, %32
%125 = icmp ult i32 %123, %124
br i1 %125, label %64, label %126
126: ; preds = %120
%127 = load i32, i32* %3
br label %128
128: ; preds = %126, %54
%129 = phi i32 [ %127, %126 ], [ %55, %54 ]
%130 = phi i32 [ %121, %126 ], [ %56, %54 ]
%131 = phi i32 [ %121, %126 ], [ %57, %54 ]
%132 = add nuw i32 %58, 1
%133 = sub i32 %129, %32
%134 = icmp ult i32 %132, %133
br i1 %134, label %54, label %135
135: ; preds = %128, %30
%136 = load double*, double** %21
%137 = call i32 @free(double* %136)
%138 = sitofp i32 %32 to double
%139 = fneg double %14
%140 = call double @llvm.fmuladd.f64(double %139, double %138, double %11)
store double %140, double* %4
%141 = fneg double %15
%142 = call double @llvm.fmuladd.f64(double %141, double %138, double %12)
store double %142, double* %5
%143 = fneg double %16
%144 = call double @llvm.fmuladd.f64(double %143, double %138, double %13)
store double %144, double* %6
ret void
}