; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (solvers)

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

%"struct.alglib_impl::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.0 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.0 = type { ptr }
%"struct.alglib_impl::ae_vector" = type { i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.1 }
%union.anon.1 = type { ptr }

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl26spdmatrixcholeskysolvefastEPNS_9ae_matrixElbPNS_9ae_vectorEPlPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  %16 = zext i1 %2 to i8
  store i8 %16, ptr %9, align 1, !tbaa !11
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %17 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 0, ptr %17, align 8, !tbaa !9
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 1, ptr %18, align 8, !tbaa !9
  %19 = load i64, ptr %8, align 8, !tbaa !9
  %20 = icmp sle i64 %19, 0
  br i1 %20, label %21, label %23

21:                                               ; preds = %6
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -1, ptr %22, align 8, !tbaa !9
  store i32 1, ptr %15, align 4
  br label %68

23:                                               ; preds = %6
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %24

24:                                               ; preds = %58, %23
  %25 = load i64, ptr %14, align 8, !tbaa !9
  %26 = load i64, ptr %8, align 8, !tbaa !9
  %27 = sub nsw i64 %26, 1
  %28 = icmp sle i64 %25, %27
  br i1 %28, label %29, label %61

29:                                               ; preds = %24
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %30, i32 0, i32 6
  %32 = load ptr, ptr %31, align 8, !tbaa !13
  %33 = load i64, ptr %14, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %32, i64 %33
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = load i64, ptr %14, align 8, !tbaa !9
  %37 = getelementptr inbounds double, ptr %35, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !14
  %39 = call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %38, double noundef 0.000000e+00)
  br i1 %39, label %40, label %57

40:                                               ; preds = %29
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %41

41:                                               ; preds = %52, %40
  %42 = load i64, ptr %13, align 8, !tbaa !9
  %43 = load i64, ptr %8, align 8, !tbaa !9
  %44 = sub nsw i64 %43, 1
  %45 = icmp sle i64 %42, %44
  br i1 %45, label %46, label %55

46:                                               ; preds = %41
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !13
  %50 = load i64, ptr %13, align 8, !tbaa !9
  %51 = getelementptr inbounds double, ptr %49, i64 %50
  store double 0.000000e+00, ptr %51, align 8, !tbaa !14
  br label %52

52:                                               ; preds = %46
  %53 = load i64, ptr %13, align 8, !tbaa !9
  %54 = add nsw i64 %53, 1
  store i64 %54, ptr %13, align 8, !tbaa !9
  br label %41, !llvm.loop !16

55:                                               ; preds = %41
  %56 = load ptr, ptr %11, align 8, !tbaa !5
  store i64 -3, ptr %56, align 8, !tbaa !9
  store i32 1, ptr %15, align 4
  br label %68

57:                                               ; preds = %29
  br label %58

58:                                               ; preds = %57
  %59 = load i64, ptr %14, align 8, !tbaa !9
  %60 = add nsw i64 %59, 1
  store i64 %60, ptr %14, align 8, !tbaa !9
  br label %24, !llvm.loop !18

61:                                               ; preds = %24
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = load i8, ptr %9, align 1, !tbaa !11, !range !19, !noundef !20
  %65 = trunc i8 %64 to i1
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  %67 = load ptr, ptr %12, align 8, !tbaa !5
  call void @_ZN11alglib_implL40directdensesolvers_spdbasiccholeskysolveEPNS_9ae_matrixElbPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %62, i64 noundef %63, i1 noundef zeroext %65, ptr noundef %66, ptr noundef %67)
  store i32 0, ptr %15, align 4
  br label %68

68:                                               ; preds = %61, %55, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  %69 = load i32, ptr %15, align 4
  switch i32 %69, label %71 [
    i32 0, label %70
    i32 1, label %70
  ]

70:                                               ; preds = %68, %68
  ret void

71:                                               ; preds = %68
  unreachable
}

declare noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL40directdensesolvers_spdbasiccholeskysolveEPNS_9ae_matrixElbPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef, i64 noundef, i1 noundef zeroext, ptr noundef, ptr noundef) #1

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

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = !{i8 0, i8 2}
!20 = !{}


