; 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.17" = type { i64 }
%"class.vl::database::log_internal::LogTransactions" = type { %"class.vl::Object", i64, %"class.vl::collections::Dictionary.18", ptr }
%"class.vl::Object" = type { ptr }
%"class.vl::collections::Dictionary.18" = type { %"class.vl::Object", %"class.vl::collections::SortedList.19", %"class.vl::collections::List.27", %"class.vl::collections::IEnumerable.35" }
%"class.vl::collections::SortedList.19" = type { %"class.vl::collections::ListBase.base.25", %"class.vl::collections::IEnumerable.23" }
%"class.vl::collections::ListBase.base.25" = type <{ %"class.vl::collections::ArrayBase.base.24", i64, i8 }>
%"class.vl::collections::ArrayBase.base.24" = type { %"class.vl::collections::ListStore.22", ptr, i64 }
%"class.vl::collections::ListStore.22" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.23" = type { %"class.vl::Interface" }
%"class.vl::Interface" = type { ptr }
%"class.vl::collections::List.27" = type { %"class.vl::collections::ListBase.base.33", %"class.vl::collections::IEnumerable.31" }
%"class.vl::collections::ListBase.base.33" = type <{ %"class.vl::collections::ArrayBase.base.32", i64, i8 }>
%"class.vl::collections::ArrayBase.base.32" = type { %"class.vl::collections::ListStore.30", ptr, i64 }
%"class.vl::collections::ListStore.30" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.31" = type { %"class.vl::Interface" }
%"class.vl::collections::IEnumerable.35" = type { %"class.vl::Interface" }

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN2vl8database12log_internal15LogTransactions14GetTransactionEm(ptr noundef nonnull align 8 dereferenceable(136) %0, i64 noundef %1) #0 align 2 {
  %3 = alloca %"struct.vl::database::IdObject.17", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load i64, ptr %5, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.vl::database::log_internal::LogTransactions", ptr %6, i32 0, i32 1
  %9 = load volatile i64, ptr %8, align 8, !tbaa !11
  %10 = icmp ult i64 %7, %9
  br i1 %10, label %11, label %13

11:                                               ; preds = %2
  %12 = load i64, ptr %5, align 8, !tbaa !9
  call void @_ZN2vl8database8IdObjectImLl3EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %12)
  br label %16

13:                                               ; preds = %2
  %14 = call i64 @_ZN2vl8database8IdObjectImLl3EE7InvalidEv()
  %15 = getelementptr inbounds %"struct.vl::database::IdObject.17", ptr %3, i32 0, i32 0
  store i64 %14, ptr %15, align 8
  br label %16

16:                                               ; preds = %13, %11
  %17 = getelementptr inbounds %"struct.vl::database::IdObject.17", ptr %3, i32 0, i32 0
  %18 = load i64, ptr %17, align 8
  ret i64 %18
}

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

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

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 = { 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" }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"_ZTSN2vl8database12log_internal15LogTransactionsE", !13, i64 0, !10, i64 8, !14, i64 16, !6, i64 128}
!13 = !{!"_ZTSN2vl6ObjectE"}
!14 = !{!"_ZTSN2vl11collections10DictionaryINS_8database8IdObjectImLl3EEENS_3PtrINS2_12log_internal12LogTransDescEEES4_PS7_EE", !13, i64 0, !15, i64 8, !20, i64 56}
!15 = !{!"_ZTSN2vl11collections10SortedListINS_8database8IdObjectImLl3EEES4_EE", !16, i64 0}
!16 = !{!"_ZTSN2vl11collections8ListBaseINS_8database8IdObjectImLl3EEES4_EE", !17, i64 0, !10, i64 24, !19, i64 32}
!17 = !{!"_ZTSN2vl11collections9ArrayBaseINS_8database8IdObjectImLl3EEEEE", !18, i64 0, !6, i64 8, !10, i64 16}
!18 = !{!"_ZTSN2vl11collections9ListStoreINS_8database8IdObjectImLl3EEELb1EEE", !13, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"_ZTSN2vl11collections4ListINS_3PtrINS_8database12log_internal12LogTransDescEEEPS5_EE", !21, i64 0}
!21 = !{!"_ZTSN2vl11collections8ListBaseINS_3PtrINS_8database12log_internal12LogTransDescEEEPS5_EE", !22, i64 0, !10, i64 24, !19, i64 32}
!22 = !{!"_ZTSN2vl11collections9ArrayBaseINS_3PtrINS_8database12log_internal12LogTransDescEEEEE", !23, i64 0, !6, i64 8, !10, i64 16}
!23 = !{!"_ZTSN2vl11collections9ListStoreINS_3PtrINS_8database12log_internal12LogTransDescEEELb0EEE", !13, 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"

%"struct.vl::database::IdObject.17" = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local i64 @_ZN2vl8database12log_internal15LogTransactions14GetTransactionEm(ptr noundef nonnull align 8 dereferenceable(136) %0, i64 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %"struct.vl::database::IdObject.17", align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load volatile i64, ptr %4, align 8, !tbaa !5
  %6 = icmp ugt i64 %5, %1
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  call void @_ZN2vl8database8IdObjectImLl3EEC2Em(ptr noundef nonnull align 8 dereferenceable(8) %3, i64 noundef %1)
  %.pre = load i64, ptr %3, align 8
  br label %10

8:                                                ; preds = %2
  %9 = tail call i64 @_ZN2vl8database8IdObjectImLl3EE7InvalidEv()
  br label %10

10:                                               ; preds = %8, %7
  %11 = phi i64 [ %9, %8 ], [ %.pre, %7 ]
  ret i64 %11
}

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

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

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 = { 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" }

!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 8}
!6 = !{!"_ZTSN2vl8database12log_internal15LogTransactionsE", !7, i64 0, !8, i64 8, !11, i64 16, !16, i64 128}
!7 = !{!"_ZTSN2vl6ObjectE"}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN2vl11collections10DictionaryINS_8database8IdObjectImLl3EEENS_3PtrINS2_12log_internal12LogTransDescEEES4_PS7_EE", !7, i64 0, !12, i64 8, !18, i64 56}
!12 = !{!"_ZTSN2vl11collections10SortedListINS_8database8IdObjectImLl3EEES4_EE", !13, i64 0}
!13 = !{!"_ZTSN2vl11collections8ListBaseINS_8database8IdObjectImLl3EEES4_EE", !14, i64 0, !8, i64 24, !17, i64 32}
!14 = !{!"_ZTSN2vl11collections9ArrayBaseINS_8database8IdObjectImLl3EEEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSN2vl11collections9ListStoreINS_8database8IdObjectImLl3EEELb1EEE", !7, i64 0}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!"bool", !9, i64 0}
!18 = !{!"_ZTSN2vl11collections4ListINS_3PtrINS_8database12log_internal12LogTransDescEEEPS5_EE", !19, i64 0}
!19 = !{!"_ZTSN2vl11collections8ListBaseINS_3PtrINS_8database12log_internal12LogTransDescEEEPS5_EE", !20, i64 0, !8, i64 24, !17, i64 32}
!20 = !{!"_ZTSN2vl11collections9ArrayBaseINS_3PtrINS_8database12log_internal12LogTransDescEEEEE", !21, i64 0, !16, i64 8, !8, i64 16}
!21 = !{!"_ZTSN2vl11collections9ListStoreINS_3PtrINS_8database12log_internal12LogTransDescEEELb0EEE", !7, i64 0}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,SROAPass,TailCallElimPass