; 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::SpinLock::Scope" = type { %"class.vl::Object", ptr }
%"class.vl::Object" = type { ptr }
%"class.vl::database::LogManager" = type { %"class.vl::Object", ptr, %"struct.vl::database::IdObject", i8, %"class.vl::database::log_internal::LogAddressItem", %"class.vl::database::log_internal::LogBlocks", %"class.vl::database::log_internal::LogTransactions", %"class.vl::SpinLock" }
%"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::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 }
%"class.vl::database::log_internal::LogBlocks" = type { %"class.vl::Object", ptr, %"struct.vl::database::IdObject", i64, %"struct.vl::database::IdObject.16" }
%"struct.vl::database::IdObject.16" = type { i64 }
%"class.vl::database::log_internal::LogTransactions" = type { %"class.vl::Object", i64, %"class.vl::collections::Dictionary.18", 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::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" }
%"class.vl::SpinLock" = type { %"class.vl::Object", i64 }

; 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) #0

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) #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl8database12log_internal15LogTransactions16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(136), i64) #2 align 2

declare void @_ZN2vl8SpinLock5ScopeC1ERS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database10LogManager16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(304) %0, i64 %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.vl::database::IdObject.17", align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %"class.vl::SpinLock::Scope", align 8
  %9 = alloca %"struct.vl::database::IdObject.17", align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = getelementptr inbounds %"struct.vl::database::IdObject.17", ptr %3, i32 0, i32 0
  store i64 %1, ptr %12, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #5
  store i8 0, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #5
  store i8 1, ptr %6, align 1, !tbaa !9
  %14 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %15 = trunc i8 %14 to i1
  br i1 %15, label %16, label %35

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #5
  %17 = getelementptr inbounds %"class.vl::database::LogManager", ptr %13, i32 0, i32 7
  call void @_ZN2vl8SpinLock5ScopeC1ERS0_(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %17)
  store ptr %8, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %29, %16
  %19 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %20 = trunc i8 %19 to i1
  br i1 %20, label %22, label %21

21:                                               ; preds = %18
  call void @_ZN2vl8SpinLock5ScopeD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %34

22:                                               ; preds = %18
  %23 = getelementptr inbounds %"class.vl::database::LogManager", ptr %13, i32 0, i32 6
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %3, i64 8, i1 false), !tbaa.struct !13
  %24 = getelementptr inbounds %"struct.vl::database::IdObject.17", ptr %9, i32 0, i32 0
  %25 = load i64, ptr %24, align 8
  %26 = invoke noundef zeroext i1 @_ZN2vl8database12log_internal15LogTransactions16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(136) %23, i64 %25)
          to label %27 unwind label %30

27:                                               ; preds = %22
  %28 = zext i1 %26 to i8
  store i8 %28, ptr %5, align 1, !tbaa !9
  br label %29

29:                                               ; preds = %27
  store i8 0, ptr %6, align 1, !tbaa !9
  br label %18, !llvm.loop !16

30:                                               ; preds = %22
  %31 = landingpad { ptr, i32 }
          cleanup
  %32 = extractvalue { ptr, i32 } %31, 0
  store ptr %32, ptr %10, align 8
  %33 = extractvalue { ptr, i32 } %31, 1
  store i32 %33, ptr %11, align 4
  call void @_ZN2vl8SpinLock5ScopeD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  br label %38

34:                                               ; preds = %21
  br label %35

35:                                               ; preds = %34, %2
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  %36 = load i8, ptr %5, align 1, !tbaa !9, !range !11, !noundef !12
  %37 = trunc i8 %36 to i1
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #5
  ret i1 %37

38:                                               ; preds = %30
  %39 = load ptr, ptr %10, align 8
  %40 = load i32, ptr %11, align 4
  %41 = insertvalue { ptr, i32 } poison, ptr %39, 0
  %42 = insertvalue { ptr, i32 } %41, i32 %40, 1
  resume { ptr, i32 } %42
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{i64 0, i64 8, !14}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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::SpinLock::Scope" = type { %"class.vl::Object", ptr }
%"class.vl::Object" = type { ptr }

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 noundef zeroext i1 @_ZN2vl8database12log_internal15LogTransactions16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(136), i64) local_unnamed_addr #1 align 2

declare void @_ZN2vl8SpinLock5ScopeC1ERS0_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN2vl8database10LogManager16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(304) %0, i64 %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.vl::SpinLock::Scope", align 8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %4 = getelementptr inbounds i8, ptr %0, i64 288
  call void @_ZN2vl8SpinLock5ScopeC1ERS0_(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  %5 = getelementptr inbounds i8, ptr %0, i64 152
  %6 = invoke noundef zeroext i1 @_ZN2vl8database12log_internal15LogTransactions16CloseTransactionENS0_8IdObjectImLl3EEE(ptr noundef nonnull align 8 dereferenceable(136) %5, i64 %1)
          to label %7 unwind label %8, !llvm.loop !5

7:                                                ; preds = %2
  call void @_ZN2vl8SpinLock5ScopeD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  ret i1 %6

8:                                                ; preds = %2
  %9 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN2vl8SpinLock5ScopeD1Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  resume { ptr, i32 } %9
}

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 = { "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 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass