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

; 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 }
%union.anon = 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
declare dso_local noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11alglib_impl4rgerElldPKNS_9ae_vectorES2_PNS_9ae_matrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, double noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #1 {
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca double, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca double, align 8
  %18 = alloca i32, align 4
  store i64 %0, ptr %8, align 8, !tbaa !5
  store i64 %1, ptr %9, align 8, !tbaa !5
  store double %2, ptr %10, align 8, !tbaa !9
  store ptr %3, ptr %11, align 8, !tbaa !11
  store ptr %4, ptr %12, align 8, !tbaa !11
  store ptr %5, ptr %13, align 8, !tbaa !11
  store ptr %6, ptr %14, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %19 = load i64, ptr %8, align 8, !tbaa !5
  %20 = icmp sle i64 %19, 0
  br i1 %20, label %27, label %21

21:                                               ; preds = %7
  %22 = load i64, ptr %9, align 8, !tbaa !5
  %23 = icmp sle i64 %22, 0
  br i1 %23, label %27, label %24

24:                                               ; preds = %21
  %25 = load double, ptr %10, align 8, !tbaa !9
  %26 = call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %25, double noundef 0.000000e+00)
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %21, %7
  store i32 1, ptr %18, align 4
  br label %82

28:                                               ; preds = %24
  store i64 0, ptr %15, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %78, %28
  %30 = load i64, ptr %15, align 8, !tbaa !5
  %31 = load i64, ptr %8, align 8, !tbaa !5
  %32 = sub nsw i64 %31, 1
  %33 = icmp sle i64 %30, %32
  br i1 %33, label %34, label %81

34:                                               ; preds = %29
  %35 = load double, ptr %10, align 8, !tbaa !9
  %36 = load ptr, ptr %11, align 8, !tbaa !11
  %37 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = load i64, ptr %15, align 8, !tbaa !5
  %40 = getelementptr inbounds double, ptr %38, i64 %39
  %41 = load double, ptr %40, align 8, !tbaa !9
  %42 = fmul double %35, %41
  store double %42, ptr %17, align 8, !tbaa !9
  store i64 0, ptr %16, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %74, %34
  %44 = load i64, ptr %16, align 8, !tbaa !5
  %45 = load i64, ptr %9, align 8, !tbaa !5
  %46 = sub nsw i64 %45, 1
  %47 = icmp sle i64 %44, %46
  br i1 %47, label %48, label %77

48:                                               ; preds = %43
  %49 = load ptr, ptr %13, align 8, !tbaa !11
  %50 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %49, i32 0, i32 6
  %51 = load ptr, ptr %50, align 8, !tbaa !13
  %52 = load i64, ptr %15, align 8, !tbaa !5
  %53 = getelementptr inbounds ptr, ptr %51, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !11
  %55 = load i64, ptr %16, align 8, !tbaa !5
  %56 = getelementptr inbounds double, ptr %54, i64 %55
  %57 = load double, ptr %56, align 8, !tbaa !9
  %58 = load double, ptr %17, align 8, !tbaa !9
  %59 = load ptr, ptr %12, align 8, !tbaa !11
  %60 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %59, i32 0, i32 4
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  %62 = load i64, ptr %16, align 8, !tbaa !5
  %63 = getelementptr inbounds double, ptr %61, i64 %62
  %64 = load double, ptr %63, align 8, !tbaa !9
  %65 = call double @llvm.fmuladd.f64(double %58, double %64, double %57)
  %66 = load ptr, ptr %13, align 8, !tbaa !11
  %67 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %66, i32 0, i32 6
  %68 = load ptr, ptr %67, align 8, !tbaa !13
  %69 = load i64, ptr %15, align 8, !tbaa !5
  %70 = getelementptr inbounds ptr, ptr %68, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = load i64, ptr %16, align 8, !tbaa !5
  %73 = getelementptr inbounds double, ptr %71, i64 %72
  store double %65, ptr %73, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %48
  %75 = load i64, ptr %16, align 8, !tbaa !5
  %76 = add nsw i64 %75, 1
  store i64 %76, ptr %16, align 8, !tbaa !5
  br label %43, !llvm.loop !14

77:                                               ; preds = %43
  br label %78

78:                                               ; preds = %77
  %79 = load i64, ptr %15, align 8, !tbaa !5
  %80 = add nsw i64 %79, 1
  store i64 %80, ptr %15, align 8, !tbaa !5
  br label %29, !llvm.loop !16

81:                                               ; preds = %29
  store i32 0, ptr %18, align 4
  br label %82

82:                                               ; preds = %81, %27
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  %83 = load i32, ptr %18, align 4
  switch i32 %83, label %85 [
    i32 0, label %84
    i32 1, label %84
  ]

84:                                               ; preds = %82, %82
  ret void

