; LLVM IR from Dimandragon/non-parametric-dsp :: 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.1 }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, ptr }
%union.anon.1 = type { ptr }

@.str.195 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.196 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.197 = external hidden unnamed_addr constant [145 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_impl20sparsemultiplycolsbyEPNS_12sparsematrixEPKNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %11, i32 0, i32 5
  %13 = load i64, ptr %12, align 8, !tbaa !9
  %14 = icmp eq i64 %13, 1
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %14, ptr noundef @.str.195, ptr noundef %15)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %16, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !15
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %19, i32 0, i32 7
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = icmp sge i64 %18, %21
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %22, ptr noundef @.str.196, ptr noundef %23)
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %24, i32 0, i32 9
  %26 = load i64, ptr %25, align 8, !tbaa !17
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %27, i32 0, i32 2
  %29 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %28, i32 0, i32 4
  %30 = load ptr, ptr %29, align 8, !tbaa !18
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %31, i32 0, i32 6
  %33 = load i64, ptr %32, align 8, !tbaa !19
  %34 = getelementptr inbounds i64, ptr %30, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !20
  %36 = icmp eq i64 %26, %35
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %36, ptr noundef @.str.197, ptr noundef %37)
  store i64 0, ptr %7, align 8, !tbaa !20
  br label %38

38:                                               ; preds = %98, %3
  %39 = load i64, ptr %7, align 8, !tbaa !20
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %40, i32 0, i32 6
  %42 = load i64, ptr %41, align 8, !tbaa !19
  %43 = sub nsw i64 %42, 1
  %44 = icmp sle i64 %39, %43
  br i1 %44, label %45, label %101

45:                                               ; preds = %38
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %46, i32 0, i32 2
  %48 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %47, i32 0, i32 4
  %49 = load ptr, ptr %48, align 8, !tbaa !18
  %50 = load i64, ptr %7, align 8, !tbaa !20
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !20
  store i64 %52, ptr %8, align 8, !tbaa !20
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %53, i32 0, i32 2
  %55 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %54, i32 0, i32 4
  %56 = load ptr, ptr %55, align 8, !tbaa !18
  %57 = load i64, ptr %7, align 8, !tbaa !20
  %58 = add nsw i64 %57, 1
  %59 = getelementptr inbounds i64, ptr %56, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !20
  %61 = sub nsw i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !20
  %62 = load i64, ptr %8, align 8, !tbaa !20
  store i64 %62, ptr %10, align 8, !tbaa !20
  br label %63

63:                                               ; preds = %94, %45
  %64 = load i64, ptr %10, align 8, !tbaa !20
  %65 = load i64, ptr %9, align 8, !tbaa !20
  %66 = icmp sle i64 %64, %65
  br i1 %66, label %67, label %97

67:                                               ; preds = %63
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %69, i32 0, i32 4
  %71 = load ptr, ptr %70, align 8, !tbaa !18
  %72 = load i64, ptr %10, align 8, !tbaa !20
  %73 = getelementptr inbounds double, ptr %71, i64 %72
  %74 = load double, ptr %73, align 8, !tbaa !21
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %75, i32 0, i32 4
  %77 = load ptr, ptr %76, align 8, !tbaa !18
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %78, i32 0, i32 1
  %80 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %79, i32 0, i32 4
  %81 = load ptr, ptr %80, align 8, !tbaa !18
  %82 = load i64, ptr %10, align 8, !tbaa !20
  %83 = getelementptr inbounds i64, ptr %81, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !20
  %85 = getelementptr inbounds double, ptr %77, i64 %84
  %86 = load double, ptr %85, align 8, !tbaa !21
  %87 = fmul double %74, %86
  %88 = load ptr, ptr %4, align 8, !tbaa !5
  %89 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %88, i32 0, i32 0
  %90 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %89, i32 0, i32 4
  %91 = load ptr, ptr %90, align 8, !tbaa !18
  %92 = load i64, ptr %10, align 8, !tbaa !20
  %93 = getelementptr inbounds double, ptr %91, i64 %92
  store double %87, ptr %93, align 8, !tbaa !21
  br label %94

94:                                               ; preds = %67
  %95 = load i64, ptr %10, align 8, !tbaa !20
  %96 = add nsw i64 %95, 1
  store i64 %96, ptr %10, align 8, !tbaa !20
  br label %63, !llvm.loop !23

97:                                               ; preds = %63
  br label %98

98:                                               ; preds = %97
  %99 = load i64, ptr %7, align 8, !tbaa !20
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %7, align 8, !tbaa !20
  br label %38, !llvm.loop !25

101:                                              ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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


; 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.195 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.196 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.197 = external hidden unnamed_addr constant [145 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_impl20sparsemultiplycolsbyEPNS_12sparsematrixEPKNS_9ae_vectorEPNS_8ae_stateE(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 320
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i64 %5, 1
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %6, ptr noundef nonnull @.str.195, ptr noundef %2)
  %7 = load i64, ptr %1, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 336
  %9 = load i64, ptr %8, align 8, !tbaa !15
  %10 = icmp sge i64 %7, %9
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %10, ptr noundef nonnull @.str.196, ptr noundef %2)
  %11 = getelementptr inbounds i8, ptr %0, i64 352
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %0, i64 184
  %14 = load ptr, ptr %13, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %0, i64 328
  %16 = load i64, ptr %15, align 8, !tbaa !18
  %17 = getelementptr inbounds i64, ptr %14, i64 %16
  %18 = load i64, ptr %17, align 8, !tbaa !19
  %19 = icmp eq i64 %12, %18
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %19, ptr noundef nonnull @.str.197, ptr noundef %2)
  %20 = load i64, ptr %15, align 8, !tbaa !18
  %.not.not30 = icmp sgt i64 %20, 0
  br i1 %.not.not30, label %.lr.ph32, label %._crit_edge

.lr.ph32:                                         ; preds = %3
  %21 = getelementptr inbounds i8, ptr %0, i64 56
  %22 = getelementptr inbounds i8, ptr %1, i64 56
  %23 = getelementptr inbounds i8, ptr %0, i64 120
  br label %24

.loopexit:                                        ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %24
  %exitcond33.not = icmp eq i64 %28, %20
  br i1 %exitcond33.not, label %._crit_edge, label %24, !llvm.loop !20

24:                                               ; preds = %.lr.ph32, %.loopexit
  %.02631 = phi i64 [ 0, %.lr.ph32 ], [ %28, %.loopexit ]
  %25 = load ptr, ptr %13, align 8, !tbaa !17
  %26 = getelementptr inbounds i64, ptr %25, i64 %.02631
  %27 = load i64, ptr %26, align 8, !tbaa !19
  %28 = add nuw nsw i64 %.02631, 1
  %29 = getelementptr inbounds i64, ptr %25, i64 %28
  %30 = load i64, ptr %29, align 8, !tbaa !19
  %.not.not2728 = icmp slt i64 %27, %30
  br i1 %.not.not2728, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %24
  %31 = sub i64 %30, %27
  %.neg = add i64 %27, 1
  %xtraiter = and i64 %31, 1
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %32 = load ptr, ptr %21, align 8, !tbaa !17
  %33 = getelementptr inbounds double, ptr %32, i64 %27
  %34 = load double, ptr %33, align 8, !tbaa !22
  %35 = load ptr, ptr %22, align 8, !tbaa !17
  %36 = load ptr, ptr %23, align 8, !tbaa !17
  %37 = getelementptr inbounds i64, ptr %36, i64 %27
  %38 = load i64, ptr %37, align 8, !tbaa !19
  %39 = getelementptr inbounds double, ptr %35, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !22
  %41 = fmul double %34, %40
  store double %41, ptr %33, align 8, !tbaa !22
  %42 = add nsw i64 %27, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.029.unr = phi i64 [ %27, %.lr.ph.preheader ], [ %42, %.lr.ph.prol ]
  %43 = icmp eq i64 %30, %.neg
  br i1 %43, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.029 = phi i64 [ %65, %.lr.ph ], [ %.029.unr, %.lr.ph.prol.loopexit ]
  %44 = load ptr, ptr %21, align 8, !tbaa !17
  %45 = getelementptr inbounds double, ptr %44, i64 %.029
  %46 = load double, ptr %45, align 8, !tbaa !22
  %47 = load ptr, ptr %22, align 8, !tbaa !17
  %48 = load ptr, ptr %23, align 8, !tbaa !17
  %49 = getelementptr inbounds i64, ptr %48, i64 %.029
  %50 = load i64, ptr %49, align 8, !tbaa !19
  %51 = getelementptr inbounds double, ptr %47, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !22
  %53 = fmul double %46, %52
  store double %53, ptr %45, align 8, !tbaa !22
  %54 = add nsw i64 %.029, 1
  %55 = load ptr, ptr %21, align 8, !tbaa !17
  %56 = getelementptr inbounds double, ptr %55, i64 %54
  %57 = load double, ptr %56, align 8, !tbaa !22
  %58 = load ptr, ptr %22, align 8, !tbaa !17
  %59 = load ptr, ptr %23, align 8, !tbaa !17
  %60 = getelementptr inbounds i64, ptr %59, i64 %54
  %61 = load i64, ptr %60, align 8, !tbaa !19
  %62 = getelementptr inbounds double, ptr %58, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !22
  %64 = fmul double %57, %63
  store double %64, ptr %56, align 8, !tbaa !22
  %65 = add nsw i64 %.029, 2
  %exitcond.not.1 = icmp eq i64 %65, %30
  br i1 %exitcond.not.1, label %.loopexit, label %.lr.ph, !llvm.loop !24

._crit_edge:                                      ; preds = %.loopexit, %3
  ret void
}

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 320}
!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 = !{!7, !8, i64 0}
!15 = !{!6, !8, i64 336}
!16 = !{!6, !8, i64 352}
!17 = !{!9, !9, i64 0}
!18 = !{!6, !8, i64 328}
!19 = !{!8, !8, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !23, i64 0}
!23 = !{!"double", !9, i64 0}
!24 = distinct !{!24, !21}


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