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

; 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 uwtable
define dso_local void @_ZN11alglib_impl12hqrndnormalmEPNS_10hqrndstateEllPNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, 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
  %14 = alloca double, align 8
  %15 = alloca double, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i64 %1, ptr %7, align 8, !tbaa !9
  store i64 %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !5
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %16 = load ptr, ptr %9, align 8, !tbaa !5
  call void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef %16)
  %17 = load i64, ptr %8, align 8, !tbaa !9
  %18 = sdiv i64 %17, 2
  store i64 %18, ptr %13, align 8, !tbaa !9
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = load i64, ptr %8, align 8, !tbaa !9
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef %19, i64 noundef %20, i64 noundef %21, ptr noundef %22)
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %23

23:                                               ; preds = %80, %5
  %24 = load i64, ptr %11, align 8, !tbaa !9
  %25 = load i64, ptr %7, align 8, !tbaa !9
  %26 = sub nsw i64 %25, 1
  %27 = icmp sle i64 %24, %26
  br i1 %27, label %28, label %83

28:                                               ; preds = %23
  store i64 0, ptr %12, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %59, %28
  %30 = load i64, ptr %12, align 8, !tbaa !9
  %31 = load i64, ptr %13, align 8, !tbaa !9
  %32 = sub nsw i64 %31, 1
  %33 = icmp sle i64 %30, %32
  br i1 %33, label %34, label %62

34:                                               ; preds = %29
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %35, ptr noundef %14, ptr noundef %15, ptr noundef %36)
  %37 = load double, ptr %14, align 8, !tbaa !11
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %38, i32 0, i32 6
  %40 = load ptr, ptr %39, align 8, !tbaa !13
  %41 = load i64, ptr %11, align 8, !tbaa !9
  %42 = getelementptr inbounds ptr, ptr %40, i64 %41
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  %44 = load i64, ptr %12, align 8, !tbaa !9
  %45 = mul nsw i64 2, %44
  %46 = add nsw i64 %45, 0
  %47 = getelementptr inbounds double, ptr %43, i64 %46
  store double %37, ptr %47, align 8, !tbaa !11
  %48 = load double, ptr %15, align 8, !tbaa !11
  %49 = load ptr, ptr %9, align 8, !tbaa !5
  %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 %11, align 8, !tbaa !9
  %53 = getelementptr inbounds ptr, ptr %51, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = load i64, ptr %12, align 8, !tbaa !9
  %56 = mul nsw i64 2, %55
  %57 = add nsw i64 %56, 1
  %58 = getelementptr inbounds double, ptr %54, i64 %57
  store double %48, ptr %58, align 8, !tbaa !11
  br label %59

59:                                               ; preds = %34
  %60 = load i64, ptr %12, align 8, !tbaa !9
  %61 = add nsw i64 %60, 1
  store i64 %61, ptr %12, align 8, !tbaa !9
  br label %29, !llvm.loop !14

62:                                               ; preds = %29
  %63 = load i64, ptr %8, align 8, !tbaa !9
  %64 = srem i64 %63, 2
  %65 = icmp ne i64 %64, 0
  br i1 %65, label %66, label %79

66:                                               ; preds = %62
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %67, ptr noundef %14, ptr noundef %15, ptr noundef %68)
  %69 = load double, ptr %14, align 8, !tbaa !11
  %70 = load ptr, ptr %9, align 8, !tbaa !5
  %71 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %70, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = load i64, ptr %11, align 8, !tbaa !9
  %74 = getelementptr inbounds ptr, ptr %72, i64 %73
  %75 = load ptr, ptr %74, align 8, !tbaa !5
  %76 = load i64, ptr %8, align 8, !tbaa !9
  %77 = sub nsw i64 %76, 1
  %78 = getelementptr inbounds double, ptr %75, i64 %77
  store double %69, ptr %78, align 8, !tbaa !11
  br label %79

79:                                               ; preds = %66, %62
  br label %80

80:                                               ; preds = %79
  %81 = load i64, ptr %11, align 8, !tbaa !9
  %82 = add nsw i64 %81, 1
  store i64 %82, ptr %11, align 8, !tbaa !9
  br label %23, !llvm.loop !16

83:                                               ; preds = %23
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  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
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #2

declare void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { "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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; 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 void @_ZN11alglib_impl12hqrndnormalmEPNS_10hqrndstateEllPNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  tail call void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef %3)
  %8 = sdiv i64 %2, 2
  tail call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef %3, i64 noundef %1, i64 noundef %2, ptr noundef %4)
  %.not.not29 = icmp sgt i64 %1, 0
  br i1 %.not.not29, label %.preheader.lr.ph, label %._crit_edge31

.preheader.lr.ph:                                 ; preds = %5
  %.not.not2627 = icmp sgt i64 %2, 1
  %9 = getelementptr inbounds i8, ptr %3, i64 72
  %10 = and i64 %2, 1
  %.not = icmp eq i64 %10, 0
  br i1 %.not.not2627, label %.preheader.lr.ph.split.us, label %.preheader.lr.ph.split

.preheader.lr.ph.split.us:                        ; preds = %.preheader.lr.ph
  br i1 %.not, label %.preheader.us.us, label %.preheader.us