; 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: mustprogress uwtable
define dso_local void @_ZN11alglib_impl26spdmatrixcholeskysolvefastEPNS_9ae_matrixElbPNS_9ae_vectorEPlPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i1 noundef zeroext %2, ptr noundef %3, ptr nocapture noundef writeonly %4, ptr noundef %5) local_unnamed_addr #0 {
  store i64 1, ptr %4, align 8, !tbaa !5
  %7 = icmp slt i64 %1, 1
  br i1 %7, label %9, label %.preheader24

.preheader24:                                     ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  br label %12

9:                                                ; preds = %6
  store i64 -1, ptr %4, align 8, !tbaa !5
  br label %38

10:                                               ; preds = %12
  %11 = add nuw nsw i64 %.025, 1
  %exitcond.not = icmp eq i64 %11, %1
  br i1 %exitcond.not, label %37, label %12, !llvm.loop !9

12:                                               ; preds = %.preheader24, %10
  %.025 = phi i64 [ 0, %.preheader24 ], [ %11, %10 ]
  %13 = load ptr, ptr %8, align 8, !tbaa !11
  %14 = getelementptr inbounds ptr, ptr %13, i64 %.025
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = getelementptr inbounds double, ptr %15, i64 %.025
  %17 = load double, ptr %16, align 8, !tbaa !14
  %18 = tail call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %17, double noundef 0.000000e+00)
  br i1 %18, label %.lr.ph, label %10

.lr.ph:                                           ; preds = %12
  %19 = getelementptr inbounds i8, ptr %3, i64 56
  %xtraiter = and i64 %1, 3
  %20 = icmp ult i64 %1, 4
  br i1 %20, label %._crit_edge.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %1, 9223372036854775804
  br label %21

21:                                               ; preds = %21, %.lr.ph.new
  %.02027 = phi i64 [ 0, %.lr.ph.new ], [ %33, %21 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %21 ]
  %22 = load ptr, ptr %19, align 8, !tbaa !11
  %23 = getelementptr inbounds double, ptr %22, i64 %.02027
  store double 0.000000e+00, ptr %23, align 8, !tbaa !14
  %24 = or disjoint i64 %.02027, 1
  %25 = load ptr, ptr %19, align 8, !tbaa !11
  %26 = getelementptr inbounds double, ptr %25, i64 %24
  store double 0.000000e+00, ptr %26, align 8, !tbaa !14
  %27 = or disjoint i64 %.02027, 2
  %28 = load ptr, ptr %19, align 8, !tbaa !11
  %29 = getelementptr inbounds double, ptr %28, i64 %27
  store double 0.000000e+00, ptr %29, align 8, !tbaa !14
  %30 = or disjoint i64 %.02027, 3
  %31 = load ptr, ptr %19, align 8, !tbaa !11
  %32 = getelementptr inbounds double, ptr %31, i64 %30
  store double 0.000000e+00, ptr %32, align 8, !tbaa !14
  %33 = add nuw nsw i64 %.02027, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %21, !llvm.loop !16

._crit_edge.unr-lcssa:                            ; preds = %21, %.lr.ph
  %.02027.unr = phi i64 [ 0, %.lr.ph ], [ %33, %21 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.unr-lcssa, %.epil.preheader
  %.02027.epil = phi i64 [ %36, %.epil.preheader ], [ %.02027.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.unr-lcssa ]
  %34 = load ptr, ptr %19, align 8, !tbaa !11
  %35 = getelementptr inbounds double, ptr %34, i64 %.02027.epil
  store double 0.000000e+00, ptr %35, align 8, !tbaa !14
  %36 = add nuw nsw i64 %.02027.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.epil.preheader, !llvm.loop !17

._crit_edge:                                      ; preds = %.epil.preheader, %._crit_edge.unr-lcssa
  store i64 -3, ptr %4, align 8, !tbaa !5
  br label %38

37:                                               ; preds = %10
  tail call void @_ZN11alglib_implL40directdensesolvers_spdbasiccholeskysolveEPNS_9ae_matrixElbPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef nonnull %0, i64 noundef %1, i1 noundef zeroext %2, ptr noundef %3, ptr noundef %5)
  br label %38

38:                                               ; preds = %37, %._crit_edge, %9
  ret void
}

declare noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL40directdensesolvers_spdbasiccholeskysolveEPNS_9ae_matrixElbPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef, i64 noundef, i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #0

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 = { "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" }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.unroll.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass