; LLVM IR from neondatabase-labs/pg_embedding :: hnswalg.ll (Z9searchKnnP12HnswMetadataPKfm)

; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::priority_queue.5" = type <{ %"class.std::vector.6", [8 x i8] }>
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { float, i32 }
%"struct.std::pair.12" = type { float, i64 }

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

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

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #2 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) #3

declare zeroext i1 @hnsw_begin_read(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #4

declare void @hnsw_end_read(ptr noundef) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #5 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL15searchBaseLayerP12HnswMetadataPKfm(ptr dead_on_unwind noalias writable sret(%"class.std::priority_queue") align 8, ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9searchKnnP12HnswMetadataPKfm(ptr dead_on_unwind noalias writable sret(%"class.std::priority_queue.5") align 8 %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) #2 personality ptr @__gxx_personality_v0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i1, align 1
  %10 = alloca %"class.std::priority_queue", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %"struct.std::pair", align 4
  %14 = alloca i64, align 8
  %15 = alloca %"struct.std::pair.12", align 8
  store ptr %0, ptr %5, align 8
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i64 %3, ptr %8, align 8, !tbaa !9
  store i1 false, ptr %9, align 1
  call void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %0)
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #6
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = load i64, ptr %8, align 8, !tbaa !9
  invoke void @_ZL15searchBaseLayerP12HnswMetadataPKfm(ptr dead_on_unwind writable sret(%"class.std::priority_queue") align 8 %10, ptr noundef %16, ptr noundef %17, i64 noundef %18)
          to label %19 unwind label %27

19:                                               ; preds = %4
  br label %20

20:                                               ; preds = %26, %19
  %21 = invoke noundef i64 @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %10)
          to label %22 unwind label %31

22:                                               ; preds = %20
  %23 = load i64, ptr %8, align 8, !tbaa !9
  %24 = icmp ugt i64 %21, %23
  br i1 %24, label %25, label %35

25:                                               ; preds = %22
  invoke void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %10)
          to label %26 unwind label %31

26:                                               ; preds = %25
  br label %20, !llvm.loop !11

27:                                               ; preds = %4
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %11, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %12, align 4
  br label %76

31:                                               ; preds = %36, %25, %20
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %11, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %12, align 4
  br label %75

35:                                               ; preds = %22
  br label %36

36:                                               ; preds = %70, %35
  %37 = invoke noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %10)
          to label %38 unwind label %31

38:                                               ; preds = %36
  %39 = xor i1 %37, true
  br i1 %39, label %40, label %73

40:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %41 = invoke noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %10)
          to label %42 unwind label %55

42:                                               ; preds = %40
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %41, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 1
  %45 = load i32, ptr %44, align 4, !tbaa !13
  %46 = invoke zeroext i1 @hnsw_begin_read(ptr noundef %43, i32 noundef %45, ptr noundef null, ptr noundef null, ptr noundef %14)
          to label %47 unwind label %59

47:                                               ; preds = %42
  %48 = load i64, ptr %14, align 8, !tbaa !9
  %49 = invoke zeroext i1 @hnsw_is_deleted(i64 noundef %48)
          to label %50 unwind label %59

50:                                               ; preds = %47
  br i1 %49, label %67, label %51

51:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #6
  %52 = getelementptr inbounds %"struct.std::pair", ptr %13, i32 0, i32 0
  invoke void @_ZNSt4pairIfmEC2IRfRmTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 4 dereferenceable(4) %52, ptr noundef nonnull align 8 dereferenceable(8) %14)
          to label %53 unwind label %63

53:                                               ; preds = %51
  invoke void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %0, ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %54 unwind label %63

54:                                               ; preds = %53
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  br label %67

55:                                               ; preds = %40
  %56 = landingpad { ptr, i32 }
          cleanup
  %57 = extractvalue { ptr, i32 } %56, 0
  store ptr %57, ptr %11, align 8
  %58 = extractvalue { ptr, i32 } %56, 1
  store i32 %58, ptr %12, align 4
  br label %72

59:                                               ; preds = %68, %67, %47, %42
  %60 = landingpad { ptr, i32 }
          cleanup
  %61 = extractvalue { ptr, i32 } %60, 0
  store ptr %61, ptr %11, align 8
  %62 = extractvalue { ptr, i32 } %60, 1
  store i32 %62, ptr %12, align 4
  br label %71

63:                                               ; preds = %53, %51
  %64 = landingpad { ptr, i32 }
          cleanup
  %65 = extractvalue { ptr, i32 } %64, 0
  store ptr %65, ptr %11, align 8
  %66 = extractvalue { ptr, i32 } %64, 1
  store i32 %66, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #6
  br label %71

67:                                               ; preds = %54, %50
  invoke void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %10)
          to label %68 unwind label %59

68:                                               ; preds = %67
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  invoke void @hnsw_end_read(ptr noundef %69)
          to label %70 unwind label %59

70:                                               ; preds = %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %36, !llvm.loop !17

71:                                               ; preds = %63, %59
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  br label %72

72:                                               ; preds = %71, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  br label %75

73:                                               ; preds = %38
  store i1 true, ptr %9, align 1
  call void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %10) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #6
  %74 = load i1, ptr %9, align 1
  br i1 %74, label %78, label %77

75:                                               ; preds = %72, %31
  call void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %10) #6
  br label %76

76:                                               ; preds = %75, %27
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #6
  call void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %0) #6
  br label %79

77:                                               ; preds = %73
  call void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %0) #6
  br label %78

78:                                               ; preds = %77, %73
  ret void

79:                                               ; preds = %76
  %80 = load ptr, ptr %11, align 8
  %81 = load i32, ptr %12, align 4
  %82 = insertvalue { ptr, i32 } poison, ptr %80, 0
  %83 = insertvalue { ptr, i32 } %82, i32 %81, 1
  resume { ptr, i32 } %83
}

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

declare zeroext i1 @hnsw_is_deleted(i64 noundef) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(16)) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #5 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { "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 = { 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 #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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !16, i64 4}
!14 = !{!"_ZTSSt4pairIfjE", !15, i64 0, !16, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = distinct !{!17, !12}


; 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::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<float, unsigned int>, std::allocator<std::pair<float, unsigned int>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::priority_queue.5" = type <{ %"class.std::vector.6", [8 x i8] }>
%"class.std::vector.6" = type { %"struct.std::_Vector_base.7" }
%"struct.std::_Vector_base.7" = type { %"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<float, unsigned long>, std::allocator<std::pair<float, unsigned long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::pair" = type { float, i32 }
%"struct.std::pair.12" = type { float, i64 }

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

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) 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) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #2 align 2

declare zeroext i1 @hnsw_begin_read(ptr noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @hnsw_end_read(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #4 align 2

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

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL15searchBaseLayerP12HnswMetadataPKfm(ptr dead_on_unwind noalias writable sret(%"class.std::priority_queue") align 8, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z9searchKnnP12HnswMetadataPKfm(ptr dead_on_unwind noalias nonnull writable sret(%"class.std::priority_queue.5") align 8 %0, ptr noundef %1, ptr noundef %2, i64 noundef %3) local_unnamed_addr #2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.std::priority_queue", align 8
  %6 = alloca %"struct.std::pair", align 8
  %7 = alloca i64, align 8
  %8 = alloca %"struct.std::pair.12", align 8
  tail call void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EEC2IS4_vEEv(ptr noundef nonnull align 8 dereferenceable(25) %0)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #5
  invoke void @_ZL15searchBaseLayerP12HnswMetadataPKfm(ptr dead_on_unwind nonnull writable sret(%"class.std::priority_queue") align 8 %5, ptr noundef %1, ptr noundef %2, i64 noundef %3)
          to label %.preheader15 unwind label %13

.preheader15:                                     ; preds = %4, %12
  %9 = call noundef i64 @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
  %10 = icmp ugt i64 %9, %3
  br i1 %10, label %12, label %.preheader

.preheader:                                       ; preds = %.preheader15
  %11 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
  br i1 %11, label %._crit_edge, label %.lr.ph

12:                                               ; preds = %.preheader15
  invoke void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
          to label %.preheader15 unwind label %15, !llvm.loop !5

13:                                               ; preds = %4
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %38

15:                                               ; preds = %12
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %37

.lr.ph:                                           ; preds = %.preheader, %34
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %17 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
  %18 = load i64, ptr %17, align 4
  store i64 %18, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #5
  %19 = lshr i64 %18, 32
  %20 = trunc nuw i64 %19 to i32
  %21 = invoke zeroext i1 @hnsw_begin_read(ptr noundef %1, i32 noundef %20, ptr noundef null, ptr noundef null, ptr noundef nonnull %7)
          to label %22 unwind label %28

22:                                               ; preds = %.lr.ph
  %23 = load i64, ptr %7, align 8, !tbaa !7
  %24 = invoke zeroext i1 @hnsw_is_deleted(i64 noundef %23)
          to label %25 unwind label %28

25:                                               ; preds = %22
  br i1 %24, label %32, label %26

26:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #5
  call void @_ZNSt4pairIfmEC2IRfRmTnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS5_S6_EEEbE4typeELb1EEEOS5_OS6_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 8 dereferenceable(8) %7)
  invoke void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25) %0, ptr noundef nonnull align 8 dereferenceable(16) %8)
          to label %27 unwind label %30

27:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  br label %32

28:                                               ; preds = %33, %32, %22, %.lr.ph
  %29 = landingpad { ptr, i32 }
          cleanup
  br label %36

30:                                               ; preds = %26
  %31 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #5
  br label %36

32:                                               ; preds = %27, %25
  invoke void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
          to label %33 unwind label %28

33:                                               ; preds = %32
  invoke void @hnsw_end_read(ptr noundef %1)
          to label %34 unwind label %28

34:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  %35 = call noundef zeroext i1 @_ZNKSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(25) %5)
  br i1 %35, label %._crit_edge, label %.lr.ph, !llvm.loop !11

36:                                               ; preds = %30, %28
  %.pn = phi { ptr, i32 } [ %29, %28 ], [ %31, %30 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  br label %37

._crit_edge:                                      ; preds = %34, %.preheader
  call void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %5) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  ret void

37:                                               ; preds = %36, %15
  %.pn12 = phi { ptr, i32 } [ %16, %15 ], [ %.pn, %36 ]
  call void @_ZNSt14priority_queueISt4pairIfjESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %5) #5
  br label %38

38:                                               ; preds = %37, %13
  %.pn12.pn = phi { ptr, i32 } [ %.pn12, %37 ], [ %14, %13 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #5
  call void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25) %0) #5
  resume { ptr, i32 } %.pn12.pn
}

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

declare zeroext i1 @hnsw_is_deleted(i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EE4pushEOS1_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZNSt14priority_queueISt4pairIfmESt6vectorIS1_SaIS1_EESt4lessIS1_EED2Ev(ptr noundef nonnull align 8 dereferenceable(25)) unnamed_addr #4 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 #4 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


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