#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_inside_erode(double **outmap, double *inmap,
                                  unsigned in_extx, unsigned in_exty,
                                  unsigned in_extz, double *kernel,
                                  unsigned kernel_size) {
  unsigned long out_nvox;
  unsigned indx, indy, indz;
  int indx2, indy2, indz2, margin;
  double *tmpmap;
  double dval, dval2;
  unsigned skip;
  char *program = "lib_vwk";
  if (kernel_size < 1 || 2 * ((kernel_size + 1) / 2) - kernel_size - 1 != 0) {
    error_kernel_size(17150, program, kernel_size);
  }
  margin = (kernel_size - 1) / 2;
  out_nvox = in_extx * in_exty * in_extz;
  do_vect(&tmpmap, out_nvox);
  cp_vect(&tmpmap, &inmap, out_nvox);
  zero_vect(*outmap, out_nvox);
  for (indz = margin; indz < in_extz - margin; indz++)
    for (indy = margin; indy < in_exty - margin; indy++)
      for (indx = margin; indx < in_extx - margin; indx++) {
        skip = 0;
        for (indz2 = -margin; skip == 0 && indz2 <= margin; indz2++)
          for (indy2 = -margin; skip == 0 && indy2 <= margin; indy2++)
            for (indx2 = -margin; skip == 0 && indx2 <= margin; indx2++) {
              dval = *(tmpmap + gidz_general(indz + indz2, indy + indy2,
                                             indx + indx2, in_exty, in_extx));
              dval2 = *(kernel + gidz_cube(margin - indz2, margin - indy2,
                                           margin - indx2, kernel_size));
              if (dval == 0.0 && dval2 != 0.0)
                skip = 1;
            }
        if (skip == 0) {
          for (indz2 = -margin; indz2 <= margin; indz2++)
            for (indy2 = -margin; indy2 <= margin; indy2++)
              for (indx2 = -margin; indx2 <= margin; indx2++) {
                dval = *(tmpmap + gidz_general(indz + indz2, indy + indy2,
                                               indx + indx2, in_exty, in_extx));
                dval2 = *(kernel + gidz_cube(margin - indz2, margin - indy2,
                                             margin - indx2, kernel_size));
                *(*outmap + gidz_general(indz, indy, indx, in_exty, in_extx)) +=
                    dval * dval2;
              }
        }
      }
  free(tmpmap);
}


