#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__ A1_oo_A2(int **, int **, int **, int, int, int *, int *);
int /*<<< orphan*/ populate_bonds(int **, int **, int, int, double);
double P_A1_oo_A2(int **site_marks, int **vbonds, int **hbonds, int M, int N,
                  double p, int reps, int A1[2], int A2[2]) {
  double nctd = 0.0;
  int rep;
  for (rep = 0; rep < reps; rep++) {
    populate_bonds(vbonds, hbonds, M, N, p);
    if (A1_oo_A2(site_marks, vbonds, hbonds, M, N, A1, A2))
      nctd += 1.0;
  }
  return nctd / reps;
}


x86 assembly (clang, -O0):
<P_A1_oo_A2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x18(%rbp),%rax
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,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    11d2 <P_A1_oo_A2+0xb2>
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
mov    0x18(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <A1_oo_A2@plt>
cmp    $0x0,%rax
je     11bf <P_A1_oo_A2+0x9f>
movsd  0xe4b(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11c4 <P_A1_oo_A2+0xa4>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    115b <P_A1_oo_A2+0x3b>
movsd  -0x38(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<P_A1_oo_A2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x20(%rsp)
test   %r9d,%r9d
mov    %r9d,0x1c(%rsp)
jle    11ba <P_A1_oo_A2+0x9a>
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %rsi,%rbx
mov    %rdi,%r13
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r9d,%r14d
jmp    1166 <P_A1_oo_A2+0x46>
nopl   0x0(%rax)
add    $0xffffffff,%r14d
je     11c4 <P_A1_oo_A2+0xa4>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
mov    %r15d,%ecx
movsd  0x20(%rsp),%xmm0
call   1030 <populate_bonds@plt>
mov    0x68(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0x60(%rsp),%r9
call   1040 <A1_oo_A2@plt>
movsd  0x10(%rsp),%xmm0
addsd  0xe53(%rip),%xmm0
test   %rax,%rax
je     1160 <P_A1_oo_A2+0x40>
movsd  %xmm0,0x10(%rsp)
jmp    1160 <P_A1_oo_A2+0x40>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
cvtsi2sdl 0x1c(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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