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

; 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 { i32 }
%"class.vl::database::log_internal::LogAddressItem" = type { %"class.vl::Object", ptr, %"struct.vl::database::IdObject", i64, i64, %"class.vl::collections::List" }
%"class.vl::Object" = type { ptr }
%"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::Interface" = type { ptr }

@_ZTVN2vl8database12log_internal14LogAddressItemE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl8database12log_internal14LogAddressItemC2EPNS0_13BufferManagerENS0_8IdObjectIiLl0EEE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1, i32 %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"struct.vl::database::IdObject", align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = getelementptr inbounds %"struct.vl::database::IdObject", ptr %4, i32 0, i32 0
  store i32 %2, ptr %9, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %5, align 8
  call void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  store ptr getelementptr inbounds inrange(-16, 16) ({ [4 x ptr] }, ptr @_ZTVN2vl8database12log_internal14LogAddressItemE, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !9
  %11 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 1
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %12, ptr %11, align 8, !tbaa !11
  %13 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 4 %4, i64 4, i1 false), !tbaa.struct !22
  %14 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 3
  store i64 0, ptr %14, align 8, !tbaa !24
  %15 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 4
  store i64 0, ptr %15, align 8, !tbaa !25
  %16 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 5
  invoke void @_ZN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_EC1Ev(ptr noundef nonnull align 8 dereferenceable(33) %16)
          to label %17 unwind label %28

17:                                               ; preds = %3
  %18 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = invoke noundef i64 @_ZN2vl8database13BufferManager11GetPageSizeEv(ptr noundef nonnull align 8 dereferenceable(168) %19)
          to label %21 unwind label %32

21:                                               ; preds = %17
  %22 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 3
  store i64 %20, ptr %22, align 8, !tbaa !24
  %23 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 3
  %24 = load i64, ptr %23, align 8, !tbaa !24
  %25 = sub i64 %24, 16
  %26 = udiv i64 %25, 8
  %27 = getelementptr inbounds %"class.vl::database::log_internal::LogAddressItem", ptr %10, i32 0, i32 4
  store i64 %26, ptr %27, align 8, !tbaa !25
  ret void

28:                                               ; preds = %3
  %29 = landingpad { ptr, i32 }
          cleanup
  %30 = extractvalue { ptr, i32 } %29, 0
  store ptr %30, ptr %7, align 8
  %31 = extractvalue { ptr, i32 } %29, 1
  store i32 %31, ptr %8, align 4
  br label %36

32:                                               ; preds = %17
  %33 = landingpad { ptr, i32 }
          cleanup
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %7, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %8, align 4
  call void @_ZN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_ED1Ev(ptr noundef nonnull align 8 dereferenceable(33) %16) #5
  br label %36

36:                                               ; preds = %32, %28
  call void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %10) #5
  br label %37

37:                                               ; preds = %36
  %38 = load ptr, ptr %7, align 8
  %39 = load i32, ptr %8, align 4
  %40 = insertvalue { ptr, i32 } poison, ptr %38, 0
  %41 = insertvalue { ptr, i32 } %40, i32 %39, 1
  resume { ptr, i32 } %41
}

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

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

declare i32 @__gxx_personality_v0(...)

declare noundef i64 @_ZN2vl8database13BufferManager11GetPageSizeEv(ptr noundef nonnull align 8 dereferenceable(168)) #3

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

; Function Attrs: nounwind
declare void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #4

attributes #0 = { 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 #1 = { inlinehint 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 "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, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"_ZTSN2vl8database12log_internal14LogAddressItemE", !13, i64 0, !6, i64 8, !14, i64 16, !16, i64 24, !16, i64 32, !17, i64 40}
!13 = !{!"_ZTSN2vl6ObjectE"}
!14 = !{!"_ZTSN2vl8database8IdObjectIiLl0EEE", !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!"_ZTSN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_EE", !18, i64 0}
!18 = !{!"_ZTSN2vl11collections8ListBaseINS_8database8IdObjectImLl1EEES4_EE", !19, i64 0, !16, i64 24, !21, i64 32}
!19 = !{!"_ZTSN2vl11collections9ArrayBaseINS_8database8IdObjectImLl1EEEEE", !20, i64 0, !6, i64 8, !16, i64 16}
!20 = !{!"_ZTSN2vl11collections9ListStoreINS_8database8IdObjectImLl1EEELb1EEE", !13, i64 0}
!21 = !{!"bool", !7, i64 0}
!22 = !{i64 0, i64 4, !23}
!23 = !{!15, !15, i64 0}
!24 = !{!12, !16, i64 24}
!25 = !{!12, !16, i64 32}


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

