; LLVM IR from yinqiwen/ardb :: src/db/codec.ll (ZN4ardb11ValueObject10DecodeMetaERNS_6BufferE)

; 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.ardb::ValueObject" = type { i8, i16, %"struct.ardb::MetaObject", %"class.std::vector" }
%"struct.ardb::MetaObject" = type { i8, i64, i64, i8, %"struct.ardb::StreamID" }
%"struct.ardb::StreamID" = type { i64, i64 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<ardb::Data, std::allocator<ardb::Data>>::_Vector_impl" }
%"struct.std::_Vector_base<ardb::Data, std::allocator<ardb::Data>>::_Vector_impl" = type { %"struct.std::_Vector_base<ardb::Data, std::allocator<ardb::Data>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ardb::Data, std::allocator<ardb::Data>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb10MetaObject6DecodeERNS_6BufferEh(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(33), i8 noundef zeroext) #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4ardb11ValueObject10DecodeMetaERNS_6BufferE(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(33) %1) #3 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  call void @_ZN4ardb11ValueObject5ClearEv(ptr noundef nonnull align 8 dereferenceable(80) %8)
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %9)
  br i1 %10, label %12, label %11

11:                                               ; preds = %2
  store i1 true, ptr %3, align 1
  br label %39

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #6
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = call noundef zeroext i1 @_ZN4ardb6Buffer8ReadByteERc(ptr noundef nonnull align 8 dereferenceable(33) %13, ptr noundef nonnull align 1 dereferenceable(1) %6)
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %38

16:                                               ; preds = %12
  %17 = load i8, ptr %6, align 1, !tbaa !9
  %18 = getelementptr inbounds %"class.ardb::ValueObject", ptr %8, i32 0, i32 0
  store i8 %17, ptr %18, align 8, !tbaa !10
  %19 = getelementptr inbounds %"class.ardb::ValueObject", ptr %8, i32 0, i32 0
  %20 = load i8, ptr %19, align 8, !tbaa !10
  %21 = zext i8 %20 to i32
  switch i32 %21, label %36 [
    i32 30, label %22
    i32 2, label %28
    i32 5, label %28
    i32 7, label %28
    i32 9, label %28
    i32 3, label %28
    i32 12, label %28
  ]

22:                                               ; preds = %16
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.ardb::ValueObject", ptr %8, i32 0, i32 1
  %25 = call noundef zeroext i1 @_ZN4ardb12BufferHelper13ReadFixUInt16ERNS_6BufferERtb(ptr noundef nonnull align 8 dereferenceable(33) %23, ptr noundef nonnull align 2 dereferenceable(2) %24, i1 noundef zeroext false)
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %38

27:                                               ; preds = %22
  br label %37

28:                                               ; preds = %16, %16, %16, %16, %16, %16
  %29 = getelementptr inbounds %"class.ardb::ValueObject", ptr %8, i32 0, i32 2
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"class.ardb::ValueObject", ptr %8, i32 0, i32 0
  %32 = load i8, ptr %31, align 8, !tbaa !10
  %33 = call noundef zeroext i1 @_ZN4ardb10MetaObject6DecodeERNS_6BufferEh(ptr noundef nonnull align 8 dereferenceable(48) %29, ptr noundef nonnull align 8 dereferenceable(33) %30, i8 noundef zeroext %32)
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %28
  br label %37

36:                                               ; preds = %16
  br label %37

37:                                               ; preds = %36, %35, %27
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %38

38:                                               ; preds = %37, %34, %26, %15
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #6
  br label %39

39:                                               ; preds = %38, %11
  %40 = load i1, ptr %3, align 1
  ret i1 %40
}

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