85:                                               ; preds = %82
  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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!7, !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 nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef, double noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN11alglib_impl4rgerElldPKNS_9ae_vectorES2_PNS_9ae_matrixEPNS_8ae_stateE(i64 noundef %0, i64 noundef %1, double noundef %2, ptr nocapture noundef readonly %3, ptr nocapture noundef readonly %4, ptr nocapture noundef readonly %5, ptr nocapture noundef readnone %6) local_unnamed_addr #0 {
  %8 = icmp slt i64 %0, 1
  %9 = icmp slt i64 %1, 1
  %or.cond = or i1 %8, %9
  br i1 %or.cond, label %.loopexit, label %10

10:                                               ; preds = %7
  %11 = tail call noundef zeroext i1 @_ZN11alglib_impl8ae_fp_eqEdd(double noundef %2, double noundef 0.000000e+00)
  br i1 %11, label %.loopexit, label %.lr.ph.us.preheader

.lr.ph.us.preheader:                              ; preds = %10
  %12 = getelementptr inbounds i8, ptr %3, i64 56
  %13 = getelementptr inbounds i8, ptr %5, i64 72
  %14 = getelementptr inbounds i8, ptr %4, i64 56
  %xtraiter = and i64 %1, 1
  %15 = icmp eq i64 %1, 1
  %unroll_iter = and i64 %1, 9223372036854775806
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.lr.ph.us

.lr.ph.us:                                        ; preds = %.lr.ph.us.preheader, %._crit_edge.us
  %.028.us = phi i64 [ %49, %._crit_edge.us ], [ 0, %.lr.ph.us.preheader ]
  %16 = load ptr, ptr %12, align 8, !tbaa !5
  %17 = getelementptr inbounds double, ptr %16, i64 %.028.us
  %18 = load double, ptr %17, align 8, !tbaa !8
  %19 = fmul double %18, %2
  br i1 %15, label %._crit_edge.us.unr-lcssa, label %.lr.ph.us.new

.lr.ph.us.new:                                    ; preds = %.lr.ph.us, %.lr.ph.us.new
  %.02126.us = phi i64 [ %39, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %niter = phi i64 [ %niter.next.1, %.lr.ph.us.new ], [ 0, %.lr.ph.us ]
  %20 = load ptr, ptr %13, align 8, !tbaa !5
  %21 = getelementptr inbounds ptr, ptr %20, i64 %.028.us
  %22 = load ptr, ptr %21, align 8, !tbaa !10
  %23 = getelementptr inbounds double, ptr %22, i64 %.02126.us
  %24 = load double, ptr %23, align 8, !tbaa !8
  %25 = load ptr, ptr %14, align 8, !tbaa !5
  %26 = getelementptr inbounds double, ptr %25, i64 %.02126.us
  %27 = load double, ptr %26, align 8, !tbaa !8
  %28 = tail call double @llvm.fmuladd.f64(double %19, double %27, double %24)
  store double %28, ptr %23, align 8, !tbaa !8
  %29 = or disjoint i64 %.02126.us, 1
  %30 = load ptr, ptr %13, align 8, !tbaa !5
  %31 = getelementptr inbounds ptr, ptr %30, i64 %.028.us
  %32 = load ptr, ptr %31, align 8, !tbaa !10
  %33 = getelementptr inbounds double, ptr %32, i64 %29
  %34 = load double, ptr %33, align 8, !tbaa !8
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 %29
  %37 = load double, ptr %36, align 8, !tbaa !8
  %38 = tail call double @llvm.fmuladd.f64(double %19, double %37, double %34)
  store double %38, ptr %33, align 8, !tbaa !8
  %39 = add nuw nsw i64 %.02126.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 %.lr.ph.us.new, !llvm.loop !12

._crit_edge.us.unr-lcssa:                         ; preds = %.lr.ph.us.new, %.lr.ph.us
  %.02126.us.unr = phi i64 [ 0, %.lr.ph.us ], [ %39, %.lr.ph.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 %13, align 8, !tbaa !5
  %41 = getelementptr inbounds ptr, ptr %40, i64 %.028.us
  %42 = load ptr, ptr %41, align 8, !tbaa !10
  %43 = getelementptr inbounds double, ptr %42, i64 %.02126.us.unr
  %44 = load double, ptr %43, align 8, !tbaa !8
  %45 = load ptr, ptr %14, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %45, i64 %.02126.us.unr
  %47 = load double, ptr %46, align 8, !tbaa !8
  %48 = tail call double @llvm.fmuladd.f64(double %19, double %47, double %44)
  store double %48, ptr %43, align 8, !tbaa !8
  br label %._crit_edge.us

._crit_edge.us:                                   ; preds = %._crit_edge.us.unr-lcssa, %._crit_edge.us.epilog-lcssa
  %49 = add nuw nsw i64 %.028.us, 1
  %exitcond32.not = icmp eq i64 %49, %0
  br i1 %exitcond32.not, label %.loopexit, label %.lr.ph.us, !llvm.loop !14

.loopexit:                                        ; preds = %._crit_edge.us, %7, %10
  ret void
}

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"double", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


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