; 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::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 }
%"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 }

@.str.98 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.101 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [42 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
declare dso_local noundef double @_ZN11alglib_impl9sparsegetEPNS_12sparsematrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl17sparsegetdiagonalEPNS_12sparsematrixElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca double, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca double, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load i64, ptr %6, align 8, !tbaa !9
  %11 = icmp sge i64 %10, 0
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %11, ptr noundef @.str.98, ptr noundef %12)
  %13 = load i64, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %14, i32 0, i32 6
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = icmp slt i64 %13, %16
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %17, ptr noundef @.str.99, ptr noundef %18)
  %19 = load i64, ptr %6, align 8, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %20, i32 0, i32 7
  %22 = load i64, ptr %21, align 8, !tbaa !16
  %23 = icmp slt i64 %19, %22
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %23, ptr noundef @.str.100, ptr noundef %24)
  store double 0.000000e+00, ptr %8, align 8, !tbaa !17
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %25, i32 0, i32 5
  %27 = load i64, ptr %26, align 8, !tbaa !19
  %28 = icmp eq i64 %27, 0
  br i1 %28, label %29, label %36

29:                                               ; preds = %3
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %6, align 8, !tbaa !9
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  %34 = call noundef double @_ZN11alglib_impl9sparsegetEPNS_12sparsematrixEllPNS_8ae_stateE(ptr noundef %30, i64 noundef %31, i64 noundef %32, ptr noundef %33)
  store double %34, ptr %8, align 8, !tbaa !17
  %35 = load double, ptr %8, align 8, !tbaa !17
  store double %35, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %112

36:                                               ; preds = %3
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %37, i32 0, i32 5
  %39 = load i64, ptr %38, align 8, !tbaa !19
  %40 = icmp eq i64 %39, 1
  br i1 %40, label %41, label %73

41:                                               ; preds = %36
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %42, i32 0, i32 3
  %44 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %43, i32 0, i32 4
  %45 = load ptr, ptr %44, align 8, !tbaa !20
  %46 = load i64, ptr %6, align 8, !tbaa !9
  %47 = getelementptr inbounds i64, ptr %45, i64 %46
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %49, i32 0, i32 4
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !20
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = getelementptr inbounds i64, ptr %52, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !9
  %56 = icmp ne i64 %48, %55
  br i1 %56, label %57, label %71

57:                                               ; preds = %41
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %58, i32 0, i32 0
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !20
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %62, i32 0, i32 3
  %64 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !20
  %66 = load i64, ptr %6, align 8, !tbaa !9
  %67 = getelementptr inbounds i64, ptr %65, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !9
  %69 = getelementptr inbounds double, ptr %61, i64 %68
  %70 = load double, ptr %69, align 8, !tbaa !17
  store double %70, ptr %8, align 8, !tbaa !17
  br label %71

71:                                               ; preds = %57, %41
  %72 = load double, ptr %8, align 8, !tbaa !17
  store double %72, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %112

73:                                               ; preds = %36
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %74, i32 0, i32 5
  %76 = load i64, ptr %75, align 8, !tbaa !19
  %77 = icmp eq i64 %76, 2
  br i1 %77, label %78, label %109

78:                                               ; preds = %73
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %79, i32 0, i32 6
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %82, i32 0, i32 7
  %84 = load i64, ptr %83, align 8, !tbaa !16
  %85 = icmp eq i64 %81, %84
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %85, ptr noundef @.str.101, ptr noundef %86)
  %87 = load ptr, ptr %5, align 8, !tbaa !5
  %88 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %87, i32 0, i32 0
  %89 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %88, i32 0, i32 4
  %90 = load ptr, ptr %89, align 8, !tbaa !20
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %91, i32 0, i32 2
  %93 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %92, i32 0, i32 4
  %94 = load ptr, ptr %93, align 8, !tbaa !20
  %95 = load i64, ptr %6, align 8, !tbaa !9
  %96 = getelementptr inbounds i64, ptr %94, i64 %95
  %97 = load i64, ptr %96, align 8, !tbaa !9
  %98 = load ptr, ptr %5, align 8, !tbaa !5
  %99 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %98, i32 0, i32 3
  %100 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %99, i32 0, i32 4
  %101 = load ptr, ptr %100, align 8, !tbaa !20
  %102 = load i64, ptr %6, align 8, !tbaa !9
  %103 = getelementptr inbounds i64, ptr %101, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !9
  %105 = add nsw i64 %97, %104
  %106 = getelementptr inbounds double, ptr %90, i64 %105
  %107 = load double, ptr %106, align 8, !tbaa !17
  store double %107, ptr %8, align 8, !tbaa !17
  %108 = load double, ptr %8, align 8, !tbaa !17
  store double %108, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %112