declare noundef zeroext i1 @_ZN4ardb12BufferHelper13ReadFixUInt16ERNS_6BufferERtb(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 2 dereferenceable(2), i1 noundef zeroext) #5

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { 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 #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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 0}
!11 = !{!"_ZTSN4ardb11ValueObjectE", !7, i64 0, !12, i64 2, !13, i64 8, !17, i64 56}
!12 = !{!"short", !7, i64 0}
!13 = !{!"_ZTSN4ardb10MetaObjectE", !7, i64 0, !14, i64 8, !14, i64 16, !15, i64 24, !16, i64 32}
!14 = !{!"long", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSN4ardb8StreamIDE", !14, i64 0, !14, i64 8}
!17 = !{!"_ZTSSt6vectorIN4ardb4DataESaIS1_EE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIN4ardb4DataESaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}


; 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"

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb10MetaObject6DecodeERNS_6BufferEh(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(33), i8 noundef zeroext) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4ardb11ValueObject10DecodeMetaERNS_6BufferE(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(33) %1) local_unnamed_addr #3 align 2 {
  %3 = alloca i8, align 1
  tail call void @_ZN4ardb11ValueObject5ClearEv(ptr noundef nonnull align 8 dereferenceable(80) %0)
  %4 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %1)
  br i1 %4, label %5, label %17

5:                                                ; preds = %2
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #6
  %6 = call noundef zeroext i1 @_ZN4ardb6Buffer8ReadByteERc(ptr noundef nonnull align 8 dereferenceable(33) %1, ptr noundef nonnull align 1 dereferenceable(1) %3)
  br i1 %6, label %7, label %16

7:                                                ; preds = %5
  %8 = load i8, ptr %3, align 1, !tbaa !5
  store i8 %8, ptr %0, align 8, !tbaa !8
  switch i8 %8, label %15 [
    i8 30, label %9
    i8 2, label %12
    i8 5, label %12
    i8 7, label %12
    i8 9, label %12
    i8 3, label %12
    i8 12, label %12
  ]

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 2
  %11 = call noundef zeroext i1 @_ZN4ardb12BufferHelper13ReadFixUInt16ERNS_6BufferERtb(ptr noundef nonnull align 8 dereferenceable(33) %1, ptr noundef nonnull align 2 dereferenceable(2) %10, i1 noundef zeroext false)
  br i1 %11, label %15, label %16

12:                                               ; preds = %7, %7, %7, %7, %7, %7
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = call noundef zeroext i1 @_ZN4ardb10MetaObject6DecodeERNS_6BufferEh(ptr noundef nonnull align 8 dereferenceable(48) %13, ptr noundef nonnull align 8 dereferenceable(33) %1, i8 noundef zeroext %8)
  br i1 %14, label %15, label %16

15:                                               ; preds = %7, %12, %9
  br label %16

16:                                               ; preds = %12, %9, %5, %15
  %.0 = phi i1 [ true, %15 ], [ false, %5 ], [ false, %9 ], [ false, %12 ]
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #6
  br label %17

17:                                               ; preds = %2, %16
  %.1 = phi i1 [ %.0, %16 ], [ true, %2 ]
  ret i1 %.1
}

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

declare noundef zeroext i1 @_ZN4ardb12BufferHelper13ReadFixUInt16ERNS_6BufferERtb(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 2 dereferenceable(2), i1 noundef zeroext) local_unnamed_addr #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { 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 #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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !6, i64 0}
!9 = !{!"_ZTSN4ardb11ValueObjectE", !6, i64 0, !10, i64 2, !11, i64 8, !15, i64 56}
!10 = !{!"short", !6, i64 0}
!11 = !{!"_ZTSN4ardb10MetaObjectE", !6, i64 0, !12, i64 8, !12, i64 16, !13, i64 24, !14, i64 32}
!12 = !{!"long", !6, i64 0}
!13 = !{!"bool", !6, i64 0}
!14 = !{!"_ZTSN4ardb8StreamIDE", !12, i64 0, !12, i64 8}
!15 = !{!"_ZTSSt6vectorIN4ardb4DataESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN4ardb4DataESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE17_Vector_impl_dataE", !19, i64 0, !19, i64 8, !19, i64 16}
!19 = !{!"any pointer", !6, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass