; LLVM IR from berquist/rchem :: libpyquante2 (cints)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
declare dso_local double @binomial_prefactor(i32 noundef, i32 noundef, i32 noundef, double noundef, double noundef) #0

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: nounwind uwtable
define dso_local double @overlap_1D(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store double %2, ptr %8, align 8, !tbaa !9
  store double %3, ptr %9, align 8, !tbaa !9
  store double %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  store double 0.000000e+00, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %46, %5
  %14 = load i32, ptr %11, align 4, !tbaa !5
  %15 = sitofp i32 %14 to double
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !5
  %18 = add nsw i32 %16, %17
  %19 = sitofp i32 %18 to double
  %20 = fmul double 5.000000e-01, %19
  %21 = call double @llvm.floor.f64(double %20)
  %22 = fadd double 1.000000e+00, %21
  %23 = fcmp olt double %15, %22
  br i1 %23, label %24, label %49

24:                                               ; preds = %13
  %25 = load i32, ptr %11, align 4, !tbaa !5
  %26 = mul nsw i32 2, %25
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load double, ptr %8, align 8, !tbaa !9
  %30 = load double, ptr %9, align 8, !tbaa !9
  %31 = call double @binomial_prefactor(i32 noundef %26, i32 noundef %27, i32 noundef %28, double noundef %29, double noundef %30)
  %32 = load i32, ptr %11, align 4, !tbaa !5
  %33 = mul nsw i32 2, %32
  %34 = sub nsw i32 %33, 1
  %35 = call i32 @fact2(i32 noundef %34)
  %36 = sitofp i32 %35 to double
  %37 = fmul double %31, %36
  %38 = load double, ptr %10, align 8, !tbaa !9
  %39 = fmul double 2.000000e+00, %38
  %40 = load i32, ptr %11, align 4, !tbaa !5
  %41 = sitofp i32 %40 to double
  %42 = call double @pow(double noundef %39, double noundef %41) #4
  %43 = fdiv double %37, %42
  %44 = load double, ptr %12, align 8, !tbaa !9
  %45 = fadd double %44, %43
  store double %45, ptr %12, align 8, !tbaa !9
  br label %46

46:                                               ; preds = %24
  %47 = load i32, ptr %11, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %11, align 4, !tbaa !5
  br label %13, !llvm.loop !11

49:                                               ; preds = %13
  %50 = load double, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret double %50
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @fact2(i32 noundef) #0

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind uwtable
declare dso_local double @binomial_prefactor(i32 noundef, i32 noundef, i32 noundef, double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @pow(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local double @overlap_1D(i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3, double noundef %4) local_unnamed_addr #0 {
  %6 = add nsw i32 %1, %0
  %7 = sitofp i32 %6 to double
  %8 = fmul double %7, 5.000000e-01
  %9 = tail call double @llvm.floor.f64(double %8)
  %10 = fadd double %9, 1.000000e+00
  %11 = fcmp ogt double %10, 0.000000e+00
  br i1 %11, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %12 = fmul double %4, 2.000000e+00
  br label %13

13:                                               ; preds = %.lr.ph, %13
  %14 = phi double [ 0.000000e+00, %.lr.ph ], [ %25, %13 ]
  %.016 = phi double [ 0.000000e+00, %.lr.ph ], [ %23, %13 ]
  %.01315 = phi i32 [ 0, %.lr.ph ], [ %24, %13 ]
  %15 = shl nuw nsw i32 %.01315, 1
  %16 = tail call double @binomial_prefactor(i32 noundef %15, i32 noundef %0, i32 noundef %1, double noundef %2, double noundef %3)
  %17 = add nsw i32 %15, -1
  %18 = tail call i32 @fact2(i32 noundef %17)
  %19 = sitofp i32 %18 to double
  %20 = fmul double %16, %19
  %21 = tail call double @pow(double noundef %12, double noundef %14) #3
  %22 = fdiv double %20, %21
  %23 = fadd double %.016, %22
  %24 = add nuw nsw i32 %.01315, 1
  %25 = uitofp nneg i32 %24 to double
  %26 = fcmp ogt double %10, %25
  br i1 %26, label %13, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %13, %5
  %.0.lcssa = phi double [ 0.000000e+00, %5 ], [ %23, %13 ]
  ret double %.0.lcssa
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.floor.f64(double) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @fact2(i32 noundef) local_unnamed_addr #0

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass