#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 */
scalar_t__ RAND_MAX;
int pow(int, int);
scalar_t__ rand();
void gaussian_distribution(int ii, int jj, int kk, int xx, int yy, int zz,
                           double **connections, double *probs) {
  int i, j, k, cell_to_check, cell_evaluating, N_square, distance_without_root;
  double random_number, probability;
  N_square = xx * yy;
  cell_evaluating = kk * N_square + jj * xx + ii;
  for (i = 0; i < xx; i++)
    for (j = 0; j < yy; j++)
      for (k = 0; k < zz; k++) {
        cell_to_check = k * N_square + j * xx + i;
        distance_without_root =
            pow(i - ii, 2) + pow(j - jj, 2) + pow(k - kk, 2);
        probability = probs[distance_without_root];
        random_number = (double)rand() / (double)RAND_MAX;
        if (random_number <= probability)
          connections[cell_evaluating][cell_to_check] = 0.04;
      }
  return;
}


x86 assembly (clang, -O0):
<gaussian_distribution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
mov    -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
imul   -0x30(%rbp),%eax
mov    -0x8(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
add    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1297 <gaussian_distribution+0x177>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1284 <gaussian_distribution+0x164>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1271 <gaussian_distribution+0x151>
mov    -0x24(%rbp),%eax
imul   -0x30(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
sub    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,-0x50(%rbp)
mov    -0x20(%rbp),%edi
sub    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x24(%rbp),%edi
sub    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2dc9(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     125e <gaussian_distribution+0x13e>
mov    0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
movsd  0xda7(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1263 <gaussian_distribution+0x143>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1191 <gaussian_distribution+0x71>
jmp    1276 <gaussian_distribution+0x156>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    117e <gaussian_distribution+0x5e>
jmp    1289 <gaussian_distribution+0x169>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <gaussian_distribution+0x4b>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gaussian_distribution>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %r9d,0x20(%rsp)
mov    %r8d,0xc(%rsp)
mov    %esi,0x1c(%rsp)
mov    %edi,0x18(%rsp)
mov    %ecx,0x8(%rsp)
test   %ecx,%ecx
jle    12bf <gaussian_distribution+0x19f>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%eax
imul   %eax,%ecx
imul   0x1c(%rsp),%eax
add    0x18(%rsp),%eax
mov    %ecx,0x28(%rsp)
imul   %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
mov    %rax,0x38(%rsp)
mov    0x20(%rsp),%eax
mov    %rax,0x30(%rsp)
neg    %edx
mov    %edx,0x24(%rsp)
movl   $0x0,0x4(%rsp)
jmp    11a5 <gaussian_distribution+0x85>
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x4(%rsp)
cmp    0x8(%rsp),%eax
je     12bf <gaussian_distribution+0x19f>
cmpl   $0x0,0xc(%rsp)
jle    1190 <gaussian_distribution+0x70>
mov    0x4(%rsp),%eax
mov    %eax,%ecx
sub    0x18(%rsp),%ecx
mov    %ecx,0x2c(%rsp)
movl   $0x0,0x14(%rsp)
mov    %eax,0x10(%rsp)
jmp    11ed <gaussian_distribution+0xcd>
nopl   0x0(%rax,%rax,1)
mov    0x14(%rsp),%eax
add    $0x1,%eax
mov    0x10(%rsp),%ecx
add    0x8(%rsp),%ecx
mov    %ecx,0x10(%rsp)
mov    %eax,0x14(%rsp)
cmp    0xc(%rsp),%eax
je     1190 <gaussian_distribution+0x70>
cmpl   $0x0,0x20(%rsp)
jle    11d0 <gaussian_distribution+0xb0>
mov    0x14(%rsp),%r15d
sub    0x1c(%rsp),%r15d
mov    0x30(%rsp),%rbx
mov    0x24(%rsp),%r12d
mov    0x10(%rsp),%r13d
jmp    121f <gaussian_distribution+0xff>
nop
add    0x28(%rsp),%r13d
add    $0x1,%r12d
add    $0xffffffffffffffff,%rbx
je     11d0 <gaussian_distribution+0xb0>
mov    0x2c(%rsp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%r14d
mov    %r15d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ebp
add    %r14d,%ebp
mov    %r12d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
add    %ebp,%eax
cltq
mov    0x88(%rsp),%rcx
movsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,0x40(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x2d6c(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  0x40(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jb     1210 <gaussian_distribution+0xf0>
mov    0x80(%rsp),%rax
mov    0x38(%rsp),%rcx
mov    (%rax,%rcx,8),%rax
movslq %r13d,%rcx
movabs $0x3fa47ae147ae147b,%rdx
7a a4 3f
mov    %rdx,(%rax,%rcx,8)
jmp    1210 <gaussian_distribution+0xf0>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global i64 0
define void @gaussian_distribution(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double** %6, double* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca double**
%16 = alloca double*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca double
%25 = alloca double
store i32 %0, i32* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store double** %6, double*** %15
store double* %7, double** %16
%26 = load i32, i32* %12
%27 = load i32, i32* %13
%28 = mul nsw i32 %26, %27
store i32 %28, i32* %22
%29 = load i32, i32* %11
%30 = load i32, i32* %22
%31 = mul nsw i32 %29, %30
%32 = load i32, i32* %10
%33 = load i32, i32* %12
%34 = mul nsw i32 %32, %33
%35 = add nsw i32 %31, %34
%36 = load i32, i32* %9
%37 = add nsw i32 %35, %36
store i32 %37, i32* %21
store i32 0, i32* %17
br label %38
38: ; preds = %107, %8
%39 = load i32, i32* %17
%40 = load i32, i32* %12
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %110
42: ; preds = %38
store i32 0, i32* %18
br label %43
43: ; preds = %103, %42
%44 = load i32, i32* %18
%45 = load i32, i32* %13
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %106
47: ; preds = %43
store i32 0, i32* %19
br label %48
48: ; preds = %99, %47
%49 = load i32, i32* %19
%50 = load i32, i32* %14
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %102
52: ; preds = %48
%53 = load i32, i32* %19
%54 = load i32, i32* %22
%55 = mul nsw i32 %53, %54
%56 = load i32, i32* %18
%57 = load i32, i32* %12
%58 = mul nsw i32 %56, %57
%59 = add nsw i32 %55, %58
%60 = load i32, i32* %17
%61 = add nsw i32 %59, %60
store i32 %61, i32* %20
%62 = load i32, i32* %17
%63 = load i32, i32* %9
%64 = sub nsw i32 %62, %63
%65 = call i32 @pow(i32 %64, i32 2)
%66 = load i32, i32* %18
%67 = load i32, i32* %10
%68 = sub nsw i32 %66, %67
%69 = call i32 @pow(i32 %68, i32 2)
%70 = add nsw i32 %65, %69
%71 = load i32, i32* %19
%72 = load i32, i32* %11
%73 = sub nsw i32 %71, %72
%74 = call i32 @pow(i32 %73, i32 2)
%75 = add nsw i32 %70, %74
store i32 %75, i32* %23
%76 = load double*, double** %16
%77 = load i32, i32* %23
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds double, double* %76, i64 %78
%80 = load double, double* %79
store double %80, double* %25
%81 = call i64 (...) @rand()
%82 = sitofp i64 %81 to double
%83 = load i64, i64* @RAND_MAX
%84 = sitofp i64 %83 to double
%85 = fdiv double %82, %84
store double %85, double* %24
%86 = load double, double* %24
%87 = load double, double* %25
%88 = fcmp ole double %86, %87
br i1 %88, label %89, label %98
89: ; preds = %52
%90 = load double**, double*** %15
%91 = load i32, i32* %21
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds double*, double** %90, i64 %92
%94 = load double*, double** %93
%95 = load i32, i32* %20
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %94, i64 %96
store double 4.000000e-02, double* %97
br label %98
98: ; preds = %89, %52
br label %99
99: ; preds = %98
%100 = load i32, i32* %19
%101 = add nsw i32 %100, 1
store i32 %101, i32* %19
br label %48
102: ; preds = %48
br label %103
103: ; preds = %102
%104 = load i32, i32* %18
%105 = add nsw i32 %104, 1
store i32 %105, i32* %18
br label %43
106: ; preds = %43
br label %107
107: ; preds = %106
%108 = load i32, i32* %17
%109 = add nsw i32 %108, 1
store i32 %109, i32* %17
br label %38
110: ; preds = %38
ret void
}

LLVM IR (-O2):
@RAND_MAX = global i64 0
define void @gaussian_distribution(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5, double** nocapture %6, double* nocapture %7) {
%9 = mul nsw i32 %4, %3
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %65
11: ; preds = %8
%12 = mul nsw i32 %3, %1
%13 = add i32 %12, %0
%14 = mul nsw i32 %9, %2
%15 = add i32 %13, %14
%16 = icmp sgt i32 %4, 0
%17 = icmp sgt i32 %5, 0
%18 = sext i32 %15 to i64
%19 = getelementptr inbounds double*, double** %6, i64 %18
%20 = zext i32 %5 to i64
br label %21
21: ; preds = %11, %62
%22 = phi i32 [ 0, %11 ], [ %63, %62 ]
br i1 %16, label %23, label %62
23: ; preds = %21
%24 = sub nsw i32 %22, %0
br label %25
25: ; preds = %23, %59
%26 = phi i32 [ 0, %23 ], [ %60, %59 ]
br i1 %17, label %27, label %59
27: ; preds = %25
%28 = sub nsw i32 %26, %1
%29 = mul nsw i32 %26, %3
%30 = add i32 %29, %22
br label %31
31: ; preds = %27, %56
%32 = phi i64 [ 0, %27 ], [ %57, %56 ]
%33 = tail call i32 @pow(i32 %24, i32 2)
%34 = tail call i32 @pow(i32 %28, i32 2)
%35 = add nsw i32 %34, %33
%36 = trunc i64 %32 to i32
%37 = sub i32 %36, %2
%38 = tail call i32 @pow(i32 %37, i32 2)
%39 = add nsw i32 %35, %38
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %7, i64 %40
%42 = load double, double* %41
%43 = tail call i64 (...) @rand()
%44 = sitofp i64 %43 to double
%45 = load i64, i64* @RAND_MAX
%46 = sitofp i64 %45 to double
%47 = fdiv double %44, %46
%48 = fcmp ugt double %47, %42
br i1 %48, label %56, label %49
49: ; preds = %31
%50 = trunc i64 %32 to i32
%51 = mul i32 %9, %50
%52 = add i32 %30, %51
%53 = load double*, double** %19
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds double, double* %53, i64 %54
store double 4.000000e-02, double* %55
br label %56
56: ; preds = %31, %49
%57 = add nuw nsw i64 %32, 1
%58 = icmp eq i64 %57, %20
br i1 %58, label %59, label %31
59: ; preds = %56, %25
%60 = add nuw nsw i32 %26, 1
%61 = icmp eq i32 %60, %4
br i1 %61, label %62, label %25
62: ; preds = %59, %21
%63 = add nuw nsw i32 %22, 1
%64 = icmp eq i32 %63, %3
br i1 %64, label %65, label %21
65: ; preds = %62, %8
ret void
}