; LLVM IR from PuYuuu/CppRobotics :: utils/src (KDTree)

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

%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.std::pair" = type { %"class.std::vector", i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.KDTree = type { %"class.std::shared_ptr", %"class.std::shared_ptr" }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12NewKDNodePtrv(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #1 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %17 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %18 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %19 = alloca i64, align 8
  %20 = alloca i64, align 8
  %21 = alloca %"class.std::shared_ptr", align 8
  %22 = alloca %"class.std::shared_ptr", align 8
  %23 = alloca i64, align 8
  %24 = alloca ptr, align 8
  %25 = alloca i32, align 4
  %26 = alloca %"class.std::shared_ptr", align 8
  %27 = alloca %"class.std::shared_ptr", align 8
  %28 = alloca i64, align 8
  store ptr %0, ptr %7, align 8
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  store ptr %5, ptr %12, align 8, !tbaa !5
  %29 = load ptr, ptr %8, align 8
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = call noundef zeroext i1 @_ZN9__gnu_cxxeqIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEEbRKNS_17__normal_iteratorIT_T0_EESE_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef nonnull align 8 dereferenceable(8) %31) #6
  br i1 %32, label %33, label %34

33:                                               ; preds = %6
  call void @_Z12NewKDNodePtrv(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %0)
  br label %116

34:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %35) #6
  %37 = getelementptr inbounds %"struct.std::pair", ptr %36, i32 0, i32 0
  %38 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %37) #6
  store i64 %38, ptr %13, align 8, !tbaa !9
  %39 = load ptr, ptr %11, align 8, !tbaa !5
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = icmp ugt i64 %40, 1
  br i1 %41, label %42, label %47

42:                                               ; preds = %34
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load ptr, ptr %12, align 8, !tbaa !5
  %46 = load i64, ptr %45, align 8, !tbaa !9
  call void @_Z11sort_on_idxRKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEESB_m(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull align 8 dereferenceable(8) %44, i64 noundef %46)
  br label %47

47:                                               ; preds = %42, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = udiv i64 %50, 2
  %52 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %48, i64 noundef %51) #6
  %53 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %14, i32 0, i32 0
  store ptr %52, ptr %53, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %54, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %14, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %55 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %14, i64 noundef 1) #6
  %56 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %17, i32 0, i32 0
  store ptr %55, ptr %56, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %57 = load ptr, ptr %10, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %57, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #6
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %60 = udiv i64 %59, 2
  store i64 %60, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = load i64, ptr %61, align 8, !tbaa !9
  %63 = load i64, ptr %19, align 8, !tbaa !9
  %64 = sub i64 %62, %63
  %65 = sub i64 %64, 1
  store i64 %65, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #6
  call void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %21) #6
  %66 = load i64, ptr %19, align 8, !tbaa !9
  %67 = icmp ugt i64 %66, 0
  br i1 %67, label %68, label %83

68:                                               ; preds = %47
  %69 = load i64, ptr %13, align 8, !tbaa !9
  %70 = icmp ugt i64 %69, 0
  br i1 %70, label %71, label %83

71:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 16, ptr %22) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #6
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load i64, ptr %72, align 8, !tbaa !9
  %74 = add i64 %73, 1
  %75 = load i64, ptr %13, align 8, !tbaa !9
  %76 = urem i64 %74, %75
  store i64 %76, ptr %23, align 8, !tbaa !9
  invoke void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %22, ptr noundef nonnull align 8 dereferenceable(32) %29, ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %16, ptr noundef nonnull align 8 dereferenceable(8) %19, ptr noundef nonnull align 8 dereferenceable(8) %23)
          to label %77 unwind label %79

77:                                               ; preds = %71
  %78 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %22) #6
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %22) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #6
  br label %86

79:                                               ; preds = %71
  %80 = landingpad { ptr, i32 }
          cleanup
  %81 = extractvalue { ptr, i32 } %80, 0
  store ptr %81, ptr %24, align 8
  %82 = extractvalue { ptr, i32 } %80, 1
  store i32 %82, ptr %25, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %22) #6
  br label %115

83:                                               ; preds = %68, %47
  %84 = getelementptr inbounds %class.KDTree, ptr %29, i32 0, i32 1
  %85 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %84) #6
  br label %86

86:                                               ; preds = %83, %77
  call void @llvm.lifetime.start.p0(i64 16, ptr %26) #6
  call void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %26) #6
  %87 = load i64, ptr %20, align 8, !tbaa !9
  %88 = icmp ugt i64 %87, 0
  br i1 %88, label %89, label %104

89:                                               ; preds = %86
  %90 = load i64, ptr %13, align 8, !tbaa !9
  %91 = icmp ugt i64 %90, 0
  br i1 %91, label %92, label %104

92:                                               ; preds = %89
  call void @llvm.lifetime.start.p0(i64 16, ptr %27) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %28) #6
  %93 = load ptr, ptr %12, align 8, !tbaa !5
  %94 = load i64, ptr %93, align 8, !tbaa !9
  %95 = add i64 %94, 1
  %96 = load i64, ptr %13, align 8, !tbaa !9
  %97 = urem i64 %95, %96
  store i64 %97, ptr %28, align 8, !tbaa !9
  invoke void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %27, ptr noundef nonnull align 8 dereferenceable(32) %29, ptr noundef nonnull align 8 dereferenceable(8) %17, ptr noundef nonnull align 8 dereferenceable(8) %18, ptr noundef nonnull align 8 dereferenceable(8) %20, ptr noundef nonnull align 8 dereferenceable(8) %28)
          to label %98 unwind label %100

98:                                               ; preds = %92
  %99 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %27) #6
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %27) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %27) #6
  br label %107

100:                                              ; preds = %92
  %101 = landingpad { ptr, i32 }
          cleanup
  %102 = extractvalue { ptr, i32 } %101, 0
  store ptr %102, ptr %24, align 8
  %103 = extractvalue { ptr, i32 } %101, 1
  store i32 %103, ptr %25, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %28) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %27) #6
  br label %114

104:                                              ; preds = %89, %86
  %105 = getelementptr inbounds %class.KDTree, ptr %29, i32 0, i32 1
  %106 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %105) #6
  br label %107

107:                                              ; preds = %104, %98
  %108 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %14) #6
  invoke void @_ZSt11make_sharedI6KDNodeJRSt4pairISt6vectorIdSaIdEEmERSt10shared_ptrIS0_ES9_EES7_INSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %108, ptr noundef nonnull align 8 dereferenceable(16) %21, ptr noundef nonnull align 8 dereferenceable(16) %26)
          to label %109 unwind label %110

109:                                              ; preds = %107
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %26) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %26) #6
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %21) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %116

110:                                              ; preds = %107
  %111 = landingpad { ptr, i32 }
          cleanup
  %112 = extractvalue { ptr, i32 } %111, 0
  store ptr %112, ptr %24, align 8
  %113 = extractvalue { ptr, i32 } %111, 1
  store i32 %113, ptr %25, align 4
  br label %114

114:                                              ; preds = %110, %100
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %26) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %26) #6
  br label %115

115:                                              ; preds = %114, %79
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %21) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %117

116:                                              ; preds = %109, %33
  ret void

117:                                              ; preds = %115
  %118 = load ptr, ptr %24, align 8
  %119 = load i32, ptr %25, align 4
  %120 = insertvalue { ptr, i32 } poison, ptr %118, 0
  %121 = insertvalue { ptr, i32 } %120, i32 %119, 1
  resume { ptr, i32 } %121
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxeqIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEEbRKNS_17__normal_iteratorIT_T0_EESE_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z11sort_on_idxRKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEESB_m(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11make_sharedI6KDNodeJRSt4pairISt6vectorIdSaIdEEmERSt10shared_ptrIS0_ES9_EES7_INSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

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 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 = { inlinehint 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 #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{i64 0, i64 8, !5}


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

%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z12NewKDNodePtrv(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %4, ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %5) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %9 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %10 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %11 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca %"class.std::shared_ptr", align 8
  %15 = alloca %"class.std::shared_ptr", align 8
  %16 = alloca i64, align 8
  %17 = alloca %"class.std::shared_ptr", align 8
  %18 = alloca %"class.std::shared_ptr", align 8
  %19 = alloca i64, align 8
  %20 = tail call noundef zeroext i1 @_ZN9__gnu_cxxeqIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEEbRKNS_17__normal_iteratorIT_T0_EESE_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #5
  br i1 %20, label %21, label %22

21:                                               ; preds = %6
  tail call void @_Z12NewKDNodePtrv(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %0)
  br label %73

22:                                               ; preds = %6
  %23 = tail call noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #5
  %24 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #5
  %25 = load i64, ptr %4, align 8, !tbaa !5
  %26 = icmp ugt i64 %25, 1
  br i1 %26, label %27, label %29

27:                                               ; preds = %22
  %28 = load i64, ptr %5, align 8, !tbaa !5
  tail call void @_Z11sort_on_idxRKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEESB_m(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %28)
  %.pre = load i64, ptr %4, align 8, !tbaa !5
  br label %29

29:                                               ; preds = %27, %22
  %30 = phi i64 [ %.pre, %27 ], [ %25, %22 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %31 = lshr i64 %30, 1
  %32 = tail call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %2, i64 noundef %31) #5
  store ptr %32, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #5
  %33 = load i64, ptr %2, align 8, !tbaa !9
  store i64 %33, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #5
  %.cast = ptrtoint ptr %32 to i64
  store i64 %.cast, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %10) #5
  %34 = call ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8) %7, i64 noundef 1) #5
  store ptr %34, ptr %10, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %35 = load i64, ptr %3, align 8, !tbaa !9
  store i64 %35, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %12) #5
  %36 = load i64, ptr %4, align 8, !tbaa !5
  %37 = lshr i64 %36, 1
  store i64 %37, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %13) #5
  %38 = xor i64 %37, -1
  %39 = add i64 %36, %38
  store i64 %39, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %14) #5
  call void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #5
  %40 = icmp ugt i64 %36, 1
  %41 = icmp ne i64 %24, 0
  %or.cond = and i1 %41, %40
  br i1 %or.cond, label %42, label %50

42:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %16) #5
  %43 = load i64, ptr %5, align 8, !tbaa !5
  %44 = add i64 %43, 1
  %45 = urem i64 %44, %24
  store i64 %45, ptr %16, align 8, !tbaa !5
  invoke void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr") align 8 %15, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9, ptr noundef nonnull align 8 dereferenceable(8) %12, ptr noundef nonnull align 8 dereferenceable(8) %16)
          to label %46 unwind label %48

46:                                               ; preds = %42
  %47 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #5
  br label %53

48:                                               ; preds = %42
  %49 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %16) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %15) #5
  br label %72

50:                                               ; preds = %29
  %51 = getelementptr inbounds i8, ptr %1, i64 16
  %52 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(16) %51) #5
  br label %53

53:                                               ; preds = %50, %46
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %17) #5
  call void @_ZNSt10shared_ptrI6KDNodeEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #5
  %54 = icmp ne i64 %39, 0
  %or.cond3 = and i1 %41, %54
  br i1 %or.cond3, label %55, label %63

55:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %19) #5
  %56 = load i64, ptr %5, align 8, !tbaa !5
  %57 = add i64 %56, 1
  %58 = urem i64 %57, %24
  store i64 %58, ptr %19, align 8, !tbaa !5
  invoke void @_ZN6KDTree9make_treeERKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES3_IS6_SaIS6_EEEESC_RKmSE_(ptr dead_on_unwind nonnull writable sret(%"class.std::shared_ptr") align 8 %18, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(8) %10, ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %13, ptr noundef nonnull align 8 dereferenceable(8) %19)
          to label %59 unwind label %61

59:                                               ; preds = %55
  %60 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(16) %18) #5
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %19) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %18) #5
  br label %66

61:                                               ; preds = %55
  %62 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %19) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %18) #5
  br label %71

63:                                               ; preds = %53
  %64 = getelementptr inbounds i8, ptr %1, i64 16
  %65 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSERKS1_(ptr noundef nonnull align 8 dereferenceable(16) %17, ptr noundef nonnull align 8 dereferenceable(16) %64) #5
  br label %66

66:                                               ; preds = %63, %59
  %67 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %7) #5
  invoke void @_ZSt11make_sharedI6KDNodeJRSt4pairISt6vectorIdSaIdEEmERSt10shared_ptrIS0_ES9_EES7_INSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind writable sret(%"class.std::shared_ptr") align 8 %0, ptr noundef nonnull align 8 dereferenceable(32) %67, ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(16) %17)
          to label %68 unwind label %69

68:                                               ; preds = %66
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %17) #5
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  br label %73

69:                                               ; preds = %66
  %70 = landingpad { ptr, i32 }
          cleanup
  br label %71

71:                                               ; preds = %69, %61
  %.pn = phi { ptr, i32 } [ %70, %69 ], [ %62, %61 ]
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %17) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %17) #5
  br label %72

72:                                               ; preds = %71, %48
  %.pn.pn = phi { ptr, i32 } [ %.pn, %71 ], [ %49, %48 ]
  call void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %14) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  resume { ptr, i32 } %.pn.pn

73:                                               ; preds = %68, %21
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxeqIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEEbRKNS_17__normal_iteratorIT_T0_EESE_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEptEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z11sort_on_idxRKN9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEESB_m(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEplEl(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrI6KDNodeEaSEOS1_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt11make_sharedI6KDNodeJRSt4pairISt6vectorIdSaIdEEmERSt10shared_ptrIS0_ES9_EES7_INSt9enable_ifIXntsr8is_arrayIT_EE5valueESB_E4typeEEDpOT0_(ptr dead_on_unwind noalias writable sret(%"class.std::shared_ptr") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPSt4pairISt6vectorIdSaIdEEmES2_IS5_SaIS5_EEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrI6KDNodeLN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #0 align 2

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 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 = { inlinehint 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 #3 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 #5 = { 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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass