; LLVM IR from weicao/cascadb :: src/tree/msg.ll (ZN7cascadb6MsgBuf6appendENS_10FastVectorINS_3MsgELi32EE8IteratorES4_)

; 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.cascadb::FastVector<cascadb::Msg>::Iterator" = type { ptr, i64, i64 }
%"class.cascadb::KeyComp" = type { ptr }
%"class.cascadb::MsgBuf" = type { ptr, %"class.cascadb::RWLock", %"class.cascadb::FastVector", i64 }
%"class.cascadb::RWLock" = type { %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%"class.cascadb::FastVector" = type { %"class.std::vector", i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<cascadb::Msg> *, std::allocator<std::vector<cascadb::Msg> *>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<cascadb::Msg> *, std::allocator<std::vector<cascadb::Msg> *>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<cascadb::Msg> *, std::allocator<std::vector<cascadb::Msg> *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<cascadb::Msg> *, std::allocator<std::vector<cascadb::Msg> *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.cascadb::Msg" = type { i32, [4 x i8], %"class.cascadb::Slice", %"class.cascadb::Slice" }
%"class.cascadb::Slice" = type <{ ptr, i32, [4 x i8] }>

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

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

; 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 @_ZN7cascadb3Msg7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE3endEv(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) #2 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7cascadbneERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE6insertENS2_8IteratorERKS1_(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(40)) #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) #4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cascadb6MsgBuf6appendENS_10FastVectorINS_3MsgELi32EE8IteratorES4_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %1, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %2) #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %6 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %7 = alloca %"class.cascadb::KeyComp", align 8
  %8 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %9 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %10 = alloca %"class.cascadb::KeyComp", align 8
  %11 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %12 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %13 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr %5) #5
  %15 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 2
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE5beginEv(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %5, ptr noundef nonnull align 8 dereferenceable(32) %15)
  call void @llvm.lifetime.start.p0(i64 24, ptr %6) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %1, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %16 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !12
  call void @_ZN7cascadb7KeyCompC2EPNS_10ComparatorE(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef %17)
  br label %18

18:                                               ; preds = %58, %3
  %19 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %2)
  br i1 %19, label %20, label %60

20:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #5
  %21 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %5, i64 24, i1 false), !tbaa.struct !9
  %22 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %23 = getelementptr inbounds %"class.cascadb::Msg", ptr %22, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %7, i64 8, i1 false), !tbaa.struct !20
  %24 = getelementptr inbounds %"class.cascadb::KeyComp", ptr %10, i32 0, i32 0
  %25 = load ptr, ptr %24, align 8
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE11lower_boundINS_5SliceENS_7KeyCompEEENS2_8IteratorES6_RKT_T0_(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %8, ptr noundef nonnull align 8 dereferenceable(32) %21, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(12) %23, ptr %25)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %8, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  %26 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 2
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE3endEv(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %11, ptr noundef nonnull align 8 dereferenceable(32) %26)
  %27 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratoreqERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %11)
  br i1 %27, label %34, label %28

28:                                               ; preds = %20
  %29 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %30 = getelementptr inbounds %"class.cascadb::Msg", ptr %29, i32 0, i32 2
  %31 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %32 = getelementptr inbounds %"class.cascadb::Msg", ptr %31, i32 0, i32 2
  %33 = call noundef zeroext i1 @_ZN7cascadbneERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12) %30, ptr noundef nonnull align 8 dereferenceable(12) %32)
  br label %34

34:                                               ; preds = %28, %20
  %35 = phi i1 [ true, %20 ], [ %33, %28 ]
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  br i1 %35, label %36, label %44

36:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #5
  %37 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %5, i64 24, i1 false), !tbaa.struct !9
  %38 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE6insertENS2_8IteratorERKS1_(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %12, ptr noundef nonnull align 8 dereferenceable(32) %37, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %13, ptr noundef nonnull align 8 dereferenceable(40) %38)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %5, ptr align 8 %12, i64 24, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #5
  %39 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %40 = call noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %39)
  %41 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 3
  %42 = load i64, ptr %41, align 8, !tbaa !21
  %43 = add i64 %42, %40
  store i64 %43, ptr %41, align 8, !tbaa !21
  br label %58

44:                                               ; preds = %34
  %45 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %46 = call noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %45)
  %47 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 3
  %48 = load i64, ptr %47, align 8, !tbaa !21
  %49 = sub i64 %48, %46
  store i64 %49, ptr %47, align 8, !tbaa !21
  %50 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @_ZN7cascadb3Msg7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %50)
  %51 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %52 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %52, ptr align 8 %51, i64 40, i1 false), !tbaa.struct !22
  %53 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %54 = call noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %53)
  %55 = getelementptr inbounds %"class.cascadb::MsgBuf", ptr %14, i32 0, i32 3
  %56 = load i64, ptr %55, align 8, !tbaa !21
  %57 = add i64 %56, %54
  store i64 %57, ptr %55, align 8, !tbaa !21
  br label %58

58:                                               ; preds = %44, %36
  %59 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24) %6, i32 noundef 0)
  br label %18, !llvm.loop !27

60:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %5) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE11lower_boundINS_5SliceENS_7KeyCompEEENS2_8IteratorES6_RKT_T0_(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(12), ptr) #0 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 0, i64 8, !5, i64 8, i64 8, !10, i64 16, i64 8, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTSN7cascadb6MsgBufE", !6, i64 0, !14, i64 8, !15, i64 64, !11, i64 96}
!14 = !{!"_ZTSN7cascadb6RWLockE", !7, i64 0}
!15 = !{!"_ZTSN7cascadb10FastVectorINS_3MsgELi32EEE", !16, i64 0, !11, i64 24}
!16 = !{!"_ZTSSt6vectorIPS_IN7cascadb3MsgESaIS1_EESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!20 = !{i64 0, i64 8, !5}
!21 = !{!13, !11, i64 96}
!22 = !{i64 0, i64 4, !23, i64 8, i64 8, !5, i64 16, i64 4, !25, i64 24, i64 8, !5, i64 32, i64 4, !25}
!23 = !{!24, !24, i64 0}
!24 = !{!"_ZTSN7cascadb7MsgTypeE", !7, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"int", !7, i64 0}
!27 = distinct !{!27, !28}
!28 = !{!"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"

%"class.cascadb::FastVector<cascadb::Msg>::Iterator" = type { ptr, i64, i64 }
%"class.cascadb::KeyComp" = type { ptr }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40)) 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

; 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 @_ZN7cascadb3Msg7destroyEv(ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE5beginEv(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE3endEv(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef) local_unnamed_addr #2 align 2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7cascadbneERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE6insertENS2_8IteratorERKS1_(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress 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) #4

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN7cascadb6MsgBuf6appendENS_10FastVectorINS_3MsgELi32EE8IteratorES4_(ptr noundef nonnull align 8 dereferenceable(104) %0, ptr nocapture noundef readonly byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %1, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %2) local_unnamed_addr #0 align 2 {
  %4 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %5 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %6 = alloca %"class.cascadb::KeyComp", align 8
  %7 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %8 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %9 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %10 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %11 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  %12 = getelementptr inbounds i8, ptr %0, i64 64
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(32) %12)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %1, i64 24, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #5
  %13 = load ptr, ptr %0, align 8, !tbaa !12
  call void @_ZN7cascadb7KeyCompC2EPNS_10ComparatorE(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef %13)
  %14 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %2)
  br i1 %14, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %15 = getelementptr inbounds i8, ptr %0, i64 96
  br label %16

16:                                               ; preds = %.lr.ph, %36
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %8, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !5
  %17 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %18 = getelementptr inbounds i8, ptr %17, i64 8
  %.sroa.0.0.copyload = load ptr, ptr %6, align 8, !tbaa !6
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE11lower_boundINS_5SliceENS_7KeyCompEEENS2_8IteratorES6_RKT_T0_(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %8, ptr noundef nonnull align 8 dereferenceable(12) %18, ptr %.sroa.0.0.copyload)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %7, i64 24, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %9) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE3endEv(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(32) %12)
  %19 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratoreqERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %9)
  br i1 %19, label %.critedge, label %20

20:                                               ; preds = %16
  %21 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %22 = getelementptr inbounds i8, ptr %21, i64 8
  %23 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = call noundef zeroext i1 @_ZN7cascadbneERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12) %22, ptr noundef nonnull align 8 dereferenceable(12) %24)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %9) #5
  br i1 %25, label %26, label %28

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

26:                                               ; preds = %.critedge, %20
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %11, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !5
  %27 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE6insertENS2_8IteratorERKS1_(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %11, ptr noundef nonnull align 8 dereferenceable(40) %27)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %10, i64 24, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %10) #5
  br label %36

28:                                               ; preds = %20
  %29 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  %30 = call noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %29)
  %31 = load i64, ptr %15, align 8, !tbaa !20
  %32 = sub i64 %31, %30
  store i64 %32, ptr %15, align 8, !tbaa !20
  %33 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @_ZN7cascadb3Msg7destroyEv(ptr noundef nonnull align 8 dereferenceable(40) %33)
  %34 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %35 = call noundef nonnull align 8 dereferenceable(40) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratordeEv(ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %35, ptr noundef nonnull align 8 dereferenceable(40) %34, i64 40, i1 false), !tbaa.struct !21
  br label %36

36:                                               ; preds = %28, %26
  %.sink2 = phi ptr [ %4, %28 ], [ %5, %26 ]
  %37 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %.sink2)
  %38 = call noundef i64 @_ZNK7cascadb3Msg4sizeEv(ptr noundef nonnull align 8 dereferenceable(40) %37)
  %39 = load i64, ptr %15, align 8, !tbaa !20
  %40 = add i64 %39, %38
  store i64 %40, ptr %15, align 8, !tbaa !20
  %41 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24) %5, i32 noundef 0)
  %42 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %2)
  br i1 %42, label %16, label %._crit_edge, !llvm.loop !26

._crit_edge:                                      ; preds = %36, %3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #5
  ret void
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb10FastVectorINS_3MsgELi32EE11lower_boundINS_5SliceENS_7KeyCompEEENS2_8IteratorES6_RKT_T0_(ptr dead_on_unwind noalias writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(32), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef nonnull align 8 dereferenceable(12), ptr) local_unnamed_addr #0 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 8, !6, i64 8, i64 8, !10, i64 16, i64 8, !10}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!13, !7, i64 0}
!13 = !{!"_ZTSN7cascadb6MsgBufE", !7, i64 0, !14, i64 8, !15, i64 64, !11, i64 96}
!14 = !{!"_ZTSN7cascadb6RWLockE", !8, i64 0}
!15 = !{!"_ZTSN7cascadb10FastVectorINS_3MsgELi32EEE", !16, i64 0, !11, i64 24}
!16 = !{!"_ZTSSt6vectorIPS_IN7cascadb3MsgESaIS1_EESaIS4_EE", !17, i64 0}
!17 = !{!"_ZTSSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE12_Vector_implE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIPSt6vectorIN7cascadb3MsgESaIS2_EESaIS5_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!20 = !{!13, !11, i64 96}
!21 = !{i64 0, i64 4, !22, i64 8, i64 8, !6, i64 16, i64 4, !24, i64 24, i64 8, !6, i64 32, i64 4, !24}
!22 = !{!23, !23, i64 0}
!23 = !{!"_ZTSN7cascadb7MsgTypeE", !8, i64 0}
!24 = !{!25, !25, i64 0}
!25 = !{!"int", !8, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}


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