; LLVM IR from weicao/cascadb :: src/tree/node.ll (ZN7cascadb9InnerNode7cascadeEPNS_6MsgBufEPS0_)

; 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::Slice" = type <{ ptr, i32, [4 x i8] }>
%"class.cascadb::DataNode" = type <{ %"class.cascadb::Node", ptr, i32, [4 x i8] }>
%"class.cascadb::Node" = type { ptr, %"class.std::__cxx11::basic_string", i64, %"class.cascadb::Mutex", i8, i8, i8, %struct.timeval, %struct.timeval, i32, i32, %"class.cascadb::RWLock" }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.cascadb::Mutex" = type { i8, %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.timeval = type { i64, 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::InnerNode" = type { %"class.cascadb::DataNode.base", i8, i64, ptr, %"class.cascadb::Slice", i32, i32, i32, i16, %"class.std::vector", i64, i64, i64 }
%"class.cascadb::DataNode.base" = type <{ %"class.cascadb::Node", ptr, i32 }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<cascadb::Pivot, std::allocator<cascadb::Pivot>>::_Vector_impl" }
%"struct.std::_Vector_base<cascadb::Pivot, std::allocator<cascadb::Pivot>>::_Vector_impl" = type { %"struct.std::_Vector_base<cascadb::Pivot, std::allocator<cascadb::Pivot>>::_Vector_impl_data" }
%"struct.std::_Vector_base<cascadb::Pivot, std::allocator<cascadb::Pivot>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.cascadb::Msg" = type { i32, [4 x i8], %"class.cascadb::Slice", %"class.cascadb::Slice" }

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb4Node9set_dirtyEb(ptr noundef nonnull align 8 dereferenceable(200), i1 noundef zeroext) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7cascadb9InnerNode15load_all_msgbufEv(ptr noundef nonnull align 8 dereferenceable(312)) #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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7cascadb9InnerNode7cascadeEPNS_6MsgBufEPS0_(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"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
  %12 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %13 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %14 = alloca i64, align 8
  %15 = alloca %"class.cascadb::Slice", align 8
  %16 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %17 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %18 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %19 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %4, align 8
  call void @_ZN7cascadb4Node9read_lockEv(ptr noundef nonnull align 8 dereferenceable(200) %20)
  %21 = getelementptr inbounds %"class.cascadb::DataNode", ptr %20, i32 0, i32 2
  %22 = load i32, ptr %21, align 8, !tbaa !9
  %23 = icmp eq i32 %22, 2
  br i1 %23, label %24, label %26

24:                                               ; preds = %3
  %25 = call noundef zeroext i1 @_ZN7cascadb9InnerNode15load_all_msgbufEv(ptr noundef nonnull align 8 dereferenceable(312) %20)
  br label %26

26:                                               ; preds = %24, %3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN7cascadb6MsgBuf10write_lockEv(ptr noundef nonnull align 8 dereferenceable(104) %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = call noundef i64 @_ZNK7cascadb6MsgBuf5countEv(ptr noundef nonnull align 8 dereferenceable(104) %28)
  store i64 %29, ptr %7, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104) %30)
  store i64 %31, ptr %8, align 8, !tbaa !21
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %9)
  call void @llvm.lifetime.start.p0(i64 24, ptr %10) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10)
  call void @llvm.lifetime.start.p0(i64 24, ptr %11) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %11)
  call void @llvm.lifetime.start.p0(i64 24, ptr %12) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN7cascadb6MsgBuf5beginEv(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %12, ptr noundef nonnull align 8 dereferenceable(104) %32)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %12, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %10, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 24, ptr %12) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #5
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN7cascadb6MsgBuf3endEv(ptr dead_on_unwind writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %13, ptr noundef nonnull align 8 dereferenceable(104) %33)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %13, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  store i64 0, ptr %14, align 8, !tbaa !21
  br label %34

34:                                               ; preds = %64, %26
  %35 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(24) %11)
  br i1 %35, label %36, label %41

36:                                               ; preds = %34
  %37 = load i64, ptr %14, align 8, !tbaa !21
  %38 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %20, i32 0, i32 9
  %39 = call noundef i64 @_ZNKSt6vectorIN7cascadb5PivotESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %38) #5
  %40 = icmp ult i64 %37, %39
  br label %41

41:                                               ; preds = %36, %34
  %42 = phi i1 [ false, %34 ], [ %40, %36 ]
  br i1 %42, label %43, label %65

43:                                               ; preds = %41
  %44 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %10)
  %45 = getelementptr inbounds %"class.cascadb::Msg", ptr %44, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 8 %45, i64 16, i1 false), !tbaa.struct !23
  %46 = load i64, ptr %14, align 8, !tbaa !21
  %47 = trunc i64 %46 to i32
  %48 = getelementptr inbounds { ptr, i32 }, ptr %15, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8
  %50 = getelementptr inbounds { ptr, i32 }, ptr %15, i32 0, i32 1
  %51 = load i32, ptr %50, align 8
  %52 = call noundef i32 @_ZN7cascadb9InnerNode10comp_pivotENS_5SliceEi(ptr noundef nonnull align 8 dereferenceable(312) %20, ptr %49, i32 %51, i32 noundef %47)
  %53 = icmp slt i32 %52, 0
  br i1 %53, label %54, label %56

54:                                               ; preds = %43
  %55 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24) %10, i32 noundef 0)
  br label %64

56:                                               ; preds = %43
  %57 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %10)
  br i1 %57, label %58, label %61

58:                                               ; preds = %56
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %16, ptr align 8 %9, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %17, ptr align 8 %10, i64 24, i1 false), !tbaa.struct !22
  %59 = load i64, ptr %14, align 8, !tbaa !21
  %60 = trunc i64 %59 to i32
  call void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312) %20, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %16, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %17, i32 noundef %60)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %10, i64 24, i1 false), !tbaa.struct !22
  br label %61

61:                                               ; preds = %58, %56
  %62 = load i64, ptr %14, align 8, !tbaa !21
  %63 = add i64 %62, 1
  store i64 %63, ptr %14, align 8, !tbaa !21
  br label %64

64:                                               ; preds = %61, %54
  br label %34, !llvm.loop !25

65:                                               ; preds = %41
  %66 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %9, ptr noundef nonnull align 8 dereferenceable(24) %11)
  br i1 %66, label %67, label %70

67:                                               ; preds = %65
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %9, i64 24, i1 false), !tbaa.struct !22
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 8 %11, i64 24, i1 false), !tbaa.struct !22
  %68 = load i64, ptr %14, align 8, !tbaa !21
  %69 = trunc i64 %68 to i32
  call void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312) %20, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %18, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %19, i32 noundef %69)
  br label %70

70:                                               ; preds = %67, %65
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN7cascadb6MsgBuf5clearEv(ptr noundef nonnull align 8 dereferenceable(104) %71)
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %72, i32 0, i32 11
  %74 = load i64, ptr %73, align 8, !tbaa !27
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = call noundef i64 @_ZNK7cascadb6MsgBuf5countEv(ptr noundef nonnull align 8 dereferenceable(104) %75)
  %77 = add i64 %74, %76
  %78 = load i64, ptr %7, align 8, !tbaa !21
  %79 = sub i64 %77, %78
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %80, i32 0, i32 11
  store i64 %79, ptr %81, align 8, !tbaa !27
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %82, i32 0, i32 12
  %84 = load i64, ptr %83, align 8, !tbaa !35
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = call noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104) %85)
  %87 = add i64 %84, %86
  %88 = load i64, ptr %8, align 8, !tbaa !21
  %89 = sub i64 %87, %88
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %90, i32 0, i32 12
  store i64 %89, ptr %91, align 8, !tbaa !35
  %92 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN7cascadb6MsgBuf6unlockEv(ptr noundef nonnull align 8 dereferenceable(104) %92)
  %93 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN7cascadb4Node6unlockEv(ptr noundef nonnull align 8 dereferenceable(200) %93)
  call void @_ZN7cascadb4Node9set_dirtyEb(ptr noundef nonnull align 8 dereferenceable(200) %20, i1 noundef zeroext true)
  call void @_ZN7cascadb9InnerNode13maybe_cascadeEv(ptr noundef nonnull align 8 dereferenceable(312) %20)
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret i1 true
}

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

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, i32 noundef) #2 align 2

declare void @_ZN7cascadb6MsgBuf5clearEv(ptr noundef nonnull align 8 dereferenceable(104)) #4

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { 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, !20, i64 208}
!10 = !{!"_ZTSN7cascadb8DataNodeE", !11, i64 0, !6, i64 200, !20, i64 208}
!11 = !{!"_ZTSN7cascadb4NodeE", !12, i64 8, !14, i64 40, !15, i64 48, !16, i64 96, !16, i64 97, !16, i64 98, !17, i64 104, !17, i64 120, !18, i64 136, !18, i64 140, !19, i64 144}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!"_ZTSN7cascadb5MutexE", !16, i64 0, !7, i64 8}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS7timeval", !14, i64 0, !14, i64 8}
!18 = !{!"int", !7, i64 0}
!19 = !{!"_ZTSN7cascadb6RWLockE", !7, i64 0}
!20 = !{!"_ZTSN7cascadb10NodeStatusE", !7, i64 0}
!21 = !{!14, !14, i64 0}
!22 = !{i64 0, i64 8, !5, i64 8, i64 8, !21, i64 16, i64 8, !21}
!23 = !{i64 0, i64 8, !5, i64 8, i64 4, !24}
!24 = !{!18, !18, i64 0}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}
!27 = !{!28, !14, i64 296}
!28 = !{!"_ZTSN7cascadb9InnerNodeE", !10, i64 0, !16, i64 212, !14, i64 216, !6, i64 224, !29, i64 232, !18, i64 248, !18, i64 252, !18, i64 256, !30, i64 260, !31, i64 264, !14, i64 288, !14, i64 296, !14, i64 304}
!29 = !{!"_ZTSN7cascadb5SliceE", !6, i64 0, !18, i64 8}
!30 = !{!"short", !7, i64 0}
!31 = !{!"_ZTSSt6vectorIN7cascadb5PivotESaIS1_EE", !32, i64 0}
!32 = !{!"_ZTSSt12_Vector_baseIN7cascadb5PivotESaIS1_EE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIN7cascadb5PivotESaIS1_EE12_Vector_implE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIN7cascadb5PivotESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!35 = !{!28, !14, i64 304}


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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb4Node9set_dirtyEb(ptr noundef nonnull align 8 dereferenceable(200), i1 noundef zeroext) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN7cascadb9InnerNode15load_all_msgbufEv(ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #2 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) #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7cascadb9InnerNode7cascadeEPNS_6MsgBufEPS0_(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1, ptr noundef %2) unnamed_addr #2 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::FastVector<cascadb::Msg>::Iterator", align 8
  %7 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  %8 = alloca %"class.cascadb::FastVector<cascadb::Msg>::Iterator", align 8
  tail call void @_ZN7cascadb4Node9read_lockEv(ptr noundef nonnull align 8 dereferenceable(200) %0)
  %9 = getelementptr inbounds i8, ptr %0, i64 208
  %10 = load i32, ptr %9, align 8, !tbaa !5
  %11 = icmp eq i32 %10, 2
  br i1 %11, label %12, label %14

12:                                               ; preds = %3
  %13 = tail call noundef zeroext i1 @_ZN7cascadb9InnerNode15load_all_msgbufEv(ptr noundef nonnull align 8 dereferenceable(312) %0)
  br label %14

14:                                               ; preds = %12, %3
  tail call void @_ZN7cascadb6MsgBuf10write_lockEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %15 = tail call noundef i64 @_ZNK7cascadb6MsgBuf5countEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %16 = tail call noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %5) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %5)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %6) #5
  call void @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %6)
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #5
  call void @_ZN7cascadb6MsgBuf5beginEv(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %7, ptr noundef nonnull align 8 dereferenceable(104) %1)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %7, i64 24, i1 false), !tbaa.struct !20
  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)
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #5
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %8) #5
  call void @_ZN7cascadb6MsgBuf3endEv(ptr dead_on_unwind nonnull writable sret(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %8, ptr noundef nonnull align 8 dereferenceable(104) %1)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %6, ptr noundef nonnull align 8 dereferenceable(24) %8, i64 24, i1 false), !tbaa.struct !20
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %8) #5
  %17 = getelementptr inbounds i8, ptr %0, i64 264
  %18 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %6)
  br i1 %18, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %14, %34
  %.022 = phi i64 [ %.1, %34 ], [ 0, %14 ]
  %19 = call noundef i64 @_ZNKSt6vectorIN7cascadb5PivotESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #5
  %20 = icmp ult i64 %.022, %19
  br i1 %20, label %21, label %.critedge.loopexit

21:                                               ; preds = %.lr.ph
  %22 = call noundef ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorptEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %.sroa.0.0.copyload = load ptr, ptr %23, align 8, !tbaa !21
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %22, i64 16
  %.sroa.2.0.copyload = load i32, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !23
  %24 = trunc i64 %.022 to i32
  %25 = call noundef i32 @_ZN7cascadb9InnerNode10comp_pivotENS_5SliceEi(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr %.sroa.0.0.copyload, i32 %.sroa.2.0.copyload, i32 noundef %24)
  %26 = icmp slt i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %21
  %28 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZN7cascadb10FastVectorINS_3MsgELi32EE8IteratorppEi(ptr noundef nonnull align 8 dereferenceable(24) %5, i32 noundef 0)
  br label %34

29:                                               ; preds = %21
  %30 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %5)
  br i1 %30, label %31, label %32

31:                                               ; preds = %29
  call void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %4, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %5, i32 noundef %24)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %5, i64 24, i1 false), !tbaa.struct !20
  br label %32

32:                                               ; preds = %31, %29
  %33 = add nuw i64 %.022, 1
  br label %34

34:                                               ; preds = %32, %27
  %.1 = phi i64 [ %.022, %27 ], [ %33, %32 ]
  %35 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %5, ptr noundef nonnull align 8 dereferenceable(24) %6)
  br i1 %35, label %.lr.ph, label %.critedge.loopexit, !llvm.loop !24

.critedge.loopexit:                               ; preds = %34, %.lr.ph
  %.0.lcssa.ph = phi i64 [ %.022, %.lr.ph ], [ %.1, %34 ]
  %36 = trunc i64 %.0.lcssa.ph to i32
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %14
  %.0.lcssa = phi i32 [ 0, %14 ], [ %36, %.critedge.loopexit ]
  %37 = call noundef zeroext i1 @_ZNK7cascadb10FastVectorINS_3MsgELi32EE8IteratorneERKS3_(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) %6)
  br i1 %37, label %38, label %39

38:                                               ; preds = %.critedge
  call void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %4, ptr noundef nonnull byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8 %6, i32 noundef %.0.lcssa)
  br label %39