x86 assembly (clang, -O0):
<convolve_kernel_inside_erode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9,-0x28(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x78(%rbp)
cmpl   $0x1,0x10(%rbp)
jb     11c4 <convolve_kernel_inside_erode+0x54>
mov    0x10(%rbp),%eax
add    $0x1,%eax
shr    $0x1,%eax
shl    $0x1,%eax
sub    0x10(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
je     11d5 <convolve_kernel_inside_erode+0x65>
mov    -0x78(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    $0x42fe,%edi
call   1040 <error_kernel_size@plt>
mov    0x10(%rbp),%eax
sub    $0x1,%eax
shr    $0x1,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,%eax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    -0x58(%rbp),%rdi
call   1070 <do_vect@plt>
mov    -0x30(%rbp),%rdx
lea    -0x58(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <cp_vect@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <zero_vect@plt>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    -0x4c(%rbp),%ecx
cmp    %ecx,%eax
jae    1591 <convolve_kernel_inside_erode+0x421>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    -0x4c(%rbp),%ecx
cmp    %ecx,%eax
jae    157e <convolve_kernel_inside_erode+0x40e>
mov    -0x4c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x4c(%rbp),%ecx
cmp    %ecx,%eax
jae    156b <convolve_kernel_inside_erode+0x3fb>
movl   $0x0,-0x6c(%rbp)
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x6c(%rbp)
mov    %al,-0x79(%rbp)
jne    128f <convolve_kernel_inside_erode+0x11f>
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
setle  %al
mov    %al,-0x79(%rbp)
mov    -0x79(%rbp),%al
test   $0x1,%al
jne    129f <convolve_kernel_inside_erode+0x12f>
jmp    13f4 <convolve_kernel_inside_erode+0x284>
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x6c(%rbp)
mov    %al,-0x7a(%rbp)
jne    12c2 <convolve_kernel_inside_erode+0x152>
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
setle  %al
mov    %al,-0x7a(%rbp)
mov    -0x7a(%rbp),%al
test   $0x1,%al
jne    12d2 <convolve_kernel_inside_erode+0x162>
jmp    13e1 <convolve_kernel_inside_erode+0x271>
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x40(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x6c(%rbp)
mov    %al,-0x7b(%rbp)
jne    12f5 <convolve_kernel_inside_erode+0x185>
mov    -0x40(%rbp),%eax
cmp    -0x4c(%rbp),%eax
setle  %al
mov    %al,-0x7b(%rbp)
mov    -0x7b(%rbp),%al
test   $0x1,%al
jne    1305 <convolve_kernel_inside_erode+0x195>
jmp    13ce <convolve_kernel_inside_erode+0x25e>
mov    -0x58(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x3c(%rbp),%edi
add    -0x48(%rbp),%edi
mov    -0x38(%rbp),%esi
add    -0x44(%rbp),%esi
mov    -0x34(%rbp),%edx
add    -0x40(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1050 <gidz_general@plt>
mov    %eax,%ecx
mov    -0x90(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x4c(%rbp),%edi
sub    -0x48(%rbp),%edi
mov    -0x4c(%rbp),%esi
sub    -0x44(%rbp),%esi
mov    -0x4c(%rbp),%edx
sub    -0x40(%rbp),%edx
mov    0x10(%rbp),%ecx
call   1080 <gidz_cube@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13bb <convolve_kernel_inside_erode+0x24b>
jp     13bb <convolve_kernel_inside_erode+0x24b>
movsd  -0x68(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    13b4 <convolve_kernel_inside_erode+0x244>
jp     13b4 <convolve_kernel_inside_erode+0x244>
jmp    13bb <convolve_kernel_inside_erode+0x24b>
movl   $0x1,-0x6c(%rbp)
jmp    13c0 <convolve_kernel_inside_erode+0x250>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    12da <convolve_kernel_inside_erode+0x16a>
jmp    13d3 <convolve_kernel_inside_erode+0x263>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12a7 <convolve_kernel_inside_erode+0x137>
jmp    13e6 <convolve_kernel_inside_erode+0x276>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1274 <convolve_kernel_inside_erode+0x104>
cmpl   $0x0,-0x6c(%rbp)
jne    1558 <convolve_kernel_inside_erode+0x3e8>
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     1553 <convolve_kernel_inside_erode+0x3e3>
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     1540 <convolve_kernel_inside_erode+0x3d0>
xor    %eax,%eax
sub    -0x4c(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     152d <convolve_kernel_inside_erode+0x3bd>
mov    -0x58(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x3c(%rbp),%edi
add    -0x48(%rbp),%edi
mov    -0x38(%rbp),%esi
add    -0x44(%rbp),%esi
mov    -0x34(%rbp),%edx
add    -0x40(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1050 <gidz_general@plt>
mov    %eax,%ecx
mov    -0xb8(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x4c(%rbp),%edi
sub    -0x48(%rbp),%edi
mov    -0x4c(%rbp),%esi
sub    -0x44(%rbp),%esi
mov    -0x4c(%rbp),%edx
sub    -0x40(%rbp),%edx
mov    0x10(%rbp),%ecx
call   1080 <gidz_cube@plt>
mov    %eax,%ecx
mov    -0xb0(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x98(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1050 <gidz_general@plt>
movsd  -0xa8(%rbp),%xmm0
ff
movsd  -0xa0(%rbp),%xmm2
mov    %eax,%ecx
mov    -0x98(%rbp),%rax
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    142e <convolve_kernel_inside_erode+0x2be>
jmp    1532 <convolve_kernel_inside_erode+0x3c2>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    141a <convolve_kernel_inside_erode+0x2aa>
jmp    1545 <convolve_kernel_inside_erode+0x3d5>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1406 <convolve_kernel_inside_erode+0x296>
jmp    1558 <convolve_kernel_inside_erode+0x3e8>
jmp    155d <convolve_kernel_inside_erode+0x3ed>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1254 <convolve_kernel_inside_erode+0xe4>
jmp    1570 <convolve_kernel_inside_erode+0x400>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    123d <convolve_kernel_inside_erode+0xcd>
jmp    1583 <convolve_kernel_inside_erode+0x413>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1226 <convolve_kernel_inside_erode+0xb6>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convolve_kernel_inside_erode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r12
mov    %r8d,%r14d
mov    %ecx,%ebx
mov    %edx,%r13d
mov    %rdi,0x68(%rsp)
mov    0xc0(%rsp),%ebp
mov    %rsi,0x80(%rsp)
test   %ebp,%ebp
je     11ab <convolve_kernel_inside_erode+0x3b>
lea    0x1(%rbp),%eax
test   $0x1,%al
je     11be <convolve_kernel_inside_erode+0x4e>
lea    0xe56(%rip),%rsi
mov    $0x42fe,%edi
mov    %ebp,%edx
call   1040 <error_kernel_size@plt>
lea    -0x1(%rbp),%r15d
shr    %r15d
mov    %ebx,0x1c(%rsp)
mov    %r13d,0x18(%rsp)
imul   %r13d,%ebx
mov    %r14d,%ebp
imul   %r14d,%ebx
lea    0x58(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <do_vect@plt>
lea    0x80(%rsp),%rsi
mov    %r14,%rdi
mov    %rbx,%rdx
call   1090 <cp_vect@plt>
mov    0x68(%rsp),%rax
mov    (%rax),%rdi
mov    %rbx,%rsi
call   1060 <zero_vect@plt>
mov    %r15,%rdx
sub    %edx,%ebp
mov    %ebp,0x64(%rsp)
cmp    %ebp,%edx
jae    14e3 <convolve_kernel_inside_erode+0x373>
mov    0x1c(%rsp),%eax
sub    %edx,%eax
mov    %eax,0x28(%rsp)
mov    0x18(%rsp),%eax
sub    %edx,%eax
mov    %eax,0x2c(%rsp)
mov    %edx,%eax
neg    %eax
mov    %eax,0x4(%rsp)
lea    (%rdx,%rdx,1),%eax
mov    %eax,0x30(%rsp)
mov    %edx,%esi
mov    %r12,0x70(%rsp)
jmp    125d <convolve_kernel_inside_erode+0xed>
nopl   0x0(%rax)
add    $0x1,%esi
cmp    0x64(%rsp),%esi
je     14e3 <convolve_kernel_inside_erode+0x373>
cmp    0x28(%rsp),%edx
jae    1250 <convolve_kernel_inside_erode+0xe0>
mov    %edx,%ebx
mov    %rsi,0x48(%rsp)
jmp    1279 <convolve_kernel_inside_erode+0x109>
nopl   0x0(%rax)
add    $0x1,%ebx
cmp    0x28(%rsp),%ebx
je     1250 <convolve_kernel_inside_erode+0xe0>
cmp    0x2c(%rsp),%edx
jae    1270 <convolve_kernel_inside_erode+0x100>
movl   $0x0,0x8(%rsp)
mov    %edx,%eax
mov    %rbx,0x50(%rsp)
jmp    12a2 <convolve_kernel_inside_erode+0x132>
mov    0x34(%rsp),%eax
add    $0x1,%eax
addl   $0x1,0x8(%rsp)
cmp    0x2c(%rsp),%eax
je     1270 <convolve_kernel_inside_erode+0x100>
mov    %eax,0x34(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,%ecx
nopl   0x0(%rax)
lea    (%rcx,%rsi,1),%eax
mov    %eax,0x10(%rsp)
mov    %edx,%eax
mov    %rcx,0x38(%rsp)
sub    %ecx,%eax
mov    %eax,0xc(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,%ecx
nopw   0x0(%rax,%rax,1)
lea    (%rcx,%rbx,1),%eax
mov    %eax,0x20(%rsp)
mov    %edx,%eax
mov    %rcx,0x40(%rsp)
sub    %ecx,%eax
mov    %eax,0x14(%rsp)
mov    0x8(%rsp),%ebp
mov    0x30(%rsp),%ebx
mov    0x4(%rsp),%eax
mov    %eax,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x58(%rsp),%r12
mov    0x10(%rsp),%edi
mov    0x20(%rsp),%esi
mov    %rdx,%r15
mov    %ebp,%edx
mov    0x1c(%rsp),%ecx
mov    0x18(%rsp),%r8d
call   1050 <gidz_general@plt>
cltq
xorpd  %xmm0,%xmm0
ucomisd (%r12,%rax,8),%xmm0
sete   %r12b
setnp  %r13b
mov    0xc(%rsp),%edi
mov    0x14(%rsp),%esi
mov    %ebx,%edx
mov    0xc0(%rsp),%ecx
call   1080 <gidz_cube@plt>
mov    %r15,%rdx
cltq
and    %r12b,%r13b
mov    0x70(%rsp),%r12
xorpd  %xmm0,%xmm0
ucomisd (%r12,%rax,8),%xmm0
setp   %cl
setne  %al
or     %cl,%al
and    %r13b,%al
cmp    $0x1,%al
je     1386 <convolve_kernel_inside_erode+0x216>
lea    0x1(%r14),%ecx
add    $0xffffffff,%ebx
add    $0x1,%ebp
cmp    %r14d,%edx
mov    %ecx,%r14d
jg     1300 <convolve_kernel_inside_erode+0x190>
test   %al,%al
mov    0x50(%rsp),%rbx
mov    0x40(%rsp),%rsi
jne    139f <convolve_kernel_inside_erode+0x22f>
lea    0x1(%rsi),%ecx
cmp    %esi,%edx
jg     12d0 <convolve_kernel_inside_erode+0x160>
test   %al,%al
mov    0x48(%rsp),%rsi
mov    0x38(%rsp),%rbp
jne    13b8 <convolve_kernel_inside_erode+0x248>
lea    0x1(%rbp),%ecx
cmp    %ebp,%edx
jg     12b0 <convolve_kernel_inside_erode+0x140>
test   %al,%al
jne    1290 <convolve_kernel_inside_erode+0x120>
mov    0x4(%rsp),%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rax,%rsi,1),%edi
mov    %edx,%ecx
mov    %rax,0x78(%rsp)
sub    %eax,%ecx
mov    %ecx,0xc(%rsp)
mov    0x4(%rsp),%eax
mov    %edi,0x40(%rsp)
nopl   0x0(%rax,%rax,1)
lea    (%rax,%rbx,1),%ecx
mov    %ecx,0x14(%rsp)
mov    %edx,%ecx
mov    %rax,0x38(%rsp)
sub    %eax,%ecx
mov    %ecx,0x10(%rsp)
mov    0x8(%rsp),%ebx
mov    0x30(%rsp),%ebp
nopl   0x0(%rax)
mov    0x58(%rsp),%r14
mov    0x14(%rsp),%esi
mov    %ebx,%edx
mov    0x1c(%rsp),%r13d
mov    %r13d,%ecx
mov    0x18(%rsp),%r12d
mov    %r12d,%r8d
call   1050 <gidz_general@plt>
cltq
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
mov    %ebp,%edx
mov    0xc0(%rsp),%ecx
call   1080 <gidz_cube@plt>
cltq
mov    0x68(%rsp),%rcx
mov    (%rcx),%r14
mov    0x70(%rsp),%rcx
movsd  0x20(%rsp),%xmm0
mulsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x48(%rsp),%rdi
mov    0x50(%rsp),%rsi
mov    0x34(%rsp),%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
call   1050 <gidz_general@plt>
mov    0x40(%rsp),%edi
cltq
movsd  0x20(%rsp),%xmm0
addsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%ebx
add    $0xffffffff,%ebp
jb     1410 <convolve_kernel_inside_erode+0x2a0>
mov    0x38(%rsp),%rcx
lea    0x1(%rcx),%eax
mov    %r15,%rdx
cmp    %ecx,%edx
mov    0x50(%rsp),%rbx
jne    13f0 <convolve_kernel_inside_erode+0x280>
mov    0x78(%rsp),%rcx
lea    0x1(%rcx),%eax
cmp    %ecx,%edx
mov    0x48(%rsp),%rsi
jne    13d0 <convolve_kernel_inside_erode+0x260>
jmp    1290 <convolve_kernel_inside_erode+0x120>
mov    0x58(%rsp),%rdi
call   1030 <free@plt>
add    $0x88,%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_inside_erode(double** %0, double* %1, i32 %2, i32 %3, i32 %4, double* %5, i32 %6) {
%8 = alloca double**
%9 = alloca double*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double*
%14 = alloca i32
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double*
%24 = alloca double
%25 = alloca double
%26 = alloca i32
%27 = alloca i8*
store double** %0, double*** %8
store double* %1, double** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store double* %5, double** %13
store i32 %6, i32* %14
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %27
%28 = load i32, i32* %14
%29 = icmp ult i32 %28, 1
br i1 %29, label %39, label %30
30: ; preds = %7
%31 = load i32, i32* %14
%32 = add i32 %31, 1
%33 = udiv i32 %32, 2
%34 = mul i32 2, %33
%35 = load i32, i32* %14
%36 = sub i32 %34, %35
%37 = sub i32 %36, 1
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %30, %7
%40 = load i8*, i8** %27
%41 = load i32, i32* %14
%42 = call i32 @error_kernel_size(i32 17150, i8* %40, i32 %41)
br label %43
43: ; preds = %39, %30
%44 = load i32, i32* %14
%45 = sub i32 %44, 1
%46 = udiv i32 %45, 2
store i32 %46, i32* %22
%47 = load i32, i32* %10
%48 = load i32, i32* %11
%49 = mul i32 %47, %48
%50 = load i32, i32* %12
%51 = mul i32 %49, %50
%52 = zext i32 %51 to i64
store i64 %52, i64* %15
%53 = load i64, i64* %15
%54 = call i32 @do_vect(double** %23, i64 %53)
%55 = load i64, i64* %15
%56 = call i32 @cp_vect(double** %23, double** %9, i64 %55)
%57 = load double**, double*** %8
%58 = load double*, double** %57
%59 = load i64, i64* %15
%60 = call i32 @zero_vect(double* %58, i64 %59)
%61 = load i32, i32* %22
store i32 %61, i32* %18
br label %62
62: ; preds = %261, %43
%63 = load i32, i32* %18
%64 = load i32, i32* %12
%65 = load i32, i32* %22
%66 = sub i32 %64, %65
%67 = icmp ult i32 %63, %66
br i1 %67, label %68, label %264
68: ; preds = %62
%69 = load i32, i32* %22
store i32 %69, i32* %17
br label %70
70: ; preds = %257, %68
%71 = load i32, i32* %17
%72 = load i32, i32* %11
%73 = load i32, i32* %22
%74 = sub i32 %72, %73
%75 = icmp ult i32 %71, %74
br i1 %75, label %76, label %260
76: ; preds = %70
%77 = load i32, i32* %22
store i32 %77, i32* %16
br label %78
78: ; preds = %253, %76
%79 = load i32, i32* %16
%80 = load i32, i32* %10
%81 = load i32, i32* %22
%82 = sub i32 %80, %81
%83 = icmp ult i32 %79, %82
br i1 %83, label %84, label %256
84: ; preds = %78
store i32 0, i32* %26
%85 = load i32, i32* %22
%86 = sub nsw i32 0, %85
store i32 %86, i32* %21
br label %87
87: ; preds = %167, %84
%88 = load i32, i32* %26
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = load i32, i32* %21
%92 = load i32, i32* %22
%93 = icmp sle i32 %91, %92
br label %94
94: ; preds = %90, %87
%95 = phi i1 [ false, %87 ], [ %93, %90 ]
br i1 %95, label %96, label %170
96: ; preds = %94
%97 = load i32, i32* %22
%98 = sub nsw i32 0, %97
store i32 %98, i32* %20
br label %99
99: ; preds = %163, %96
%100 = load i32, i32* %26
%101 = icmp eq i32 %100, 0
br i1 %101, label %102, label %106
102: ; preds = %99
%103 = load i32, i32* %20
%104 = load i32, i32* %22
%105 = icmp sle i32 %103, %104
br label %106
106: ; preds = %102, %99
%107 = phi i1 [ false, %99 ], [ %105, %102 ]
br i1 %107, label %108, label %166
108: ; preds = %106
%109 = load i32, i32* %22
%110 = sub nsw i32 0, %109
store i32 %110, i32* %19
br label %111
111: ; preds = %159, %108
%112 = load i32, i32* %26
%113 = icmp eq i32 %112, 0
br i1 %113, label %114, label %118
114: ; preds = %111
%115 = load i32, i32* %19
%116 = load i32, i32* %22
%117 = icmp sle i32 %115, %116
br label %118
118: ; preds = %114, %111
%119 = phi i1 [ false, %111 ], [ %117, %114 ]
br i1 %119, label %120, label %162
120: ; preds = %118
%121 = load double*, double** %23
%122 = load i32, i32* %18
%123 = load i32, i32* %21
%124 = add i32 %122, %123
%125 = load i32, i32* %17
%126 = load i32, i32* %20
%127 = add i32 %125, %126
%128 = load i32, i32* %16
%129 = load i32, i32* %19
%130 = add i32 %128, %129
%131 = load i32, i32* %11
%132 = load i32, i32* %10
%133 = call i32 @gidz_general(i32 %124, i32 %127, i32 %130, i32 %131, i32 %132)
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds double, double* %121, i64 %134
%136 = load double, double* %135
store double %136, double* %24
%137 = load double*, double** %13
%138 = load i32, i32* %22
%139 = load i32, i32* %21
%140 = sub nsw i32 %138, %139
%141 = load i32, i32* %22
%142 = load i32, i32* %20
%143 = sub nsw i32 %141, %142
%144 = load i32, i32* %22
%145 = load i32, i32* %19
%146 = sub nsw i32 %144, %145
%147 = load i32, i32* %14
%148 = call i32 @gidz_cube(i32 %140, i32 %143, i32 %146, i32 %147)
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds double, double* %137, i64 %149
%151 = load double, double* %150
store double %151, double* %25
%152 = load double, double* %24
%153 = fcmp oeq double %152, 0.000000e+00
br i1 %153, label %154, label %158
154: ; preds = %120
%155 = load double, double* %25
%156 = fcmp une double %155, 0.000000e+00
br i1 %156, label %157, label %158
157: ; preds = %154
store i32 1, i32* %26
br label %158
158: ; preds = %157, %154, %120
br label %159
159: ; preds = %158
%160 = load i32, i32* %19
%161 = add nsw i32 %160, 1
store i32 %161, i32* %19
br label %111
162: ; preds = %118
br label %163
163: ; preds = %162
%164 = load i32, i32* %20
%165 = add nsw i32 %164, 1
store i32 %165, i32* %20
br label %99
166: ; preds = %106
br label %167
167: ; preds = %166
%168 = load i32, i32* %21
%169 = add nsw i32 %168, 1
store i32 %169, i32* %21
br label %87
170: ; preds = %94
%171 = load i32, i32* %26
%172 = icmp eq i32 %171, 0
br i1 %172, label %173, label %252
173: ; preds = %170
%174 = load i32, i32* %22
%175 = sub nsw i32 0, %174
store i32 %175, i32* %21
br label %176
176: ; preds = %248, %173
%177 = load i32, i32* %21
%178 = load i32, i32* %22
%179 = icmp sle i32 %177, %178
br i1 %179, label %180, label %251
180: ; preds = %176
%181 = load i32, i32* %22
%182 = sub nsw i32 0, %181
store i32 %182, i32* %20
br label %183
183: ; preds = %244, %180
%184 = load i32, i32* %20
%185 = load i32, i32* %22
%186 = icmp sle i32 %184, %185
br i1 %186, label %187, label %247
187: ; preds = %183
%188 = load i32, i32* %22
%189 = sub nsw i32 0, %188
store i32 %189, i32* %19
br label %190
190: ; preds = %240, %187
%191 = load i32, i32* %19
%192 = load i32, i32* %22
%193 = icmp sle i32 %191, %192
br i1 %193, label %194, label %243
194: ; preds = %190
%195 = load double*, double** %23
%196 = load i32, i32* %18
%197 = load i32, i32* %21
%198 = add i32 %196, %197
%199 = load i32, i32* %17
%200 = load i32, i32* %20
%201 = add i32 %199, %200
%202 = load i32, i32* %16
%203 = load i32, i32* %19
%204 = add i32 %202, %203
%205 = load i32, i32* %11
%206 = load i32, i32* %10
%207 = call i32 @gidz_general(i32 %198, i32 %201, i32 %204, i32 %205, i32 %206)
%208 = sext i32 %207 to i64
%209 = getelementptr inbounds double, double* %195, i64 %208
%210 = load double, double* %209
store double %210, double* %24
%211 = load double*, double** %13
%212 = load i32, i32* %22
%213 = load i32, i32* %21
%214 = sub nsw i32 %212, %213
%215 = load i32, i32* %22
%216 = load i32, i32* %20
%217 = sub nsw i32 %215, %216
%218 = load i32, i32* %22
%219 = load i32, i32* %19
%220 = sub nsw i32 %218, %219
%221 = load i32, i32* %14
%222 = call i32 @gidz_cube(i32 %214, i32 %217, i32 %220, i32 %221)
%223 = sext i32 %222 to i64
%224 = getelementptr inbounds double, double* %211, i64 %223
%225 = load double, double* %224
store double %225, double* %25
%226 = load double, double* %24
%227 = load double, double* %25
%228 = load double**, double*** %8
%229 = load double*, double** %228
%230 = load i32, i32* %18
%231 = load i32, i32* %17
%232 = load i32, i32* %16
%233 = load i32, i32* %11
%234 = load i32, i32* %10
%235 = call i32 @gidz_general(i32 %230, i32 %231, i32 %232, i32 %233, i32 %234)
%236 = sext i32 %235 to i64
%237 = getelementptr inbounds double, double* %229, i64 %236
%238 = load double, double* %237
%239 = call double @llvm.fmuladd.f64(double %226, double %227, double %238)
store double %239, double* %237
br label %240
240: ; preds = %194
%241 = load i32, i32* %19
%242 = add nsw i32 %241, 1
store i32 %242, i32* %19
br label %190
243: ; preds = %190
br label %244
244: ; preds = %243
%245 = load i32, i32* %20
%246 = add nsw i32 %245, 1
store i32 %246, i32* %20
br label %183
247: ; preds = %183
br label %248
248: ; preds = %247
%249 = load i32, i32* %21
%250 = add nsw i32 %249, 1
store i32 %250, i32* %21
br label %176
251: ; preds = %176
br label %252
252: ; preds = %251, %170
br label %253
253: ; preds = %252
%254 = load i32, i32* %16
%255 = add i32 %254, 1
store i32 %255, i32* %16
br label %78
256: ; preds = %78
br label %257
257: ; preds = %256
%258 = load i32, i32* %17
%259 = add i32 %258, 1
store i32 %259, i32* %17
br label %70
260: ; preds = %70
br label %261
261: ; preds = %260
%262 = load i32, i32* %18
%263 = add i32 %262, 1
store i32 %263, i32* %18
br label %62
264: ; preds = %62
%265 = load double*, double** %23
%266 = call i32 @free(double* %265)
ret void
}

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