#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 get_cluster_size(int **, int **, int **, int, int, int *);
int /*<<< orphan*/ populate_bonds(int **, int **, int, int, double);
double get_mean_C0_size(int **site_marks, int **vbonds, int **hbonds, int M,
                        int N, double p, int reps, int A1[2]) {
  double mean_C0_size = 0.0;
  int C0_size;
  int rep;
  for (rep = 0; rep < reps; rep++) {
    populate_bonds(vbonds, hbonds, M, N, p);
    C0_size = get_cluster_size(site_marks, vbonds, hbonds, M, N, A1);
    mean_C0_size += C0_size;
  }
  mean_C0_size /= reps;
  return mean_C0_size;
}


x86 assembly (clang, -O0):
<get_mean_C0_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11b7 <get_mean_C0_size+0x97>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
movsd  -0x28(%rbp),%xmm0
call   1030 <populate_bonds@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
mov    0x10(%rbp),%r9
call   1040 <get_cluster_size@plt>
mov    %eax,-0x3c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1157 <get_mean_C0_size+0x37>
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mean_C0_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %r9d,%r9d
mov    %r9d,0x4(%rsp)
jle    11af <get_mean_C0_size+0x8f>
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r13
xorpd  %xmm1,%xmm1
mov    %r9d,%r14d
movsd  %xmm0,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  %xmm1,0x10(%rsp)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
movsd  0x8(%rsp),%xmm0
call   1030 <populate_bonds@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0x50(%rsp),%r9
call   1040 <get_cluster_size@plt>
movsd  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
add    $0xffffffff,%r14d
jne    1160 <get_mean_C0_size+0x40>
jmp    11b3 <get_mean_C0_size+0x93>
xorpd  %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @get_mean_C0_size(i32** %0, i32** %1, i32** %2, i32 %3, i32 %4, double %5, i32 %6, i32* %7) {
%9 = alloca i32**
%10 = alloca i32**
%11 = alloca i32**
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca i32
%16 = alloca i32*
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
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 double %5, double* %14
store i32 %6, i32* %15
store i32* %7, i32** %16
store double 0.000000e+00, double* %17
store i32 0, i32* %19
br label %20
20: ; preds = %42, %8
%21 = load i32, i32* %19
%22 = load i32, i32* %15
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %45
24: ; preds = %20
%25 = load i32**, i32*** %10
%26 = load i32**, i32*** %11
%27 = load i32, i32* %12
%28 = load i32, i32* %13
%29 = load double, double* %14
%30 = call i32 @populate_bonds(i32** %25, i32** %26, i32 %27, i32 %28, double %29)
%31 = load i32**, i32*** %9
%32 = load i32**, i32*** %10
%33 = load i32**, i32*** %11
%34 = load i32, i32* %12
%35 = load i32, i32* %13
%36 = load i32*, i32** %16
%37 = call i32 @get_cluster_size(i32** %31, i32** %32, i32** %33, i32 %34, i32 %35, i32* %36)
store i32 %37, i32* %18
%38 = load i32, i32* %18
%39 = sitofp i32 %38 to double
%40 = load double, double* %17
%41 = fadd double %40, %39
store double %41, double* %17
br label %42
42: ; preds = %24
%43 = load i32, i32* %19
%44 = add nsw i32 %43, 1
store i32 %44, i32* %19
br label %20
45: ; preds = %20
%46 = load i32, i32* %15
%47 = sitofp i32 %46 to double
%48 = load double, double* %17
%49 = fdiv double %48, %47
store double %49, double* %17
%50 = load double, double* %17
ret double %50
}

LLVM IR (-O2):
define double @get_mean_C0_size(i32** %0, i32** %1, i32** %2, i32 %3, i32 %4, double %5, i32 %6, i32* %7) {
%9 = icmp sgt i32 %6, 0
br i1 %9, label %10, label %19
10: ; preds = %8, %10
%11 = phi i32 [ %17, %10 ], [ 0, %8 ]
%12 = phi double [ %16, %10 ], [ 0.000000e+00, %8 ]
%13 = tail call i32 @populate_bonds(i32** %1, i32** %2, i32 %3, i32 %4, double %5)
%14 = tail call i32 @get_cluster_size(i32** %0, i32** %1, i32** %2, i32 %3, i32 %4, i32* %7)
%15 = sitofp i32 %14 to double
%16 = fadd double %12, %15
%17 = add nuw nsw i32 %11, 1
%18 = icmp eq i32 %17, %6
br i1 %18, label %19, label %10
19: ; preds = %10, %8
%20 = phi double [ 0.000000e+00, %8 ], [ %16, %10 ]
%21 = sitofp i32 %6 to double
%22 = fdiv double %20, %21
ret double %22
}