; LLVM IR from Dimandragon/non-parametric-dsp :: alglib-cpp/src (optimization)

; 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::ae_matrix" = type { i64, i64, i64, i64, i8, %"struct.alglib_impl::ae_dyn_block", %union.anon.1 }
%union.anon.1 = type { ptr }

@.str.1241 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1242 = external hidden unnamed_addr constant [35 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_impl8unpackdjEllPKNS_9ae_vectorEPNS_9ae_matrixEPNS_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
  %13 = 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
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %14 = load ptr, ptr %8, align 8, !tbaa !9
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %14, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !11
  %17 = load i64, ptr %6, align 8, !tbaa !5
  %18 = load i64, ptr %7, align 8, !tbaa !5
  %19 = mul nsw i64 %17, %18
  %20 = icmp slt i64 %16, %19
  br i1 %20, label %21, label %23

21:                                               ; preds = %5
  %22 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef @.str.1241, ptr noundef %22)
  br label %23

23:                                               ; preds = %21, %5
  %24 = load ptr, ptr %9, align 8, !tbaa !9
  %25 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %24, i32 0, i32 0
  %26 = load i64, ptr %25, align 8, !tbaa !15
  %27 = load i64, ptr %6, align 8, !tbaa !5
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %35, label %29

29:                                               ; preds = %23
  %30 = load ptr, ptr %9, align 8, !tbaa !9
  %31 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = load i64, ptr %7, align 8, !tbaa !5
  %34 = icmp slt i64 %32, %33
  br i1 %34, label %35, label %37

35:                                               ; preds = %29, %23
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef @.str.1242, ptr noundef %36)
  br label %37

37:                                               ; preds = %35, %29
  store i64 0, ptr %13, align 8, !tbaa !5
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %70, %37
  %39 = load i64, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %6, align 8, !tbaa !5
  %41 = sub nsw i64 %40, 1
  %42 = icmp sle i64 %39, %41
  br i1 %42, label %43, label %73

43:                                               ; preds = %38
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %44

44:                                               ; preds = %66, %43
  %45 = load i64, ptr %12, align 8, !tbaa !5
  %46 = load i64, ptr %7, align 8, !tbaa !5
  %47 = sub nsw i64 %46, 1
  %48 = icmp sle i64 %45, %47
  br i1 %48, label %49, label %69

49:                                               ; preds = %44
  %50 = load ptr, ptr %8, align 8, !tbaa !9
  %51 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = load i64, ptr %13, align 8, !tbaa !5
  %54 = getelementptr inbounds double, ptr %52, i64 %53
  %55 = load double, ptr %54, align 8, !tbaa !19
  %56 = load ptr, ptr %9, align 8, !tbaa !9
  %57 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %56, i32 0, i32 6
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = load i64, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds ptr, ptr %58, i64 %59
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  %62 = load i64, ptr %12, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %61, i64 %62
  store double %55, ptr %63, align 8, !tbaa !19
  %64 = load i64, ptr %13, align 8, !tbaa !5
  %65 = add nsw i64 %64, 1
  store i64 %65, ptr %13, align 8, !tbaa !5
  br label %66

66:                                               ; preds = %49
  %67 = load i64, ptr %12, align 8, !tbaa !5
  %68 = add nsw i64 %67, 1
  store i64 %68, ptr %12, align 8, !tbaa !5
  br label %44, !llvm.loop !21

69:                                               ; preds = %44
  br label %70

70:                                               ; preds = %69
  %71 = load i64, ptr %11, align 8, !tbaa !5
  %72 = add nsw i64 %71, 1
  store i64 %72, ptr %11, align 8, !tbaa !5
  br label %38, !llvm.loop !23

73:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #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 = !{!"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 0}
!16 = !{!"_ZTSN11alglib_impl9ae_matrixE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !14, i64 40, !7, i64 72}
!17 = !{!16, !6, i64 8}
!18 = !{!7, !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !22}


; 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.1241 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.1242 = external hidden unnamed_addr constant [35 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_impl8unpackdjEllPKNS_9ae_vectorEPNS_9ae_matrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = load i64, ptr %2, align 8, !tbaa !5
  %7 = mul nsw i64 %1, %0
  %8 = icmp slt i64 %6, %7
  br i1 %8, label %9, label %10

9:                                                ; preds = %5
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef nonnull @.str.1241, ptr noundef %4)
  br label %10

10:                                               ; preds = %9, %5
  %11 = load i64, ptr %3, align 8, !tbaa !13
  %12 = icmp slt i64 %11, %0
  br i1 %12, label %17, label %13

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %3, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !15
  %16 = icmp slt i64 %15, %1
  br i1 %16, label %17, label %18

17:                                               ; preds = %13, %10
  tail call void @_ZN11alglib_impl9ae_assertEbPKcPNS_8ae_stateE(i1 noundef zeroext false, ptr noundef nonnull @.str.1242, ptr noundef %4)
  br label %18

18:                                               ; preds = %17, %13
  %.not.not26 = icmp sgt i64 %0, 0
  br i1 %.not.not26, label %.preheader.lr.ph, label %._crit_edge29

.preheader.lr.ph:                                 ; preds = %18
  %.not.not2223 = icmp sgt i64 %1, 0
  %19 = getelementptr inbounds i8, ptr %2, i64 56
  %20 = getelementptr inbounds i8, ptr %3, i64 72
  br i1 %.not.not2223, label %.preheader.us.preheader, label %._crit_edge29

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %xtraiter = and i64 %1, 1
  %21 = icmp eq i64 %1, 1
  %unroll_iter = and i64 %1, 9223372036854775806
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.028.us = phi i64 [ %.lcssa, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %.02127.us = phi i64 [ %48, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  br i1 %21, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %.125.us = phi i64 [ %38, %.preheader.us.new ], [ %.028.us, %.preheader.us ]
  %.02024.us = phi i64 [ %39, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %22 = load ptr, ptr %19, align 8, !tbaa !16
  %23 = getelementptr inbounds double, ptr %22, i64 %.125.us
  %24 = load double, ptr %23, align 8, !tbaa !17
  %25 = load ptr, ptr %20, align 8, !tbaa !16
  %26 = getelementptr inbounds ptr, ptr %25, i64 %.02127.us
  %27 = load ptr, ptr %26, align 8, !tbaa !19
  %28 = getelementptr inbounds double, ptr %27, i64 %.02024.us
  store double %24, ptr %28, align 8, !tbaa !17
  %29 = or disjoint i64 %.02024.us, 1
  %30 = load ptr, ptr %19, align 8, !tbaa !16
  %31 = getelementptr double, ptr %30, i64 %.125.us
  %32 = getelementptr i8, ptr %31, i64 8
  %33 = load double, ptr %32, align 8, !tbaa !17
  %34 = load ptr, ptr %20, align 8, !tbaa !16
  %35 = getelementptr inbounds ptr, ptr %34, i64 %.02127.us
  %36 = load ptr, ptr %35, align 8, !tbaa !19
  %37 = getelementptr inbounds double, ptr %36, i64 %29
  store double %33, ptr %37, align 8, !tbaa !17
  %38 = add nsw i64 %.125.us, 2
  %39 = add nuw nsw i64 %.02024.us, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !20

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa.ph = phi i64 [ poison, %.preheader.us ], [ %38, %.preheader.us.new ]
  %.125.us.unr = phi i64 [ %.028.us, %.preheader.us ], [ %38, %.preheader.us.new ]
  %.02024.us.unr = phi i64 [ 0, %.preheader.us ], [ %39, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %._crit_edge.us.epilog-lcssa

._crit_edge.us.epilog-lcssa:                      ; preds = %._crit_edge.us.unr-lcssa
  %40 = load ptr, ptr %19, align 8, !tbaa !16
  %41 = getelementptr inbounds double, ptr %40, i64 %.125.us.unr
  %42 = load double, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %20, align 8, !tbaa !16
  %44 = getelementptr inbounds ptr, ptr %43, i64 %.02127.us
  %45 = load ptr, ptr %44, align 8, !tbaa !19
  %46 = getelementptr inbounds double, ptr %45, i64 %.02024.us.unr
  store double %42, ptr %46, align 8, !tbaa !17
  %47 = add nsw i64 %.125.us.unr, 1
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %.lcssa = phi i64 [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %47, %._crit_edge.us.epilog-lcssa ]
  %48 = add nuw nsw i64 %.02127.us, 1
  %exitcond31.not = icmp eq i64 %48, %0
  br i1 %exitcond31.not, label %._crit_edge29, label %.preheader.us, !llvm.loop !22

._crit_edge29:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %18
  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, !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 0}
!14 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !8, i64 72}
!15 = !{!14, !7, i64 8}
!16 = !{!8, !8, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"double", !8, i64 0}
!19 = !{!12, !12, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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