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

; 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_vector" = type { 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::sparsematrix" = type { %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", %"struct.alglib_impl::ae_vector", i64, i64, i64, i64, i64, i64 }

@.str.45 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [53 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl18sparsecreatecrsbufEllPNS_9ae_vectorEPNS_12sparsematrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  store i64 %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %13 = load i64, ptr %6, align 8, !tbaa !5
  %14 = icmp sgt i64 %13, 0
  %15 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %14, ptr noundef @.str.45, ptr noundef %15)
  %16 = load i64, ptr %7, align 8, !tbaa !5
  %17 = icmp sgt i64 %16, 0
  %18 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %17, ptr noundef @.str.46, ptr noundef %18)
  %19 = load ptr, ptr %8, align 8, !tbaa !9
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %19, i32 0, i32 0
  %21 = load i64, ptr %20, align 8, !tbaa !11
  %22 = load i64, ptr %6, align 8, !tbaa !5
  %23 = icmp sge i64 %21, %22
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %23, ptr noundef @.str.47, ptr noundef %24)
  store i64 0, ptr %12, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !9
  %26 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %25, i32 0, i32 5
  store i64 1, ptr %26, align 8, !tbaa !15
  %27 = load ptr, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %27, i32 0, i32 9
  store i64 0, ptr %28, align 8, !tbaa !17
  %29 = load i64, ptr %6, align 8, !tbaa !5
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %30, i32 0, i32 6
  store i64 %29, ptr %31, align 8, !tbaa !18
  %32 = load i64, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !9
  %34 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %33, i32 0, i32 7
  store i64 %32, ptr %34, align 8, !tbaa !19
  %35 = load ptr, ptr %9, align 8, !tbaa !9
  %36 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %35, i32 0, i32 2
  %37 = load ptr, ptr %9, align 8, !tbaa !9
  %38 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %37, i32 0, i32 6
  %39 = load i64, ptr %38, align 8, !tbaa !18
  %40 = add nsw i64 %39, 1
  %41 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %36, i64 noundef %40, ptr noundef %41)
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %42, i32 0, i32 2
  %44 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = getelementptr inbounds i64, ptr %45, i64 0
  store i64 0, ptr %46, align 8, !tbaa !5
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %92, %5
  %48 = load i64, ptr %11, align 8, !tbaa !5
  %49 = load ptr, ptr %9, align 8, !tbaa !9
  %50 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %49, i32 0, i32 6
  %51 = load i64, ptr %50, align 8, !tbaa !18
  %52 = sub nsw i64 %51, 1
  %53 = icmp sle i64 %48, %52
  br i1 %53, label %54, label %95

54:                                               ; preds = %47
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  %56 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !20
  %58 = load i64, ptr %11, align 8, !tbaa !5
  %59 = getelementptr inbounds i64, ptr %57, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !5
  %61 = icmp sge i64 %60, 0
  %62 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %61, ptr noundef @.str.48, ptr noundef %62)
  %63 = load i64, ptr %12, align 8, !tbaa !5
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  %65 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !20
  %67 = load i64, ptr %11, align 8, !tbaa !5
  %68 = getelementptr inbounds i64, ptr %66, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !5
  %70 = add nsw i64 %63, %69
  store i64 %70, ptr %12, align 8, !tbaa !5
  %71 = load ptr, ptr %9, align 8, !tbaa !9
  %72 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %71, i32 0, i32 2
  %73 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !20
  %75 = load i64, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds i64, ptr %74, i64 %75
  %77 = load i64, ptr %76, align 8, !tbaa !5
  %78 = load ptr, ptr %8, align 8, !tbaa !9
  %79 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %78, i32 0, i32 4
  %80 = load ptr, ptr %79, align 8, !tbaa !20
  %81 = load i64, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds i64, ptr %80, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !5
  %84 = add nsw i64 %77, %83
  %85 = load ptr, ptr %9, align 8, !tbaa !9
  %86 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %85, i32 0, i32 2
  %87 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %86, i32 0, i32 4
  %88 = load ptr, ptr %87, align 8, !tbaa !20
  %89 = load i64, ptr %11, align 8, !tbaa !5
  %90 = add nsw i64 %89, 1
  %91 = getelementptr inbounds i64, ptr %88, i64 %90
  store i64 %84, ptr %91, align 8, !tbaa !5
  br label %92

92:                                               ; preds = %54
  %93 = load i64, ptr %11, align 8, !tbaa !5
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %11, align 8, !tbaa !5
  br label %47, !llvm.loop !21

95:                                               ; preds = %47
  %96 = load ptr, ptr %9, align 8, !tbaa !9
  %97 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %96, i32 0, i32 0
  %98 = load i64, ptr %12, align 8, !tbaa !5
  %99 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %97, i64 noundef %98, ptr noundef %99)
  %100 = load ptr, ptr %9, align 8, !tbaa !9
  %101 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %100, i32 0, i32 1
  %102 = load i64, ptr %12, align 8, !tbaa !5
  %103 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef %101, i64 noundef %102, ptr noundef %103)
  %104 = load i64, ptr %12, align 8, !tbaa !5
  %105 = icmp eq i64 %104, 0
  br i1 %105, label %106, label %109

106:                                              ; preds = %95
  %107 = load ptr, ptr %9, align 8, !tbaa !9
  %108 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl15sparseinitduidxEPNS_12sparsematrixEPNS_8ae_stateE(ptr noundef %107, ptr noundef %108)
  br label %109

109:                                              ; preds = %106, %95
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  ret void
}

