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

; 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::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.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::Slice" = type <{ ptr, i32, [4 x i8] }>
%"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::Pivot" = type <{ %"class.cascadb::Slice", %"class.cascadb::Slice", i64, ptr, i32, i32, i32, i16, [2 x i8] }>
%"class.cascadb::DataNode" = type <{ %"class.cascadb::Node", ptr, i32, [4 x i8] }>

@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE = external hidden unnamed_addr constant [49 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(12) %2) #3 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp sge i32 %12, 0
  br i1 %13, label %14, label %20

14:                                               ; preds = %3
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %11, i32 0, i32 9
  %18 = call noundef i64 @_ZNKSt6vectorIN7cascadb5PivotESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %17) #5
  %19 = icmp ule i64 %16, %18
  br label %20

20:                                               ; preds = %14, %3
  %21 = phi i1 [ false, %3 ], [ %19, %14 ]
  br i1 %21, label %22, label %23

22:                                               ; preds = %20
  br label %25

23:                                               ; preds = %20
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 209, ptr noundef @__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE) #6
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %11, i32 0, i32 4
  br label %37

30:                                               ; preds = %25
  %31 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %11, i32 0, i32 9
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 8 dereferenceable(62) ptr @_ZNSt6vectorIN7cascadb5PivotESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %34) #5
  %36 = getelementptr inbounds %"class.cascadb::Pivot", ptr %35, i32 0, i32 1
  br label %37

37:                                               ; preds = %30, %28
  %38 = phi ptr [ %29, %28 ], [ %36, %30 ]
  store ptr %38, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %43

41:                                               ; preds = %37
  %42 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %11, i32 0, i32 3
  br label %50

43:                                               ; preds = %37
  %44 = getelementptr inbounds %"class.cascadb::InnerNode", ptr %11, i32 0, i32 9
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = sub nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(62) ptr @_ZNSt6vectorIN7cascadb5PivotESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %44, i64 noundef %47) #5
  %49 = getelementptr inbounds %"class.cascadb::Pivot", ptr %48, i32 0, i32 3
  br label %50

50:                                               ; preds = %43, %41
  %51 = phi ptr [ %42, %41 ], [ %49, %43 ]
  store ptr %51, ptr %9, align 8, !tbaa !5
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = load ptr, ptr %52, align 8, !tbaa !5
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %58

55:                                               ; preds = %50
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  store ptr %57, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %75

58:                                               ; preds = %50
  %59 = getelementptr inbounds %"class.cascadb::DataNode", ptr %11, i32 0, i32 2
  %60 = load i32, ptr %59, align 8, !tbaa !11
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %62, label %63

62:                                               ; preds = %58
  br label %65

63:                                               ; preds = %58
  call void @__assert_fail(ptr noundef @.str.4, ptr noundef @.str.1, i32 noundef 216, ptr noundef @__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE) #6
  unreachable

64:                                               ; No predecessors!
  br label %65

65:                                               ; preds = %64, %62
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = call noundef zeroext i1 @_ZN7cascadb13bloom_matchesERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12) %66, ptr noundef nonnull align 8 dereferenceable(12) %67)
  br i1 %68, label %69, label %72

69:                                               ; preds = %65
  %70 = load i32, ptr %6, align 4, !tbaa !9
  %71 = call noundef zeroext i1 @_ZN7cascadb9InnerNode11load_msgbufEi(ptr noundef nonnull align 8 dereferenceable(312) %11, i32 noundef %70)
  br label %72

72:                                               ; preds = %69, %65
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = load ptr, ptr %73, align 8, !tbaa !5
  store ptr %74, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %75

75:                                               ; preds = %72, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %76 = load ptr, ptr %4, align 8
  ret ptr %76
}

declare noundef zeroext i1 @_ZN7cascadb13bloom_matchesERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 = { "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 }
attributes #6 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !21, i64 208}
!12 = !{!"_ZTSN7cascadb8DataNodeE", !13, i64 0, !6, i64 200, !21, i64 208}
!13 = !{!"_ZTSN7cascadb4NodeE", !14, i64 8, !16, i64 40, !17, i64 48, !18, i64 96, !18, i64 97, !18, i64 98, !19, i64 104, !19, i64 120, !10, i64 136, !10, i64 140, !20, i64 144}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN7cascadb5MutexE", !18, i64 0, !7, i64 8}
!18 = !{!"bool", !7, i64 0}
!19 = !{!"_ZTS7timeval", !16, i64 0, !16, i64 8}
!20 = !{!"_ZTSN7cascadb6RWLockE", !7, i64 0}
!21 = !{!"_ZTSN7cascadb10NodeStatusE", !7, i64 0}


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

@.str.1 = external hidden unnamed_addr constant [66 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE = external hidden unnamed_addr constant [49 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(62) ptr @_ZNSt6vectorIN7cascadb5PivotESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %1, ptr noundef nonnull align 8 dereferenceable(12) %2) local_unnamed_addr #2 align 2 {
  %4 = icmp sgt i32 %1, -1
  br i1 %4, label %5, label %.critedge

5:                                                ; preds = %3
  %6 = zext nneg i32 %1 to i64
  %7 = getelementptr inbounds i8, ptr %0, i64 264
  %8 = tail call noundef i64 @_ZNKSt6vectorIN7cascadb5PivotESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %.not = icmp ult i64 %8, %6
  br i1 %.not, label %.critedge, label %9

.critedge:                                        ; preds = %3, %5
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 209, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE) #5
  unreachable

9:                                                ; preds = %5
  %10 = icmp eq i32 %1, 0
  br i1 %10, label %11, label %14

11:                                               ; preds = %9
  %12 = getelementptr inbounds i8, ptr %0, i64 232
  %13 = getelementptr inbounds i8, ptr %0, i64 224
  br label %21

14:                                               ; preds = %9
  %15 = add nsw i32 %1, -1
  %16 = zext nneg i32 %15 to i64
  %17 = tail call noundef nonnull align 8 dereferenceable(62) ptr @_ZNSt6vectorIN7cascadb5PivotESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %16) #4
  %18 = getelementptr inbounds i8, ptr %17, i64 16
  %19 = tail call noundef nonnull align 8 dereferenceable(62) ptr @_ZNSt6vectorIN7cascadb5PivotESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %16) #4
  %20 = getelementptr inbounds i8, ptr %19, i64 40
  br label %21

21:                                               ; preds = %14, %11
  %22 = phi ptr [ %12, %11 ], [ %18, %14 ]
  %23 = phi ptr [ %13, %11 ], [ %20, %14 ]
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %.not15 = icmp eq ptr %24, null
  br i1 %.not15, label %25, label %36

25:                                               ; preds = %21
  %26 = getelementptr inbounds i8, ptr %0, i64 208
  %27 = load i32, ptr %26, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 2
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  tail call void @__assert_fail(ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.1, i32 noundef 216, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN7cascadb9InnerNode6msgbufEiRNS_5SliceE) #5
  unreachable

30:                                               ; preds = %25
  %31 = tail call noundef zeroext i1 @_ZN7cascadb13bloom_matchesERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12) %2, ptr noundef nonnull align 8 dereferenceable(12) %22)
  br i1 %31, label %32, label %34

32:                                               ; preds = %30
  %33 = tail call noundef zeroext i1 @_ZN7cascadb9InnerNode11load_msgbufEi(ptr noundef nonnull align 8 dereferenceable(312) %0, i32 noundef %1)
  br label %34

34:                                               ; preds = %32, %30
  %35 = load ptr, ptr %23, align 8, !tbaa !5
  br label %36

36:                                               ; preds = %21, %34
  %.0 = phi ptr [ %35, %34 ], [ %24, %21 ]
  ret ptr %.0
}

declare noundef zeroext i1 @_ZN7cascadb13bloom_matchesERKNS_5SliceES2_(ptr noundef nonnull align 8 dereferenceable(12), ptr noundef nonnull align 8 dereferenceable(12)) local_unnamed_addr #3

attributes #0 = { noreturn nounwind "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 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 = { "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 = { nounwind }
attributes #5 = { noreturn 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}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass