; LLVM IR from venumb/ZSPACE :: cpp/depends/alglib/cpp/src (dataanalysis)

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

; 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 noundef double @_ZN11alglib_impl11knnprocess0EPNS_8knnmodelEPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %"struct.alglib_impl::knnmodel", ptr %10, i32 0, i32 0
  %12 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %12, ptr %8, align 8, !tbaa !20
  store i64 0, ptr %7, align 8, !tbaa !20
  br label %13

13:                                               ; preds = %32, %3
  %14 = load i64, ptr %7, align 8, !tbaa !20
  %15 = load i64, ptr %8, align 8, !tbaa !20
  %16 = sub nsw i64 %15, 1
  %17 = icmp sle i64 %14, %16
  br i1 %17, label %18, label %35

18:                                               ; preds = %13
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !21
  %22 = load i64, ptr %7, align 8, !tbaa !20
  %23 = getelementptr inbounds double, ptr %21, i64 %22
  %24 = load double, ptr %23, align 8, !tbaa !22
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.alglib_impl::knnmodel", ptr %25, i32 0, i32 7
  %27 = getelementptr inbounds %"struct.alglib_impl::knnbuffer", ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = load i64, ptr %7, align 8, !tbaa !20
  %31 = getelementptr inbounds double, ptr %29, i64 %30
  store double %24, ptr %31, align 8, !tbaa !22
  br label %32

32:                                               ; preds = %18
  %33 = load i64, ptr %7, align 8, !tbaa !20
  %34 = add nsw i64 %33, 1
  store i64 %34, ptr %7, align 8, !tbaa !20
  br label %13, !llvm.loop !23

35:                                               ; preds = %13
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %"struct.alglib_impl::knnmodel", ptr %37, i32 0, i32 7
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN11alglib_implL19knn_processinternalEPNS_8knnmodelEPNS_9knnbufferEPNS_8ae_stateE(ptr noundef %36, ptr noundef %38, ptr noundef %39)
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.alglib_impl::knnmodel", ptr %40, i32 0, i32 7
  %42 = getelementptr inbounds %"struct.alglib_impl::knnbuffer", ptr %41, i32 0, i32 2
  %43 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %42, i32 0, i32 4
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  %45 = getelementptr inbounds double, ptr %44, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !22
  store double %46, ptr %9, align 8, !tbaa !22
  %47 = load double, ptr %9, align 8, !tbaa !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret double %47
}

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

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 = { 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, !11, i64 0}
!10 = !{!"_ZTSN11alglib_impl8knnmodelE", !11, i64 0, !11, i64 8, !11, i64 16, !12, i64 24, !13, i64 32, !13, i64 33, !14, i64 40, !19, i64 1040}
!11 = !{!"long", !7, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl6kdtreeE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !15, i64 32, !17, i64 112, !17, i64 176, !17, i64 240, !17, i64 304, !17, i64 368, !18, i64 432, !11, i64 992}
!15 = !{!"_ZTSN11alglib_impl9ae_matrixE", !11, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !13, i64 32, !16, i64 40, !7, i64 72}
!16 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"_ZTSN11alglib_impl9ae_vectorE", !11, i64 0, !11, i64 8, !13, i64 16, !16, i64 24, !7, i64 56}
!18 = !{!"_ZTSN11alglib_impl19kdtreerequestbufferE", !17, i64 0, !17, i64 64, !17, i64 128, !11, i64 192, !12, i64 200, !13, i64 208, !12, i64 216, !11, i64 224, !17, i64 232, !17, i64 296, !17, i64 360, !17, i64 424, !17, i64 488, !12, i64 552}
!19 = !{!"_ZTSN11alglib_impl9knnbufferE", !18, i64 0, !17, i64 560, !17, i64 624, !17, i64 688, !15, i64 752}
!20 = !{!11, !11, i64 0}
!21 = !{!7, !7, i64 0}
!22 = !{!12, !12, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
define dso_local noundef double @_ZN11alglib_impl11knnprocess0EPNS_8knnmodelEPNS_9ae_vectorEPNS_8ae_stateE(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %.not.not12 = icmp sgt i64 %4, 0
  br i1 %.not.not12, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %5 = getelementptr inbounds i8, ptr %1, i64 56
  %6 = getelementptr inbounds i8, ptr %0, i64 1656
  %xtraiter = and i64 %4, 3
  %7 = icmp ult i64 %4, 4
  br i1 %7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %4, 9223372036854775804
  br label %8

8:                                                ; preds = %8, %.lr.ph.new
  %.013 = phi i64 [ 0, %.lr.ph.new ], [ %32, %8 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.3, %8 ]
  %9 = load ptr, ptr %5, align 8, !tbaa !19
  %10 = getelementptr inbounds double, ptr %9, i64 %.013
  %11 = load double, ptr %10, align 8, !tbaa !20
  %12 = load ptr, ptr %6, align 8, !tbaa !19
  %13 = getelementptr inbounds double, ptr %12, i64 %.013
  store double %11, ptr %13, align 8, !tbaa !20
  %14 = or disjoint i64 %.013, 1
  %15 = load ptr, ptr %5, align 8, !tbaa !19
  %16 = getelementptr inbounds double, ptr %15, i64 %14
  %17 = load double, ptr %16, align 8, !tbaa !20
  %18 = load ptr, ptr %6, align 8, !tbaa !19
  %19 = getelementptr inbounds double, ptr %18, i64 %14
  store double %17, ptr %19, align 8, !tbaa !20
  %20 = or disjoint i64 %.013, 2
  %21 = load ptr, ptr %5, align 8, !tbaa !19
  %22 = getelementptr inbounds double, ptr %21, i64 %20
  %23 = load double, ptr %22, align 8, !tbaa !20
  %24 = load ptr, ptr %6, align 8, !tbaa !19
  %25 = getelementptr inbounds double, ptr %24, i64 %20
  store double %23, ptr %25, align 8, !tbaa !20
  %26 = or disjoint i64 %.013, 3
  %27 = load ptr, ptr %5, align 8, !tbaa !19
  %28 = getelementptr inbounds double, ptr %27, i64 %26
  %29 = load double, ptr %28, align 8, !tbaa !20
  %30 = load ptr, ptr %6, align 8, !tbaa !19
  %31 = getelementptr inbounds double, ptr %30, i64 %26
  store double %29, ptr %31, align 8, !tbaa !20
  %32 = add nuw nsw i64 %.013, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %8, !llvm.loop !21

._crit_edge.loopexit.unr-lcssa:                   ; preds = %8, %.lr.ph
  %.013.unr = phi i64 [ 0, %.lr.ph ], [ %32, %8 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader
  %.013.epil = phi i64 [ %38, %.epil.preheader ], [ %.013.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %33 = load ptr, ptr %5, align 8, !tbaa !19
  %34 = getelementptr inbounds double, ptr %33, i64 %.013.epil
  %35 = load double, ptr %34, align 8, !tbaa !20
  %36 = load ptr, ptr %6, align 8, !tbaa !19
  %37 = getelementptr inbounds double, ptr %36, i64 %.013.epil
  store double %35, ptr %37, align 8, !tbaa !20
  %38 = add nuw nsw i64 %.013.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, label %.epil.preheader, !llvm.loop !23

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.epil.preheader, %3
  %39 = getelementptr inbounds i8, ptr %0, i64 1040
  tail call void @_ZN11alglib_implL19knn_processinternalEPNS_8knnmodelEPNS_9knnbufferEPNS_8ae_stateE(ptr noundef nonnull %0, ptr noundef nonnull %39, ptr noundef %2)
  %40 = getelementptr inbounds i8, ptr %0, i64 1720
  %41 = load ptr, ptr %40, align 8, !tbaa !19
  %42 = load double, ptr %41, align 8, !tbaa !20
  ret double %42
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN11alglib_implL19knn_processinternalEPNS_8knnmodelEPNS_9knnbufferEPNS_8ae_stateE(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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_impl8knnmodelE", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !11, i64 32, !11, i64 33, !12, i64 40, !18, i64 1040}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!"_ZTSN11alglib_impl6kdtreeE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !13, i64 32, !16, i64 112, !16, i64 176, !16, i64 240, !16, i64 304, !16, i64 368, !17, i64 432, !7, i64 992}
!13 = !{!"_ZTSN11alglib_impl9ae_matrixE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32, !14, i64 40, !8, i64 72}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!15 = !{!"any pointer", !8, i64 0}
!16 = !{!"_ZTSN11alglib_impl9ae_vectorE", !7, i64 0, !7, i64 8, !11, i64 16, !14, i64 24, !8, i64 56}
!17 = !{!"_ZTSN11alglib_impl19kdtreerequestbufferE", !16, i64 0, !16, i64 64, !16, i64 128, !7, i64 192, !10, i64 200, !11, i64 208, !10, i64 216, !7, i64 224, !16, i64 232, !16, i64 296, !16, i64 360, !16, i64 424, !16, i64 488, !10, i64 552}
!18 = !{!"_ZTSN11alglib_impl9knnbufferE", !17, i64 0, !16, i64 560, !16, i64 624, !16, i64 688, !13, i64 752}
!19 = !{!8, !8, i64 0}
!20 = !{!10, !10, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}


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