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

; 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_matrix" = type { i64, i64, 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 }

; 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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11alglib_impl6rcopymEllPKNS_9ae_matrixEPS0_PNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %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 i32, align 4
  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) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %14 = load i64, ptr %6, align 8, !tbaa !5
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %19, label %16

16:                                               ; preds = %5
  %17 = load i64, ptr %7, align 8, !tbaa !5
  %18 = icmp eq i64 %17, 0
  br i1 %18, label %19, label %20

19:                                               ; preds = %16, %5
  store i32 1, ptr %13, align 4
  br label %58

20:                                               ; preds = %16
  store i64 0, ptr %11, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %54, %20
  %22 = load i64, ptr %11, align 8, !tbaa !5
  %23 = load i64, ptr %6, align 8, !tbaa !5
  %24 = sub nsw i64 %23, 1
  %25 = icmp sle i64 %22, %24
  br i1 %25, label %26, label %57

26:                                               ; preds = %21
  store i64 0, ptr %12, align 8, !tbaa !5
  br label %27

27:                                               ; preds = %50, %26
  %28 = load i64, ptr %12, align 8, !tbaa !5
  %29 = load i64, ptr %7, align 8, !tbaa !5
  %30 = sub nsw i64 %29, 1
  %31 = icmp sle i64 %28, %30
  br i1 %31, label %32, label %53

32:                                               ; preds = %27
  %33 = load ptr, ptr %8, align 8, !tbaa !9
  %34 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = load i64, ptr %11, align 8, !tbaa !5
  %37 = getelementptr inbounds ptr, ptr %35, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = load i64, ptr %12, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !12
  %42 = load ptr, ptr %9, align 8, !tbaa !9
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %42, i32 0, i32 6
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = load i64, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds ptr, ptr %44, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = load i64, ptr %12, align 8, !tbaa !5
  %49 = getelementptr inbounds double, ptr %47, i64 %48
  store double %41, ptr %49, align 8, !tbaa !12
  br label %50

50:                                               ; preds = %32
  %51 = load i64, ptr %12, align 8, !tbaa !5
  %52 = add nsw i64 %51, 1
  store i64 %52, ptr %12, align 8, !tbaa !5
  br label %27, !llvm.loop !14

53:                                               ; preds = %27
  br label %54

54:                                               ; preds = %53
  %55 = load i64, ptr %11, align 8, !tbaa !5
  %56 = add nsw i64 %55, 1
  store i64 %56, ptr %11, align 8, !tbaa !5
  br label %21, !llvm.loop !16

57:                                               ; preds = %21
  store i32 0, ptr %13, align 4
  br label %58

58:                                               ; preds = %57, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  %59 = load i32, ptr %13, align 4
  switch i32 %59, label %61 [
    i32 0, label %60
    i32 1, label %60
  ]

60:                                               ; preds = %58, %58
  ret void

61:                                               ; preds = %58
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind 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 #2 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN11alglib_impl6rcopymEllPKNS_9ae_matrixEPS0_PNS_8ae_stateE(i64 noundef %0, i64 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readnone %4) local_unnamed_addr #0 {
  %6 = icmp ne i64 %1, 0
  %.not.not21 = icmp sgt i64 %0, 0
  %or.cond23 = and i1 %.not.not21, %6
  br i1 %or.cond23, label %.preheader.lr.ph, label %.loopexit

.preheader.lr.ph:                                 ; preds = %5
  %.not.not1719 = icmp sgt i64 %1, 0
  %7 = getelementptr inbounds i8, ptr %2, i64 72
  %8 = getelementptr inbounds i8, ptr %3, i64 72
  br i1 %.not.not1719, label %.preheader.us.preheader, label %.loopexit

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %xtraiter = and i64 %1, 1
  %9 = 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
  %.01422.us = phi i64 [ %39, %._crit_edge.us ], [ 0, %.preheader.us.preheader ]
  br i1 %9, label %._crit_edge.us.unr-lcssa, label %.preheader.us.new

.preheader.us.new:                                ; preds = %.preheader.us, %.preheader.us.new
  %.020.us = phi i64 [ %29, %.preheader.us.new ], [ 0, %.preheader.us ]
  %niter = phi i64 [ %niter.next.1, %.preheader.us.new ], [ 0, %.preheader.us ]
  %10 = load ptr, ptr %7, align 8, !tbaa !5
  %11 = getelementptr inbounds ptr, ptr %10, i64 %.01422.us
  %12 = load ptr, ptr %11, align 8, !tbaa !8
  %13 = getelementptr inbounds double, ptr %12, i64 %.020.us
  %14 = load double, ptr %13, align 8, !tbaa !10
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds ptr, ptr %15, i64 %.01422.us
  %17 = load ptr, ptr %16, align 8, !tbaa !8
  %18 = getelementptr inbounds double, ptr %17, i64 %.020.us
  store double %14, ptr %18, align 8, !tbaa !10
  %19 = or disjoint i64 %.020.us, 1
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %20, i64 %.01422.us
  %22 = load ptr, ptr %21, align 8, !tbaa !8
  %23 = getelementptr inbounds double, ptr %22, i64 %19
  %24 = load double, ptr %23, align 8, !tbaa !10
  %25 = load ptr, ptr %8, align 8, !tbaa !5
  %26 = getelementptr inbounds ptr, ptr %25, i64 %.01422.us
  %27 = load ptr, ptr %26, align 8, !tbaa !8
  %28 = getelementptr inbounds double, ptr %27, i64 %19
  store double %24, ptr %28, align 8, !tbaa !10
  %29 = add nuw nsw i64 %.020.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 !12

._crit_edge.us.unr-lcssa:                         ; preds = %.preheader.us.new, %.preheader.us
  %.020.us.unr = phi i64 [ 0, %.preheader.us ], [ %29, %.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
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %30, i64 %.01422.us
  %32 = load ptr, ptr %31, align 8, !tbaa !8
  %33 = getelementptr inbounds double, ptr %32, i64 %.020.us.unr
  %34 = load double, ptr %33, align 8, !tbaa !10
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = getelementptr inbounds ptr, ptr %35, i64 %.01422.us
  %37 = load ptr, ptr %36, align 8, !tbaa !8
  %38 = getelementptr inbounds double, ptr %37, i64 %.020.us.unr
  store double %34, ptr %38, align 8, !tbaa !10
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %39 = add nuw nsw i64 %.01422.us, 1
  %exitcond27.not = icmp eq i64 %39, %0
  br i1 %exitcond27.not, label %.loopexit, label %.preheader.us, !llvm.loop !14

.loopexit:                                        ; preds = %._crit_edge.us, %.preheader.lr.ph, %5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"double", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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