@_ZTVN2vl8database12log_internal14LogAddressItemE = external dso_local unnamed_addr constant { [4 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN2vl8database12log_internal14LogAddressItemC2EPNS0_13BufferManagerENS0_8IdObjectIiLl0EEE(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef %1, i32 %2) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN2vl6ObjectC2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  store ptr getelementptr inbounds inrange(-16, 16) (i8, ptr @_ZTVN2vl8database12log_internal14LogAddressItemE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %1, ptr %4, align 8, !tbaa !8
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %2, ptr %5, align 8, !tbaa !21
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %6, i8 0, i64 16, i1 false)
  invoke void @_ZN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_EC1Ev(ptr noundef nonnull align 8 dereferenceable(33) %7)
          to label %8 unwind label %15

8:                                                ; preds = %3
  %9 = load ptr, ptr %4, align 8, !tbaa !8
  %10 = invoke noundef i64 @_ZN2vl8database13BufferManager11GetPageSizeEv(ptr noundef nonnull align 8 dereferenceable(168) %9)
          to label %11 unwind label %17

11:                                               ; preds = %8
  %12 = getelementptr inbounds i8, ptr %0, i64 32
  store i64 %10, ptr %6, align 8, !tbaa !22
  %13 = add i64 %10, -16
  %14 = lshr i64 %13, 3
  store i64 %14, ptr %12, align 8, !tbaa !23
  ret void

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

17:                                               ; preds = %8
  %18 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_ED1Ev(ptr noundef nonnull align 8 dereferenceable(33) %7) #5
  br label %19

19:                                               ; preds = %17, %15
  %.pn = phi { ptr, i32 } [ %18, %17 ], [ %16, %15 ]
  tail call void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %0) #5
  resume { ptr, i32 } %.pn
}

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

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

declare i32 @__gxx_personality_v0(...)

declare noundef i64 @_ZN2vl8database13BufferManager11GetPageSizeEv(ptr noundef nonnull align 8 dereferenceable(168)) local_unnamed_addr #2

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

; Function Attrs: nounwind
declare void @_ZN2vl6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { 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 #1 = { inlinehint 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 = { "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 "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: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !11, i64 8}
!9 = !{!"_ZTSN2vl8database12log_internal14LogAddressItemE", !10, i64 0, !11, i64 8, !13, i64 16, !15, i64 24, !15, i64 32, !16, i64 40}
!10 = !{!"_ZTSN2vl6ObjectE"}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"_ZTSN2vl8database8IdObjectIiLl0EEE", !14, i64 0}
!14 = !{!"int", !12, i64 0}
!15 = !{!"long", !12, i64 0}
!16 = !{!"_ZTSN2vl11collections4ListINS_8database8IdObjectImLl1EEES4_EE", !17, i64 0}
!17 = !{!"_ZTSN2vl11collections8ListBaseINS_8database8IdObjectImLl1EEES4_EE", !18, i64 0, !15, i64 24, !20, i64 32}
!18 = !{!"_ZTSN2vl11collections9ArrayBaseINS_8database8IdObjectImLl1EEEEE", !19, i64 0, !11, i64 8, !15, i64 16}
!19 = !{!"_ZTSN2vl11collections9ListStoreINS_8database8IdObjectImLl1EEELb1EEE", !10, i64 0}
!20 = !{!"bool", !12, i64 0}
!21 = !{!14, !14, i64 0}
!22 = !{!9, !15, i64 24}
!23 = !{!9, !15, i64 32}


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