#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 *neuron_connections, double *probs) {
  int i, j, k, cell_to_check, distance_without_root;
  double random_number, probability;
  for (i = 0; i < zz; i++)
    for (j = 0; j < yy; j++)
      for (k = 0; k < xx; k++) {
        cell_to_check = i * xx * yy + j * xx + k;
        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)
          neuron_connections[cell_to_check] = 0.04;
        else
          neuron_connections[cell_to_check] = 0;
      }
  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)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1288 <gaussian_distribution+0x168>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1275 <gaussian_distribution+0x155>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1262 <gaussian_distribution+0x142>
mov    -0x1c(%rbp),%eax
imul   -0x10(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    -0x20(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
sub    -0x4(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
sub    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x24(%rbp),%edi
sub    -0xc(%rbp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   1040 <rand@plt>
cvtsi2sd %rax,%xmm0
mov    0x2de5(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     123f <gaussian_distribution+0x11f>
mov    0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  0xdcb(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    124f <gaussian_distribution+0x12f>
mov    0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
jmp    1254 <gaussian_distribution+0x134>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1171 <gaussian_distribution+0x51>
jmp    1267 <gaussian_distribution+0x147>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115e <gaussian_distribution+0x3e>
jmp    127a <gaussian_distribution+0x15a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114b <gaussian_distribution+0x2b>
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    %r8d,0xc(%rsp)
mov    %edx,0x14(%rsp)
mov    %esi,0x28(%rsp)
mov    %edi,0x1c(%rsp)
mov    %r9d,0x24(%rsp)
test   %r9d,%r9d
jle    12be <gaussian_distribution+0x19e>
mov    0x88(%rsp),%r14
mov    %ecx,%eax
mov    %rax,0x38(%rsp)
negl   0x14(%rsp)
mov    0xc(%rsp),%eax
imul   %ecx,%eax
mov    %eax,0x20(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
mov    %ecx,0x2c(%rsp)
jmp    11b1 <gaussian_distribution+0x91>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x4(%rsp),%edx
add    $0x1,%edx
mov    0x8(%rsp),%eax
add    0x20(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    %edx,0x4(%rsp)
cmp    0x24(%rsp),%edx
je     12be <gaussian_distribution+0x19e>
cmpl   $0x0,0xc(%rsp)
jle    1190 <gaussian_distribution+0x70>
mov    0x4(%rsp),%edx
sub    0x1c(%rsp),%edx
movl   $0x0,0x10(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x18(%rsp)
mov    %edx,0x30(%rsp)
jmp    11f9 <gaussian_distribution+0xd9>
cs nopw 0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
add    $0x1,%eax
mov    0x2c(%rsp),%ecx
add    %ecx,0x18(%rsp)
mov    %eax,0x10(%rsp)
cmp    0xc(%rsp),%eax
je     1190 <gaussian_distribution+0x70>
test   %ecx,%ecx
jle    11e0 <gaussian_distribution+0xc0>
mov    0x10(%rsp),%eax
sub    0x28(%rsp),%eax
mov    %eax,0x34(%rsp)
mov    0x38(%rsp),%rbx
mov    0x18(%rsp),%eax
mov    %eax,%r13d
mov    0x14(%rsp),%r15d
nopw   0x0(%rax,%rax,1)
mov    0x30(%rsp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%r12d
mov    0x34(%rsp),%edi
mov    $0x2,%esi
call   1030 <pow@plt>
mov    %eax,%ebp
add    %r12d,%ebp
mov    %r15d,%edi
mov    $0x2,%esi
call   1030 <pow@plt>
add    %ebp,%eax
cltq
movsd  (%r14,%rax,8),%xmm0
movsd  %xmm0,0x40(%rsp)
xor    %eax,%eax
call   1040 <rand@plt>
mov    0x2d79(%rip),%rcx
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mov    0x80(%rsp),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rcx),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd6d(%rip),%xmm1
movslq %r13d,%r13
cmpnlesd 0x40(%rsp),%xmm0
andnpd %xmm1,%xmm0
movlpd %xmm0,(%rax,%r13,8)
add    $0x1,%r15d
add    $0x1,%r13d
add    $0xffffffffffffffff,%rbx
jne    1220 <gaussian_distribution+0x100>
jmp    11e0 <gaussian_distribution+0xc0>
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 double
%23 = 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
store i32 0, i32* %17
br label %24
24: ; preds = %96, %8
%25 = load i32, i32* %17
%26 = load i32, i32* %14
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %99
28: ; preds = %24
store i32 0, i32* %18
br label %29
29: ; preds = %92, %28
%30 = load i32, i32* %18
%31 = load i32, i32* %13
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %95
33: ; preds = %29
store i32 0, i32* %19
br label %34
34: ; preds = %88, %33
%35 = load i32, i32* %19
%36 = load i32, i32* %12
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %91
38: ; preds = %34
%39 = load i32, i32* %17
%40 = load i32, i32* %12
%41 = mul nsw i32 %39, %40
%42 = load i32, i32* %13
%43 = mul nsw i32 %41, %42
%44 = load i32, i32* %18
%45 = load i32, i32* %12
%46 = mul nsw i32 %44, %45
%47 = add nsw i32 %43, %46
%48 = load i32, i32* %19
%49 = add nsw i32 %47, %48
store i32 %49, i32* %20
%50 = load i32, i32* %17
%51 = load i32, i32* %9
%52 = sub nsw i32 %50, %51
%53 = call i32 @pow(i32 %52, i32 2)
%54 = load i32, i32* %18
%55 = load i32, i32* %10
%56 = sub nsw i32 %54, %55
%57 = call i32 @pow(i32 %56, i32 2)
%58 = add nsw i32 %53, %57
%59 = load i32, i32* %19
%60 = load i32, i32* %11
%61 = sub nsw i32 %59, %60
%62 = call i32 @pow(i32 %61, i32 2)
%63 = add nsw i32 %58, %62
store i32 %63, i32* %21
%64 = load double*, double** %16
%65 = load i32, i32* %21
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds double, double* %64, i64 %66
%68 = load double, double* %67
store double %68, double* %23
%69 = call i64 (...) @rand()
%70 = sitofp i64 %69 to double
%71 = load i64, i64* @RAND_MAX
%72 = sitofp i64 %71 to double
%73 = fdiv double %70, %72
store double %73, double* %22
%74 = load double, double* %22
%75 = load double, double* %23
%76 = fcmp ole double %74, %75
br i1 %76, label %77, label %82
77: ; preds = %38
%78 = load double*, double** %15
%79 = load i32, i32* %20
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds double, double* %78, i64 %80
store double 4.000000e-02, double* %81
br label %87
82: ; preds = %38
%83 = load double*, double** %15
%84 = load i32, i32* %20
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %83, i64 %85
store double 0.000000e+00, double* %86
br label %87
87: ; preds = %82, %77
br label %88
88: ; preds = %87
%89 = load i32, i32* %19
%90 = add nsw i32 %89, 1
store i32 %90, i32* %19
br label %34
91: ; preds = %34
br label %92
92: ; preds = %91
%93 = load i32, i32* %18
%94 = add nsw i32 %93, 1
store i32 %94, i32* %18
br label %29
95: ; preds = %29
br label %96
96: ; preds = %95
%97 = load i32, i32* %17
%98 = add nsw i32 %97, 1
store i32 %98, i32* %17
br label %24
99: ; preds = %24
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 writeonly %6, double* nocapture %7) {
%9 = icmp sgt i32 %5, 0
br i1 %9, label %10, label %56
10: ; preds = %8
%11 = icmp sgt i32 %4, 0
%12 = icmp sgt i32 %3, 0
%13 = zext i32 %3 to i64
br label %14
14: ; preds = %10, %53
%15 = phi i32 [ 0, %10 ], [ %54, %53 ]
br i1 %11, label %16, label %53
16: ; preds = %14
%17 = mul i32 %15, %4
%18 = sub nsw i32 %15, %0
br label %19
19: ; preds = %16, %50
%20 = phi i32 [ 0, %16 ], [ %51, %50 ]
br i1 %12, label %21, label %50
21: ; preds = %19
%22 = add i32 %20, %17
%23 = mul i32 %22, %3
%24 = sub nsw i32 %20, %1
br label %25
25: ; preds = %21, %25
%26 = phi i64 [ 0, %21 ], [ %48, %25 ]
%27 = trunc i64 %26 to i32
%28 = add i32 %23, %27
%29 = tail call i32 @pow(i32 %18, i32 2)
%30 = tail call i32 @pow(i32 %24, i32 2)
%31 = add nsw i32 %30, %29
%32 = trunc i64 %26 to i32
%33 = sub i32 %32, %2
%34 = tail call i32 @pow(i32 %33, i32 2)
%35 = add nsw i32 %31, %34
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds double, double* %7, i64 %36
%38 = load double, double* %37
%39 = tail call i64 (...) @rand()
%40 = sitofp i64 %39 to double
%41 = load i64, i64* @RAND_MAX
%42 = sitofp i64 %41 to double
%43 = fdiv double %40, %42
%44 = fcmp ugt double %43, %38
%45 = sext i32 %28 to i64
%46 = getelementptr inbounds double, double* %6, i64 %45
%47 = select i1 %44, double 0.000000e+00, double 4.000000e-02
store double %47, double* %46
%48 = add nuw nsw i64 %26, 1
%49 = icmp eq i64 %48, %13
br i1 %49, label %50, label %25
50: ; preds = %25, %19
%51 = add nuw nsw i32 %20, 1
%52 = icmp eq i32 %51, %4
br i1 %52, label %53, label %19
53: ; preds = %50, %14
%54 = add nuw nsw i32 %15, 1
%55 = icmp eq i32 %54, %5
br i1 %55, label %56, label %14
56: ; preds = %53, %8
ret void
}