.preheader.us.us:                                 ; preds = %.preheader.lr.ph.split.us, %._crit_edge.us.us
  %.030.us.us = phi i64 [ %25, %._crit_edge.us.us ], [ 0, %.preheader.lr.ph.split.us ]
  br label %11

11:                                               ; preds = %11, %.preheader.us.us
  %.02528.us.us = phi i64 [ 0, %.preheader.us.us ], [ %24, %11 ]
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef %4)
  %12 = load double, ptr %6, align 8, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !9
  %14 = getelementptr inbounds ptr, ptr %13, i64 %.030.us.us
  %15 = load ptr, ptr %14, align 8, !tbaa !10
  %16 = shl nuw nsw i64 %.02528.us.us, 1
  %17 = getelementptr inbounds double, ptr %15, i64 %16
  store double %12, ptr %17, align 8, !tbaa !5
  %18 = load double, ptr %7, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %19, i64 %.030.us.us
  %21 = load ptr, ptr %20, align 8, !tbaa !10
  %22 = or disjoint i64 %16, 1
  %23 = getelementptr inbounds double, ptr %21, i64 %22
  store double %18, ptr %23, align 8, !tbaa !5
  %24 = add nuw nsw i64 %.02528.us.us, 1
  %exitcond40.not = icmp eq i64 %24, %8
  br i1 %exitcond40.not, label %._crit_edge.us.us, label %11, !llvm.loop !12

._crit_edge.us.us:                                ; preds = %11
  %25 = add nuw nsw i64 %.030.us.us, 1
  %exitcond41.not = icmp eq i64 %25, %1
  br i1 %exitcond41.not, label %._crit_edge31, label %.preheader.us.us, !llvm.loop !14

.preheader.us:                                    ; preds = %.preheader.lr.ph.split.us, %._crit_edge.us
  %.030.us = phi i64 [ %46, %._crit_edge.us ], [ 0, %.preheader.lr.ph.split.us ]
  br label %26

26:                                               ; preds = %.preheader.us, %26
  %.02528.us = phi i64 [ 0, %.preheader.us ], [ %39, %26 ]
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef %4)
  %27 = load double, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !9
  %29 = getelementptr inbounds ptr, ptr %28, i64 %.030.us
  %30 = load ptr, ptr %29, align 8, !tbaa !10
  %31 = shl nuw nsw i64 %.02528.us, 1
  %32 = getelementptr inbounds double, ptr %30, i64 %31
  store double %27, ptr %32, align 8, !tbaa !5
  %33 = load double, ptr %7, align 8, !tbaa !5
  %34 = load ptr, ptr %9, align 8, !tbaa !9
  %35 = getelementptr inbounds ptr, ptr %34, i64 %.030.us
  %36 = load ptr, ptr %35, align 8, !tbaa !10
  %37 = or disjoint i64 %31, 1
  %38 = getelementptr inbounds double, ptr %36, i64 %37
  store double %33, ptr %38, align 8, !tbaa !5
  %39 = add nuw nsw i64 %.02528.us, 1
  %exitcond38.not = icmp eq i64 %39, %8
  br i1 %exitcond38.not, label %._crit_edge.us, label %26, !llvm.loop !12

._crit_edge.us:                                   ; preds = %26
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef %4)
  %40 = load double, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %9, align 8, !tbaa !9
  %42 = getelementptr inbounds ptr, ptr %41, i64 %.030.us
  %43 = load ptr, ptr %42, align 8, !tbaa !10
  %44 = getelementptr double, ptr %43, i64 %2
  %45 = getelementptr i8, ptr %44, i64 -8
  store double %40, ptr %45, align 8, !tbaa !5
  %46 = add nuw nsw i64 %.030.us, 1
  %exitcond39.not = icmp eq i64 %46, %1
  br i1 %exitcond39.not, label %._crit_edge31, label %.preheader.us, !llvm.loop !14

.preheader.lr.ph.split:                           ; preds = %.preheader.lr.ph
  br i1 %.not, label %._crit_edge31, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph.split, %.preheader
  %.030 = phi i64 [ %53, %.preheader ], [ 0, %.preheader.lr.ph.split ]
  call void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef %0, ptr noundef nonnull %6, ptr noundef nonnull %7, ptr noundef %4)
  %47 = load double, ptr %6, align 8, !tbaa !5
  %48 = load ptr, ptr %9, align 8, !tbaa !9
  %49 = getelementptr inbounds ptr, ptr %48, i64 %.030
  %50 = load ptr, ptr %49, align 8, !tbaa !10
  %51 = getelementptr double, ptr %50, i64 %2
  %52 = getelementptr i8, ptr %51, i64 -8
  store double %47, ptr %52, align 8, !tbaa !5
  %53 = add nuw nsw i64 %.030, 1
  %exitcond.not = icmp eq i64 %53, %1
  br i1 %exitcond.not, label %._crit_edge31, label %.preheader, !llvm.loop !14

._crit_edge31:                                    ; preds = %.preheader, %._crit_edge.us, %._crit_edge.us.us, %.preheader.lr.ph.split, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN11alglib_impl12hqrndnormal2EPNS_10hqrndstateEPdS2_PNS_8ae_stateE(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #2

declare void @_ZN11alglib_impl15ae_matrix_clearEPNS_9ae_matrixE(ptr noundef) local_unnamed_addr #2

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


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