#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 generate_gaussian_number(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ round(float);
int conn_marking_nearest_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, connections_found = 0, step;
  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));
  step = 1;
  while ((connections_found < total_amount_connections) && (step < nw_size)) {
    sender_cell = global_cell_id + step;
    if (sender_cell < nw_size) {
      conn_buffer[sender_cell]++;
      connections_found++;
      if ((sender_cell / local_nw_size) != core_id)
        external_cell[sender_cell] = 1;
    }
    sender_cell = global_cell_id - step;
    if (sender_cell >= 0) {
      conn_buffer[sender_cell]++;
      connections_found++;
      if ((sender_cell / local_nw_size) != core_id)
        external_cell[sender_cell] = 1;
    }
    step++;
  }
  return connections_found;
}


x86 assembly (clang, -O0):
<conn_marking_nearest_1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%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)
movl   $0x0,-0x38(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1188 <conn_marking_nearest_1D+0x68>
jp     1188 <conn_marking_nearest_1D+0x68>
movl   $0x0,-0x30(%rbp)
jmp    11d4 <conn_marking_nearest_1D+0xb4>
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe6f(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <round@plt>
mov    %eax,-0x44(%rbp)
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe46(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <round@plt>
mov    -0x44(%rbp),%edi
mov    %eax,%esi
call   1030 <generate_gaussian_number@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
mov    -0x38(%rbp),%ecx
xor    %eax,%eax
cmp    -0x30(%rbp),%ecx
mov    %al,-0x45(%rbp)
jge    11f8 <conn_marking_nearest_1D+0xd8>
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x45(%rbp)
mov    -0x45(%rbp),%al
test   $0x1,%al
jne    1208 <conn_marking_nearest_1D+0xe8>
jmp    12b8 <conn_marking_nearest_1D+0x198>
mov    -0x14(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    125a <conn_marking_nearest_1D+0x13a>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    -0x2c(%rbp),%eax
je     1255 <conn_marking_nearest_1D+0x135>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movw   $0x1,(%rax,%rcx,2)
jmp    125a <conn_marking_nearest_1D+0x13a>
mov    -0x14(%rbp),%eax
sub    -0x3c(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     12aa <conn_marking_nearest_1D+0x18a>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
add    $0x1,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    -0x2c(%rbp),%eax
je     12a5 <conn_marking_nearest_1D+0x185>
mov    -0x10(%rbp),%rax
movslq -0x34(%rbp),%rcx
movw   $0x1,(%rax,%rcx,2)
jmp    12aa <conn_marking_nearest_1D+0x18a>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11db <conn_marking_nearest_1D+0xbb>
mov    -0x38(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conn_marking_nearest_1D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %ebx,%ebx
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    114d <conn_marking_nearest_1D+0x2d>
jp     114d <conn_marking_nearest_1D+0x2d>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r9d,%r12d
mov    %r8d,%r13d
mov    %ecx,%r14d
mov    %rdi,%r15
mov    %edx,0x4(%rsp)
mov    %rsi,0x8(%rsp)
xorps  %xmm1,%xmm1
cvtsi2sd %r8d,%xmm1
mulsd  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  0xe76(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <round@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
mulsd  0xe61(%rip),%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <round@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1030 <generate_gaussian_number@plt>
test   %eax,%eax
jle    113c <conn_marking_nearest_1D+0x1c>
cmp    $0x2,%r13d
jl     113c <conn_marking_nearest_1D+0x1c>
mov    %eax,%r11d
movslq 0x4(%rsp),%rax
mov    %r13d,%edi
lea    -0x1(%rax),%r13
lea    (%r15,%rax,4),%r8
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,2),%r9
mov    %eax,%r10d
xor    %ebx,%ebx
mov    $0x2,%ecx
mov    %r13,%rsi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    (%rcx,%r13,1),%rax
cmp    %rdi,%rax
jge    122a <conn_marking_nearest_1D+0x10a>
addl   $0x1,-0x4(%r8,%rcx,4)
add    $0x1,%ebx
lea    (%r10,%rcx,1),%eax
add    $0xffffffff,%eax
cltd
idiv   %r14d
cmp    %r12d,%eax
je     122a <conn_marking_nearest_1D+0x10a>
movw   $0x1,-0x2(%r9,%rcx,2)
test   %rsi,%rsi
js     124f <conn_marking_nearest_1D+0x12f>
mov    %esi,%ebp
addl   $0x1,(%r15,%rbp,4)
add    $0x1,%ebx
mov    %esi,%eax
cltd
idiv   %r14d
cmp    %r12d,%eax
je     124f <conn_marking_nearest_1D+0x12f>
mov    0x8(%rsp),%rax
movw   $0x1,(%rax,%rbp,2)
cmp    %r11d,%ebx
jge    113c <conn_marking_nearest_1D+0x1c>
add    $0xffffffffffffffff,%rsi
lea    0x1(%rcx),%rax
cmp    %rdi,%rcx
mov    %rax,%rcx
jb     1200 <conn_marking_nearest_1D+0xe0>
jmp    113c <conn_marking_nearest_1D+0x1c>

LLVM IR (-O0):
define i32 @conn_marking_nearest_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 i32
%18 = alloca i32
%19 = alloca float
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 i32 0, i32* %17
%20 = load i32, i32* %12
%21 = sitofp i32 %20 to double
%22 = load double, double* %13
%23 = fmul double %21, %22
%24 = fptrunc double %23 to float
store float %24, float* %19
%25 = load double, double* %13
%26 = fcmp oeq double %25, 0.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %7
store i32 0, i32* %15
br label %40
28: ; preds = %7
%29 = load float, float* %19
%30 = fpext float %29 to double
%31 = fmul double %30, 9.000000e-01
%32 = fptrunc double %31 to float
%33 = call i32 @round(float %32)
%34 = load float, float* %19
%35 = fpext float %34 to double
%36 = fmul double %35, 1.100000e+00
%37 = fptrunc double %36 to float
%38 = call i32 @round(float %37)
%39 = call i32 @generate_gaussian_number(i32 %33, i32 %38)
store i32 %39, i32* %15
br label %40
40: ; preds = %28, %27
store i32 1, i32* %18
br label %41
41: ; preds = %104, %40
%42 = load i32, i32* %17
%43 = load i32, i32* %15
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i32, i32* %18
%47 = load i32, i32* %12
%48 = icmp slt i32 %46, %47
br label %49
49: ; preds = %45, %41
%50 = phi i1 [ false, %41 ], [ %48, %45 ]
br i1 %50, label %51, label %107
51: ; preds = %49
%52 = load i32, i32* %10
%53 = load i32, i32* %18
%54 = add nsw i32 %52, %53
store i32 %54, i32* %16
%55 = load i32, i32* %16
%56 = load i32, i32* %12
%57 = icmp slt i32 %55, %56
br i1 %57, label %58, label %78
58: ; preds = %51
%59 = load i32*, i32** %8
%60 = load i32, i32* %16
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i32, i32* %59, i64 %61
%63 = load i32, i32* %62
%64 = add nsw i32 %63, 1
store i32 %64, i32* %62
%65 = load i32, i32* %17
%66 = add nsw i32 %65, 1
store i32 %66, i32* %17
%67 = load i32, i32* %16
%68 = load i32, i32* %11
%69 = sdiv i32 %67, %68
%70 = load i32, i32* %14
%71 = icmp ne i32 %69, %70
br i1 %71, label %72, label %77
72: ; preds = %58
%73 = load i16*, i16** %9
%74 = load i32, i32* %16
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i16, i16* %73, i64 %75
store i16 1, i16* %76
br label %77
77: ; preds = %72, %58
br label %78
78: ; preds = %77, %51
%79 = load i32, i32* %10
%80 = load i32, i32* %18
%81 = sub nsw i32 %79, %80
store i32 %81, i32* %16
%82 = load i32, i32* %16
%83 = icmp sge i32 %82, 0
br i1 %83, label %84, label %104
84: ; preds = %78
%85 = load i32*, i32** %8
%86 = load i32, i32* %16
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = add nsw i32 %89, 1
store i32 %90, i32* %88
%91 = load i32, i32* %17
%92 = add nsw i32 %91, 1
store i32 %92, i32* %17
%93 = load i32, i32* %16
%94 = load i32, i32* %11
%95 = sdiv i32 %93, %94
%96 = load i32, i32* %14
%97 = icmp ne i32 %95, %96
br i1 %97, label %98, label %103
98: ; preds = %84
%99 = load i16*, i16** %9
%100 = load i32, i32* %16
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i16, i16* %99, i64 %101
store i16 1, i16* %102
br label %103
103: ; preds = %98, %84
br label %104
104: ; preds = %103, %78
%105 = load i32, i32* %18
%106 = add nsw i32 %105, 1
store i32 %106, i32* %18
br label %41
107: ; preds = %49
%108 = load i32, i32* %17
ret i32 %108
}

LLVM IR (-O2):
define i32 @conn_marking_nearest_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 %63, 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)
%21 = icmp sgt i32 %20, 0
%22 = icmp sgt i32 %4, 1
%23 = and i1 %21, %22
br i1 %23, label %24, label %63
24: ; preds = %9
%25 = sext i32 %2 to i64
%26 = zext i32 %4 to i64
br label %27
27: ; preds = %24, %57
%28 = phi i64 [ 1, %24 ], [ %59, %57 ]
%29 = phi i32 [ 0, %24 ], [ %58, %57 ]
%30 = add nsw i64 %28, %25
%31 = icmp slt i64 %30, %26
br i1 %31, label %32, label %42
32: ; preds = %27
%33 = getelementptr inbounds i32, i32* %0, i64 %30
%34 = load i32, i32* %33
%35 = add nsw i32 %34, 1
store i32 %35, i32* %33
%36 = add nsw i32 %29, 1
%37 = trunc i64 %30 to i32
%38 = sdiv i32 %37, %3
%39 = icmp eq i32 %38, %6
br i1 %39, label %42, label %40
40: ; preds = %32
%41 = getelementptr inbounds i16, i16* %1, i64 %30
store i16 1, i16* %41
br label %42
42: ; preds = %32, %40, %27
%43 = phi i32 [ %36, %40 ], [ %36, %32 ], [ %29, %27 ]
%44 = sub nsw i64 %25, %28
%45 = icmp sgt i64 %44, -1
br i1 %45, label %46, label %57
46: ; preds = %42
%47 = trunc i64 %44 to i32
%48 = and i64 %44, 4294967295
%49 = getelementptr inbounds i32, i32* %0, i64 %48
%50 = load i32, i32* %49
%51 = add nsw i32 %50, 1
store i32 %51, i32* %49
%52 = add nsw i32 %43, 1
%53 = sdiv i32 %47, %3
%54 = icmp eq i32 %53, %6
br i1 %54, label %57, label %55
55: ; preds = %46
%56 = getelementptr inbounds i16, i16* %1, i64 %48
store i16 1, i16* %56
br label %57
57: ; preds = %46, %55, %42
%58 = phi i32 [ %52, %55 ], [ %52, %46 ], [ %43, %42 ]
%59 = add nuw nsw i64 %28, 1
%60 = icmp slt i32 %58, %20
%61 = icmp ult i64 %59, %26
%62 = select i1 %60, i1 %61, i1 false
br i1 %62, label %27, label %63
63: ; preds = %57, %7, %9
%64 = phi i32 [ 0, %9 ], [ 0, %7 ], [ %58, %57 ]
ret i32 %64
}