; LLVM IR from dcajasn/Riskfolio-Lib :: lib/spectra-1.0.1/test (SymGEigsCholesky)

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

%"class.Eigen::SparseMatrix" = type { %"class.Eigen::SparseCompressedBase", i64, i64, ptr, ptr, %"class.Eigen::internal::CompressedStorage" }
%"class.Eigen::SparseCompressedBase" = type { %"class.Eigen::SparseMatrixBase" }
%"class.Eigen::SparseMatrixBase" = type { i8 }
%"class.Eigen::internal::CompressedStorage" = type { ptr, ptr, i64, i64 }
%"class.Eigen::Product.38" = type { %"class.Eigen::ProductImpl.39", %"class.Eigen::Transpose.42", ptr }
%"class.Eigen::ProductImpl.39" = type { %"class.Eigen::SparseMatrixBase.40" }
%"class.Eigen::SparseMatrixBase.40" = type { i8 }
%"class.Eigen::Transpose.42" = type { %"class.Eigen::TransposeImpl.43", ptr }
%"class.Eigen::TransposeImpl.43" = type { %"class.Eigen::internal::SparseTransposeImpl" }
%"class.Eigen::internal::SparseTransposeImpl" = type { %"class.Eigen::SparseCompressedBase.44" }
%"class.Eigen::SparseCompressedBase.44" = type { %"class.Eigen::SparseMatrixBase.45" }
%"class.Eigen::SparseMatrixBase.45" = type { i8 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6sprandid(ptr dead_on_unwind noalias writable sret(%"class.Eigen::SparseMatrix") align 8, i32 noundef, double noundef) #0

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z15gen_sparse_dataiRN5Eigen12SparseMatrixIdLi0EiEES2_d(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef nonnull align 8 dereferenceable(72) %2, double noundef %3) #0 personality ptr @__gxx_personality_v0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca %"class.Eigen::SparseMatrix", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca %"class.Eigen::Product.38", align 8
  %13 = alloca %"class.Eigen::Transpose.42", align 8
  %14 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  store double %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 72, ptr %9) #4
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load double, ptr %8, align 8, !tbaa !11
  call void @_Z6sprandid(ptr dead_on_unwind writable sret(%"class.Eigen::SparseMatrix") align 8 %9, i32 noundef %15, double noundef %16)
  %17 = load ptr, ptr %6, align 8, !tbaa !9
  %18 = invoke noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(72) %17, ptr noundef nonnull align 8 dereferenceable(72) %9)
          to label %19 unwind label %34

19:                                               ; preds = %4
  call void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72) %9) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %20 = load ptr, ptr %6, align 8, !tbaa !9
  %21 = call { i8, ptr } @_ZN5Eigen16SparseMatrixBaseINS_12SparseMatrixIdLi0EiEEE9transposeEv(ptr noundef nonnull align 1 dereferenceable(1) %20)
  %22 = getelementptr inbounds { i8, ptr }, ptr %13, i32 0, i32 0
  %23 = extractvalue { i8, ptr } %21, 0
  store i8 %23, ptr %22, align 8
  %24 = getelementptr inbounds { i8, ptr }, ptr %13, i32 0, i32 1
  %25 = extractvalue { i8, ptr } %21, 1
  store ptr %25, ptr %24, align 8
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  call void @_ZNK5Eigen16SparseMatrixBaseINS_9TransposeINS_12SparseMatrixIdLi0EiEEEEEmlIS3_EEKNS_7ProductIS4_T_Li2EEERKNS0_IS8_EE(ptr dead_on_unwind writable sret(%"class.Eigen::Product.38") align 8 %12, ptr noundef nonnull align 1 dereferenceable(1) %13, ptr noundef nonnull align 1 dereferenceable(1) %26)
  %27 = load ptr, ptr %7, align 8, !tbaa !9
  %28 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSINS_9TransposeIS1_EES1_EERS1_RKNS_7ProductIT_T0_Li2EEE(ptr noundef nonnull align 8 dereferenceable(72) %27, ptr noundef nonnull align 8 dereferenceable(32) %12)
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %47, %19
  %30 = load i32, ptr %14, align 4, !tbaa !5
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = icmp slt i32 %30, %31
  br i1 %32, label %38, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %50

34:                                               ; preds = %4
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %10, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %11, align 4
  call void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72) %9) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr %9) #4
  br label %51

38:                                               ; preds = %29
  %39 = load ptr, ptr %7, align 8, !tbaa !9
  %40 = load i32, ptr %14, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = load i32, ptr %14, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5Eigen12SparseMatrixIdLi0EiE8coeffRefEll(ptr noundef nonnull align 8 dereferenceable(72) %39, i64 noundef %41, i64 noundef %43)
  %45 = load double, ptr %44, align 8, !tbaa !11
  %46 = fadd double %45, 1.000000e-01
  store double %46, ptr %44, align 8, !tbaa !11
  br label %47

47:                                               ; preds = %38
  %48 = load i32, ptr %14, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %14, align 4, !tbaa !5
  br label %29, !llvm.loop !13

50:                                               ; preds = %33
  ret void

51:                                               ; preds = %34
  %52 = load ptr, ptr %10, align 8
  %53 = load i32, ptr %11, align 4
  %54 = insertvalue { ptr, i32 } poison, ptr %52, 0
  %55 = insertvalue { ptr, i32 } %54, i32 %53, 1
  resume { ptr, i32 } %55
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i8, ptr } @_ZN5Eigen16SparseMatrixBaseINS_12SparseMatrixIdLi0EiEEE9transposeEv(ptr noundef nonnull align 1 dereferenceable(1)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Eigen16SparseMatrixBaseINS_9TransposeINS_12SparseMatrixIdLi0EiEEEEEmlIS3_EEKNS_7ProductIS4_T_Li2EEERKNS0_IS8_EE(ptr dead_on_unwind noalias writable sret(%"class.Eigen::Product.38") align 8, ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSINS_9TransposeIS1_EES1_EERS1_RKNS_7ProductIT_T0_Li2EEE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5Eigen12SparseMatrixIdLi0EiE8coeffRefEll(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i64 noundef) #3 align 2

attributes #0 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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"

%"class.Eigen::SparseMatrix" = type { %"class.Eigen::SparseCompressedBase", i64, i64, ptr, ptr, %"class.Eigen::internal::CompressedStorage" }
%"class.Eigen::SparseCompressedBase" = type { %"class.Eigen::SparseMatrixBase" }
%"class.Eigen::SparseMatrixBase" = type { i8 }
%"class.Eigen::internal::CompressedStorage" = type { ptr, ptr, i64, i64 }
%"class.Eigen::Product.38" = type { %"class.Eigen::ProductImpl.39", %"class.Eigen::Transpose.42", ptr }
%"class.Eigen::ProductImpl.39" = type { %"class.Eigen::SparseMatrixBase.40" }
%"class.Eigen::SparseMatrixBase.40" = type { i8 }
%"class.Eigen::Transpose.42" = type { %"class.Eigen::TransposeImpl.43", ptr }
%"class.Eigen::TransposeImpl.43" = type { %"class.Eigen::internal::SparseTransposeImpl" }
%"class.Eigen::internal::SparseTransposeImpl" = type { %"class.Eigen::SparseCompressedBase.44" }
%"class.Eigen::SparseCompressedBase.44" = type { %"class.Eigen::SparseMatrixBase.45" }
%"class.Eigen::SparseMatrixBase.45" = type { i8 }

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6sprandid(ptr dead_on_unwind noalias writable sret(%"class.Eigen::SparseMatrix") align 8, i32 noundef, double noundef) local_unnamed_addr #0

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

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72)) unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z15gen_sparse_dataiRN5Eigen12SparseMatrixIdLi0EiEES2_d(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef nonnull align 8 dereferenceable(72) %2, double noundef %3) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.Eigen::SparseMatrix", align 8
  %6 = alloca %"class.Eigen::Product.38", align 8
  %7 = alloca %"class.Eigen::Transpose.42", align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %5) #4
  call void @_Z6sprandid(ptr dead_on_unwind nonnull writable sret(%"class.Eigen::SparseMatrix") align 8 %5, i32 noundef %0, double noundef %3)
  %8 = invoke noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(72) %1, ptr noundef nonnull align 8 dereferenceable(72) %5)
          to label %9 unwind label %16

9:                                                ; preds = %4
  call void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #4
  %10 = call { i8, ptr } @_ZN5Eigen16SparseMatrixBaseINS_12SparseMatrixIdLi0EiEEE9transposeEv(ptr noundef nonnull align 1 dereferenceable(1) %1)
  %11 = extractvalue { i8, ptr } %10, 0
  store i8 %11, ptr %7, align 8
  %12 = getelementptr inbounds i8, ptr %7, i64 8
  %13 = extractvalue { i8, ptr } %10, 1
  store ptr %13, ptr %12, align 8
  call void @_ZNK5Eigen16SparseMatrixBaseINS_9TransposeINS_12SparseMatrixIdLi0EiEEEEEmlIS3_EEKNS_7ProductIS4_T_Li2EEERKNS0_IS8_EE(ptr dead_on_unwind nonnull writable sret(%"class.Eigen::Product.38") align 8 %6, ptr noundef nonnull align 1 dereferenceable(1) %7, ptr noundef nonnull align 1 dereferenceable(1) %1)
  %14 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSINS_9TransposeIS1_EES1_EERS1_RKNS_7ProductIT_T0_Li2EEE(ptr noundef nonnull align 8 dereferenceable(72) %2, ptr noundef nonnull align 8 dereferenceable(32) %6)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #4
  %15 = icmp sgt i32 %0, 0
  br i1 %15, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %9
  %wide.trip.count = zext nneg i32 %0 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %9
  ret void

16:                                               ; preds = %4
  %17 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN5Eigen12SparseMatrixIdLi0EiED2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5) #4
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %5) #4
  resume { ptr, i32 } %17

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN5Eigen12SparseMatrixIdLi0EiE8coeffRefEll(ptr noundef nonnull align 8 dereferenceable(72) %2, i64 noundef %indvars.iv, i64 noundef %indvars.iv)
  %19 = load double, ptr %18, align 8, !tbaa !5
  %20 = fadd double %19, 1.000000e-01
  store double %20, ptr %18, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local { i8, ptr } @_ZN5Eigen16SparseMatrixBaseINS_12SparseMatrixIdLi0EiEEE9transposeEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZNK5Eigen16SparseMatrixBaseINS_9TransposeINS_12SparseMatrixIdLi0EiEEEEEmlIS3_EEKNS_7ProductIS4_T_Li2EEERKNS0_IS8_EE(ptr dead_on_unwind noalias writable sret(%"class.Eigen::Product.38") align 8, ptr noundef nonnull align 1 dereferenceable(1), ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN5Eigen12SparseMatrixIdLi0EiEaSINS_9TransposeIS1_EES1_EERS1_RKNS_7ProductIT_T0_Li2EEE(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN5Eigen12SparseMatrixIdLi0EiE8coeffRefEll(ptr noundef nonnull align 8 dereferenceable(72), i64 noundef, i64 noundef) local_unnamed_addr #3 align 2

attributes #0 = { mustprogress 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { inlinehint mustprogress 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 }

!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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass