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

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ free(double *);
scalar_t__ malloc(int);
int /*<<< orphan*/ smooth2d(double *, int, int);
void smooth3d(double *data, int size0, int size1, int size2) {
  long i, j, k, ihelp, jhelp;
  double *p;
  int size;
  size = size1 * size2;
  for (i = 0; i < size0; i++) {
    smooth2d(&data[i * size], size1, size2);
  }
  size = size0 * size2;
  p = (double *)malloc(size * sizeof(double));
  for (i = 0; i < size1; i++) {
    ihelp = i * size2;
    for (j = 0; j < size0; j++) {
      jhelp = j * size1 * size2 + ihelp;
      for (k = 0; k < size2; k++) {
        p[j * size2 + k] = data[jhelp + k];
      }
    }
    smooth2d(p, size0, size2);
  }
  free(p);
  size = size0 * size1;
  p = (double *)malloc(size * sizeof(double));
  for (i = 0; i < size2; i++) {
    for (j = 0; j < size0; j++) {
      jhelp = j * size1 * size2 + i;
      for (k = 0; k < size1; k++) {
        p[j * size1 + k] = data[jhelp + k * size2];
      }
    }
    smooth2d(p, size0, size1);
  }
  free(p);
}


x86 assembly (clang, -O0):
<smooth3d>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jge    119b <smooth3d+0x6b>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq -0x4c(%rbp),%rcx
imul   %rcx,%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <smooth2d@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1157 <smooth3d+0x27>
mov    -0xc(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmp    %rcx,%rax
jge    12a0 <smooth3d+0x170>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   %rcx,%rax
mov    %rax,-0x38(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jge    1280 <smooth3d+0x150>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
movslq -0x14(%rbp),%rcx
imul   %rcx,%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jge    126a <smooth3d+0x13a>
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
add    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x14(%rbp),%rdx
imul   %rdx,%rcx
add    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    121e <smooth3d+0xee>
jmp    126f <smooth3d+0x13f>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    11e9 <smooth3d+0xb9>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1040 <smooth2d@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11c0 <smooth3d+0x90>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x4c(%rbp)
movslq -0x4c(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmp    %rcx,%rax
jge    13a9 <smooth3d+0x279>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jge    1389 <smooth3d+0x259>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
imul   %rcx,%rax
movslq -0x14(%rbp),%rcx
imul   %rcx,%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x10(%rbp),%rcx
cmp    %rcx,%rax
jge    1373 <smooth3d+0x243>
mov    -0x8(%rbp),%rax
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%rdx
movslq -0x14(%rbp),%rsi
imul   %rsi,%rdx
add    %rdx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x48(%rbp),%rax
mov    -0x28(%rbp),%rcx
movslq -0x10(%rbp),%rdx
imul   %rdx,%rcx
add    -0x30(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    131c <smooth3d+0x1ec>
jmp    1378 <smooth3d+0x248>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12e7 <smooth3d+0x1b7>
mov    -0x48(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <smooth2d@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12ce <smooth3d+0x19e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smooth3d>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
mov    %rdi,0x20(%rsp)
mov    %rsi,0x60(%rsp)
movslq %esi,%rax
mov    %rax,0x90(%rsp)
test   %eax,%eax
mov    %edx,0xc(%rsp)
mov    %ecx,0x18(%rsp)
jle    119d <smooth3d+0x6d>
mov    %ecx,%eax
imul   %edx,%eax
movslq %eax,%r14
shl    $0x3,%r14
mov    0x20(%rsp),%rbx
mov    0x90(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %edx,%esi
mov    %ecx,%edx
call   1040 <smooth2d@plt>
mov    0x18(%rsp),%ecx
mov    0xc(%rsp),%edx
add    %r14,%rbx
add    $0xffffffffffffffff,%rbp
jne    1180 <smooth3d+0x50>
movabs $0x7ffffffffffffffe,%rax
ff ff 7f
mov    %rax,0xa0(%rsp)
mov    0x60(%rsp),%rbp
lea    0x0(,%rbp,8),%edi
mov    %edi,0x9c(%rsp)
imul   %ecx,%edi
mov    %edx,%ebx
call   1050 <malloc@plt>
mov    0x18(%rsp),%edx
mov    %rax,0x28(%rsp)
movslq %ebx,%r14
movslq %edx,%r12
test   %ebx,%ebx
mov    %r12,0x38(%rsp)
jle    14c0 <smooth3d+0x390>
mov    %r12,%rcx
imul   %r14,%rcx
lea    -0x4(%r12),%rax
mov    %rax,0x78(%rsp)
mov    %rax,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
mov    %r12,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,0x68(%rsp)
mov    %rsi,%rax
mov    %rsi,0x70(%rsp)
movabs $0x7ffffffffffffffe,%rax
ff ff 7f
and    %rax,%rsi
mov    %rsi,0x58(%rsp)
mov    %edx,%r8d
and    $0x3,%r8d
mov    0x20(%rsp),%rax
lea    0x30(%rax),%rsi
mov    %rsi,0x48(%rsp)
lea    0x0(,%r12,8),%r13
mov    %rcx,0x88(%rsp)
lea    0x0(,%rcx,8),%r15
mov    0x28(%rsp),%rcx
add    $0x30,%rcx
mov    %rcx,0x50(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x30(%rsp)
mov    %rax,0x40(%rsp)
mov    %r8,(%rsp)
jmp    12bd <smooth3d+0x18d>
nopw   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rdi
mov    0x60(%rsp),%rbp
mov    %ebp,%esi
call   1040 <smooth2d@plt>
mov    (%rsp),%r8
mov    0x18(%rsp),%edx
mov    0x30(%rsp),%rcx
add    $0x1,%rcx
add    %r13,0x48(%rsp)
add    %r13,0x40(%rsp)
mov    %rcx,%rax
mov    %rcx,0x30(%rsp)
cmp    %r14,%rcx
je     14c0 <smooth3d+0x390>
test   %ebp,%ebp
jle    1280 <smooth3d+0x150>
mov    0x30(%rsp),%rax
imul   %r12,%rax
mov    %rax,0x80(%rsp)
add    %r12,%rax
mov    %rax,0x10(%rsp)
mov    0x40(%rsp),%r9
mov    0x28(%rsp),%rsi
mov    0x50(%rsp),%rdi
mov    0x48(%rsp),%rcx
xor    %r11d,%r11d
jmp    131e <smooth3d+0x1ee>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r11
add    %r15,%rcx
add    %r13,%rdi
add    %r13,%rsi
add    %r15,%r9
cmp    0x90(%rsp),%r11
je     1280 <smooth3d+0x150>
test   %edx,%edx
jle    1300 <smooth3d+0x1d0>
cmp    $0x4,%edx
jae    1330 <smooth3d+0x200>
xor    %ebp,%ebp
jmp    1440 <smooth3d+0x310>
xchg   %ax,%ax
mov    %r11,%r10
imul   %r12,%r10
mov    0x88(%rsp),%rax
imul   %r11,%rax
mov    0x10(%rsp),%rdx
lea    (%rdx,%rax,1),%rbx
mov    0x28(%rsp),%rdx
lea    (%rdx,%r10,8),%rbp
mov    %r12,%r8
mov    0x20(%rsp),%r12
lea    (%r12,%rbx,8),%rbx
cmp    %rbx,%rbp
jae    1391 <smooth3d+0x261>
lea    (%r10,%r8,1),%rbx
add    0x80(%rsp),%rax
lea    (%rdx,%rbx,8),%rbx
lea    (%r12,%rax,8),%rax
cmp    %rbx,%rax
jae    1391 <smooth3d+0x261>
xor    %ebp,%ebp
mov    %r8,%r12
mov    0x18(%rsp),%edx
mov    (%rsp),%r8
jmp    1440 <smooth3d+0x310>
cmpq   $0x4,0x78(%rsp)
jae    13a6 <smooth3d+0x276>
xor    %ebx,%ebx
mov    0x38(%rsp),%r12
mov    (%rsp),%r8
jmp    13f0 <smooth3d+0x2c0>
mov    0x58(%rsp),%rbp
xor    %ebx,%ebx
mov    0x38(%rsp),%r12
mov    (%rsp),%r8
cs nopw 0x0(%rax,%rax,1)
movups -0x30(%rcx,%rbx,8),%xmm0
movups -0x20(%rcx,%rbx,8),%xmm1
movups %xmm0,-0x30(%rdi,%rbx,8)
movups %xmm1,-0x20(%rdi,%rbx,8)
movups -0x10(%rcx,%rbx,8),%xmm0
movups (%rcx,%rbx,8),%xmm1
movups %xmm0,-0x10(%rdi,%rbx,8)
movups %xmm1,(%rdi,%rbx,8)
add    $0x8,%rbx
add    $0xfffffffffffffffe,%rbp
jne    13c0 <smooth3d+0x290>
testb  $0x1,0x70(%rsp)
je     1427 <smooth3d+0x2f7>
mov    %r11,%rax
imul   %r14,%rax
add    0x30(%rsp),%rax
imul   %r12,%rax
add    %rbx,%rax
mov    0x20(%rsp),%rbp
movups 0x0(%rbp,%rax,8),%xmm0
movups 0x10(%rbp,%rax,8),%xmm1
add    %rbx,%r10
movups %xmm0,(%rdx,%r10,8)
movups %xmm1,0x10(%rdx,%r10,8)
mov    0x68(%rsp),%rax
mov    %rax,%rbp
cmp    %r12,%rax
mov    0x18(%rsp),%edx
je     1300 <smooth3d+0x1d0>
nopl   0x0(%rax)
mov    %rbp,%rbx
not    %rbx
add    %r12,%rbx
test   %r8,%r8
je     1475 <smooth3d+0x345>
mov    %r8,%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsd  (%r9,%rbp,8),%xmm0
movsd  %xmm0,(%rsi,%rbp,8)
add    $0x1,%rbp
add    $0xffffffffffffffff,%rax
jne    1460 <smooth3d+0x330>
cmp    $0x3,%rbx
jb     1300 <smooth3d+0x1d0>
nop
movsd  (%r9,%rbp,8),%xmm0
movsd  %xmm0,(%rsi,%rbp,8)
movsd  0x8(%r9,%rbp,8),%xmm0
movsd  %xmm0,0x8(%rsi,%rbp,8)
movsd  0x10(%r9,%rbp,8),%xmm0
movsd  %xmm0,0x10(%rsi,%rbp,8)
movsd  0x18(%r9,%rbp,8),%xmm0
movsd  %xmm0,0x18(%rsi,%rbp,8)
add    $0x4,%rbp
cmp    %rbp,%r12
jne    1480 <smooth3d+0x350>
jmp    1300 <smooth3d+0x1d0>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%ebx
mov    0x9c(%rsp),%edi
imul   %ebx,%edi
call   1050 <malloc@plt>
mov    0x18(%rsp),%ecx
mov    %rax,0x10(%rsp)
test   %ecx,%ecx
mov    0x20(%rsp),%r8
jle    17f2 <smooth3d+0x6c2>
mov    %ebx,%edx
lea    -0x4(%r14),%rax
mov    %rax,0x78(%rsp)
mov    %rax,%rsi
shr    $0x2,%rsi
add    $0x1,%rsi
cmp    $0x4,%ebx
setae  %al
cmp    $0x1,%ecx
sete   %cl
and    %al,%cl
mov    %cl,0x88(%rsp)
mov    %r14,%rax
and    $0xfffffffffffffffc,%rax
mov    %rax,0x68(%rsp)
mov    %rsi,%rax
mov    %rsi,0x70(%rsp)
and    %rsi,0xa0(%rsp)
mov    %r14,%rax
neg    %rax
mov    %rax,0x80(%rsp)
mov    0x10(%rsp),%rax
add    $0x30,%rax
mov    %rax,0x50(%rsp)
lea    0x0(,%r14,8),%rax
mov    %rax,0x18(%rsp)
mov    %r12,%rax
shl    $0x5,%rax
add    %r8,%rax
add    $0x10,%rax
mov    %rax,0x48(%rsp)
mov    %r12,%rax
imul   %r14,%rax
shl    $0x3,%rax
mov    %rax,0x28(%rsp)
mov    %r12,%rax
shl    $0x6,%rax
mov    %rax,0x58(%rsp)
lea    0x10(%r8),%rax
mov    %rax,0x40(%rsp)
mov    %r12,%r15
shl    $0x4,%r15
xor    %eax,%eax
mov    %rax,(%rsp)
jmp    15f0 <smooth3d+0x4c0>
nopw   0x0(%rax,%rax,1)
mov    0x10(%rsp),%rdi
mov    0x60(%rsp),%rbp
mov    %ebp,%esi
call   1040 <smooth2d@plt>
mov    0x20(%rsp),%r8
mov    0xc(%rsp),%edx
mov    (%rsp),%rcx
add    $0x1,%rcx
addq   $0x8,0x48(%rsp)
addq   $0x8,0x40(%rsp)
mov    %rcx,%rax
mov    %rcx,(%rsp)
cmp    0x38(%rsp),%rcx
je     17f2 <smooth3d+0x6c2>
test   %ebp,%ebp
jle    15b0 <smooth3d+0x480>
mov    (%rsp),%rax
add    %r14,%rax
mov    %rax,0x30(%rsp)
mov    $0x1,%r9d
mov    0x10(%rsp),%r12
xor    %r10d,%r10d
mov    0x40(%rsp),%r13
mov    0x48(%rsp),%rax
mov    0x50(%rsp),%rbp
xor    %r11d,%r11d
jmp    165e <smooth3d+0x52e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r11
mov    0x18(%rsp),%rcx
add    %rcx,%rbp
mov    0x28(%rsp),%rsi
add    %rsi,%rax
add    %rsi,%r13
add    %r14,%r10
add    %r14,%r9
add    %rcx,%r12
cmp    0x90(%rsp),%r11
je     15b0 <smooth3d+0x480>
test   %edx,%edx
jle    1630 <smooth3d+0x500>
mov    %r11,%rbx
imul   %r14,%rbx
cmpb   $0x0,0x88(%rsp)
je     16ad <smooth3d+0x57d>
mov    0x30(%rsp),%rcx
add    %rbx,%rcx
mov    0x10(%rsp),%rdi
lea    (%rdi,%rbx,8),%rsi
lea    (%r8,%rcx,8),%rcx
cmp    %rcx,%rsi
jae    1748 <smooth3d+0x618>
lea    (%rbx,%r14,1),%rcx
mov    (%rsp),%rsi
add    %rbx,%rsi
lea    (%rdi,%rcx,8),%rcx
lea    (%r8,%rsi,8),%rsi
cmp    %rcx,%rsi
jae    1748 <smooth3d+0x618>
xor    %ecx,%ecx
mov    %rcx,%rsi
test   $0x1,%r14b
je     16df <smooth3d+0x5af>
add    %rcx,%rbx
mov    %rbx,%rsi
imul   0x38(%rsp),%rsi
add    (%rsp),%rsi
movsd  (%r8,%rsi,8),%xmm0
mov    0x10(%rsp),%rsi
movsd  %xmm0,(%rsi,%rbx,8)
mov    %rcx,%rsi
or     $0x1,%rsi
not    %rcx
cmp    0x80(%rsp),%rcx
je     1630 <smooth3d+0x500>
lea    (%rsi,%r10,1),%rcx
mov    0x38(%rsp),%rdi
imul   %rdi,%rcx
mov    (%rsp),%rbx
mov    %r8,%rdx
mov    %rbx,%r8
add    %rbx,%rcx
lea    (%rsi,%r9,1),%rbx
imul   %rdi,%rbx
add    %r8,%rbx
mov    %rdx,%r8
mov    0xc(%rsp),%edx
mov    %r8,%rdi
nop
movsd  (%rdi,%rcx,8),%xmm0
movsd  %xmm0,(%r12,%rsi,8)
movsd  (%rdi,%rbx,8),%xmm0
movsd  %xmm0,0x8(%r12,%rsi,8)
add    $0x2,%rsi
add    %r15,%rdi
cmp    %rsi,%r14
jne    1720 <smooth3d+0x5f0>
jmp    1630 <smooth3d+0x500>
cmpq   $0x4,0x78(%rsp)
jae    1754 <smooth3d+0x624>
xor    %esi,%esi
jmp    17a8 <smooth3d+0x678>
mov    0xa0(%rsp),%rcx
xor    %r8d,%r8d
xor    %esi,%esi
mov    0x58(%rsp),%rdx
cs nopw 0x0(%rax,%rax,1)
movups -0x10(%r13,%r8,1),%xmm0
movups 0x0(%r13,%r8,1),%xmm1
movups %xmm0,-0x30(%rbp,%rsi,8)
movups %xmm1,-0x20(%rbp,%rsi,8)
movups -0x10(%rax,%r8,1),%xmm0
movups (%rax,%r8,1),%xmm1
movups %xmm0,-0x10(%rbp,%rsi,8)
movups %xmm1,0x0(%rbp,%rsi,8)
add    $0x8,%rsi
add    %rdx,%r8
add    $0xfffffffffffffffe,%rcx
jne    1770 <smooth3d+0x640>
testb  $0x1,0x70(%rsp)
mov    0x20(%rsp),%r8
je     17d8 <smooth3d+0x6a8>
add    %rbx,%rsi
mov    %rsi,%rcx
imul   0x38(%rsp),%rcx
add    (%rsp),%rcx
movups (%r8,%rcx,8),%xmm0
movups 0x10(%r8,%rcx,8),%xmm1
movups %xmm0,(%rdi,%rsi,8)
movups %xmm1,0x10(%rdi,%rsi,8)
mov    0x68(%rsp),%rdx
mov    %rdx,%rcx
cmp    %r14,%rdx
mov    0xc(%rsp),%edx
je     1630 <smooth3d+0x500>
jmp    16af <smooth3d+0x57f>
mov    0x10(%rsp),%rdi
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @smooth3d(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca double*
%15 = alloca i32
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%16 = load i32, i32* %7
%17 = load i32, i32* %8
%18 = mul nsw i32 %16, %17
store i32 %18, i32* %15
store i64 0, i64* %9
br label %19
19: ; preds = %34, %4
%20 = load i64, i64* %9
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %24, label %37
24: ; preds = %19
%25 = load double*, double** %5
%26 = load i64, i64* %9
%27 = load i32, i32* %15
%28 = sext i32 %27 to i64
%29 = mul nsw i64 %26, %28
%30 = getelementptr inbounds double, double* %25, i64 %29
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = call i32 @smooth2d(double* %30, i32 %31, i32 %32)
br label %34
34: ; preds = %24
%35 = load i64, i64* %9
%36 = add nsw i64 %35, 1
store i64 %36, i64* %9
br label %19
37: ; preds = %19
%38 = load i32, i32* %6
%39 = load i32, i32* %8
%40 = mul nsw i32 %38, %39
store i32 %40, i32* %15
%41 = load i32, i32* %15
%42 = sext i32 %41 to i64
%43 = mul i64 %42, 8
%44 = trunc i64 %43 to i32
%45 = call i64 @malloc(i32 %44)
%46 = inttoptr i64 %45 to double*
store double* %46, double** %14
store i64 0, i64* %9
br label %47
47: ; preds = %104, %37
%48 = load i64, i64* %9
%49 = load i32, i32* %7
%50 = sext i32 %49 to i64
%51 = icmp slt i64 %48, %50
br i1 %51, label %52, label %107
52: ; preds = %47
%53 = load i64, i64* %9
%54 = load i32, i32* %8
%55 = sext i32 %54 to i64
%56 = mul nsw i64 %53, %55
store i64 %56, i64* %12
store i64 0, i64* %10
br label %57
57: ; preds = %96, %52
%58 = load i64, i64* %10
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = icmp slt i64 %58, %60
br i1 %61, label %62, label %99
62: ; preds = %57
%63 = load i64, i64* %10
%64 = load i32, i32* %7
%65 = sext i32 %64 to i64
%66 = mul nsw i64 %63, %65
%67 = load i32, i32* %8
%68 = sext i32 %67 to i64
%69 = mul nsw i64 %66, %68
%70 = load i64, i64* %12
%71 = add nsw i64 %69, %70
store i64 %71, i64* %13
store i64 0, i64* %11
br label %72
72: ; preds = %92, %62
%73 = load i64, i64* %11
%74 = load i32, i32* %8
%75 = sext i32 %74 to i64
%76 = icmp slt i64 %73, %75
br i1 %76, label %77, label %95
77: ; preds = %72
%78 = load double*, double** %5
%79 = load i64, i64* %13
%80 = load i64, i64* %11
%81 = add nsw i64 %79, %80
%82 = getelementptr inbounds double, double* %78, i64 %81
%83 = load double, double* %82
%84 = load double*, double** %14
%85 = load i64, i64* %10
%86 = load i32, i32* %8
%87 = sext i32 %86 to i64
%88 = mul nsw i64 %85, %87
%89 = load i64, i64* %11
%90 = add nsw i64 %88, %89
%91 = getelementptr inbounds double, double* %84, i64 %90
store double %83, double* %91
br label %92
92: ; preds = %77
%93 = load i64, i64* %11
%94 = add nsw i64 %93, 1
store i64 %94, i64* %11
br label %72
95: ; preds = %72
br label %96
96: ; preds = %95
%97 = load i64, i64* %10
%98 = add nsw i64 %97, 1
store i64 %98, i64* %10
br label %57
99: ; preds = %57
%100 = load double*, double** %14
%101 = load i32, i32* %6
%102 = load i32, i32* %8
%103 = call i32 @smooth2d(double* %100, i32 %101, i32 %102)
br label %104
104: ; preds = %99
%105 = load i64, i64* %9
%106 = add nsw i64 %105, 1
store i64 %106, i64* %9
br label %47
107: ; preds = %47
%108 = load double*, double** %14
%109 = call i32 @free(double* %108)
%110 = load i32, i32* %6
%111 = load i32, i32* %7
%112 = mul nsw i32 %110, %111
store i32 %112, i32* %15
%113 = load i32, i32* %15
%114 = sext i32 %113 to i64
%115 = mul i64 %114, 8
%116 = trunc i64 %115 to i32
%117 = call i64 @malloc(i32 %116)
%118 = inttoptr i64 %117 to double*
store double* %118, double** %14
store i64 0, i64* %9
br label %119
119: ; preds = %175, %107
%120 = load i64, i64* %9
%121 = load i32, i32* %8
%122 = sext i32 %121 to i64
%123 = icmp slt i64 %120, %122
br i1 %123, label %124, label %178
124: ; preds = %119
store i64 0, i64* %10
br label %125
125: ; preds = %167, %124
%126 = load i64, i64* %10
%127 = load i32, i32* %6
%128 = sext i32 %127 to i64
%129 = icmp slt i64 %126, %128
br i1 %129, label %130, label %170
130: ; preds = %125
%131 = load i64, i64* %10
%132 = load i32, i32* %7
%133 = sext i32 %132 to i64
%134 = mul nsw i64 %131, %133
%135 = load i32, i32* %8
%136 = sext i32 %135 to i64
%137 = mul nsw i64 %134, %136
%138 = load i64, i64* %9
%139 = add nsw i64 %137, %138
store i64 %139, i64* %13
store i64 0, i64* %11
br label %140
140: ; preds = %163, %130
%141 = load i64, i64* %11
%142 = load i32, i32* %7
%143 = sext i32 %142 to i64
%144 = icmp slt i64 %141, %143
br i1 %144, label %145, label %166
145: ; preds = %140
%146 = load double*, double** %5
%147 = load i64, i64* %13
%148 = load i64, i64* %11
%149 = load i32, i32* %8
%150 = sext i32 %149 to i64
%151 = mul nsw i64 %148, %150
%152 = add nsw i64 %147, %151
%153 = getelementptr inbounds double, double* %146, i64 %152
%154 = load double, double* %153
%155 = load double*, double** %14
%156 = load i64, i64* %10
%157 = load i32, i32* %7
%158 = sext i32 %157 to i64
%159 = mul nsw i64 %156, %158
%160 = load i64, i64* %11
%161 = add nsw i64 %159, %160
%162 = getelementptr inbounds double, double* %155, i64 %161
store double %154, double* %162
br label %163
163: ; preds = %145
%164 = load i64, i64* %11
%165 = add nsw i64 %164, 1
store i64 %165, i64* %11
br label %140
166: ; preds = %140
br label %167
167: ; preds = %166
%168 = load i64, i64* %10
%169 = add nsw i64 %168, 1
store i64 %169, i64* %10
br label %125
170: ; preds = %125
%171 = load double*, double** %14
%172 = load i32, i32* %6
%173 = load i32, i32* %7
%174 = call i32 @smooth2d(double* %171, i32 %172, i32 %173)
br label %175
175: ; preds = %170
%176 = load i64, i64* %9
%177 = add nsw i64 %176, 1
store i64 %177, i64* %9
br label %119
178: ; preds = %119
%179 = load double*, double** %14
%180 = call i32 @free(double* %179)
ret void
}

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