39:                                               ; preds = %38, %.critedge
  call void @_ZN7cascadb6MsgBuf5clearEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %40 = getelementptr inbounds i8, ptr %2, i64 296
  %41 = load i64, ptr %40, align 8, !tbaa !26
  %42 = call noundef i64 @_ZNK7cascadb6MsgBuf5countEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %43 = sub i64 %41, %15
  %44 = add i64 %43, %42
  store i64 %44, ptr %40, align 8, !tbaa !26
  %45 = getelementptr inbounds i8, ptr %2, i64 304
  %46 = load i64, ptr %45, align 8, !tbaa !34
  %47 = call noundef i64 @_ZNK7cascadb6MsgBuf4sizeEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  %48 = sub i64 %46, %16
  %49 = add i64 %48, %47
  store i64 %49, ptr %45, align 8, !tbaa !34
  call void @_ZN7cascadb6MsgBuf6unlockEv(ptr noundef nonnull align 8 dereferenceable(104) %1)
  call void @_ZN7cascadb4Node6unlockEv(ptr noundef nonnull align 8 dereferenceable(200) %2)
  call void @_ZN7cascadb4Node9set_dirtyEb(ptr noundef nonnull align 8 dereferenceable(200) %0, i1 noundef zeroext true)
  call void @_ZN7cascadb9InnerNode13maybe_cascadeEv(ptr noundef nonnull align 8 dereferenceable(312) %0)
  call void @llvm.lifetime.end.p0(i64 24, 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 i1 true
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNK7cascadb6MsgBuf5countEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #2 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7cascadb9InnerNode13insert_msgbufENS_10FastVectorINS_3MsgELi32EE8IteratorES4_i(ptr noundef nonnull align 8 dereferenceable(312), ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, ptr noundef byval(%"class.cascadb::FastVector<cascadb::Msg>::Iterator") align 8, i32 noundef) local_unnamed_addr #2 align 2

declare void @_ZN7cascadb6MsgBuf5clearEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #4

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { mustprogress 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 = { 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, !19, i64 208}
!6 = !{!"_ZTSN7cascadb8DataNodeE", !7, i64 0, !10, i64 200, !19, i64 208}
!7 = !{!"_ZTSN7cascadb4NodeE", !8, i64 8, !13, i64 40, !14, i64 48, !15, i64 96, !15, i64 97, !15, i64 98, !16, i64 104, !16, i64 120, !17, i64 136, !17, i64 140, !18, i64 144}
!8 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !9, i64 0, !13, i64 8, !11, i64 16}
!9 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!10 = !{!"any pointer", !11, i64 0}
!11 = !{!"omnipotent char", !12, i64 0}
!12 = !{!"Simple C++ TBAA"}
!13 = !{!"long", !11, i64 0}
!14 = !{!"_ZTSN7cascadb5MutexE", !15, i64 0, !11, i64 8}
!15 = !{!"bool", !11, i64 0}
!16 = !{!"_ZTS7timeval", !13, i64 0, !13, i64 8}
!17 = !{!"int", !11, i64 0}
!18 = !{!"_ZTSN7cascadb6RWLockE", !11, i64 0}
!19 = !{!"_ZTSN7cascadb10NodeStatusE", !11, i64 0}
!20 = !{i64 0, i64 8, !21, i64 8, i64 8, !22, i64 16, i64 8, !22}
!21 = !{!10, !10, i64 0}
!22 = !{!13, !13, i64 0}
!23 = !{!17, !17, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}
!26 = !{!27, !13, i64 296}
!27 = !{!"_ZTSN7cascadb9InnerNodeE", !6, i64 0, !15, i64 212, !13, i64 216, !10, i64 224, !28, i64 232, !17, i64 248, !17, i64 252, !17, i64 256, !29, i64 260, !30, i64 264, !13, i64 288, !13, i64 296, !13, i64 304}
!28 = !{!"_ZTSN7cascadb5SliceE", !10, i64 0, !17, i64 8}
!29 = !{!"short", !11, i64 0}
!30 = !{!"_ZTSSt6vectorIN7cascadb5PivotESaIS1_EE", !31, i64 0}
!31 = !{!"_ZTSSt12_Vector_baseIN7cascadb5PivotESaIS1_EE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIN7cascadb5PivotESaIS1_EE12_Vector_implE", !33, i64 0}
!33 = !{!"_ZTSNSt12_Vector_baseIN7cascadb5PivotESaIS1_EE17_Vector_impl_dataE", !10, i64 0, !10, i64 8, !10, i64 16}
!34 = !{!27, !13, i64 304}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass