; 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::FileUseMasks" = type { %"class.vl::Object", i32, i64, %"class.vl::collections::List.8", i64, 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] }>

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

; 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) #1 align 2

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl8database15buffer_internal12FileUseMasks24InitializeExistingSourceEPNS1_11FileMappingE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.vl::database::IdObject", align 8
  %6 = alloca %"class.vl::Ptr", align 8
  %7 = alloca %"struct.vl::database::IdObject", align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"class.vl::database::buffer_internal::FileUseMasks", ptr %11, i32 0, i32 5
  store ptr %12, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds %"class.vl::database::buffer_internal::FileUseMasks", ptr %11, i32 0, i32 3
  %15 = call noundef zeroext i1 @_ZN2vl11collections8ListBaseImmE5ClearEv(ptr noundef nonnull align 8 dereferenceable(33) %14)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @_ZN2vl8database8IdObjectImLl1EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %5, i64 noundef 0)
  br label %16

16:                                               ; preds = %29, %2
  %17 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %5, i32 0, i32 0
  %18 = load i64, ptr %17, align 8, !tbaa !19
  %19 = icmp ne i64 %18, -1
  br i1 %19, label %20, label %40

20:                                               ; preds = %16
  %21 = getelementptr inbounds %"class.vl::database::buffer_internal::FileUseMasks", ptr %11, i32 0, i32 3
  %22 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %5, i32 0, i32 0
  %23 = call noundef i64 @_ZN2vl11collections4ListImmE3AddERKm(ptr noundef nonnull align 8 dereferenceable(33) %21, ptr noundef nonnull align 8 dereferenceable(8) %22)
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #4
  %24 = getelementptr inbounds %"class.vl::database::buffer_internal::FileUseMasks", ptr %11, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %5, i64 8, i1 false), !tbaa.struct !21
  %26 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %7, i32 0, i32 0
  %27 = load i64, ptr %26, align 8
  call void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind writable sret(%"class.vl::Ptr") align 8 %6, ptr noundef nonnull align 8 dereferenceable(152) %25, i64 %27)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %28 = invoke noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %6)
          to label %29 unwind label %36

29:                                               ; preds = %20
  %30 = getelementptr inbounds %"class.vl::database::BufferPageDesc", ptr %28, i32 0, i32 0
  %31 = load ptr, ptr %30, align 8, !tbaa !23
  store ptr %31, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds i64, ptr %32, i64 0
  %34 = load i64, ptr %33, align 8, !tbaa !22
  %35 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %5, i32 0, i32 0
  store i64 %34, ptr %35, align 8, !tbaa !19
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #4
  br label %16, !llvm.loop !25

36:                                               ; preds = %20
  %37 = landingpad { ptr, i32 }
          cleanup
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %9, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %6) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %41

40:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void

41:                                               ; preds = %36
  %42 = load ptr, ptr %9, align 8
  %43 = load i32, ptr %10, align 4
  %44 = insertvalue { ptr, i32 } poison, ptr %42, 0
  %45 = insertvalue { ptr, i32 } %44, i32 %43, 1
  resume { ptr, i32 } %45
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !6, i64 80}
!10 = !{!"_ZTSN2vl8database15buffer_internal12FileUseMasksE", !11, i64 0, !12, i64 8, !13, i64 16, !14, i64 24, !13, i64 72, !6, i64 80}
!11 = !{!"_ZTSN2vl6ObjectE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTSN2vl11collections4ListImmEE", !15, i64 0}
!15 = !{!"_ZTSN2vl11collections8ListBaseImmEE", !16, i64 0, !13, i64 24, !18, i64 32}
!16 = !{!"_ZTSN2vl11collections9ArrayBaseImEE", !17, i64 0, !6, i64 8, !13, i64 16}
!17 = !{!"_ZTSN2vl11collections9ListStoreImLb1EEE", !11, i64 0}
!18 = !{!"bool", !7, i64 0}
!19 = !{!20, !13, i64 0}
!20 = !{!"_ZTSN2vl8database8IdObjectImLl1EEE", !13, i64 0}
!21 = !{i64 0, i64 8, !22}
!22 = !{!13, !13, i64 0}
!23 = !{!24, !6, i64 0}
!24 = !{!"_ZTSN2vl8database14BufferPageDescE", !6, i64 0, !13, i64 8, !18, i64 16, !13, i64 24, !18, i64 32}
!25 = distinct !{!25, !26}
!26 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.vl::Ptr" = type { ptr, ptr, ptr, ptr }
%"struct.vl::database::IdObject" = type { i64 }

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

; 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 #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 #2 align 2

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl11collections8ListBaseImmE5ClearEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl8database15buffer_internal12FileUseMasks24InitializeExistingSourceEPNS1_11FileMappingE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.vl::database::IdObject", align 8
  %4 = alloca %"class.vl::Ptr", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %1, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = tail call noundef zeroext i1 @_ZN2vl11collections8ListBaseImmE5ClearEv(ptr noundef nonnull align 8 dereferenceable(33) %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  call void @_ZN2vl8database8IdObjectImLl1EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef 0)
  %8 = load i64, ptr %3, align 8, !tbaa !18
  %.not3 = icmp eq i64 %8, -1
  br i1 %.not3, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %9 = call noundef i64 @_ZN2vl11collections4ListImmE3AddERKm(ptr noundef nonnull align 8 dereferenceable(33) %6, ptr noundef nonnull align 8 dereferenceable(8) %3)
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %.sroa.0.0.copyload = load i64, ptr %3, align 8, !tbaa !20
  call void @_ZN2vl8database15buffer_internal11FileMapping7MapPageENS0_8IdObjectImLl1EEE(ptr dead_on_unwind nonnull writable sret(%"class.vl::Ptr") align 8 %4, ptr noundef nonnull align 8 dereferenceable(152) %10, i64 %.sroa.0.0.copyload)
  %11 = call noundef ptr @_ZNK2vl3PtrINS_8database14BufferPageDescEEptEv(ptr noundef nonnull align 8 dereferenceable(32) %4)
  %12 = load ptr, ptr %11, align 8, !tbaa !21
  %13 = load i64, ptr %12, align 8, !tbaa !20
  store i64 %13, ptr %3, align 8, !tbaa !18
  call void @_ZN2vl3PtrINS_8database14BufferPageDescEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %4) #3
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #3
  %14 = load i64, ptr %3, align 8, !tbaa !18
  %.not = icmp eq i64 %14, -1
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !23

._crit_edge:                                      ; preds = %.lr.ph, %2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 = { 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, !16, i64 80}
!6 = !{!"_ZTSN2vl8database15buffer_internal12FileUseMasksE", !7, i64 0, !8, i64 8, !11, i64 16, !12, i64 24, !11, i64 72, !16, i64 80}
!7 = !{!"_ZTSN2vl6ObjectE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"_ZTSN2vl11collections4ListImmEE", !13, i64 0}
!13 = !{!"_ZTSN2vl11collections8ListBaseImmEE", !14, i64 0, !11, i64 24, !17, i64 32}
!14 = !{!"_ZTSN2vl11collections9ArrayBaseImEE", !15, i64 0, !16, i64 8, !11, i64 16}
!15 = !{!"_ZTSN2vl11collections9ListStoreImLb1EEE", !7, i64 0}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!"bool", !9, i64 0}
!18 = !{!19, !11, i64 0}
!19 = !{!"_ZTSN2vl8database8IdObjectImLl1EEE", !11, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!22, !16, i64 0}
!22 = !{!"_ZTSN2vl8database14BufferPageDescE", !16, i64 0, !11, i64 8, !17, i64 16, !11, i64 24, !17, i64 32}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


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