; LLVM IR from KoishiDB/Koishi-DB :: src/db_impl.ll (ZN8koishidb6DBimplD2Ev)

; 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.std::unique_lock" = type <{ ptr, i8, [7 x i8] }>
%"struct.std::adopt_lock_t" = type { i8 }
%"class.koishidb::Status" = type { ptr }
%"class.koishidb::DBimpl" = type { %"class.koishidb::DB", %"class.std::deque", %"class.std::shared_mutex", %"class.std::mutex", ptr, ptr, %"class.std::condition_variable", i8, i64, %"struct.std::atomic", %"class.std::vector", i64, ptr }
%"class.koishidb::DB" = type { ptr }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<koishidb::DBimpl::Writer *, std::allocator<koishidb::DBimpl::Writer *>>::_Deque_impl" }
%"struct.std::_Deque_base<koishidb::DBimpl::Writer *, std::allocator<koishidb::DBimpl::Writer *>>::_Deque_impl" = type { %"struct.std::_Deque_base<koishidb::DBimpl::Writer *, std::allocator<koishidb::DBimpl::Writer *>>::_Deque_impl_data" }
%"struct.std::_Deque_base<koishidb::DBimpl::Writer *, std::allocator<koishidb::DBimpl::Writer *>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::shared_mutex" = type { %"class.std::__shared_mutex_pthread" }
%"class.std::__shared_mutex_pthread" = type { %union.pthread_rwlock_t }
%union.pthread_rwlock_t = type { %struct.__pthread_rwlock_arch_t }
%struct.__pthread_rwlock_arch_t = type { i32, i32, i32, i32, i32, i32, i32, i32, i8, [7 x i8], i64, i32 }
%"class.std::mutex" = type { %"class.std::__mutex_base" }
%"class.std::__mutex_base" = type { %union.pthread_mutex_t }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::condition_variable" = type { %"class.std::__condvar" }
%"class.std::__condvar" = type { %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%"struct.std::atomic" = type { %"struct.std::__atomic_base" }
%"struct.std::__atomic_base" = type { i8 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<koishidb::FileMeta *, std::allocator<koishidb::FileMeta *>>::_Vector_impl" }
%"struct.std::_Vector_base<koishidb::FileMeta *, std::allocator<koishidb::FileMeta *>>::_Vector_impl" = type { %"struct.std::_Vector_base<koishidb::FileMeta *, std::allocator<koishidb::FileMeta *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<koishidb::FileMeta *, std::allocator<koishidb::FileMeta *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZTVN8koishidb6DBimplE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@__PRETTY_FUNCTION__._ZN8koishidb6DBimplD2Ev = external hidden unnamed_addr constant [28 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #0

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

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8koishidb6DBimplD2Ev(ptr noundef nonnull align 8 dereferenceable(312) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::unique_lock", align 8
  %4 = alloca %"struct.std::adopt_lock_t", align 1
  %5 = alloca %"class.koishidb::Status", align 8
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTVN8koishidb6DBimplE, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 2
  invoke void @_ZNSt12shared_mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(56) %8)
          to label %9 unwind label %78

9:                                                ; preds = %1
  %10 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 9
  call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %10, i1 noundef zeroext true, i32 noundef 3) #9
  br label %11

11:                                               ; preds = %20, %9
  %12 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 7
  %13 = load i8, ptr %12, align 8, !tbaa !11, !range !33, !noundef !34
  %14 = trunc i8 %13 to i1
  %15 = zext i1 %14 to i32
  %16 = icmp eq i32 %15, 1
  br i1 %16, label %17, label %21

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #9
  %18 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 3
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_St12adopt_lock_t(ptr noundef nonnull align 8 dereferenceable(9) %3, ptr noundef nonnull align 8 dereferenceable(40) %18) #9
  %19 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 6
  invoke void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48) %19, ptr noundef nonnull align 8 dereferenceable(9) %3)
          to label %20 unwind label %78

20:                                               ; preds = %17
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %3) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #9
  br label %11, !llvm.loop !35

21:                                               ; preds = %11
  %22 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 2
  invoke void @_ZNSt12shared_mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(56) %22)
          to label %23 unwind label %78

23:                                               ; preds = %21
  %24 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !37
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %38

