#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 */
typedef struct TYPE_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  double member_0;
  double member_1;
  double member_2;
};
struct TYPE_5__ {
  double member_0;
  int member_1;
  double member_2;
};
struct TYPE_4__ {
  double member_0;
  double member_1;
  double member_2;
};

/* Variables and functions */
int /*<<< orphan*/ do_vect(double **, unsigned long);
int gidz_cube(int, int, int, unsigned int);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned long);
void create_laplacian(double **phi, unsigned long *nvox, unsigned *ext) {
  int indx, indy, indz;
  double lap_discrete[3][3][3] = {
      {{0.0, 0.0, 0.0}, {0.0, 1. / 12.0, 0.0}, {0.0, 0.0, 0.0}},
      {{0.0, 1.0 / 12.0, 0.0},
       {1.0 / 12.0, -6.0 / 12.0, 1.0 / 12.0},
       {0.0, 1.0 / 12.0, 0.0}},
      {{0.0, 0.0, 0.0}, {0.0, 1.0 / 12.0, 0.0}, {0.0, 0.0, 0.0}}};
  *ext = 3;
  *nvox = *ext * *ext * *ext;
  printf("lib_vwk> Generating Laplacian kernel with %d^3 = %lu voxels.\n", *ext,
         *nvox);
  do_vect(phi, *nvox);
  for (indz = 0; indz < (int)*ext; indz++)
    for (indy = 0; indy < (int)*ext; indy++)
      for (indx = 0; indx < (int)*ext; indx++)
        *(*phi + gidz_cube(indz, indy, indx, *ext)) =
            lap_discrete[indx][indy][indz];
}


x86 assembly (clang, -O0):
<create_laplacian>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x100(%rbp),%rdi
lea    0xe9b(%rip),%rsi
mov    $0xd8,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
imul   (%rcx),%eax
mov    -0x18(%rbp),%rcx
imul   (%rcx),%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xf2c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <do_vect@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    12a0 <create_laplacian+0x160>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    128d <create_laplacian+0x14d>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    127a <create_laplacian+0x13a>
movslq -0x1c(%rbp),%rcx
lea    -0x100(%rbp),%rax
imul   $0x48,%rcx,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x110(%rbp)
ff
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x108(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
call   1060 <gidz_cube@plt>
movsd  -0x110(%rbp),%xmm0
ff
mov    %eax,%ecx
mov    -0x108(%rbp),%rax
movslq %ecx,%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f4 <create_laplacian+0xb4>
jmp    127f <create_laplacian+0x13f>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11de <create_laplacian+0x9e>
jmp    1292 <create_laplacian+0x152>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c8 <create_laplacian+0x88>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_laplacian>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x3,(%rdx)
movq   $0x1b,(%rsi)
lea    0xf7d(%rip),%rdi
mov    $0x1b,%edx
mov    $0x3,%esi
call   1030 <printf@plt>
mov    (%rbx),%rsi
mov    %rbp,%rdi
call   1040 <do_vect@plt>
mov    (%r15),%ecx
test   %ecx,%ecx
jle    1230 <create_laplacian+0x100>
lea    0xe79(%rip),%rdx
xor    %r13d,%r13d
mov    %rbp,0x18(%rsp)
jmp    11b5 <create_laplacian+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13
movslq %ecx,%rax
mov    0x8(%rsp),%rdx
add    $0x8,%rdx
cmp    %rax,%r13
jge    1230 <create_laplacian+0x100>
test   %ecx,%ecx
mov    %rdx,0x8(%rsp)
jle    11a0 <create_laplacian+0x70>
mov    %rdx,%rbp
xor    %r12d,%r12d
jmp    11e5 <create_laplacian+0xb5>
cs nopw 0x0(%rax,%rax,1)
movslq %ecx,%rax
add    $0x1,%r12
mov    0x10(%rsp),%rbp
add    $0x18,%rbp
cmp    %rax,%r12
jge    11a0 <create_laplacian+0x70>
test   %ecx,%ecx
mov    %rbp,0x10(%rsp)
jle    11d0 <create_laplacian+0xa0>
xor    %ebx,%ebx
movsd  0x0(%rbp),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x18(%rsp),%rax
mov    (%rax),%r14
mov    %r13d,%edi
mov    %r12d,%esi
mov    %ebx,%edx
call   1050 <gidz_cube@plt>
cltq
movsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%r14,%rax,8)
add    $0x1,%rbx
movslq (%r15),%rcx
add    $0x48,%rbp
cmp    %rcx,%rbx
jl     11f0 <create_laplacian+0xc0>
jmp    11d0 <create_laplacian+0xa0>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.create_laplacian.lap_discrete = [3 x [3 x [3 x double]]] [[3 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] zeroinitializer], [3 x [3 x double]] [[3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] [double 0x3FB5555555555555, double -5.000000e-01, double 0x3FB5555555555555], [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00]], [3 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] zeroinitializer]]
@.str = [62 x i8] c"lib_vwk> Generating Laplacian kernel with %d^3 = %lu voxels.\0A\00"
define void @create_laplacian(double** %0, i64* %1, i32* %2) {
%4 = alloca double**
%5 = alloca i64*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [3 x [3 x [3 x double]]]
store double** %0, double*** %4
store i64* %1, i64** %5
store i32* %2, i32** %6
%11 = bitcast [3 x [3 x [3 x double]]]* %10 to i8*
%12 = load i32*, i32** %6
store i32 3, i32* %12
%13 = load i32*, i32** %6
%14 = load i32, i32* %13
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = mul i32 %14, %16
%18 = load i32*, i32** %6
%19 = load i32, i32* %18
%20 = mul i32 %17, %19
%21 = zext i32 %20 to i64
%22 = load i64*, i64** %5
store i64 %21, i64* %22
%23 = load i32*, i32** %6
%24 = load i32, i32* %23
%25 = load i64*, i64** %5
%26 = load i64, i64* %25
%27 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 %24, i64 %26)
%28 = load double**, double*** %4
%29 = load i64*, i64** %5
%30 = load i64, i64* %29
%31 = call i32 @do_vect(double** %28, i64 %30)
store i32 0, i32* %9
br label %32
32: ; preds = %78, %3
%33 = load i32, i32* %9
%34 = load i32*, i32** %6
%35 = load i32, i32* %34
%36 = icmp slt i32 %33, %35
br i1 %36, label %37, label %81
37: ; preds = %32
store i32 0, i32* %8
br label %38
38: ; preds = %74, %37
%39 = load i32, i32* %8
%40 = load i32*, i32** %6
%41 = load i32, i32* %40
%42 = icmp slt i32 %39, %41
br i1 %42, label %43, label %77
43: ; preds = %38
store i32 0, i32* %7
br label %44
44: ; preds = %70, %43
%45 = load i32, i32* %7
%46 = load i32*, i32** %6
%47 = load i32, i32* %46
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %73
49: ; preds = %44
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [3 x [3 x [3 x double]]], [3 x [3 x [3 x double]]]* %10, i64 0, i64 %51
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [3 x [3 x double]], [3 x [3 x double]]* %52, i64 0, i64 %54
%56 = load i32, i32* %9
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [3 x double], [3 x double]* %55, i64 0, i64 %57
%59 = load double, double* %58
%60 = load double**, double*** %4
%61 = load double*, double** %60
%62 = load i32, i32* %9
%63 = load i32, i32* %8
%64 = load i32, i32* %7
%65 = load i32*, i32** %6
%66 = load i32, i32* %65
%67 = call i32 @gidz_cube(i32 %62, i32 %63, i32 %64, i32 %66)
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %61, i64 %68
store double %59, double* %69
br label %70
70: ; preds = %49
%71 = load i32, i32* %7
%72 = add nsw i32 %71, 1
store i32 %72, i32* %7
br label %44
73: ; preds = %44
br label %74
74: ; preds = %73
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %38
77: ; preds = %38
br label %78
78: ; preds = %77
%79 = load i32, i32* %9
%80 = add nsw i32 %79, 1
store i32 %80, i32* %9
br label %32
81: ; preds = %32
ret void
}

LLVM IR (-O2):
@__const.create_laplacian.lap_discrete = [3 x [3 x [3 x double]]] [[3 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] zeroinitializer], [3 x [3 x double]] [[3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] [double 0x3FB5555555555555, double -5.000000e-01, double 0x3FB5555555555555], [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00]], [3 x [3 x double]] [[3 x double] zeroinitializer, [3 x double] [double 0.000000e+00, double 0x3FB5555555555555, double 0.000000e+00], [3 x double] zeroinitializer]]
@.str = [62 x i8] c"lib_vwk> Generating Laplacian kernel with %d^3 = %lu voxels.\0A\00"
define void @create_laplacian(double** %0, i64* nocapture %1, i32* nocapture %2) {
store i32 3, i32* %2
store i64 27, i64* %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str, i64 0, i64 0), i32 3, i64 27)
%5 = load i64, i64* %1
%6 = tail call i32 @do_vect(double** %0, i64 %5)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %47
9: ; preds = %3, %42
%10 = phi i32 [ %43, %42 ], [ %7, %3 ]
%11 = phi i64 [ %44, %42 ], [ 0, %3 ]
%12 = icmp sgt i32 %10, 0
br i1 %12, label %13, label %42
13: ; preds = %9
%14 = trunc i64 %11 to i32
br label %15
15: ; preds = %13, %36
%16 = phi i32 [ %10, %13 ], [ %38, %36 ]
%17 = phi i32 [ %10, %13 ], [ %37, %36 ]
%18 = phi i64 [ 0, %13 ], [ %40, %36 ]
%19 = icmp sgt i32 %17, 0
br i1 %19, label %20, label %36
20: ; preds = %15
%21 = trunc i64 %18 to i32
br label %22
22: ; preds = %20, %22
%23 = phi i64 [ 0, %20 ], [ %32, %22 ]
%24 = phi i32 [ %17, %20 ], [ %33, %22 ]
%25 = getelementptr inbounds [3 x [3 x [3 x double]]], [3 x [3 x [3 x double]]]* @__const.create_laplacian.lap_discrete, i64 0, i64 %23, i64 %18, i64 %11
%26 = load double, double* %25
%27 = load double*, double** %0
%28 = trunc i64 %23 to i32
%29 = tail call i32 @gidz_cube(i32 %14, i32 %21, i32 %28, i32 %24)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %27, i64 %30
store double %26, double* %31
%32 = add nuw nsw i64 %23, 1
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %32, %34
br i1 %35, label %22, label %36
36: ; preds = %22, %15
%37 = phi i32 [ %17, %15 ], [ %33, %22 ]
%38 = phi i32 [ %16, %15 ], [ %33, %22 ]
%39 = sext i32 %37 to i64
%40 = add nuw nsw i64 %18, 1
%41 = icmp slt i64 %40, %39
br i1 %41, label %15, label %42
42: ; preds = %36, %9
%43 = phi i32 [ %10, %9 ], [ %38, %36 ]
%44 = add nuw nsw i64 %11, 1
%45 = sext i32 %43 to i64
%46 = icmp slt i64 %44, %45
br i1 %46, label %9, label %47
47: ; preds = %42, %3
ret void
}