#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 */
double binomial_prefactor(int, int, int, double, double);
double fact2(int);
int floor(double);
double pow(int, int);
double overlap_1D(int l1, int l2, double PAx, double PBx, double gamma) {
  int i;
  double sum;
  sum = 0.;
  for (i = 0; i < (1 + floor(0.5 * (l1 + l2))); i++)
    sum += binomial_prefactor(2 * i, l1, l2, PAx, PBx) * fact2(2 * i - 1) /
           pow(2 * gamma, i);
  return sum;
}


x86 assembly (clang, -O0):
<overlap_1D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x4(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  0xe7c(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1060 <floor@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1219 <overlap_1D+0xd9>
mov    -0x24(%rbp),%edi
shl    $0x1,%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1040 <binomial_prefactor@plt>
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%edi
shl    $0x1,%edi
sub    $0x1,%edi
call   1030 <fact2@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe24(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
cvttsd2si %xmm0,%edi
mov    -0x24(%rbp),%esi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x40(%rbp),%xmm0
divsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116c <overlap_1D+0x2c>
movsd  -0x30(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<overlap_1D>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
mov    %esi,%r14d
mov    %edi,%r15d
lea    (%r14,%r15,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe89(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
call   1060 <floor@plt>
test   %eax,%eax
js     121e <overlap_1D+0xde>
movsd  0x8(%rsp),%xmm0
addsd  %xmm0,%xmm0
cvttsd2si %xmm0,%r12d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0xffffffff,%ebx
mov    $0xffffffff,%ebp
nopl   (%rax)
add    $0x1,%ebp
lea    0x1(%rbx),%edi
mov    %r15d,%esi
mov    %r14d,%edx
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
call   1040 <binomial_prefactor@plt>
movsd  %xmm0,0x10(%rsp)
mov    %ebx,%edi
call   1030 <fact2@plt>
mulsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    %r12d,%edi
mov    %ebp,%esi
call   1050 <pow@plt>
movsd  0x10(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x18(%rsp),%xmm0
call   1060 <floor@plt>
add    $0x2,%ebx
cmp    %eax,%ebp
jl     11b0 <overlap_1D+0x70>
jmp    1228 <overlap_1D+0xe8>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x8(%rsp),%xmm0
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @overlap_1D(i32 %0, i32 %1, double %2, double %3, double %4) {
%6 = add nsw i32 %1, %0
%7 = sitofp i32 %6 to double
%8 = fmul double %7, 5.000000e-01
%9 = tail call i32 @floor(double %8)
%10 = icmp slt i32 %9, 0
br i1 %10, label %28, label %11
11: ; preds = %5
%12 = fmul double %4, 2.000000e+00
%13 = fptosi double %12 to i32
br label %14
14: ; preds = %11, %14
%15 = phi double [ 0.000000e+00, %11 ], [ %24, %14 ]
%16 = phi i32 [ 0, %11 ], [ %25, %14 ]
%17 = shl nuw nsw i32 %16, 1
%18 = tail call double @binomial_prefactor(i32 %17, i32 %0, i32 %1, double %2, double %3)
%19 = add nsw i32 %17, -1
%20 = tail call double @fact2(i32 %19)
%21 = fmul double %18, %20
%22 = tail call double @pow(i32 %13, i32 %16)
%23 = fdiv double %21, %22
%24 = fadd double %15, %23
%25 = add nuw nsw i32 %16, 1
%26 = tail call i32 @floor(double %8)
%27 = icmp slt i32 %16, %26
br i1 %27, label %14, label %28
28: ; preds = %14, %5
%29 = phi double [ 0.000000e+00, %5 ], [ %24, %14 ]
ret double %29
}