109:                                              ; preds = %73
  %110 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef @.str.102, ptr noundef %110)
  %111 = load double, ptr %8, align 8, !tbaa !17
  store double %111, ptr %4, align 8
  store i32 1, ptr %9, align 4
  br label %112

112:                                              ; preds = %109, %78, %71, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %113 = load double, ptr %4, align 8
  ret double %113
}

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 = !{!"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, !10, i64 328}
!12 = !{!"_ZTSN11alglib_impl12sparsematrixE", !13, i64 0, !13, i64 64, !13, i64 128, !13, i64 192, !13, i64 256, !10, i64 320, !10, i64 328, !10, i64 336, !10, i64 344, !10, i64 352, !10, i64 360}
!13 = !{!"_ZTSN11alglib_impl9ae_vectorE", !10, i64 0, !10, i64 8, !14, i64 16, !15, i64 24, !7, i64 56}
!14 = !{!"bool", !7, i64 0}
!15 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!16 = !{!12, !10, i64 336}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!12, !10, i64 320}
!20 = !{!7, !7, i64 0}


; 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.98 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.99 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.100 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.101 = external hidden unnamed_addr constant [55 x i8], align 1
@.str.102 = external hidden unnamed_addr constant [42 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
declare dso_local noundef double @_ZN11alglib_impl9sparsegetEPNS_12sparsematrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl17sparsegetdiagonalEPNS_12sparsematrixElPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = icmp sgt i64 %1, -1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %4, ptr noundef nonnull @.str.98, ptr noundef %2)
  %5 = getelementptr inbounds i8, ptr %0, i64 328
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp sgt i64 %6, %1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %7, ptr noundef nonnull @.str.99, ptr noundef %2)
  %8 = getelementptr inbounds i8, ptr %0, i64 336
  %9 = load i64, ptr %8, align 8, !tbaa !14
  %10 = icmp sgt i64 %9, %1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %10, ptr noundef nonnull @.str.100, ptr noundef %2)
  %11 = getelementptr inbounds i8, ptr %0, i64 320
  %12 = load i64, ptr %11, align 8, !tbaa !15
  switch i64 %12, label %46 [
    i64 0, label %13
    i64 1, label %15
    i64 2, label %29
  ]

13:                                               ; preds = %3
  %14 = tail call noundef double @_ZN11alglib_impl9sparsegetEPNS_12sparsematrixEllPNS_8ae_stateE(ptr noundef nonnull %0, i64 noundef %1, i64 noundef %1, ptr noundef %2)
  br label %47

15:                                               ; preds = %3
  %16 = getelementptr inbounds i8, ptr %0, i64 248
  %17 = load ptr, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds i64, ptr %17, i64 %1
  %19 = load i64, ptr %18, align 8, !tbaa !17
  %20 = getelementptr inbounds i8, ptr %0, i64 312
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds i64, ptr %21, i64 %1
  %23 = load i64, ptr %22, align 8, !tbaa !17
  %.not = icmp eq i64 %19, %23
  br i1 %.not, label %47, label %24

24:                                               ; preds = %15
  %25 = getelementptr inbounds i8, ptr %0, i64 56
  %26 = load ptr, ptr %25, align 8, !tbaa !16
  %27 = getelementptr inbounds double, ptr %26, i64 %19
  %28 = load double, ptr %27, align 8, !tbaa !18
  br label %47

29:                                               ; preds = %3
  %30 = load i64, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !14
  %32 = icmp eq i64 %30, %31
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %32, ptr noundef nonnull @.str.101, ptr noundef %2)
  %33 = getelementptr inbounds i8, ptr %0, i64 56
  %34 = load ptr, ptr %33, align 8, !tbaa !16
  %35 = getelementptr inbounds i8, ptr %0, i64 184
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = getelementptr inbounds i64, ptr %36, i64 %1
  %38 = load i64, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds i8, ptr %0, i64 248
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = getelementptr inbounds i64, ptr %40, i64 %1
  %42 = load i64, ptr %41, align 8, !tbaa !17
  %43 = getelementptr double, ptr %34, i64 %38
  %44 = getelementptr double, ptr %43, i64 %42
  %45 = load double, ptr %44, align 8, !tbaa !18
  br label %47

46:                                               ; preds = %3
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef nonnull @.str.102, ptr noundef %2)
  br label %47

47:                                               ; preds = %15, %24, %46, %29, %13
  %.035 = phi double [ %14, %13 ], [ %45, %29 ], [ 0.000000e+00, %46 ], [ %28, %24 ], [ 0.000000e+00, %15 ]
  ret double %.035
}

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass