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

; 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.0" = type { i32 }
%"class.vl::SpinLock::Scope" = type { %"class.vl::Object", ptr }
%"class.vl::Object" = type { ptr }
%"class.vl::database::LockManager" = type { %"class.vl::Object", ptr, %"class.vl::SpinLock", %"class.vl::collections::Dictionary", %"class.vl::collections::Dictionary.10", %"class.vl::collections::Array", %"class.vl::collections::Dictionary.33" }
%"class.vl::SpinLock" = type { %"class.vl::Object", i64 }
%"class.vl::collections::Dictionary" = type { %"class.vl::Object", %"class.vl::collections::SortedList", %"class.vl::collections::List", %"class.vl::collections::IEnumerable.9" }
%"class.vl::collections::SortedList" = 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::collections::List" = type { %"class.vl::collections::ListBase.base.8", %"class.vl::collections::IEnumerable.6" }
%"class.vl::collections::ListBase.base.8" = type <{ %"class.vl::collections::ArrayBase.base.7", i64, i8 }>
%"class.vl::collections::ArrayBase.base.7" = type { %"class.vl::collections::ListStore.5", ptr, i64 }
%"class.vl::collections::ListStore.5" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.6" = type { %"class.vl::Interface" }
%"class.vl::collections::IEnumerable.9" = type { %"class.vl::Interface" }
%"class.vl::collections::Dictionary.10" = type { %"class.vl::Object", %"class.vl::collections::SortedList.11", %"class.vl::collections::List.19", %"class.vl::collections::IEnumerable.27" }
%"class.vl::collections::SortedList.11" = type { %"class.vl::collections::ListBase.base.17", %"class.vl::collections::IEnumerable.15" }
%"class.vl::collections::ListBase.base.17" = type <{ %"class.vl::collections::ArrayBase.base.16", i64, i8 }>
%"class.vl::collections::ArrayBase.base.16" = type { %"class.vl::collections::ListStore.14", ptr, i64 }
%"class.vl::collections::ListStore.14" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.15" = type { %"class.vl::Interface" }
%"class.vl::collections::List.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::IEnumerable.27" = type { %"class.vl::Interface" }
%"class.vl::collections::Array" = type { %"class.vl::collections::ArrayBase.base.32", %"class.vl::collections::IEnumerable.31" }
%"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::Dictionary.33" = type { %"class.vl::Object", %"class.vl::collections::SortedList.34", %"class.vl::collections::List.42", %"class.vl::collections::IEnumerable.50" }
%"class.vl::collections::SortedList.34" = type { %"class.vl::collections::ListBase.base.40", %"class.vl::collections::IEnumerable.38" }
%"class.vl::collections::ListBase.base.40" = type <{ %"class.vl::collections::ArrayBase.base.39", i64, i8 }>
%"class.vl::collections::ArrayBase.base.39" = type { %"class.vl::collections::ListStore.37", ptr, i64 }
%"class.vl::collections::ListStore.37" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.38" = type { %"class.vl::Interface" }
%"class.vl::collections::List.42" = type { %"class.vl::collections::ListBase.base.48", %"class.vl::collections::IEnumerable.46" }
%"class.vl::collections::ListBase.base.48" = type <{ %"class.vl::collections::ArrayBase.base.47", i64, i8 }>
%"class.vl::collections::ArrayBase.base.47" = type { %"class.vl::collections::ListStore.45", ptr, i64 }
%"class.vl::collections::ListStore.45" = type { %"class.vl::Object" }
%"class.vl::collections::IEnumerable.46" = type { %"class.vl::Interface" }
%"class.vl::collections::IEnumerable.50" = type { %"class.vl::Interface" }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(33) ptr @_ZNK2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E4KeysEv(ptr noundef nonnull align 8 dereferenceable(104)) #0 align 2

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

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

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

declare i32 @__gxx_personality_v0(...)

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 @_ZN2vl8database11LockManager15UnregisterTableENS0_8IdObjectIiLl4EEE(ptr noundef nonnull align 8 dereferenceable(400) %0, i32 %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca i1, align 1
  %4 = alloca %"struct.vl::database::IdObject.0", align 4
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca %"class.vl::SpinLock::Scope", align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = getelementptr inbounds %"struct.vl::database::IdObject.0", ptr %4, i32 0, i32 0
  store i32 %1, ptr %12, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  %13 = load ptr, ptr %5, align 8
  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 %41

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::LockManager", ptr %13, i32 0, i32 2
  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 = %37, %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
  store i32 2, ptr %9, align 4
  br label %38

22:                                               ; preds = %18
  %23 = getelementptr inbounds %"class.vl::database::LockManager", ptr %13, i32 0, i32 3
  %24 = invoke noundef nonnull align 8 dereferenceable(33) ptr @_ZNK2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E4KeysEv(ptr noundef nonnull align 8 dereferenceable(104) %23)
          to label %25 unwind label %29

25:                                               ; preds = %22
  %26 = invoke noundef zeroext i1 @_ZNK2vl11collections10SortedListINS_8database8IdObjectIiLl4EEES4_E8ContainsERKS4_(ptr noundef nonnull align 8 dereferenceable(33) %24, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %27 unwind label %29

27:                                               ; preds = %25
  br i1 %26, label %33, label %28

28:                                               ; preds = %27
  store i1 false, ptr %3, align 1
  store i32 1, ptr %9, align 4
  br label %38

29:                                               ; preds = %33, %25, %22
  %30 = landingpad { ptr, i32 }
          cleanup
  %31 = extractvalue { ptr, i32 } %30, 0
  store ptr %31, ptr %10, align 8
  %32 = extractvalue { ptr, i32 } %30, 1
  store i32 %32, 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
  br label %47

33:                                               ; preds = %27
  %34 = getelementptr inbounds %"class.vl::database::LockManager", ptr %13, i32 0, i32 3
  %35 = invoke noundef zeroext i1 @_ZN2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E6RemoveERKS4_(ptr noundef nonnull align 8 dereferenceable(104) %34, ptr noundef nonnull align 4 dereferenceable(4) %4)
          to label %36 unwind label %29

36:                                               ; preds = %33
  br label %37

37:                                               ; preds = %36
  store i8 0, ptr %6, align 1, !tbaa !9
  br label %18, !llvm.loop !13

38:                                               ; preds = %28, %21
  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
  %39 = load i32, ptr %9, align 4
  switch i32 %39, label %42 [
    i32 2, label %40
  ]

40:                                               ; preds = %38
  br label %41

41:                                               ; preds = %40, %2
  store i32 0, ptr %9, align 4
  br label %42

42:                                               ; preds = %41, %38
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #5
  %43 = load i32, ptr %9, align 4
  switch i32 %43, label %52 [
    i32 0, label %44
    i32 1, label %45
  ]

44:                                               ; preds = %42
  store i1 true, ptr %3, align 1
  br label %45

45:                                               ; preds = %44, %42
  %46 = load i1, ptr %3, align 1
  ret i1 %46

47:                                               ; preds = %29
  %48 = load ptr, ptr %10, align 8
  %49 = load i32, ptr %11, align 4
  %50 = insertvalue { ptr, i32 } poison, ptr %48, 0
  %51 = insertvalue { ptr, i32 } %50, i32 %49, 1
  resume { ptr, i32 } %51

52:                                               ; preds = %42
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E6RemoveERKS4_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 4 dereferenceable(4)) #1 align 2

attributes #0 = { 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 #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 = { nocallback nofree nosync 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"struct.vl::database::IdObject.0" = type { i32 }
%"class.vl::SpinLock::Scope" = type { %"class.vl::Object", ptr }
%"class.vl::Object" = type { ptr }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(33) ptr @_ZNK2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E4KeysEv(ptr noundef nonnull align 8 dereferenceable(104)) local_unnamed_addr #0 align 2

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

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

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

declare i32 @__gxx_personality_v0(...)

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 @_ZN2vl8database11LockManager15UnregisterTableENS0_8IdObjectIiLl4EEE(ptr noundef nonnull align 8 dereferenceable(400) %0, i32 %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"struct.vl::database::IdObject.0", align 4
  %4 = alloca %"class.vl::SpinLock::Scope", align 8
  store i32 %1, ptr %3, align 4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  call void @_ZN2vl8SpinLock5ScopeC1ERS0_(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 8 dereferenceable(16) %5)
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  br label %7

7:                                                ; preds = %14, %2
  %.07 = phi i1 [ true, %2 ], [ false, %14 ]
  br i1 %.07, label %8, label %.critedge

8:                                                ; preds = %7
  %9 = call noundef nonnull align 8 dereferenceable(33) ptr @_ZNK2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E4KeysEv(ptr noundef nonnull align 8 dereferenceable(104) %6)
  %10 = invoke noundef zeroext i1 @_ZNK2vl11collections10SortedListINS_8database8IdObjectIiLl4EEES4_E8ContainsERKS4_(ptr noundef nonnull align 8 dereferenceable(33) %9, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %11 unwind label %12

11:                                               ; preds = %8
  br i1 %10, label %14, label %16

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

14:                                               ; preds = %11
  %15 = invoke noundef zeroext i1 @_ZN2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E6RemoveERKS4_(ptr noundef nonnull align 8 dereferenceable(104) %6, ptr noundef nonnull align 4 dereferenceable(4) %3)
          to label %7 unwind label %12, !llvm.loop !5

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

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

17:                                               ; preds = %16, %.critedge
  %.3 = xor i1 %.07, true
  ret i1 %.3
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN2vl11collections10DictionaryINS_8database8IdObjectIiLl4EEENS_3PtrINS2_11LockManager9TableInfoEEES4_PS7_E6RemoveERKS4_(ptr noundef nonnull align 8 dereferenceable(104), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1 align 2

attributes #0 = { 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 #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 nocallback nofree nosync 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopUnrollPass,SROAPass,SimplifyCFGPass