; 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.197 = external hidden unnamed_addr constant [145 x i8], align 1
@.str.198 = external hidden unnamed_addr constant [34 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_impl20sparsemultiplyrowsbyEPNS_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 6
  %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.198, 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 !16
  %34 = getelementptr inbounds i64, ptr %30, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !19
  %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 !19
  br label %38

38:                                               ; preds = %92, %3
  %39 = load i64, ptr %7, align 8, !tbaa !19
  %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 !16
  %43 = sub nsw i64 %42, 1
  %44 = icmp sle i64 %39, %43
  br i1 %44, label %45, label %95

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 !19
  %51 = getelementptr inbounds i64, ptr %49, i64 %50
  %52 = load i64, ptr %51, align 8, !tbaa !19
  store i64 %52, ptr %8, align 8, !tbaa !19
  %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 !19
  %58 = add nsw i64 %57, 1
  %59 = getelementptr inbounds i64, ptr %56, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !19
  %61 = sub nsw i64 %60, 1
  store i64 %61, ptr %9, align 8, !tbaa !19
  %62 = load i64, ptr %8, align 8, !tbaa !19
  store i64 %62, ptr %10, align 8, !tbaa !19
  br label %63

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

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 !19
  %73 = getelementptr inbounds double, ptr %71, i64 %72
  %74 = load double, ptr %73, align 8, !tbaa !20
  %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 i64, ptr %7, align 8, !tbaa !19
  %79 = getelementptr inbounds double, ptr %77, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !20
  %81 = fmul double %74, %80
  %82 = load ptr, ptr %4, align 8, !tbaa !5
  %83 = getelementptr inbounds %"struct.alglib_impl::sparsematrix", ptr %82, i32 0, i32 0
  %84 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %83, i32 0, i32 4
  %85 = load ptr, ptr %84, align 8, !tbaa !18
  %86 = load i64, ptr %10, align 8, !tbaa !19
  %87 = getelementptr inbounds double, ptr %85, i64 %86
  store double %81, ptr %87, align 8, !tbaa !20
  br label %88

88:                                               ; preds = %67
  %89 = load i64, ptr %10, align 8, !tbaa !19
  %90 = add nsw i64 %89, 1
  store i64 %90, ptr %10, align 8, !tbaa !19
  br label %63, !llvm.loop !22

91:                                               ; preds = %63
  br label %92

92:                                               ; preds = %91
  %93 = load i64, ptr %7, align 8, !tbaa !19
  %94 = add nsw i64 %93, 1
  store i64 %94, ptr %7, align 8, !tbaa !19
  br label %38, !llvm.loop !24

95:                                               ; 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 328}
!17 = !{!10, !12, i64 352}
!18 = !{!7, !7, i64 0}
!19 = !{!12, !12, i64 0}
!20 = !{!21, !21, i64 0}
!21 = !{!"double", !7, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = distinct !{!24, !23}


; 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.197 = external hidden unnamed_addr constant [145 x i8], align 1
@.str.198 = external hidden unnamed_addr constant [34 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_impl20sparsemultiplyrowsbyEPNS_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 328
  %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.198, 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 = load i64, ptr %8, align 8, !tbaa !15
  %16 = getelementptr inbounds i64, ptr %14, i64 %15
  %17 = load i64, ptr %16, align 8, !tbaa !18
  %18 = icmp eq i64 %12, %17
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext %18, ptr noundef nonnull @.str.197, ptr noundef %2)
  %19 = load i64, ptr %8, align 8, !tbaa !15
  %.not.not29 = icmp sgt i64 %19, 0
  br i1 %.not.not29, label %.lr.ph31, label %._crit_edge

.lr.ph31:                                         ; preds = %3
  %20 = getelementptr inbounds i8, ptr %0, i64 56
  %21 = getelementptr inbounds i8, ptr %1, i64 56
  br label %22

.loopexit:                                        ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %22
  %exitcond32.not = icmp eq i64 %26, %19
  br i1 %exitcond32.not, label %._crit_edge, label %22, !llvm.loop !19

22:                                               ; preds = %.lr.ph31, %.loopexit
  %.02530 = phi i64 [ 0, %.lr.ph31 ], [ %26, %.loopexit ]
  %23 = load ptr, ptr %13, align 8, !tbaa !17
  %24 = getelementptr inbounds i64, ptr %23, i64 %.02530
  %25 = load i64, ptr %24, align 8, !tbaa !18
  %26 = add nuw nsw i64 %.02530, 1
  %27 = getelementptr inbounds i64, ptr %23, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !18
  %.not.not2627 = icmp slt i64 %25, %28
  br i1 %.not.not2627, label %.lr.ph.preheader, label %.loopexit

.lr.ph.preheader:                                 ; preds = %22
  %29 = sub i64 %28, %25
  %.neg = add i64 %25, 1
  %xtraiter = and i64 %29, 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
  %30 = load ptr, ptr %20, align 8, !tbaa !17
  %31 = getelementptr inbounds double, ptr %30, i64 %25
  %32 = load double, ptr %31, align 8, !tbaa !21
  %33 = load ptr, ptr %21, align 8, !tbaa !17
  %34 = getelementptr inbounds double, ptr %33, i64 %.02530
  %35 = load double, ptr %34, align 8, !tbaa !21
  %36 = fmul double %32, %35
  store double %36, ptr %31, align 8, !tbaa !21
  %37 = add nsw i64 %25, 1
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.028.unr = phi i64 [ %25, %.lr.ph.preheader ], [ %37, %.lr.ph.prol ]
  %38 = icmp eq i64 %28, %.neg
  br i1 %38, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.028 = phi i64 [ %54, %.lr.ph ], [ %.028.unr, %.lr.ph.prol.loopexit ]
  %39 = load ptr, ptr %20, align 8, !tbaa !17
  %40 = getelementptr inbounds double, ptr %39, i64 %.028
  %41 = load double, ptr %40, align 8, !tbaa !21
  %42 = load ptr, ptr %21, align 8, !tbaa !17
  %43 = getelementptr inbounds double, ptr %42, i64 %.02530
  %44 = load double, ptr %43, align 8, !tbaa !21
  %45 = fmul double %41, %44
  store double %45, ptr %40, align 8, !tbaa !21
  %46 = load ptr, ptr %20, align 8, !tbaa !17
  %47 = getelementptr double, ptr %46, i64 %.028
  %48 = getelementptr i8, ptr %47, i64 8
  %49 = load double, ptr %48, align 8, !tbaa !21
  %50 = load ptr, ptr %21, align 8, !tbaa !17
  %51 = getelementptr inbounds double, ptr %50, i64 %.02530
  %52 = load double, ptr %51, align 8, !tbaa !21
  %53 = fmul double %49, %52
  store double %53, ptr %48, align 8, !tbaa !21
  %54 = add nsw i64 %.028, 2
  %exitcond.not.1 = icmp eq i64 %54, %28
  br i1 %exitcond.not.1, label %.loopexit, label %.lr.ph, !llvm.loop !23

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


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