; 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"

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.gser = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1

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

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

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

; Function Attrs: nounwind
declare double @exp(double noundef) #2

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @gser(ptr noundef %0, double noundef %1, double noundef %2, ptr noundef %3) #4 {
  %5 = alloca ptr, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store double %1, ptr %6, align 8, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #6
  %14 = load double, ptr %6, align 8, !tbaa !9
  %15 = call double @lgamma(double noundef %14) #6
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  store double %15, ptr %16, align 8, !tbaa !9
  %17 = load double, ptr %7, align 8, !tbaa !9
  %18 = fcmp ole double %17, 0.000000e+00
  br i1 %18, label %19, label %26

19:                                               ; preds = %4
  %20 = load double, ptr %7, align 8, !tbaa !9
  %21 = fcmp oge double %20, 0.000000e+00
  br i1 %21, label %22, label %23

22:                                               ; preds = %19
  br label %24

23:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 330, ptr noundef @__PRETTY_FUNCTION__.gser) #7
  unreachable

24:                                               ; preds = %22
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  store double 0.000000e+00, ptr %25, align 8, !tbaa !9
  store i32 1, ptr %13, align 4
  br label %70

26:                                               ; preds = %4
  %27 = load double, ptr %6, align 8, !tbaa !9
  store double %27, ptr %12, align 8, !tbaa !9
  %28 = load double, ptr %6, align 8, !tbaa !9
  %29 = fdiv double 1.000000e+00, %28
  store double %29, ptr %10, align 8, !tbaa !9
  store double %29, ptr %11, align 8, !tbaa !9
  store i32 1, ptr %9, align 4, !tbaa !11
  br label %30

30:                                               ; preds = %65, %26
  %31 = load i32, ptr %9, align 4, !tbaa !11
  %32 = icmp sle i32 %31, 100
  br i1 %32, label %33, label %68

33:                                               ; preds = %30
  %34 = load double, ptr %12, align 8, !tbaa !9
  %35 = fadd double %34, 1.000000e+00
  store double %35, ptr %12, align 8, !tbaa !9
  %36 = load double, ptr %7, align 8, !tbaa !9
  %37 = load double, ptr %12, align 8, !tbaa !9
  %38 = fdiv double %36, %37
  %39 = load double, ptr %11, align 8, !tbaa !9
  %40 = fmul double %39, %38
  store double %40, ptr %11, align 8, !tbaa !9
  %41 = load double, ptr %11, align 8, !tbaa !9
  %42 = load double, ptr %10, align 8, !tbaa !9
  %43 = fadd double %42, %41
  store double %43, ptr %10, align 8, !tbaa !9
  %44 = load double, ptr %11, align 8, !tbaa !9
  %45 = call double @llvm.fabs.f64(double %44)
  %46 = load double, ptr %10, align 8, !tbaa !9
  %47 = call double @llvm.fabs.f64(double %46)
  %48 = fmul double %47, 3.000000e-07
  %49 = fcmp olt double %45, %48
  br i1 %49, label %50, label %64

50:                                               ; preds = %33
  %51 = load double, ptr %10, align 8, !tbaa !9
  %52 = load double, ptr %7, align 8, !tbaa !9
  %53 = fneg double %52
  %54 = load double, ptr %6, align 8, !tbaa !9
  %55 = load double, ptr %7, align 8, !tbaa !9
  %56 = call double @log(double noundef %55) #6
  %57 = call double @llvm.fmuladd.f64(double %54, double %56, double %53)
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = load double, ptr %58, align 8, !tbaa !9
  %60 = fsub double %57, %59
  %61 = call double @exp(double noundef %60) #6
  %62 = fmul double %51, %61
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  store double %62, ptr %63, align 8, !tbaa !9
  store i32 1, ptr %13, align 4
  br label %70

64:                                               ; preds = %33
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %9, align 4, !tbaa !11
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %9, align 4, !tbaa !11
  br label %30, !llvm.loop !13

68:                                               ; preds = %30
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 1, ptr %13, align 4
  br label %70

70:                                               ; preds = %68, %50, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  ret void
}

; Function Attrs: nounwind
declare double @lgamma(double noundef) #2

; Function Attrs: nounwind
declare double @log(double noundef) #2

declare i32 @printf(ptr noundef, ...) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { noreturn 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 #4 = { 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"any pointer", !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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

@.str.1 = external hidden unnamed_addr constant [69 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@__PRETTY_FUNCTION__.gser = external hidden unnamed_addr constant [46 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1

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

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @gser(ptr nocapture noundef writeonly %0, double noundef %1, double noundef %2, ptr nocapture noundef %3) local_unnamed_addr #3 {
  %5 = tail call double @lgamma(double noundef %1) #6
  store double %5, ptr %3, align 8, !tbaa !5
  %6 = fcmp ugt double %2, 0.000000e+00
  br i1 %6, label %11, label %7

7:                                                ; preds = %4
  %8 = fcmp ult double %2, 0.000000e+00
  br i1 %8, label %9, label %10

9:                                                ; preds = %7
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 330, ptr noundef nonnull @__PRETTY_FUNCTION__.gser) #7
  unreachable

10:                                               ; preds = %7
  store double 0.000000e+00, ptr %0, align 8, !tbaa !5
  br label %43

11:                                               ; preds = %4
  %12 = fdiv double 1.000000e+00, %1
  br label %24

13:                                               ; preds = %24
  %14 = fadd double %25, 1.000000e+00
  %15 = fdiv double %2, %14
  %16 = fmul double %27, %15
  %17 = fadd double %28, %16
  %18 = tail call double @llvm.fabs.f64(double %16)
  %19 = tail call double @llvm.fabs.f64(double %17)
  %20 = fmul double %19, 3.000000e-07
  %21 = fcmp olt double %18, %20
  br i1 %21, label %33, label %22

22:                                               ; preds = %13
  %23 = add nuw nsw i32 %.02426, 2
  %exitcond.not.1 = icmp eq i32 %23, 101
  br i1 %exitcond.not.1, label %41, label %24, !llvm.loop !9

24:                                               ; preds = %22, %11
  %.029 = phi double [ %1, %11 ], [ %14, %22 ]
  %.02228 = phi double [ %12, %11 ], [ %16, %22 ]
  %.02327 = phi double [ %12, %11 ], [ %17, %22 ]
  %.02426 = phi i32 [ 1, %11 ], [ %23, %22 ]
  %25 = fadd double %.029, 1.000000e+00
  %26 = fdiv double %2, %25
  %27 = fmul double %.02228, %26
  %28 = fadd double %.02327, %27
  %29 = tail call double @llvm.fabs.f64(double %27)
  %30 = tail call double @llvm.fabs.f64(double %28)
  %31 = fmul double %30, 3.000000e-07
  %32 = fcmp olt double %29, %31
  br i1 %32, label %33, label %13

33:                                               ; preds = %13, %24
  %.lcssa = phi double [ %28, %24 ], [ %17, %13 ]
  %34 = fneg double %2
  %35 = tail call double @log(double noundef %2) #6
  %36 = tail call double @llvm.fmuladd.f64(double %1, double %35, double %34)
  %37 = load double, ptr %3, align 8, !tbaa !5
  %38 = fsub double %36, %37
  %39 = tail call double @exp(double noundef %38) #6
  %40 = fmul double %.lcssa, %39
  store double %40, ptr %0, align 8, !tbaa !5
  br label %43

41:                                               ; preds = %22
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %43

43:                                               ; preds = %41, %33, %10
  ret void
}

; Function Attrs: nounwind
declare double @lgamma(double noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { noreturn 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 #3 = { 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 #4 = { 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 #5 = { nofree 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 #6 = { nounwind }
attributes #7 = { noreturn 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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass