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

; 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.std::_Deque_iterator" = type { ptr, ptr, ptr, 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" }
%"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 }
%"struct.koishidb::DBimpl::Writer" = type { ptr, i8, %"class.std::condition_variable" }

@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE = external hidden unnamed_addr constant [62 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr noundef %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca %"struct.std::_Deque_iterator", align 8
  %10 = alloca %"struct.std::_Deque_iterator", align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %13 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %14 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %13, i32 0, i32 1
  %15 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %14) #5
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %16, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %"struct.koishidb::DBimpl::Writer", ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  store ptr %19, ptr %6, align 8, !tbaa !5
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %2
  br label %25

23:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.2, i32 noundef 222, ptr noundef @__PRETTY_FUNCTION__._ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE) #6
  unreachable

24:                                               ; No predecessors!
  br label %25

25:                                               ; preds = %24, %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef %26)
  store i64 %27, ptr %7, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 1048576, ptr %8, align 8, !tbaa !14
  %28 = load i64, ptr %7, align 8, !tbaa !14
  %29 = icmp ule i64 %28, 131072
  br i1 %29, label %30, label %33

30:                                               ; preds = %25
  %31 = load i64, ptr %7, align 8, !tbaa !14
  %32 = add i64 %31, 131072
  store i64 %32, ptr %8, align 8, !tbaa !14
  br label %33

33:                                               ; preds = %30, %25
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %34, ptr %35, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #5
  %36 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %13, i32 0, i32 1
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5beginEv(ptr dead_on_unwind writable sret(%"struct.std::_Deque_iterator") align 8 %9, ptr noundef nonnull align 8 dereferenceable(80) %36) #5
  %37 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32) %9) #5
  br label %38

38:                                               ; preds = %68, %33
  call void @llvm.lifetime.start.p0(i64 32, ptr %10) #5
  %39 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %13, i32 0, i32 1
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE3endEv(ptr dead_on_unwind writable sret(%"struct.std::_Deque_iterator") align 8 %10, ptr noundef nonnull align 8 dereferenceable(80) %39) #5
  %40 = call noundef zeroext i1 @_ZStneRKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_ES8_(ptr noundef nonnull align 8 dereferenceable(32) %9, ptr noundef nonnull align 8 dereferenceable(32) %10) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %10) #5
  br i1 %40, label %41, label %70

41:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EdeEv(ptr noundef nonnull align 8 dereferenceable(32) %9) #5
  %43 = load ptr, ptr %42, align 8, !tbaa !5
  store ptr %43, ptr %11, align 8, !tbaa !5
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = icmp ne ptr %44, null
  br i1 %45, label %46, label %62

46:                                               ; preds = %41
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %"struct.koishidb::DBimpl::Writer", ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !9
  %50 = call noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef %49)
  %51 = load i64, ptr %7, align 8, !tbaa !14
  %52 = add i64 %51, %50
  store i64 %52, ptr %7, align 8, !tbaa !14
  %53 = load i64, ptr %7, align 8, !tbaa !14
  %54 = load i64, ptr %8, align 8, !tbaa !14
  %55 = icmp ugt i64 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %46
  store i32 2, ptr %12, align 4
  br label %65

57:                                               ; preds = %46
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = load ptr, ptr %11, align 8, !tbaa !5
  %60 = getelementptr inbounds %"struct.koishidb::DBimpl::Writer", ptr %59, i32 0, i32 0
  %61 = load ptr, ptr %60, align 8, !tbaa !9
  call void @_ZN8koishidb18WriteBatchInternal6AppendEPKNS_10WriteBatchEPS1_(ptr noundef %58, ptr noundef %61)
  br label %62

62:                                               ; preds = %57, %41
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %63, ptr %64, align 8, !tbaa !5
  store i32 0, ptr %12, align 4
  br label %65

65:                                               ; preds = %62, %56
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  %66 = load i32, ptr %12, align 4
  switch i32 %66, label %72 [
    i32 0, label %67
    i32 2, label %70
  ]

67:                                               ; preds = %65
  br label %68

68:                                               ; preds = %67
  %69 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32) %9) #5
  br label %38, !llvm.loop !16

70:                                               ; preds = %65, %38
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %71

72:                                               ; preds = %65
  unreachable
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.std::_Deque_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_ES8_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE3endEv(ptr dead_on_unwind noalias writable sret(%"struct.std::_Deque_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(80)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EdeEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

declare void @_ZN8koishidb18WriteBatchInternal6AppendEPKNS_10WriteBatchEPS1_(ptr noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { "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 }
attributes #6 = { 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, !6, i64 0}
!10 = !{!"_ZTSN8koishidb6DBimpl6WriterE", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSSt18condition_variable", !13, i64 0}
!13 = !{!"_ZTSSt9__condvar", !7, i64 0}
!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"

%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@__PRETTY_FUNCTION__._ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE = external hidden unnamed_addr constant [62 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE(ptr noundef nonnull align 8 dereferenceable(312) %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #3 align 2 {
  %3 = alloca %"struct.std::_Deque_iterator", align 8
  %4 = alloca %"struct.std::_Deque_iterator", align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5frontEv(ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %10

9:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.2, i32 noundef 222, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN8koishidb6DBimpl20BuildWriteBatchGroupEPPNS0_6WriterE) #6
  unreachable

10:                                               ; preds = %2
  %11 = tail call noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef nonnull %8)
  %12 = icmp ult i64 %11, 131073
  %13 = add nuw nsw i64 %11, 131072
  %spec.select = select i1 %12, i64 %13, i64 1048576
  store ptr %7, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5beginEv(ptr dead_on_unwind nonnull writable sret(%"struct.std::_Deque_iterator") align 8 %3, ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  %14 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.std::_Deque_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  %15 = call noundef zeroext i1 @_ZStneRKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_ES8_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  br i1 %15, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10, %25
  %.01830 = phi i64 [ %.1, %25 ], [ %11, %10 ]
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EdeEv(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %.not25 = icmp eq ptr %17, null
  br i1 %.not25, label %25, label %18

18:                                               ; preds = %.lr.ph
  %19 = load ptr, ptr %17, align 8, !tbaa !9
  %20 = call noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef %19)
  %21 = add i64 %20, %.01830
  %22 = icmp ugt i64 %21, %spec.select
  br i1 %22, label %._crit_edge, label %23

23:                                               ; preds = %18
  %24 = load ptr, ptr %17, align 8, !tbaa !9
  call void @_ZN8koishidb18WriteBatchInternal6AppendEPKNS_10WriteBatchEPS1_(ptr noundef nonnull %8, ptr noundef %24)
  br label %25

25:                                               ; preds = %.lr.ph, %23
  %.1 = phi i64 [ %21, %23 ], [ %.01830, %.lr.ph ]
  store ptr %17, ptr %1, align 8, !tbaa !5
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32) %3) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #5
  call void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE3endEv(ptr dead_on_unwind nonnull writable sret(%"struct.std::_Deque_iterator") align 8 %4, ptr noundef nonnull align 8 dereferenceable(80) %5) #5
  %27 = call noundef zeroext i1 @_ZStneRKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_ES8_(ptr noundef nonnull align 8 dereferenceable(32) %3, ptr noundef nonnull align 8 dereferenceable(32) %4) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #5
  br i1 %27, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %25, %18, %10
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  ret ptr %8
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN8koishidb18WriteBatchInternal5BytesEPNS_10WriteBatchE(ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE5beginEv(ptr dead_on_unwind noalias writable sret(%"struct.std::_Deque_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EppEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_ES8_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE3endEv(ptr dead_on_unwind noalias writable sret(%"struct.std::_Deque_iterator") align 8, ptr noundef nonnull align 8 dereferenceable(80)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_EdeEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

declare void @_ZN8koishidb18WriteBatchInternal6AppendEPKNS_10WriteBatchEPS1_(ptr noundef, ptr noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 #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 = { "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 }
attributes #6 = { 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, !6, i64 0}
!10 = !{!"_ZTSN8koishidb6DBimpl6WriterE", !6, i64 0, !11, i64 8, !12, i64 16}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTSSt18condition_variable", !13, i64 0}
!13 = !{!"_ZTSSt9__condvar", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass