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

; 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.vl::Ptr" = type { ptr, ptr, ptr, ptr }
%"struct.vl::database::IdObject" = type { i64 }
%"class.vl::database::buffer_internal::FileFreePages" = type { %"class.vl::Object", i64, %"class.vl::collections::List.8", i64, i64, ptr, ptr }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::List.8" = 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::Interface" = type { ptr }
%"class.vl::database::BufferPageDesc" = type <{ ptr, i64, i8, [7 x i8], i64, i8, [7 x i8] }>

@_ZTIN2vl5ErrorE = external dso_local constant { ptr, ptr }, align 8
@.str.19 = external hidden unnamed_addr constant [120 x i32], align 4
@.str.20 = external hidden unnamed_addr constant [98 x i32], align 4

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #1

declare void @__cxa_free_exception(ptr)

declare void @__cxa_throw(ptr, ptr, ptr)

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind noalias writable sret(%"class.vl::Ptr") align 8, ptr noundef nonnull align 8 dereferenceable(152), i64) #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2vl8database8IdObjectImLl1EEC2Em(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) unnamed_addr #3 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

declare i32 @msync(ptr noundef, i64 noundef, i32 noundef) #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN2vl8database8IdObjectImLl1EE7InvalidEv() #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN2vl8database15buffer_internal13FileFreePages11PopFreePageEv(ptr noundef nonnull align 8 dereferenceable(96) %0) #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"struct.vl::database::IdObject", align 8
  %3 = alloca ptr, align 8
  %4 = alloca %"struct.vl::database::IdObject", align 8
  %5 = alloca %"class.vl::Ptr", align 8
  %6 = alloca %"struct.vl::database::IdObject", align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  %12 = load ptr, ptr %3, align 8
  %13 = call i64 @_ZN2vl8database8IdObjectImLl1EE7InvalidEv()
  %14 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %2, i32 0, i32 0
  store i64 %13, ptr %14, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %15 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 2
  %16 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2vl11collections4ListImmEixEl(ptr noundef nonnull align 8 dereferenceable(33) %15, i64 noundef %17)
  %19 = load i64, ptr %18, align 8, !tbaa !18
  call void @_ZN2vl8database8IdObjectImLl1EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %4, i64 noundef %19)
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #5
  %20 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 5
  %21 = load ptr, ptr %20, align 8, !tbaa !19
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %4, i64 8, i1 false), !tbaa.struct !20
  %22 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %6, i32 0, i32 0
  %23 = load i64, ptr %22, align 8
  call void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind writable sret(%"class.vl::Ptr") align 8 %5, ptr noundef nonnull align 8 dereferenceable(152) %21, i64 %23)
  br label %24

24:                                               ; preds = %1
  %25 = invoke noundef zeroext i1 @_ZNK2vl3PtrINS_8database14BufferPageDescEEneEPKS2_(ptr noundef nonnull align 8 dereferenceable(32) %5, ptr noundef null)
          to label %26 unwind label %30

26:                                               ; preds = %24
  br i1 %25, label %38, label %27

27:                                               ; preds = %26
  %28 = call ptr @__cxa_allocate_exception(i64 8) #5
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef @.str.19)
          to label %29 unwind label %34

29:                                               ; preds = %27
  invoke void @__cxa_throw(ptr %28, ptr @_ZTIN2vl5ErrorE, ptr null) #6
          to label %116 unwind label %30

30:                                               ; preds = %29, %24
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %7, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %8, align 4
  br label %110

34:                                               ; preds = %27
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %7, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %8, align 4
  call void @__cxa_free_exception(ptr %28) #5
  br label %110

38:                                               ; preds = %26
  br label %39

39:                                               ; preds = %38
  br label %40

40:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %41 = invoke noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %5)
          to label %42 unwind label %55

42:                                               ; preds = %40
  %43 = getelementptr inbounds %"class.vl::database::BufferPageDesc", ptr %41, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !21
  store ptr %44, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %45 = load ptr, ptr %9, align 8, !tbaa !5
  %46 = getelementptr inbounds i64, ptr %45, i64 1
  store ptr %46, ptr %10, align 8, !tbaa !5
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load i64, ptr %47, align 8, !tbaa !18
  %49 = icmp eq i64 %48, 0
  br i1 %49, label %50, label %59

50:                                               ; preds = %42
  %51 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %4, i32 0, i32 0
  %52 = load i64, ptr %51, align 8, !tbaa !23
  %53 = icmp eq i64 %52, 1
  br i1 %53, label %54, label %59

54:                                               ; preds = %50
  store i32 1, ptr %11, align 4
  br label %105

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

59:                                               ; preds = %50, %42
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load i64, ptr %60, align 8, !tbaa !18
  %62 = add i64 %61, -1
  store i64 %62, ptr %60, align 8, !tbaa !18
  %63 = load ptr, ptr %9, align 8, !tbaa !5
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = load i64, ptr %64, align 8, !tbaa !18
  %66 = add i64 2, %65
  %67 = getelementptr inbounds i64, ptr %63, i64 %66
  %68 = load i64, ptr %67, align 8, !tbaa !18
  %69 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %2, i32 0, i32 0
  store i64 %68, ptr %69, align 8, !tbaa !23
  br label %70

70:                                               ; preds = %59
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 1
  %73 = load i64, ptr %72, align 8, !tbaa !25
  %74 = invoke i32 @msync(ptr noundef %71, i64 noundef %73, i32 noundef 4)
          to label %75 unwind label %80

75:                                               ; preds = %70
  %76 = icmp ne i32 %74, -1
  br i1 %76, label %88, label %77

77:                                               ; preds = %75
  %78 = call ptr @__cxa_allocate_exception(i64 8) #5
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %78, ptr noundef @.str.20)
          to label %79 unwind label %84

79:                                               ; preds = %77
  invoke void @__cxa_throw(ptr %78, ptr @_ZTIN2vl5ErrorE, ptr null) #6
          to label %116 unwind label %80

80:                                               ; preds = %79, %70
  %81 = landingpad { ptr, i32 }
          cleanup
  %82 = extractvalue { ptr, i32 } %81, 0
  store ptr %82, ptr %7, align 8
  %83 = extractvalue { ptr, i32 } %81, 1
  store i32 %83, ptr %8, align 4
  br label %108

84:                                               ; preds = %77
  %85 = landingpad { ptr, i32 }
          cleanup
  %86 = extractvalue { ptr, i32 } %85, 0
  store ptr %86, ptr %7, align 8
  %87 = extractvalue { ptr, i32 } %85, 1
  store i32 %87, ptr %8, align 4
  call void @__cxa_free_exception(ptr %78) #5
  br label %108

88:                                               ; preds = %75
  br label %89

89:                                               ; preds = %88
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %10, align 8, !tbaa !5
  %92 = load i64, ptr %91, align 8, !tbaa !18
  %93 = icmp eq i64 %92, 0
  br i1 %93, label %94, label %104

94:                                               ; preds = %90
  %95 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 3
  %96 = load i64, ptr %95, align 8, !tbaa !9
  %97 = add nsw i64 %96, -1
  store i64 %97, ptr %95, align 8, !tbaa !9
  %98 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 3
  %99 = load i64, ptr %98, align 8, !tbaa !9
  %100 = icmp eq i64 %99, -1
  br i1 %100, label %101, label %103

101:                                              ; preds = %94
  %102 = getelementptr inbounds %"class.vl::database::buffer_internal::FileFreePages", ptr %12, i32 0, i32 3
  store i64 0, ptr %102, align 8, !tbaa !9
  br label %103

103:                                              ; preds = %101, %94
  br label %104

104:                                              ; preds = %103, %90
  store i32 1, ptr %11, align 4
  br label %105

105:                                              ; preds = %104, %54
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %106 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %2, i32 0, i32 0
  %107 = load i64, ptr %106, align 8
  ret i64 %107

108:                                              ; preds = %84, %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %109

109:                                              ; preds = %108, %55
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %110

110:                                              ; preds = %109, %34, %30
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %5) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %111

111:                                              ; preds = %110
  %112 = load ptr, ptr %7, align 8
  %113 = load i32, ptr %8, align 4
  %114 = insertvalue { ptr, i32 } poison, ptr %112, 0
  %115 = insertvalue { ptr, i32 } %114, i32 %113, 1
  resume { ptr, i32 } %115

116:                                              ; preds = %79, %29
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }

!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, !12, i64 64}
!10 = !{!"_ZTSN2vl8database15buffer_internal13FileFreePagesE", !11, i64 0, !12, i64 8, !13, i64 16, !12, i64 64, !12, i64 72, !6, i64 80, !6, i64 88}
!11 = !{!"_ZTSN2vl6ObjectE"}
!12 = !{!"long", !7, i64 0}
!13 = !{!"_ZTSN2vl11collections4ListImmEE", !14, i64 0}
!14 = !{!"_ZTSN2vl11collections8ListBaseImmEE", !15, i64 0, !12, i64 24, !17, i64 32}
!15 = !{!"_ZTSN2vl11collections9ArrayBaseImEE", !16, i64 0, !6, i64 8, !12, i64 16}
!16 = !{!"_ZTSN2vl11collections9ListStoreImLb1EEE", !11, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!12, !12, i64 0}
!19 = !{!10, !6, i64 80}
!20 = !{i64 0, i64 8, !18}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTSN2vl8database14BufferPageDescE", !6, i64 0, !12, i64 8, !17, i64 16, !12, i64 24, !17, i64 32}
!23 = !{!24, !12, i64 0}
!24 = !{!"_ZTSN2vl8database8IdObjectImLl1EEE", !12, i64 0}
!25 = !{!10, !12, i64 8}


; 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 }
%"struct.vl::database::IdObject" = type { i64 }

@_ZTIN2vl5ErrorE = external dso_local constant { ptr, ptr }, align 8
@.str.19 = external hidden unnamed_addr constant [120 x i32], align 4
@.str.20 = external hidden unnamed_addr constant [98 x i32], align 4

declare i32 @__gxx_personality_v0(...)

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

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) unnamed_addr #1

declare void @__cxa_free_exception(ptr) local_unnamed_addr

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

; 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 uwtable
declare dso_local void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind noalias writable sret(%"class.vl::Ptr") align 8, ptr noundef nonnull align 8 dereferenceable(152), i64) local_unnamed_addr #2 align 2

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

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

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

declare i32 @msync(ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local i64 @_ZN2vl8database8IdObjectImLl1EE7InvalidEv() local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN2vl8database15buffer_internal13FileFreePages11PopFreePageEv(ptr noundef nonnull align 8 dereferenceable(96) %0) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"struct.vl::database::IdObject", align 8
  %3 = alloca %"class.vl::Ptr", align 8
  %4 = tail call i64 @_ZN2vl8database8IdObjectImLl1EE7InvalidEv()
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = getelementptr inbounds i8, ptr %0, i64 64
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZN2vl11collections4ListImmEixEl(ptr noundef nonnull align 8 dereferenceable(33) %5, i64 noundef %7)
  %9 = load i64, ptr %8, align 8, !tbaa !17
  call void @_ZN2vl8database8IdObjectImLl1EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %2, i64 noundef %9)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load ptr, ptr %10, align 8, !tbaa !18
  %.sroa.0.0.copyload = load i64, ptr %2, align 8, !tbaa !17
  call void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind nonnull writable sret(%"class.vl::Ptr") align 8 %3, ptr noundef nonnull align 8 dereferenceable(152) %11, i64 %.sroa.0.0.copyload)
  %12 = call noundef zeroext i1 @_ZNK2vl3PtrINS_8database14BufferPageDescEEneEPKS2_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef null)
  br i1 %12, label %20, label %13

13:                                               ; preds = %1
  %14 = call ptr @__cxa_allocate_exception(i64 8) #5
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %14, ptr noundef nonnull @.str.19)
          to label %15 unwind label %18

15:                                               ; preds = %13
  invoke void @__cxa_throw(ptr nonnull %14, ptr nonnull @_ZTIN2vl5ErrorE, ptr null) #6
          to label %51 unwind label %16

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

18:                                               ; preds = %13
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %14) #5
  br label %50

20:                                               ; preds = %1
  %21 = call noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %3)
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load i64, ptr %23, align 8, !tbaa !17
  %25 = icmp eq i64 %24, 0
  %26 = load i64, ptr %2, align 8
  %27 = icmp eq i64 %26, 1
  %or.cond = select i1 %25, i1 %27, i1 false
  br i1 %or.cond, label %49, label %28

28:                                               ; preds = %20
  %29 = add i64 %24, -1
  store i64 %29, ptr %23, align 8, !tbaa !17
  %30 = getelementptr i64, ptr %22, i64 %24
  %31 = getelementptr i8, ptr %30, i64 8
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = getelementptr inbounds i8, ptr %0, i64 8
  %34 = load i64, ptr %33, align 8, !tbaa !21
  %35 = invoke i32 @msync(ptr noundef nonnull %22, i64 noundef %34, i32 noundef 4)
          to label %36 unwind label %40

36:                                               ; preds = %28
  %.not = icmp eq i32 %35, -1
  br i1 %.not, label %37, label %44

37:                                               ; preds = %36
  %38 = call ptr @__cxa_allocate_exception(i64 8) #5
  invoke void @_ZN2vl5ErrorC1EPKw(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef nonnull @.str.20)
          to label %39 unwind label %42

39:                                               ; preds = %37
  invoke void @__cxa_throw(ptr nonnull %38, ptr nonnull @_ZTIN2vl5ErrorE, ptr null) #6
          to label %51 unwind label %40

40:                                               ; preds = %39, %28
  %41 = landingpad { ptr, i32 }
          cleanup
  br label %50

42:                                               ; preds = %37
  %43 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %38) #5
  br label %50

44:                                               ; preds = %36
  %45 = load i64, ptr %23, align 8, !tbaa !17
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %44
  %48 = load i64, ptr %6, align 8, !tbaa !5
  %spec.store.select = call i64 @llvm.usub.sat.i64(i64 %48, i64 1)
  store i64 %spec.store.select, ptr %6, align 8
  br label %49

49:                                               ; preds = %47, %44, %20
  %.sroa.011.0 = phi i64 [ %4, %20 ], [ %32, %47 ], [ %32, %44 ]
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  ret i64 %.sroa.011.0

50:                                               ; preds = %40, %42, %18, %16
  %.pn.pn = phi { ptr, i32 } [ %17, %16 ], [ %19, %18 ], [ %41, %40 ], [ %43, %42 ]
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  resume { ptr, i32 } %.pn.pn

51:                                               ; preds = %39, %15
  unreachable
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.usub.sat.i64(i64, i64) #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }
attributes #6 = { noreturn }

!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, !8, i64 64}
!6 = !{!"_ZTSN2vl8database15buffer_internal13FileFreePagesE", !7, i64 0, !8, i64 8, !11, i64 16, !8, i64 64, !8, i64 72, !15, i64 80, !15, i64 88}
!7 = !{!"_ZTSN2vl6ObjectE"}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN2vl11collections4ListImmEE", !12, i64 0}
!12 = !{!"_ZTSN2vl11collections8ListBaseImmEE", !13, i64 0, !8, i64 24, !16, i64 32}
!13 = !{!"_ZTSN2vl11collections9ArrayBaseImEE", !14, i64 0, !15, i64 8, !8, i64 16}
!14 = !{!"_ZTSN2vl11collections9ListStoreImLb1EEE", !7, i64 0}
!15 = !{!"any pointer", !9, i64 0}
!16 = !{!"bool", !9, i64 0}
!17 = !{!8, !8, i64 0}
!18 = !{!6, !15, i64 80}
!19 = !{!20, !15, i64 0}
!20 = !{!"_ZTSN2vl8database14BufferPageDescE", !15, i64 0, !8, i64 8, !16, i64 16, !8, i64 24, !16, i64 32}
!21 = !{!6, !8, i64 8}


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