; LLVM IR from vczh/herodb :: Kernel/Source/Utility (InMemoryBuffer)

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

%"struct.vl::database::IdObject" = type { i64 }
%"class.vl::Ptr" = type { ptr, ptr, ptr, ptr }
%"class.vl::database::InMemoryBufferSource" = type { %"class.vl::Object", %"class.vl::database::IBufferSource", %"struct.vl::database::IdObject.0", ptr, i64, %"class.vl::SpinLock", %"class.vl::collections::List", %"class.vl::collections::List.1", %"struct.vl::database::IdObject" }
%"class.vl::Object" = type { ptr }
%"class.vl::database::IBufferSource" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }
%"struct.vl::database::IdObject.0" = type { i32 }
%"class.vl::SpinLock" = type { %"class.vl::Object", i64 }
%"class.vl::collections::List" = type { %"class.vl::collections::ListBase.base", %"class.vl::collections::IEnumerable" }
%"class.vl::collections::ListBase.base" = type <{ %"class.vl::collections::ArrayBase.base", i64, i8 }>
%"class.vl::collections::ArrayBase.base" = type { %"class.vl::collections::ListStore", ptr, i64 }
%"class.vl::collections::ListStore" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable" = type { %"class.vl::Interface" }
%"class.vl::collections::List.1" = type { %"class.vl::collections::ListBase.base.7", %"class.vl::collections::IEnumerable.5" }
%"class.vl::collections::ListBase.base.7" = type <{ %"class.vl::collections::ArrayBase.base.6", i64, i8 }>
%"class.vl::collections::ArrayBase.base.6" = type { %"class.vl::collections::ListStore.4", ptr, i64 }
%"class.vl::collections::ListStore.4" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.5" = type { %"class.vl::Interface" }
%"class.vl::database::BufferPageDesc" = type <{ ptr, i64, i8, [7 x i8], i64, i8, [7 x i8] }>

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_8database14BufferPageDescEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) #1 align 2

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database20InMemoryBufferSource10UnlockPageENS0_8IdObjectImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(160) %0, i64 %1, ptr noundef %2, i32 noundef %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca i1, align 1
  %6 = alloca %"struct.vl::database::IdObject", align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %"class.vl::Ptr", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %6, i32 0, i32 0
  store i64 %1, ptr %14, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  %15 = load ptr, ptr %7, align 8
  %16 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %6, i32 0, i32 0
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = getelementptr inbounds %"class.vl::database::InMemoryBufferSource", ptr %15, i32 0, i32 6
  %19 = call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_3PtrINS_8database14BufferPageDescEEEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %18)
  %20 = icmp uge i64 %17, %19
  br i1 %20, label %21, label %22

21:                                               ; preds = %4
  store i1 false, ptr %5, align 1
  br label %52

22:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #3
  %23 = getelementptr inbounds %"class.vl::database::InMemoryBufferSource", ptr %15, i32 0, i32 6
  %24 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %6, i32 0, i32 0
  %25 = load i64, ptr %24, align 8, !tbaa !11
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_8database14BufferPageDescEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33) %23, i64 noundef %25)
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(32) %26)
  %27 = invoke noundef zeroext i1 @_ZNK2vl3PtrINS_8database14BufferPageDescEEcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %28 unwind label %43

28:                                               ; preds = %22
  br i1 %27, label %29, label %42

29:                                               ; preds = %28
  %30 = invoke noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %31 unwind label %43

31:                                               ; preds = %29
  %32 = getelementptr inbounds %"class.vl::database::BufferPageDesc", ptr %30, i32 0, i32 2
  %33 = load i8, ptr %32, align 8, !tbaa !14, !range !17, !noundef !18
  %34 = trunc i8 %33 to i1
  br i1 %34, label %35, label %42

35:                                               ; preds = %31
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = invoke noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %38 unwind label %43

38:                                               ; preds = %35
  %39 = getelementptr inbounds %"class.vl::database::BufferPageDesc", ptr %37, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !19
  %41 = icmp ne ptr %36, %40
  br i1 %41, label %42, label %47

42:                                               ; preds = %38, %31, %28
  store i1 false, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %51

43:                                               ; preds = %47, %35, %29, %22
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %11, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %12, align 4
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #3
  br label %54

47:                                               ; preds = %38
  %48 = invoke noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %10)
          to label %49 unwind label %43

49:                                               ; preds = %47
  %50 = getelementptr inbounds %"class.vl::database::BufferPageDesc", ptr %48, i32 0, i32 2
  store i8 0, ptr %50, align 8, !tbaa !14
  store i1 true, ptr %5, align 1
  store i32 1, ptr %13, align 4
  br label %51

51:                                               ; preds = %49, %42
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %10) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #3
  br label %52

52:                                               ; preds = %51, %21
  %53 = load i1, ptr %5, align 1
  ret i1 %53

54:                                               ; preds = %43
  %55 = load ptr, ptr %11, align 8
  %56 = load i32, ptr %12, align 4
  %57 = insertvalue { ptr, i32 } poison, ptr %55, 0
  %58 = insertvalue { ptr, i32 } %57, i32 %56, 1
  resume { ptr, i32 } %58
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = !{!"_ZTSN2vl8database15PersistanceTypeE", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTSN2vl8database8IdObjectImLl1EEE", !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !16, i64 16}
!15 = !{!"_ZTSN2vl8database14BufferPageDescE", !6, i64 0, !13, i64 8, !16, i64 16, !13, i64 24, !16, i64 32}
!16 = !{!"bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!15, !6, 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"

%"class.vl::Ptr" = type { ptr, ptr, ptr, ptr }

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_8database14BufferPageDescEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33), i64 noundef) local_unnamed_addr #1 align 2

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database20InMemoryBufferSource10UnlockPageENS0_8IdObjectImLl1EEEPvNS0_15PersistanceTypeE(ptr noundef nonnull align 8 dereferenceable(160) %0, i64 %1, ptr noundef readnone %2, i32 noundef %3) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %5 = alloca %"class.vl::Ptr", align 8
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = tail call noundef i64 @_ZNK2vl11collections9ArrayBaseINS_3PtrINS_8database14BufferPageDescEEEE5CountEv(ptr noundef nonnull align 8 dereferenceable(24) %6)
  %.not = icmp ugt i64 %7, %1
  br i1 %.not, label %8, label %23

8:                                                ; preds = %4
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #3
  %9 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZN2vl11collections4ListINS_3PtrINS_8database14BufferPageDescEEEPS4_EixEl(ptr noundef nonnull align 8 dereferenceable(33) %6, i64 noundef %1)
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEEC2ERKS3_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef nonnull align 8 dereferenceable(32) %9)
  %10 = call noundef zeroext i1 @_ZNK2vl3PtrINS_8database14BufferPageDescEEcvbEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  br i1 %10, label %11, label %22

11:                                               ; preds = %8
  %12 = call noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %13 = getelementptr inbounds i8, ptr %12, i64 16
  %14 = load i8, ptr %13, align 8, !tbaa !5, !range !12, !noundef !13
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %16, label %22

16:                                               ; preds = %11
  %17 = call noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %.not5 = icmp eq ptr %18, %2
  br i1 %.not5, label %19, label %22

19:                                               ; preds = %16
  %20 = call noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  store i8 0, ptr %21, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %8, %11, %16, %19
  %.0 = phi i1 [ true, %19 ], [ false, %16 ], [ false, %11 ], [ false, %8 ]
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %5) #3
  br label %23

23:                                               ; preds = %4, %22
  %.1 = phi i1 [ %.0, %22 ], [ false, %4 ]
  ret i1 %.1
}

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !11, i64 16}
!6 = !{!"_ZTSN2vl8database14BufferPageDescE", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !7, i64 0}


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