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

; 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.koishidb::Status" = type { ptr }
%"class.koishidb::Slice" = type { ptr, i64 }
%"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 }

@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@__FUNCTION__._ZN8koishidb6DBimpl12ReadManifestEv = external hidden unnamed_addr constant [13 x i8], align 1
@stdout = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8koishidb6DBimpl12ReadManifestEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8 %0, ptr noundef nonnull align 8 dereferenceable(312) %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %"class.koishidb::Slice", align 8
  %9 = alloca %"class.koishidb::Slice", align 8
  %10 = alloca i32, align 4
  %11 = alloca [4196 x i8], align 16
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca %"class.koishidb::Slice", align 8
  %15 = alloca i32, align 4
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  %20 = call i32 (ptr, i32, ...) @open(ptr noundef @.str.3, i32 noundef 0)
  store i32 %20, ptr %5, align 4, !tbaa !9
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = icmp eq i32 %21, -1
  br i1 %22, label %23, label %31

23:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store ptr getelementptr (i8, ptr @.str.2, i64 1), ptr %6, align 8, !tbaa !5
  store ptr getelementptr (i8, ptr @.str.2, i64 1), ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_Z15OutputLogHeaderPKciS0_i(ptr noundef %24, i32 noundef 76, ptr noundef @__FUNCTION__._ZN8koishidb6DBimpl12ReadManifestEv, i32 noundef 500)
  %25 = load ptr, ptr @stdout, align 8, !tbaa !5
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef @.str.4) #6
  %27 = load ptr, ptr @stdout, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.5) #6
  %29 = load ptr, ptr @stdout, align 8, !tbaa !5
  %30 = call i32 @fflush(ptr noundef %29)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @_ZN8koishidb5SliceC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef @.str.4)
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #6
  call void @_ZN8koishidb5SliceC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @_ZN8koishidb6Status10CorruptionERKNS_5SliceES3_(ptr dead_on_unwind writable sret(%"class.koishidb::Status") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef nonnull align 8 dereferenceable(16) %9)
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  store i32 1, ptr %10, align 4
  br label %68

31:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4196, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  br label %32

32:                                               ; preds = %41, %31
  %33 = load i32, ptr %5, align 4, !tbaa !9
  %34 = getelementptr inbounds [4196 x i8], ptr %11, i64 0, i64 0
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds i8, ptr %34, i64 %36
  %38 = call i64 @read(i32 noundef %33, ptr noundef %37, i64 noundef 4196)
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr %13, align 4, !tbaa !9
  %40 = icmp sgt i32 %39, 0
  br i1 %40, label %41, label %45

41:                                               ; preds = %32
  %42 = load i32, ptr %13, align 4, !tbaa !9
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = add nsw i32 %43, %42
  store i32 %44, ptr %12, align 4, !tbaa !9
  br label %32, !llvm.loop !11

45:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  %46 = getelementptr inbounds [4196 x i8], ptr %11, i64 0, i64 0
  %47 = load i32, ptr %12, align 4, !tbaa !9
  %48 = sext i32 %47 to i64
  call void @_ZN8koishidb5SliceC1EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef %46, i64 noundef %48)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  call void @_ZN8koishidb11GetVarint32EPNS_5SliceEPj(ptr noundef %14, ptr noundef %15)
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %49 = call noundef zeroext i1 @_ZN8koishidb11GetVarint64EPNS_5SliceEPm(ptr noundef %14, ptr noundef %16)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  store i32 0, ptr %17, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %57, %45
  %51 = load i32, ptr %17, align 4, !tbaa !9
  %52 = load i32, ptr %15, align 4, !tbaa !9
  %53 = icmp ult i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  store i32 4, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %60

55:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  call void @_ZN8koishidb14DecodeFileMetaEPPNS_8FileMetaEPNS_5SliceE(ptr noundef %18, ptr noundef %14)
  %56 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %19, i32 0, i32 10
  call void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %56, ptr noundef nonnull align 8 dereferenceable(8) %18)
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  br label %57

57:                                               ; preds = %55
  %58 = load i32, ptr %17, align 4, !tbaa !9
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %17, align 4, !tbaa !9
  br label %50, !llvm.loop !13

60:                                               ; preds = %54
  %61 = load i64, ptr %16, align 8, !tbaa !14
  %62 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %19, i32 0, i32 8
  store i64 %61, ptr %62, align 8, !tbaa !16
  %63 = load i32, ptr %15, align 4, !tbaa !9
  %64 = zext i32 %63 to i64
  %65 = getelementptr inbounds %"class.koishidb::DBimpl", ptr %19, i32 0, i32 11
  store i64 %64, ptr %65, align 8, !tbaa !37
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = call i32 @close(i32 noundef %66)
  call void @_ZN8koishidb6Status2OKEv(ptr dead_on_unwind writable sret(%"class.koishidb::Status") align 8 %0)
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4196, ptr %11) #6
  br label %68

68:                                               ; preds = %60, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  ret void
}

; 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

declare i32 @open(ptr noundef, i32 noundef, ...) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z15OutputLogHeaderPKciS0_i(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #4

declare i32 @fflush(ptr noundef) #2

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

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

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

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #2

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

declare void @_ZN8koishidb11GetVarint32EPNS_5SliceEPj(ptr noundef, ptr noundef) #2

declare noundef zeroext i1 @_ZN8koishidb11GetVarint64EPNS_5SliceEPm(ptr noundef, ptr noundef) #2

declare void @_ZN8koishidb14DecodeFileMetaEPPNS_8FileMetaEPNS_5SliceE(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) #0 align 2

declare i32 @close(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8koishidb6Status2OKEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8) #5 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { 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 #6 = { 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 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = !{!17, !15, i64 256}
!17 = !{!"_ZTSN8koishidb6DBimplE", !18, i64 0, !19, i64 8, !24, i64 88, !26, i64 144, !6, i64 184, !6, i64 192, !28, i64 200, !30, i64 248, !15, i64 256, !31, i64 264, !33, i64 272, !15, i64 296, !6, i64 304}
!18 = !{!"_ZTSN8koishidb2DBE"}
!19 = !{!"_ZTSSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE", !21, i64 0}
!21 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE11_Deque_implE", !22, i64 0}
!22 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE16_Deque_impl_dataE", !6, i64 0, !15, i64 8, !23, i64 16, !23, i64 48}
!23 = !{!"_ZTSSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!24 = !{!"_ZTSSt12shared_mutex", !25, i64 0}
!25 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!26 = !{!"_ZTSSt5mutex", !27, i64 0}
!27 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!28 = !{!"_ZTSSt18condition_variable", !29, i64 0}
!29 = !{!"_ZTSSt9__condvar", !7, i64 0}
!30 = !{!"bool", !7, i64 0}
!31 = !{!"_ZTSSt6atomicIbE", !32, i64 0}
!32 = !{!"_ZTSSt13__atomic_baseIbE", !30, i64 0}
!33 = !{!"_ZTSSt6vectorIPN8koishidb8FileMetaESaIS2_EE", !34, i64 0}
!34 = !{!"_ZTSSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE12_Vector_implE", !36, i64 0}
!36 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!37 = !{!17, !15, i64 296}


; 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.koishidb::Status" = type { ptr }
%"class.koishidb::Slice" = type { ptr, i64 }

@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [9 x i8], align 1
@__FUNCTION__._ZN8koishidb6DBimpl12ReadManifestEv = external hidden unnamed_addr constant [13 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN8koishidb6DBimpl12ReadManifestEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8 %0, ptr noundef nonnull align 8 dereferenceable(312) %1) local_unnamed_addr #0 align 2 {
  %3 = alloca %"class.koishidb::Slice", align 8
  %4 = alloca %"class.koishidb::Slice", align 8
  %5 = alloca [4196 x i8], align 16
  %6 = alloca %"class.koishidb::Slice", align 8
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = tail call i32 (ptr, i32, ...) @open(ptr noundef nonnull @.str.3, i32 noundef 0)
  %11 = icmp eq i32 %10, -1
  br i1 %11, label %12, label %19

12:                                               ; preds = %2
  tail call void @_Z15OutputLogHeaderPKciS0_i(ptr noundef nonnull getelementptr inbounds (i8, ptr @.str.2, i64 1), i32 noundef 76, ptr noundef nonnull @__FUNCTION__._ZN8koishidb6DBimpl12ReadManifestEv, i32 noundef 500)
  %13 = load ptr, ptr @stdout, align 8, !tbaa !5
  %14 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %13, ptr noundef nonnull @.str.4) #7
  %15 = load ptr, ptr @stdout, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.5) #7
  %17 = load ptr, ptr @stdout, align 8, !tbaa !5
  %18 = tail call i32 @fflush(ptr noundef %17)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #7
  call void @_ZN8koishidb5SliceC1EPKc(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull @.str.4)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #7
  call void @_ZN8koishidb5SliceC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @_ZN8koishidb6Status10CorruptionERKNS_5SliceES3_(ptr dead_on_unwind writable sret(%"class.koishidb::Status") align 8 %0, ptr noundef nonnull align 8 dereferenceable(16) %3, ptr noundef nonnull align 8 dereferenceable(16) %4)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #7
  br label %40

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4196, ptr nonnull %5) #7
  br label %20

20:                                               ; preds = %20, %19
  %.010 = phi i32 [ 0, %19 ], [ %26, %20 ]
  %21 = zext nneg i32 %.010 to i64
  %22 = getelementptr inbounds i8, ptr %5, i64 %21
  %23 = call i64 @read(i32 noundef %10, ptr noundef nonnull %22, i64 noundef 4196)
  %24 = trunc i64 %23 to i32
  %25 = icmp sgt i32 %24, 0
  %26 = add nuw nsw i32 %.010, %24
  br i1 %25, label %20, label %27, !llvm.loop !9

27:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #7
  call void @_ZN8koishidb5SliceC1EPKcm(ptr noundef nonnull align 8 dereferenceable(16) %6, ptr noundef nonnull %5, i64 noundef %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #7
  call void @_ZN8koishidb11GetVarint32EPNS_5SliceEPj(ptr noundef nonnull %6, ptr noundef nonnull %7)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %8) #7
  %28 = call noundef zeroext i1 @_ZN8koishidb11GetVarint64EPNS_5SliceEPm(ptr noundef nonnull %6, ptr noundef nonnull %8)
  %29 = load i32, ptr %7, align 4, !tbaa !11
  %.not = icmp eq i32 %29, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %27
  %30 = getelementptr inbounds i8, ptr %1, i64 272
  br label %36

._crit_edge.loopexit:                             ; preds = %36
  %31 = zext i32 %38 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %27
  %.lcssa = phi i64 [ 0, %27 ], [ %31, %._crit_edge.loopexit ]
  %32 = load i64, ptr %8, align 8, !tbaa !13
  %33 = getelementptr inbounds i8, ptr %1, i64 256
  store i64 %32, ptr %33, align 8, !tbaa !15
  %34 = getelementptr inbounds i8, ptr %1, i64 296
  store i64 %.lcssa, ptr %34, align 8, !tbaa !36
  %35 = call i32 @close(i32 noundef %10)
  call void @_ZN8koishidb6Status2OKEv(ptr dead_on_unwind writable sret(%"class.koishidb::Status") align 8 %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %8) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #7
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #7
  call void @llvm.lifetime.end.p0(i64 4196, ptr nonnull %5) #7
  br label %40

36:                                               ; preds = %.lr.ph, %36
  %.014 = phi i32 [ 0, %.lr.ph ], [ %37, %36 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %9) #7
  call void @_ZN8koishidb14DecodeFileMetaEPPNS_8FileMetaEPNS_5SliceE(ptr noundef nonnull %9, ptr noundef nonnull %6)
  call void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24) %30, ptr noundef nonnull align 8 dereferenceable(8) %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %9) #7
  %37 = add nuw nsw i32 %.014, 1
  %38 = load i32, ptr %7, align 4, !tbaa !11
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %36, label %._crit_edge.loopexit, !llvm.loop !37

40:                                               ; preds = %._crit_edge, %12
  ret void
}

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

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

; Function Attrs: nofree
declare noundef i32 @open(ptr nocapture noundef readonly, i32 noundef, ...) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z15OutputLogHeaderPKciS0_i(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #4

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

declare void @_ZN8koishidb5SliceC1EPKc(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef) unnamed_addr #5

declare void @_ZN8koishidb5SliceC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #5

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #2

declare void @_ZN8koishidb5SliceC1EPKcm(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef, i64 noundef) unnamed_addr #5

declare void @_ZN8koishidb11GetVarint32EPNS_5SliceEPj(ptr noundef, ptr noundef) local_unnamed_addr #5

declare noundef zeroext i1 @_ZN8koishidb11GetVarint64EPNS_5SliceEPm(ptr noundef, ptr noundef) local_unnamed_addr #5

declare void @_ZN8koishidb14DecodeFileMetaEPPNS_8FileMetaEPNS_5SliceE(ptr noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIPN8koishidb8FileMetaESaIS2_EE9push_backERKS2_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0 align 2

declare i32 @close(i32 noundef) local_unnamed_addr #5

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8koishidb6Status2OKEv(ptr dead_on_unwind noalias writable sret(%"class.koishidb::Status") align 8) local_unnamed_addr #6 align 2

attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nofree "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 = { 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 #4 = { nofree 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 = { "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 #6 = { 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 #7 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!16, !14, i64 256}
!16 = !{!"_ZTSN8koishidb6DBimplE", !17, i64 0, !18, i64 8, !23, i64 88, !25, i64 144, !6, i64 184, !6, i64 192, !27, i64 200, !29, i64 248, !14, i64 256, !30, i64 264, !32, i64 272, !14, i64 296, !6, i64 304}
!17 = !{!"_ZTSN8koishidb2DBE"}
!18 = !{!"_ZTSSt5dequeIPN8koishidb6DBimpl6WriterESaIS3_EE", !19, i64 0}
!19 = !{!"_ZTSSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE", !20, i64 0}
!20 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE11_Deque_implE", !21, i64 0}
!21 = !{!"_ZTSNSt11_Deque_baseIPN8koishidb6DBimpl6WriterESaIS3_EE16_Deque_impl_dataE", !6, i64 0, !14, i64 8, !22, i64 16, !22, i64 48}
!22 = !{!"_ZTSSt15_Deque_iteratorIPN8koishidb6DBimpl6WriterERS3_PS3_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!23 = !{!"_ZTSSt12shared_mutex", !24, i64 0}
!24 = !{!"_ZTSSt22__shared_mutex_pthread", !7, i64 0}
!25 = !{!"_ZTSSt5mutex", !26, i64 0}
!26 = !{!"_ZTSSt12__mutex_base", !7, i64 0}
!27 = !{!"_ZTSSt18condition_variable", !28, i64 0}
!28 = !{!"_ZTSSt9__condvar", !7, i64 0}
!29 = !{!"bool", !7, i64 0}
!30 = !{!"_ZTSSt6atomicIbE", !31, i64 0}
!31 = !{!"_ZTSSt13__atomic_baseIbE", !29, i64 0}
!32 = !{!"_ZTSSt6vectorIPN8koishidb8FileMetaESaIS2_EE", !33, i64 0}
!33 = !{!"_ZTSSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE", !34, i64 0}
!34 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE12_Vector_implE", !35, i64 0}
!35 = !{!"_ZTSNSt12_Vector_baseIPN8koishidb8FileMetaESaIS2_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!36 = !{!16, !14, i64 296}
!37 = distinct !{!37, !10}


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