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

; 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_frame" = type { %"struct.alglib_impl::ae_dyn_block" }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, 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 }

; 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 nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl26xdebugr2internalcopyandsumEPKNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.alglib_impl::ae_frame", align 8
  %6 = alloca %"struct.alglib_impl::ae_matrix", align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %10, ptr noundef %5)
  call void @llvm.memset.p0.i64(ptr align 8 %6, i8 0, i64 80, i1 false)
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl19ae_matrix_init_copyEPNS_9ae_matrixEPKS0_PNS_8ae_stateEb(ptr noundef %6, ptr noundef %11, ptr noundef %12, i1 noundef zeroext true)
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  store i64 0, ptr %7, align 8, !tbaa !11
  br label %13

13:                                               ; preds = %41, %2
  %14 = load i64, ptr %7, align 8, !tbaa !11
  %15 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %6, i32 0, i32 0
  %16 = load i64, ptr %15, align 8, !tbaa !13
  %17 = sub nsw i64 %16, 1
  %18 = icmp sle i64 %14, %17
  br i1 %18, label %19, label %44

19:                                               ; preds = %13
  store i64 0, ptr %8, align 8, !tbaa !11
  br label %20

20:                                               ; preds = %37, %19
  %21 = load i64, ptr %8, align 8, !tbaa !11
  %22 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %6, i32 0, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !17
  %24 = sub nsw i64 %23, 1
  %25 = icmp sle i64 %21, %24
  br i1 %25, label %26, label %40

26:                                               ; preds = %20
  %27 = load double, ptr %9, align 8, !tbaa !9
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %6, i32 0, i32 6
  %29 = load ptr, ptr %28, align 8, !tbaa !18
  %30 = load i64, ptr %7, align 8, !tbaa !11
  %31 = getelementptr inbounds ptr, ptr %29, i64 %30
  %32 = load ptr, ptr %31, align 8, !tbaa !5
  %33 = load i64, ptr %8, align 8, !tbaa !11
  %34 = getelementptr inbounds double, ptr %32, i64 %33
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = fadd double %27, %35
  store double %36, ptr %9, align 8, !tbaa !9
  br label %37

37:                                               ; preds = %26
  %38 = load i64, ptr %8, align 8, !tbaa !11
  %39 = add nsw i64 %38, 1
  store i64 %39, ptr %8, align 8, !tbaa !11
  br label %20, !llvm.loop !19

40:                                               ; preds = %20
  br label %41

41:                                               ; preds = %40
  %42 = load i64, ptr %7, align 8, !tbaa !11
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %7, align 8, !tbaa !11
  br label %13, !llvm.loop !21

44:                                               ; preds = %13
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %45)
  %46 = load double, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 80, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #4
  ret double %46
}

declare void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef, ptr noundef) #3

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) #3

declare void @_ZN11alglib_impl19ae_matrix_init_copyEPNS_9ae_matrixEPKS0_PNS_8ae_stateEb(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 #4 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !12, i64 0}
!14 = !{!"_ZTSN11alglib_impl9ae_matrixE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !15, i64 32, !16, i64 40, !7, i64 72}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!14, !12, i64 8}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; 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"

%"struct.alglib_impl::ae_frame" = type { %"struct.alglib_impl::ae_dyn_block" }
%"struct.alglib_impl::ae_dyn_block" = type { ptr, ptr, ptr, 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 }

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef double @_ZN11alglib_impl26xdebugr2internalcopyandsumEPKNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #2 {
  %3 = alloca %"struct.alglib_impl::ae_frame", align 8
  %4 = alloca %"struct.alglib_impl::ae_matrix", align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 80, ptr nonnull %4) #4
  call void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef %1, ptr noundef nonnull %3)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(80) %4, i8 0, i64 80, i1 false)
  call void @_ZN11alglib_impl19ae_matrix_init_copyEPNS_9ae_matrixEPKS0_PNS_8ae_stateEb(ptr noundef nonnull %4, ptr noundef %0, ptr noundef %1, i1 noundef zeroext true)
  %5 = load i64, ptr %4, align 8, !tbaa !5
  %.not.not17 = icmp sgt i64 %5, 0
  br i1 %.not.not17, label %.preheader.lr.ph, label %._crit_edge20

.preheader.lr.ph:                                 ; preds = %2
  %6 = getelementptr inbounds i8, ptr %4, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !13
  %.not.not1314 = icmp sgt i64 %7, 0
  %8 = getelementptr inbounds i8, ptr %4, i64 72
  %9 = load ptr, ptr %8, align 8
  br i1 %.not.not1314, label %.preheader.us.preheader, label %._crit_edge20

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %xtraiter = and i64 %7, 7
  %10 = icmp ult i64 %7, 8
  %unroll_iter = and i64 %7, 9223372036854775800
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %.019.us = phi double [ %.lcssa, %._crit_edge.us ], [ 0.000000e+00, %.preheader.us.preheader ]
  %.01218.us = phi i64 [ %49, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  %11 = getelementptr inbounds ptr, ptr %9, i64 %.01218.us
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  br i1 %10, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %.116.us = phi double [ %43, %.preheader.us.new ], [ %.019.us, %.preheader.us ]
  %.01115.us = phi i64 [ %44, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.7, %.preheader.us.new ], [ 0, %.preheader.us ]
  %13 = getelementptr inbounds double, ptr %12, i64 %.01115.us
  %14 = load double, ptr %13, align 8, !tbaa !15
  %15 = fadd double %.116.us, %14
  %16 = or disjoint i64 %.01115.us, 1
  %17 = getelementptr inbounds double, ptr %12, i64 %16
  %18 = load double, ptr %17, align 8, !tbaa !15
  %19 = fadd double %15, %18
  %20 = or disjoint i64 %.01115.us, 2
  %21 = getelementptr inbounds double, ptr %12, i64 %20
  %22 = load double, ptr %21, align 8, !tbaa !15
  %23 = fadd double %19, %22
  %24 = or disjoint i64 %.01115.us, 3
  %25 = getelementptr inbounds double, ptr %12, i64 %24
  %26 = load double, ptr %25, align 8, !tbaa !15
  %27 = fadd double %23, %26
  %28 = or disjoint i64 %.01115.us, 4
  %29 = getelementptr inbounds double, ptr %12, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !15
  %31 = fadd double %27, %30
  %32 = or disjoint i64 %.01115.us, 5
  %33 = getelementptr inbounds double, ptr %12, i64 %32
  %34 = load double, ptr %33, align 8, !tbaa !15
  %35 = fadd double %31, %34
  %36 = or disjoint i64 %.01115.us, 6
  %37 = getelementptr inbounds double, ptr %12, i64 %36
  %38 = load double, ptr %37, align 8, !tbaa !15
  %39 = fadd double %35, %38
  %40 = or disjoint i64 %.01115.us, 7
  %41 = getelementptr inbounds double, ptr %12, i64 %40
  %42 = load double, ptr %41, align 8, !tbaa !15
  %43 = fadd double %39, %42
  %44 = add nuw nsw i64 %.01115.us, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new, !llvm.loop !17

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.lcssa.ph = phi double [ poison, %.preheader.us ], [ %43, %.preheader.us.new ]
  %.116.us.unr = phi double [ %.019.us, %.preheader.us ], [ %43, %.preheader.us.new ]
  %.01115.us.unr = phi i64 [ 0, %.preheader.us ], [ %44, %.preheader.us.new ]
  br i1 %lcmp.mod.not, label %._crit_edge.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.unr-lcssa, %.epil.preheader
  %.116.us.epil = phi double [ %47, %.epil.preheader ], [ %.116.us.unr, %._crit_edge.us.unr-lcssa ]
  %.01115.us.epil = phi i64 [ %48, %.epil.preheader ], [ %.01115.us.unr, %._crit_edge.us.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.us.unr-lcssa ]
  %45 = getelementptr inbounds double, ptr %12, i64 %.01115.us.epil
  %46 = load double, ptr %45, align 8, !tbaa !15
  %47 = fadd double %.116.us.epil, %46
  %48 = add nuw nsw i64 %.01115.us.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge.us, label %.epil.preheader, !llvm.loop !19

._crit_edge.us:                                   ; preds = %.epil.preheader, %._crit_edge.us.unr-lcssa
  %.lcssa = phi double [ %.lcssa.ph, %._crit_edge.us.unr-lcssa ], [ %47, %.epil.preheader ]
  %49 = add nuw nsw i64 %.01218.us, 1
  %exitcond23.not = icmp eq i64 %49, %5
  br i1 %exitcond23.not, label %._crit_edge20, label %.preheader.us, !llvm.loop !21

._crit_edge20:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %2
  %.0.lcssa = phi double [ 0.000000e+00, %2 ], [ 0.000000e+00, %.preheader.lr.ph ], [ %.lcssa, %._crit_edge.us ]
  call void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef %1)
  call void @llvm.lifetime.end.p0(i64 80, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #4
  ret double %.0.lcssa
}

declare void @_ZN11alglib_impl13ae_frame_makeEPNS_8ae_stateEPNS_8ae_frameE(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @_ZN11alglib_impl14ae_frame_leaveEPNS_8ae_stateE(ptr noundef) local_unnamed_addr #3

declare void @_ZN11alglib_impl19ae_matrix_init_copyEPNS_9ae_matrixEPKS0_PNS_8ae_stateEb(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 #4 = { 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, !7, i64 0}
!6 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !11, i64 40, !8, i64 72}
!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 = !{!6, !7, i64 8}
!14 = !{!12, !12, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !8, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = distinct !{!21, !18}


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