#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 M_PI;
scalar_t__ RAND_MAX;
scalar_t__ abs(int);
float exp(float);
int generate_gaussian_number(int /*<<< orphan*/, int /*<<< orphan*/);
float pow(float, int);
scalar_t__ rand();
int /*<<< orphan*/ round(float);
float sqrt(int);
int conn_marking_gaussian_1D(int *conn_buffer, short *external_cell,
                             int global_cell_id, int local_nw_size, int nw_size,
                             double probability, int core_id) {
  int total_amount_connections = 0, sender_cell;
  float mean = 0, deviation = 1.0, scale = 367.647;
  float gaussian_probability;
  float rndm;
  float average_connections = nw_size * probability;
  if (probability == 0)
    total_amount_connections = 0;
  else
    total_amount_connections = generate_gaussian_number(
        round(average_connections * 0.9), round(average_connections * 1.1));
  float x = 1 / (deviation * sqrt(2 * M_PI));
  float y = -(1 / (2 * pow(deviation, 2)));
  float distance_1D = 0.0;
  int connections_found = 0;
  while (connections_found < total_amount_connections) {
    for (sender_cell = 0; sender_cell < nw_size; sender_cell++) {
      if (connections_found >= total_amount_connections)
        break;
      if (sender_cell == global_cell_id)
        ;
      else if (conn_buffer[sender_cell])
        ;
      else {
        distance_1D = ((float)(abs(sender_cell - global_cell_id))) / scale;
        gaussian_probability = x * exp(pow(distance_1D - mean, 2) * y);
        rndm = ((float)rand()) / ((float)RAND_MAX);
        if (rndm <= gaussian_probability) {
          conn_buffer[sender_cell]++;
          connections_found++;
          if ((sender_cell / local_nw_size) != core_id)
            external_cell[sender_cell] = 1;
        }
      }
    }
  }
  return connections_found;
}


x86 assembly (clang, -O0):
<conn_marking_gaussian_1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
movss  0xe5a(%rip),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  0xe49(%rip),%xmm0
movss  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f3 <conn_marking_gaussian_1D+0x83>
jp     11f3 <conn_marking_gaussian_1D+0x83>
movl   $0x0,-0x30(%rbp)
jmp    123f <conn_marking_gaussian_1D+0xcf>
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe14(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <round@plt>
mov    %eax,-0x60(%rbp)
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdeb(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <round@plt>
mov    -0x60(%rbp),%edi
mov    %eax,%esi
call   1040 <generate_gaussian_number@plt>
mov    %eax,-0x30(%rbp)
movss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x64(%rbp)
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
shl    $0x1,%edi
call   1080 <sqrt@plt>
movss  -0x64(%rbp),%xmm1
mulss  %xmm0,%xmm1
movss  0xd99(%rip),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x3c(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
movss  0xd7d(%rip),%xmm1
mulss  %xmm0,%xmm1
movss  0xd6d(%rip),%xmm0
divss  %xmm1,%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x54(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    13fa <conn_marking_gaussian_1D+0x28a>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    13f5 <conn_marking_gaussian_1D+0x285>
mov    -0x5c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jl     12ec <conn_marking_gaussian_1D+0x17c>
jmp    13f5 <conn_marking_gaussian_1D+0x285>
mov    -0x34(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    12fd <conn_marking_gaussian_1D+0x18d>
jmp    13e2 <conn_marking_gaussian_1D+0x272>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
je     1314 <conn_marking_gaussian_1D+0x1a4>
jmp    13dd <conn_marking_gaussian_1D+0x26d>
mov    -0x34(%rbp),%edi
sub    -0x14(%rbp),%edi
call   1030 <abs@plt>
cvtsi2ss %rax,%xmm0
divss  -0x40(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x50(%rbp),%xmm0
movss  %xmm0,-0x68(%rbp)
movss  -0x58(%rbp),%xmm0
subss  -0x38(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mulss  -0x54(%rbp),%xmm0
call   1050 <exp@plt>
movaps %xmm0,%xmm1
movss  -0x68(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
cvtsi2ss %rax,%xmm0
mov    0x2c66(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x48(%rbp)
movss  -0x48(%rbp),%xmm1
movss  -0x44(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jb     13d8 <conn_marking_gaussian_1D+0x268>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    -0x2c(%rbp),%eax
je     13d3 <conn_marking_gaussian_1D+0x263>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movw   $0x1,(%rax,%rcx,2)
jmp    13d8 <conn_marking_gaussian_1D+0x268>
jmp    13dd <conn_marking_gaussian_1D+0x26d>
jmp    13e2 <conn_marking_gaussian_1D+0x272>
jmp    13e7 <conn_marking_gaussian_1D+0x277>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    12cf <conn_marking_gaussian_1D+0x15f>
jmp    12bc <conn_marking_gaussian_1D+0x14c>
mov    -0x5c(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conn_marking_gaussian_1D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,0x20(%rsp)
mov    %r8d,0x8(%rsp)
mov    %ecx,0x1c(%rsp)
mov    %edx,%ebx
mov    %rsi,0x28(%rsp)
mov    %rdi,%rbp
xor    %r12d,%r12d
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    $0x0,%r14d
jne    11ab <conn_marking_gaussian_1D+0x3b>
jnp    1208 <conn_marking_gaussian_1D+0x98>
xorps  %xmm1,%xmm1
cvtsi2sdl 0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe2c(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <round@plt>
mov    %eax,%r14d
movsd  0x10(%rsp),%xmm0
mulsd  0xe16(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1070 <round@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1040 <generate_gaussian_number@plt>
mov    %eax,%r14d
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
call   1080 <sqrt@plt>
movss  %xmm0,0x10(%rsp)
movss  0xdea(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
mov    $0x2,%edi
call   1060 <pow@plt>
test   %r14d,%r14d
jle    136b <conn_marking_gaussian_1D+0x1fb>
movss  0xc(%rsp),%xmm1
divss  0x10(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
addss  %xmm0,%xmm0
movss  0xdb7(%rip),%xmm1
divss  %xmm0,%xmm1
movss  %xmm1,0x24(%rsp)
mov    %rbx,%rax
mov    %eax,%r13d
movslq 0x8(%rsp),%rbx
neg    %eax
mov    %rax,0x30(%rsp)
xor    %r12d,%r12d
jmp    1289 <conn_marking_gaussian_1D+0x119>
xchg   %ax,%ax
cmp    %r14d,%r12d
jge    136b <conn_marking_gaussian_1D+0x1fb>
cmpl   $0x0,0x8(%rsp)
jle    1280 <conn_marking_gaussian_1D+0x110>
cmp    %r14d,%r12d
jge    1280 <conn_marking_gaussian_1D+0x110>
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
cmp    %r15,%r13
je     1350 <conn_marking_gaussian_1D+0x1e0>
cmpl   $0x0,0x0(%rbp,%r15,4)
jne    1350 <conn_marking_gaussian_1D+0x1e0>
mov    0x30(%rsp),%rax
lea    (%rax,%r15,1),%edi
call   1030 <abs@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
divss  0xd45(%rip),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mulss  0x24(%rsp),%xmm0
call   1050 <exp@plt>
mulss  0xc(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1090 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %rax,%xmm0
mov    0x2cd6(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
movss  0x10(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jb     1350 <conn_marking_gaussian_1D+0x1e0>
addl   $0x1,0x0(%rbp,%r15,4)
add    $0x1,%r12d
mov    %r15d,%eax
cltd
idivl  0x1c(%rsp)
cmp    0x20(%rsp),%eax
je     1350 <conn_marking_gaussian_1D+0x1e0>
mov    0x28(%rsp),%rax
movw   $0x1,(%rax,%r15,2)
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%r15
cmp    %rbx,%r15
jge    1280 <conn_marking_gaussian_1D+0x110>
cmp    %r14d,%r12d
jl     12a0 <conn_marking_gaussian_1D+0x130>
jmp    1280 <conn_marking_gaussian_1D+0x110>
mov    %r12d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global i32 0
@RAND_MAX = global i64 0
define i32 @conn_marking_gaussian_1D(i32* %0, i16* %1, i32 %2, i32 %3, i32 %4, double %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i16*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca float
%24 = alloca float
%25 = alloca float
%26 = alloca i32
store i32* %0, i32** %8
store i16* %1, i16** %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 i32 0, i32* %15
store float 0.000000e+00, float* %17
store float 1.000000e+00, float* %18
store float 0x4076FA5A20000000, float* %19
%27 = load i32, i32* %12
%28 = sitofp i32 %27 to double
%29 = load double, double* %13
%30 = fmul double %28, %29
%31 = fptrunc double %30 to float
store float %31, float* %22
%32 = load double, double* %13
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %35
34: ; preds = %7
store i32 0, i32* %15
br label %47
35: ; preds = %7
%36 = load float, float* %22
%37 = fpext float %36 to double
%38 = fmul double %37, 9.000000e-01
%39 = fptrunc double %38 to float
%40 = call i32 @round(float %39)
%41 = load float, float* %22
%42 = fpext float %41 to double
%43 = fmul double %42, 1.100000e+00
%44 = fptrunc double %43 to float
%45 = call i32 @round(float %44)
%46 = call i32 @generate_gaussian_number(i32 %40, i32 %45)
store i32 %46, i32* %15
br label %47
47: ; preds = %35, %34
%48 = load float, float* %18
%49 = load i32, i32* @M_PI
%50 = mul nsw i32 2, %49
%51 = call float @sqrt(i32 %50)
%52 = fmul float %48, %51
%53 = fdiv float 1.000000e+00, %52
store float %53, float* %23
%54 = load float, float* %18
%55 = call float @pow(float %54, i32 2)
%56 = fmul float 2.000000e+00, %55
%57 = fdiv float 1.000000e+00, %56
%58 = fneg float %57
store float %58, float* %24
store float 0.000000e+00, float* %25
store i32 0, i32* %26
br label %59
59: ; preds = %137, %47
%60 = load i32, i32* %26
%61 = load i32, i32* %15
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %138
63: ; preds = %59
store i32 0, i32* %16
br label %64
64: ; preds = %134, %63
%65 = load i32, i32* %16
%66 = load i32, i32* %12
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %137
68: ; preds = %64
%69 = load i32, i32* %26
%70 = load i32, i32* %15
%71 = icmp sge i32 %69, %70
br i1 %71, label %72, label %73
72: ; preds = %68
br label %137
73: ; preds = %68
%74 = load i32, i32* %16
%75 = load i32, i32* %10
%76 = icmp eq i32 %74, %75
br i1 %76, label %77, label %78
77: ; preds = %73
br label %133
78: ; preds = %73
%79 = load i32*, i32** %8
%80 = load i32, i32* %16
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32, i32* %79, i64 %81
%83 = load i32, i32* %82
%84 = icmp ne i32 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %78
br label %132
86: ; preds = %78
%87 = load i32, i32* %16
%88 = load i32, i32* %10
%89 = sub nsw i32 %87, %88
%90 = call i64 @abs(i32 %89)
%91 = sitofp i64 %90 to float
%92 = load float, float* %19
%93 = fdiv float %91, %92
store float %93, float* %25
%94 = load float, float* %23
%95 = load float, float* %25
%96 = load float, float* %17
%97 = fsub float %95, %96
%98 = call float @pow(float %97, i32 2)
%99 = load float, float* %24
%100 = fmul float %98, %99
%101 = call float @exp(float %100)
%102 = fmul float %94, %101
store float %102, float* %20
%103 = call i64 (...) @rand()
%104 = sitofp i64 %103 to float
%105 = load i64, i64* @RAND_MAX
%106 = sitofp i64 %105 to float
%107 = fdiv float %104, %106
store float %107, float* %21
%108 = load float, float* %21
%109 = load float, float* %20
%110 = fcmp ole float %108, %109
br i1 %110, label %111, label %131
111: ; preds = %86
%112 = load i32*, i32** %8
%113 = load i32, i32* %16
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %112, i64 %114
%116 = load i32, i32* %115
%117 = add nsw i32 %116, 1
store i32 %117, i32* %115
%118 = load i32, i32* %26
%119 = add nsw i32 %118, 1
store i32 %119, i32* %26
%120 = load i32, i32* %16
%121 = load i32, i32* %11
%122 = sdiv i32 %120, %121
%123 = load i32, i32* %14
%124 = icmp ne i32 %122, %123
br i1 %124, label %125, label %130
125: ; preds = %111
%126 = load i16*, i16** %9
%127 = load i32, i32* %16
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i16, i16* %126, i64 %128
store i16 1, i16* %129
br label %130
130: ; preds = %125, %111
br label %131
131: ; preds = %130, %86
br label %132
132: ; preds = %131, %85
br label %133
133: ; preds = %132, %77
br label %134
134: ; preds = %133
%135 = load i32, i32* %16
%136 = add nsw i32 %135, 1
store i32 %136, i32* %16
br label %64
137: ; preds = %72, %64
br label %59
138: ; preds = %59
%139 = load i32, i32* %26
ret i32 %139
}

LLVM IR (-O2):
@M_PI = global i32 0
@RAND_MAX = global i64 0
define i32 @conn_marking_gaussian_1D(i32* nocapture %0, i16* nocapture writeonly %1, i32 %2, i32 %3, i32 %4, double %5, i32 %6) {
%8 = fcmp oeq double %5, 0.000000e+00
br i1 %8, label %21, label %9
9: ; preds = %7
%10 = sitofp i32 %4 to double
%11 = fmul double %10, %5
%12 = fptrunc double %11 to float
%13 = fpext float %12 to double
%14 = fmul double %13, 9.000000e-01
%15 = fptrunc double %14 to float
%16 = tail call i32 @round(float %15)
%17 = fmul double %13, 1.100000e+00
%18 = fptrunc double %17 to float
%19 = tail call i32 @round(float %18)
%20 = tail call i32 @generate_gaussian_number(i32 %16, i32 %19)
br label %21
21: ; preds = %7, %9
%22 = phi i32 [ %20, %9 ], [ 0, %7 ]
%23 = load i32, i32* @M_PI
%24 = shl nsw i32 %23, 1
%25 = tail call float @sqrt(i32 %24)
%26 = fdiv float 1.000000e+00, %25
%27 = tail call float @pow(float 1.000000e+00, i32 2)
%28 = fmul float %27, 2.000000e+00
%29 = fdiv float -1.000000e+00, %28
%30 = icmp sgt i32 %22, 0
br i1 %30, label %31, label %80
31: ; preds = %21
%32 = icmp sgt i32 %4, 0
%33 = zext i32 %2 to i64
%34 = sext i32 %4 to i64
br label %38
35: ; preds = %74, %38
%36 = phi i32 [ %39, %38 ], [ %75, %74 ]
%37 = icmp slt i32 %36, %22
br i1 %37, label %38, label %80
38: ; preds = %31, %35
%39 = phi i32 [ 0, %31 ], [ %36, %35 ]
%40 = icmp slt i32 %39, %22
%41 = select i1 %32, i1 %40, i1 false
br i1 %41, label %42, label %35
42: ; preds = %38, %74
%43 = phi i64 [ %76, %74 ], [ 0, %38 ]
%44 = phi i32 [ %75, %74 ], [ %39, %38 ]
%45 = icmp eq i64 %43, %33
br i1 %45, label %74, label %46
46: ; preds = %42
%47 = getelementptr inbounds i32, i32* %0, i64 %43
%48 = load i32, i32* %47
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %74
50: ; preds = %46
%51 = trunc i64 %43 to i32
%52 = sub nsw i32 %51, %2
%53 = tail call i64 @abs(i32 %52)
%54 = sitofp i64 %53 to float
%55 = fdiv float %54, 0x4076FA5A20000000
%56 = tail call float @pow(float %55, i32 2)
%57 = fmul float %29, %56
%58 = tail call float @exp(float %57)
%59 = fmul float %26, %58
%60 = tail call i64 (...) @rand()
%61 = sitofp i64 %60 to float
%62 = load i64, i64* @RAND_MAX
%63 = sitofp i64 %62 to float
%64 = fdiv float %61, %63
%65 = fcmp ugt float %64, %59
br i1 %65, label %74, label %66
66: ; preds = %50
%67 = load i32, i32* %47
%68 = add nsw i32 %67, 1
store i32 %68, i32* %47
%69 = add nsw i32 %44, 1
%70 = sdiv i32 %51, %3
%71 = icmp eq i32 %70, %6
br i1 %71, label %74, label %72
72: ; preds = %66
%73 = getelementptr inbounds i16, i16* %1, i64 %43
store i16 1, i16* %73
br label %74
74: ; preds = %42, %50, %72, %66, %46
%75 = phi i32 [ %44, %42 ], [ %44, %46 ], [ %69, %72 ], [ %69, %66 ], [ %44, %50 ]
%76 = add nuw nsw i64 %43, 1
%77 = icmp slt i64 %76, %34
%78 = icmp slt i32 %75, %22
%79 = select i1 %77, i1 %78, i1 false
br i1 %79, label %42, label %35
80: ; preds = %35, %21
%81 = phi i32 [ 0, %21 ], [ %36, %35 ]
ret i32 %81
}