; LLVM IR from venumb/ZSPACE :: cpp/depends/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::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::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.1 }
%union.anon.1 = type { ptr }
%"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 }

; 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_impl21kdtreetsqueryresultsxEPNS_6kdtreeEPNS_19kdtreerequestbufferEPNS_9ae_matrixEPNS_8ae_stateE(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.alglib_impl::kdtreerequestbuffer", ptr %12, i32 0, i32 7
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %4
  store i32 1, ptr %11, align 4
  br label %85

17:                                               ; preds = %4
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %18, i32 0, i32 0
  %20 = load i64, ptr %19, align 8, !tbaa !16
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %"struct.alglib_impl::kdtreerequestbuffer", ptr %21, i32 0, i32 7
  %23 = load i64, ptr %22, align 8, !tbaa !9
  %24 = icmp slt i64 %20, %23
  br i1 %24, label %33, label %25

25:                                               ; preds = %17
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %26, i32 0, i32 1
  %28 = load i64, ptr %27, align 8, !tbaa !18
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.alglib_impl::kdtree", ptr %29, i32 0, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !19
  %32 = icmp slt i64 %28, %31
  br i1 %32, label %33, label %42

33:                                               ; preds = %25, %17
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.alglib_impl::kdtreerequestbuffer", ptr %35, i32 0, i32 7
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.alglib_impl::kdtree", ptr %38, i32 0, i32 1
  %40 = load i64, ptr %39, align 8, !tbaa !19
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef %34, i64 noundef %37, i64 noundef %40, ptr noundef %41)
  br label %42

42:                                               ; preds = %33, %25
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.alglib_impl::kdtreerequestbuffer", ptr %43, i32 0, i32 7
  %45 = load i64, ptr %44, align 8, !tbaa !9
  store i64 %45, ptr %10, align 8, !tbaa !21
  store i64 0, ptr %9, align 8, !tbaa !21
  br label %46

46:                                               ; preds = %81, %42
  %47 = load i64, ptr %9, align 8, !tbaa !21
  %48 = load i64, ptr %10, align 8, !tbaa !21
  %49 = sub nsw i64 %48, 1
  %50 = icmp sle i64 %47, %49
  br i1 %50, label %51, label %84

51:                                               ; preds = %46
  %52 = load ptr, ptr %7, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %52, i32 0, i32 6
  %54 = load ptr, ptr %53, align 8, !tbaa !22
  %55 = load i64, ptr %9, align 8, !tbaa !21
  %56 = getelementptr inbounds ptr, ptr %54, i64 %55
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  %58 = getelementptr inbounds double, ptr %57, i64 0
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.alglib_impl::kdtree", ptr %59, i32 0, i32 4
  %61 = getelementptr inbounds %"struct.alglib_impl::ae_matrix", ptr %60, i32 0, i32 6
  %62 = load ptr, ptr %61, align 8, !tbaa !22
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %"struct.alglib_impl::kdtreerequestbuffer", ptr %63, i32 0, i32 8
  %65 = getelementptr inbounds %"struct.alglib_impl::ae_vector", ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !22
  %67 = load i64, ptr %9, align 8, !tbaa !21
  %68 = getelementptr inbounds i64, ptr %66, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !21
  %70 = getelementptr inbounds ptr, ptr %62, i64 %69
  %71 = load ptr, ptr %70, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.alglib_impl::kdtree", ptr %72, i32 0, i32 1
  %74 = load i64, ptr %73, align 8, !tbaa !19
  %75 = getelementptr inbounds double, ptr %71, i64 %74
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.alglib_impl::kdtree", ptr %76, i32 0, i32 1
  %78 = load i64, ptr %77, align 8, !tbaa !19
  %79 = sub nsw i64 %78, 1
  %80 = call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef 0, i64 noundef %79)
  call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef %58, i64 noundef 1, ptr noundef %75, i64 noundef 1, i64 noundef %80)
  br label %81

81:                                               ; preds = %51
  %82 = load i64, ptr %9, align 8, !tbaa !21
  %83 = add nsw i64 %82, 1
  store i64 %83, ptr %9, align 8, !tbaa !21
  br label %46, !llvm.loop !23

84:                                               ; preds = %46
  store i32 0, ptr %11, align 4
  br label %85

85:                                               ; preds = %84, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %86 = load i32, ptr %11, align 4
  switch i32 %86, label %88 [
    i32 0, label %87
    i32 1, label %87
  ]

87:                                               ; preds = %85, %85
  ret void

88:                                               ; preds = %85
  unreachable
}

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

declare noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef, i64 noundef) #2

declare void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef, i64 noundef, i64 noundef, 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, !12, i64 224}
!10 = !{!"_ZTSN11alglib_impl19kdtreerequestbufferE", !11, i64 0, !11, i64 64, !11, i64 128, !12, i64 192, !15, i64 200, !13, i64 208, !15, i64 216, !12, i64 224, !11, i64 232, !11, i64 296, !11, i64 360, !11, i64 424, !11, i64 488, !15, i64 552}
!11 = !{!"_ZTSN11alglib_impl9ae_vectorE", !12, i64 0, !12, i64 8, !13, i64 16, !14, i64 24, !7, i64 56}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"_ZTSN11alglib_impl12ae_dyn_blockE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!15 = !{!"double", !7, i64 0}
!16 = !{!17, !12, i64 0}
!17 = !{!"_ZTSN11alglib_impl9ae_matrixE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !13, i64 32, !14, i64 40, !7, i64 72}
!18 = !{!17, !12, i64 8}
!19 = !{!20, !12, i64 8}
!20 = !{!"_ZTSN11alglib_impl6kdtreeE", !12, i64 0, !12, i64 8, !12, i64 16, !12, i64 24, !17, i64 32, !11, i64 112, !11, i64 176, !11, i64 240, !11, i64 304, !11, i64 368, !10, i64 432, !12, i64 992}
!21 = !{!12, !12, i64 0}
!22 = !{!7, !7, 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 void @_ZN11alglib_impl21kdtreetsqueryresultsxEPNS_6kdtreeEPNS_19kdtreerequestbufferEPNS_9ae_matrixEPNS_8ae_stateE(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 224
  %6 = load i64, ptr %5, align 8, !tbaa !5
  %7 = icmp eq i64 %6, 0
  br i1 %7, label %.loopexit, label %8

8:                                                ; preds = %4
  %9 = load i64, ptr %2, align 8, !tbaa !15
  %10 = icmp slt i64 %9, %6
  br i1 %10, label %._crit_edge, label %11

._crit_edge:                                      ; preds = %8
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 8
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !17
  br label %17

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %2, i64 8
  %13 = load i64, ptr %12, align 8, !tbaa !19
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !17
  %16 = icmp slt i64 %13, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %._crit_edge, %11
  %18 = phi i64 [ %.pre, %._crit_edge ], [ %15, %11 ]
  tail call void @_ZN11alglib_impl20ae_matrix_set_lengthEPNS_9ae_matrixEllPNS_8ae_stateE(ptr noundef nonnull %2, i64 noundef %6, i64 noundef %18, ptr noundef %3)
  %.pre22 = load i64, ptr %5, align 8, !tbaa !5
  br label %19

19:                                               ; preds = %17, %11
  %20 = phi i64 [ %.pre22, %17 ], [ %6, %11 ]
  %.not.not20 = icmp sgt i64 %20, 0
  br i1 %.not.not20, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %19
  %21 = getelementptr inbounds i8, ptr %2, i64 72
  %22 = getelementptr inbounds i8, ptr %0, i64 104
  %23 = getelementptr inbounds i8, ptr %1, i64 288
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  br label %25

25:                                               ; preds = %.lr.ph, %25
  %.021 = phi i64 [ 0, %.lr.ph ], [ %39, %25 ]
  %26 = load ptr, ptr %21, align 8, !tbaa !20
  %27 = getelementptr inbounds ptr, ptr %26, i64 %.021
  %28 = load ptr, ptr %27, align 8, !tbaa !21
  %29 = load ptr, ptr %22, align 8, !tbaa !20
  %30 = load ptr, ptr %23, align 8, !tbaa !20
  %31 = getelementptr inbounds i64, ptr %30, i64 %.021
  %32 = load i64, ptr %31, align 8, !tbaa !22
  %33 = getelementptr inbounds ptr, ptr %29, i64 %32
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  %35 = load i64, ptr %24, align 8, !tbaa !17
  %36 = getelementptr inbounds double, ptr %34, i64 %35
  %37 = add nsw i64 %35, -1
  %38 = tail call noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef 0, i64 noundef %37)
  tail call void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef %28, i64 noundef 1, ptr noundef %36, i64 noundef 1, i64 noundef %38)
  %39 = add nuw nsw i64 %.021, 1
  %exitcond.not = icmp eq i64 %39, %20
  br i1 %exitcond.not, label %.loopexit, label %25, !llvm.loop !23

.loopexit:                                        ; preds = %25, %19, %4
  ret void
}

declare void @_ZN11alglib_impl9ae_v_moveEPdlPKdll(ptr noundef, i64 noundef, ptr noundef, i64 noundef, i64 noundef) local_unnamed_addr #1

declare noundef i64 @_ZN11alglib_impl8ae_v_lenEll(i64 noundef, i64 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 #1

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


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