declare void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

declare void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl15sparseinitduidxEPNS_12sparsematrixEPNS_8ae_stateE(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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 = !{!"long", !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, !6, i64 0}
!12 = !{!"_ZTSN11alglib_impl9ae_vectorE", !6, i64 0, !6, i64 8, !13, i64 16, !14, i64 24, !7, i64 56}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !10, i64 0, !10, i64 8, !10, i64 16, !10, i64 24}
!15 = !{!16, !6, i64 320}
!16 = !{!"_ZTSN11alglib_impl12sparsematrixE", !12, i64 0, !12, i64 64, !12, i64 128, !12, i64 192, !12, i64 256, !6, i64 320, !6, i64 328, !6, i64 336, !6, i64 344, !6, i64 352, !6, i64 360}
!17 = !{!16, !6, i64 352}
!18 = !{!16, !6, i64 328}
!19 = !{!16, !6, i64 336}
!20 = !{!7, !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"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.45 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.46 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.48 = external hidden unnamed_addr constant [53 x i8], align 1

declare void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext, ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11alglib_impl18sparsecreatecrsbufEllPNS_9ae_vectorEPNS_12sparsematrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = icmp sgt i64 %0, 0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %6, ptr noundef nonnull @.str.45, ptr noundef %4)
  %7 = icmp sgt i64 %1, 0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %7, ptr noundef nonnull @.str.46, ptr noundef %4)
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = icmp sge i64 %8, %0
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %9, ptr noundef nonnull @.str.47, ptr noundef %4)
  %10 = getelementptr inbounds i8, ptr %3, i64 320
  store i64 1, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %3, i64 352
  store i64 0, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %3, i64 328
  store i64 %0, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %3, i64 336
  store i64 %1, ptr %13, align 8, !tbaa !17
  %14 = getelementptr inbounds i8, ptr %3, i64 128
  %15 = add nsw i64 %0, 1
  tail call void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %14, i64 noundef %15, ptr noundef %4)
  %16 = getelementptr inbounds i8, ptr %3, i64 184
  %17 = load ptr, ptr %16, align 8, !tbaa !18
  store i64 0, ptr %17, align 8, !tbaa !19
  %18 = load i64, ptr %12, align 8, !tbaa !16
  %.not.not41 = icmp sgt i64 %18, 0
  br i1 %.not.not41, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %19 = getelementptr inbounds i8, ptr %2, i64 56
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %.043 = phi i64 [ 0, %.lr.ph ], [ %28, %20 ]
  %.04042 = phi i64 [ 0, %.lr.ph ], [ %33, %20 ]
  %21 = load ptr, ptr %19, align 8, !tbaa !18
  %22 = getelementptr inbounds i64, ptr %21, i64 %.04042
  %23 = load i64, ptr %22, align 8, !tbaa !19
  %24 = icmp sgt i64 %23, -1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %24, ptr noundef nonnull @.str.48, ptr noundef %4)
  %25 = load ptr, ptr %19, align 8, !tbaa !18
  %26 = getelementptr inbounds i64, ptr %25, i64 %.04042
  %27 = load i64, ptr %26, align 8, !tbaa !19
  %28 = add nsw i64 %27, %.043
  %29 = load ptr, ptr %16, align 8, !tbaa !18
  %30 = getelementptr inbounds i64, ptr %29, i64 %.04042
  %31 = load i64, ptr %30, align 8, !tbaa !19
  %32 = add nsw i64 %31, %27
  %33 = add nuw nsw i64 %.04042, 1
  %34 = getelementptr inbounds i64, ptr %29, i64 %33
  store i64 %32, ptr %34, align 8, !tbaa !19
  %35 = load i64, ptr %12, align 8, !tbaa !16
  %.not.not = icmp slt i64 %33, %35
  br i1 %.not.not, label %20, label %._crit_edge, !llvm.loop !20

._crit_edge:                                      ; preds = %20, %5
  %.0.lcssa = phi i64 [ 0, %5 ], [ %28, %20 ]
  tail call void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %3, i64 noundef %.0.lcssa, ptr noundef %4)
  %36 = getelementptr inbounds i8, ptr %3, i64 64
  tail call void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef nonnull %36, i64 noundef %.0.lcssa, ptr noundef %4)
  %37 = icmp eq i64 %.0.lcssa, 0
  br i1 %37, label %38, label %39

38:                                               ; preds = %._crit_edge
  tail call void @_ZN11alglib_impl15sparseinitduidxEPNS_12sparsematrixEPNS_8ae_stateE(ptr noundef nonnull %3, ptr noundef %4)
  br label %39

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

declare void @_ZN11alglib_impl23rvectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

declare void @_ZN11alglib_impl23ivectorsetlengthatleastEPNS_9ae_vectorElPNS_8ae_stateE(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl15sparseinitduidxEPNS_12sparsematrixEPNS_8ae_stateE(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #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 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" }

!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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !8, i64 56}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"bool", !8, i64 0}
!11 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!14, !7, i64 320}
!14 = !{!"_ZTSN11alglib_impl12sparsematrixE", !6, i64 0, !6, i64 64, !6, i64 128, !6, i64 192, !6, i64 256, !7, i64 320, !7, i64 328, !7, i64 336, !7, i64 344, !7, i64 352, !7, i64 360}
!15 = !{!14, !7, i64 352}
!16 = !{!14, !7, i64 328}
!17 = !{!14, !7, i64 336}
!18 = !{!8, !8, i64 0}
!19 = !{!7, !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


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