27:                                               ; preds = %23
  %28 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 4
  %29 = load ptr, ptr %28, align 8, !tbaa !37
  %30 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 5
  store ptr %29, ptr %30, align 8, !tbaa !38
  invoke void @_ZN8koishidb6DBimpl15CompactMemtableEv(ptr dead_on_unwind writable sret(%"class.koishidb::Status") align 8 %5, ptr noundef nonnull align 8 dereferenceable(312) %7)
          to label %31 unwind label %78

31:                                               ; preds = %27
  call void @_ZN8koishidb6StatusD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %5) #9
  %32 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 5
  store ptr null, ptr %32, align 8, !tbaa !38
  %33 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !37
  %35 = icmp eq ptr %34, null
  br i1 %35, label %37, label %36

36:                                               ; preds = %31
  call void @_ZN8koishidb8MemtableD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %34) #9
  call void @_ZdlPvm(ptr noundef %34, i64 noundef 80) #10
  br label %37

37:                                               ; preds = %36, %31
  br label %38

38:                                               ; preds = %37, %23
  invoke void @_ZN8koishidb6DBimpl12DumpManifestEv(ptr noundef nonnull align 8 dereferenceable(312) %7)
          to label %39 unwind label %78

39:                                               ; preds = %38
  %40 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 5
  %41 = load ptr, ptr %40, align 8, !tbaa !38
  %42 = icmp eq ptr %41, null
  br i1 %42, label %43, label %44

43:                                               ; preds = %39
  br label %46

44:                                               ; preds = %39
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 61, ptr noundef @__PRETTY_FUNCTION__._ZN8koishidb6DBimplD2Ev) #11
  unreachable

45:                                               ; No predecessors!
  br label %46

46:                                               ; preds = %45, %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #9
  store i32 0, ptr %6, align 4, !tbaa !39
  br label %47

47:                                               ; preds = %63, %46
  %48 = load i32, ptr %6, align 4, !tbaa !39
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 10
  %51 = call noundef i64 @_ZNKSt6vectorIPN8koishidb8FileMetaESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %50) #9
  %52 = icmp ult i64 %49, %51
  br i1 %52, label %54, label %53

53:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #9
  br label %66

54:                                               ; preds = %47
  %55 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 10
  %56 = load i32, ptr %6, align 4, !tbaa !39
  %57 = sext i32 %56 to i64
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %55, i64 noundef %57) #9
  %59 = load ptr, ptr %58, align 8, !tbaa !5
  %60 = icmp eq ptr %59, null
  br i1 %60, label %62, label %61

61:                                               ; preds = %54
  call void @_ZN8koishidb8FileMetaD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %59) #9
  call void @_ZdlPvm(ptr noundef %59, i64 noundef 80) #10
  br label %62

62:                                               ; preds = %61, %54
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %6, align 4, !tbaa !39
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %6, align 4, !tbaa !39
  br label %47, !llvm.loop !41

66:                                               ; preds = %53
  %67 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 12
  %68 = load ptr, ptr %67, align 8, !tbaa !42
  %69 = icmp eq ptr %68, null
  br i1 %69, label %74, label %70

70:                                               ; preds = %66
  %71 = load ptr, ptr %68, align 8, !tbaa !9
  %72 = getelementptr inbounds ptr, ptr %71, i64 1
  %73 = load ptr, ptr %72, align 8
  call void %73(ptr noundef nonnull align 8 dereferenceable(8) %68) #9
  br label %74

74:                                               ; preds = %70, %66
  %75 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 10
  call void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %75) #9
  %76 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 6
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %76) #9
  %77 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %7, i32 0, i32 1
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %77) #9
  ret void

78:                                               ; preds = %38, %27, %21, %17, %1
  %79 = landingpad { ptr, i32 }
          catch ptr null
  %80 = extractvalue { ptr, i32 } %79, 0
  call void @__clang_call_terminate(ptr %80) #11
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt12shared_mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(56)) #3 align 2

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) #1 align 2

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

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

declare void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9)) #6

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt12shared_mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(56)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8koishidb6DBimpl15CompactMemtableEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8, ptr noundef nonnull align 8 dereferenceable(312)) #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8koishidb6DBimpl12DumpManifestEv(ptr noundef nonnull align 8 dereferenceable(312)) #3 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #7

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN8koishidb8FileMetaESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

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

attributes #0 = { nobuiltin 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 #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" }
attributes #2 = { 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 #3 = { 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 #4 = { noinline noreturn nounwind uwtable "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { "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 #7 = { noreturn 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin nounwind }
attributes #11 = { noreturn 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, !26, i64 248}
!12 = !{!"_ZTSN8koishidb6DBimplE", !13, i64 0, !14, i64 8, !20, i64 88, !22, i64 144, !6, i64 184, !6, i64 192, !24, i64 200, !26, i64 248, !18, i64 256, !27, i64 264, !29, i64 272, !18, i64 296, !6, i64 304}
!13 = !{!"_ZTSN8koishidb2DBE"}
!14 = !{!"_ZTSSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE16_Deque_impl_dataE", !6, i64 0, !18, i64 8, !19, i64 16, !19, i64 48}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSSt12shared_mutex", !21, i64 0}
!21 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!22 = !{!"_ZTSSt5mutex", !23, i64 0}
!23 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!24 = !{!"_ZTSSt18condition_variable", !25, i64 0}
!25 = !{!"_ZTSSt9__condvar", !7, i64 0}
!26 = !{!"bool", !7, i64 0}
!27 = !{!"_ZTSSt6atomicIbE", !28, i64 0}
!28 = !{!"_ZTSSt13__atomic_baseIbE", !26, i64 0}
!29 = !{!"_ZTSSt6vectorIPN8koishidb8FileMetaESaIS2_EE", !30, i64 0}
!30 = !{!"_ZTSSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE12_Vector_implE", !32, i64 0}
!32 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!33 = !{i8 0, i8 2}
!34 = !{}
!35 = distinct !{!35, !36}
!36 = !{!"llvm.loop.mustprogress"}
!37 = !{!12, !6, i64 184}
!38 = !{!12, !6, i64 192}
!39 = !{!40, !40, i64 0}
!40 = !{!"int", !7, i64 0}
!41 = distinct !{!41, !36}
!42 = !{!12, !6, i64 304}


; 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.std::unique_lock" = type <{ ptr, i8, [7 x i8] }>
%"class.koishidb::Status" = type { ptr }

@_ZTVN8koishidb6DBimplE = external dso_local unnamed_addr constant { [6 x ptr] }, align 8
@.str.1 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@__PRETTY_FUNCTION__._ZN8koishidb6DBimplD2Ev = external hidden unnamed_addr constant [28 x i8], align 1

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind
declare void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8koishidb6DBimplD2Ev(ptr noundef nonnull align 8 dereferenceable(312) %0) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %"class.std::unique_lock", align 8
  %3 = alloca %"class.koishidb::Status", align 8
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTVN8koishidb6DBimplE, i64 16), ptr %0, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 88
  invoke void @_ZNSt12shared_mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(56) %4)
          to label %5 unwind label %.loopexit.split-lp

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 264
  tail call void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1) %6, i1 noundef zeroext true, i32 noundef 3) #9
  %7 = getelementptr inbounds i8, ptr %0, i64 248
  %8 = load i8, ptr %7, align 8, !tbaa !8, !range !32, !noundef !33
  %9 = trunc nuw i8 %8 to i1
  br i1 %9, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 144
  %11 = getelementptr inbounds i8, ptr %0, i64 200
  br label %12

12:                                               ; preds = %.lr.ph, %13
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #9
  call void @_ZNSt11unique_lockISt5mutexEC2ERS0_St12adopt_lock_t(ptr noundef nonnull align 8 dereferenceable(9) %2, ptr noundef nonnull align 8 dereferenceable(40) %10) #9
  invoke void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48) %11, ptr noundef nonnull align 8 dereferenceable(9) %2)
          to label %13 unwind label %.loopexit

13:                                               ; preds = %12
  call void @_ZNSt11unique_lockISt5mutexED2Ev(ptr noundef nonnull align 8 dereferenceable(9) %2) #9
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #9
  %14 = load i8, ptr %7, align 8, !tbaa !8, !range !32, !noundef !33
  %15 = trunc nuw i8 %14 to i1
  br i1 %15, label %12, label %._crit_edge, !llvm.loop !34

._crit_edge:                                      ; preds = %13, %5
  invoke void @_ZNSt12shared_mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(56) %4)
          to label %16 unwind label %.loopexit.split-lp

16:                                               ; preds = %._crit_edge
  %17 = getelementptr inbounds i8, ptr %0, i64 184
  %18 = load ptr, ptr %17, align 8, !tbaa !36
  %.not = icmp eq ptr %18, null
  br i1 %.not, label %25, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %0, i64 192
  store ptr %18, ptr %20, align 8, !tbaa !37
  invoke void @_ZN8koishidb6DBimpl15CompactMemtableEv(ptr dead_on_unwind nonnull writable sret(%"class.koishidb::Status") align 8 %3, ptr noundef nonnull align 8 dereferenceable(312) %0)
          to label %21 unwind label %.loopexit.split-lp

21:                                               ; preds = %19
  call void @_ZN8koishidb6StatusD2Ev(ptr noundef nonnull align 8 dereferenceable(8) %3) #9
  store ptr null, ptr %20, align 8, !tbaa !37
  %22 = load ptr, ptr %17, align 8, !tbaa !36
  %23 = icmp eq ptr %22, null
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  call void @_ZN8koishidb8MemtableD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %22) #9
  call void @_ZdlPvm(ptr noundef nonnull %22, i64 noundef 80) #10
  br label %25

25:                                               ; preds = %21, %24, %16
  invoke void @_ZN8koishidb6DBimpl12DumpManifestEv(ptr noundef nonnull align 8 dereferenceable(312) %0)
          to label %26 unwind label %.loopexit.split-lp

26:                                               ; preds = %25
  %27 = getelementptr inbounds i8, ptr %0, i64 192
  %28 = load ptr, ptr %27, align 8, !tbaa !37
  %29 = icmp eq ptr %28, null
  br i1 %29, label %.preheader, label %32

.preheader:                                       ; preds = %26
  %30 = getelementptr inbounds i8, ptr %0, i64 272
  %31 = call noundef i64 @_ZNKSt6vectorIPN8koishidb8FileMetaESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %30) #9
  %.not11 = icmp eq i64 %31, 0
  br i1 %.not11, label %._crit_edge10, label %.lr.ph9

32:                                               ; preds = %26
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 61, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8koishidb6DBimplD2Ev) #11
  unreachable

._crit_edge10:                                    ; preds = %40, %.preheader
  %33 = getelementptr inbounds i8, ptr %0, i64 304
  %34 = load ptr, ptr %33, align 8, !tbaa !38
  %35 = icmp eq ptr %34, null
  br i1 %35, label %47, label %43

.lr.ph9:                                          ; preds = %.preheader, %40
  %indvars.iv = phi i64 [ %indvars.iv.next, %40 ], [ 0, %.preheader ]
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %30, i64 noundef %indvars.iv) #9
  %37 = load ptr, ptr %36, align 8, !tbaa !39
  %38 = icmp eq ptr %37, null
  br i1 %38, label %40, label %39

39:                                               ; preds = %.lr.ph9
  call void @_ZN8koishidb8FileMetaD2Ev(ptr noundef nonnull align 8 dereferenceable(80) %37) #9
  call void @_ZdlPvm(ptr noundef nonnull %37, i64 noundef 80) #10
  br label %40

40:                                               ; preds = %.lr.ph9, %39
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %41 = call noundef i64 @_ZNKSt6vectorIPN8koishidb8FileMetaESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %30) #9
  %42 = icmp ugt i64 %41, %indvars.iv.next
  br i1 %42, label %.lr.ph9, label %._crit_edge10, !llvm.loop !40

43:                                               ; preds = %._crit_edge10
  %44 = load ptr, ptr %34, align 8, !tbaa !5
  %45 = getelementptr inbounds i8, ptr %44, i64 8
  %46 = load ptr, ptr %45, align 8
  call void %46(ptr noundef nonnull align 8 dereferenceable(8) %34) #9
  br label %47

47:                                               ; preds = %43, %._crit_edge10
  call void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %30) #9
  %48 = getelementptr inbounds i8, ptr %0, i64 200
  call void @_ZNSt18condition_variableD1Ev(ptr noundef nonnull align 8 dereferenceable(48) %48) #9
  %49 = getelementptr inbounds i8, ptr %0, i64 8
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %49) #9
  ret void

.loopexit:                                        ; preds = %12
  %lpad.loopexit = landingpad { ptr, i32 }
          catch ptr null
  br label %50

.loopexit.split-lp:                               ; preds = %1, %._crit_edge, %19, %25
  %lpad.loopexit.split-lp = landingpad { ptr, i32 }
          catch ptr null
  br label %50

50:                                               ; preds = %.loopexit.split-lp, %.loopexit
  %lpad.phi = phi { ptr, i32 } [ %lpad.loopexit, %.loopexit ], [ %lpad.loopexit.split-lp, %.loopexit.split-lp ]
  %51 = extractvalue { ptr, i32 } %lpad.phi, 0
  call void @__clang_call_terminate(ptr %51) #11
  unreachable
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt12shared_mutex4lockEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3 align 2

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6atomicIbE5storeEbSt12memory_order(ptr noundef nonnull align 1 dereferenceable(1), i1 noundef zeroext, i32 noundef) 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) #5

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

declare void @_ZNSt18condition_variable4waitERSt11unique_lockISt5mutexE(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(9)) local_unnamed_addr #6

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt12shared_mutex6unlockEv(ptr noundef nonnull align 8 dereferenceable(56)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8koishidb6DBimpl15CompactMemtableEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8, ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN8koishidb6DBimpl12DumpManifestEv(ptr noundef nonnull align 8 dereferenceable(312)) local_unnamed_addr #3 align 2

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #7

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN8koishidb8FileMetaESaIS2_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

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

attributes #0 = { nobuiltin 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 #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" }
attributes #2 = { 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 #3 = { 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 #4 = { noinline noreturn nounwind uwtable "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { "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 #7 = { noreturn 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 #8 = { 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 #9 = { nounwind }
attributes #10 = { builtin nounwind }
attributes #11 = { noreturn 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, !25, i64 248}
!9 = !{!"_ZTSN8koishidb6DBimplE", !10, i64 0, !11, i64 8, !19, i64 88, !21, i64 144, !15, i64 184, !15, i64 192, !23, i64 200, !25, i64 248, !17, i64 256, !26, i64 264, !28, i64 272, !17, i64 296, !15, i64 304}
!10 = !{!"_ZTSN8koishidb2DBE"}
!11 = !{!"_ZTSSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE", !12, i64 0}
!12 = !{!"_ZTSSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE", !13, i64 0}
!13 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE11_Deque_implE", !14, i64 0}
!14 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE16_Deque_impl_dataE", !15, i64 0, !17, i64 8, !18, i64 16, !18, i64 48}
!15 = !{!"any pointer", !16, i64 0}
!16 = !{!"omnipotent char", !7, i64 0}
!17 = !{!"long", !16, i64 0}
!18 = !{!"_ZTSSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_E", !15, i64 0, !15, i64 8, !15, i64 16, !15, i64 24}
!19 = !{!"_ZTSSt12shared_mutex", !20, i64 0}
!20 = !{!"_ZTSSt22__shared_mutex_pthread", !16, i64 0}
!21 = !{!"_ZTSSt5mutex", !22, i64 0}
!22 = !{!"_ZTSSt12__mutex_base", !16, i64 0}
!23 = !{!"_ZTSSt18condition_variable", !24, i64 0}
!24 = !{!"_ZTSSt9__condvar", !16, i64 0}
!25 = !{!"bool", !16, i64 0}
!26 = !{!"_ZTSSt6atomicIbE", !27, i64 0}
!27 = !{!"_ZTSSt13__atomic_baseIbE", !25, i64 0}
!28 = !{!"_ZTSSt6vectorIPN8koishidb8FileMetaESaIS2_EE", !29, i64 0}
!29 = !{!"_ZTSSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE", !30, i64 0}
!30 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE12_Vector_implE", !31, i64 0}
!31 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE17_Vector_impl_dataE", !15, i64 0, !15, i64 8, !15, i64 16}
!32 = !{i8 0, i8 2}
!33 = !{}
!34 = distinct !{!34, !35}
!35 = !{!"llvm.loop.mustprogress"}
!36 = !{!9, !15, i64 184}
!37 = !{!9, !15, i64 192}
!38 = !{!9, !15, i64 304}
!39 = !{!15, !15, i64 0}
!40 = distinct !{!40, !35}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass