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

; 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.ardb::KeyObject" = type { %"struct.ardb::Data", i8, [7 x i8], %"struct.ardb::Data", %"class.std::vector" }
%"struct.ardb::Data" = type <{ i64, i32, i8, [3 x i8] }>
%"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: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4ardb9KeyObject13ComparePrefixERKS0_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 8 dereferenceable(64)) #0 align 2

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

declare noundef i32 @_ZNK4ardb4Data7CompareERKS0_b(ptr noundef nonnull align 8 dereferenceable(13), ptr noundef nonnull align 8 dereferenceable(13), i1 noundef zeroext) #2

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK4ardb9KeyObject7CompareERKS0_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) #0 align 2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef i32 @_ZNK4ardb9KeyObject13ComparePrefixERKS0_(ptr noundef nonnull align 8 dereferenceable(64) %9, ptr noundef nonnull align 8 dereferenceable(64) %10)
  store i32 %11, ptr %6, align 4, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp ne i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %2
  %15 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %15, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %68

16:                                               ; preds = %2
  %17 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %9, i32 0, i32 1
  %18 = load i8, ptr %17, align 8, !tbaa !11
  %19 = zext i8 %18 to i32
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %20, i32 0, i32 1
  %22 = load i8, ptr %21, align 8, !tbaa !11
  %23 = zext i8 %22 to i32
  %24 = sub nsw i32 %19, %23
  store i32 %24, ptr %6, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %29

27:                                               ; preds = %16
  %28 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %28, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %68

29:                                               ; preds = %16
  %30 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %9, i32 0, i32 4
  %31 = call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %30) #4
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %32, i32 0, i32 4
  %34 = call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %33) #4
  %35 = sub i64 %31, %34
  %36 = trunc i64 %35 to i32
  store i32 %36, ptr %6, align 4, !tbaa !9
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %29
  %40 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %40, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %68

41:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store i64 0, ptr %8, align 8, !tbaa !19
  br label %42

42:                                               ; preds = %62, %41
  %43 = load i64, ptr %8, align 8, !tbaa !19
  %44 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %9, i32 0, i32 4
  %45 = call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %44) #4
  %46 = icmp ult i64 %43, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  store i32 2, ptr %7, align 4
  br label %65

48:                                               ; preds = %42
  %49 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %9, i32 0, i32 4
  %50 = load i64, ptr %8, align 8, !tbaa !19
  %51 = call noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %50) #4
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %"struct.ardb::KeyObject", ptr %52, i32 0, i32 4
  %54 = load i64, ptr %8, align 8, !tbaa !19
  %55 = call noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %54) #4
  %56 = call noundef i32 @_ZNK4ardb4Data7CompareERKS0_b(ptr noundef nonnull align 8 dereferenceable(13) %51, ptr noundef nonnull align 8 dereferenceable(13) %55, i1 noundef zeroext false)
  store i32 %56, ptr %6, align 4, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = icmp ne i32 %57, 0
  br i1 %58, label %59, label %61

59:                                               ; preds = %48
  %60 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %60, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %65

61:                                               ; preds = %48
  br label %62

62:                                               ; preds = %61
  %63 = load i64, ptr %8, align 8, !tbaa !19
  %64 = add i64 %63, 1
  store i64 %64, ptr %8, align 8, !tbaa !19
  br label %42, !llvm.loop !20

65:                                               ; preds = %59, %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %66 = load i32, ptr %7, align 4
  switch i32 %66, label %68 [
    i32 2, label %67
  ]

67:                                               ; preds = %65
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %68

68:                                               ; preds = %67, %65, %39, %27, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %69 = load i32, ptr %3, align 4
  ret i32 %69
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #3 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 = { 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 }

!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 = !{!12, !7, i64 16}
!12 = !{!"_ZTSN4ardb9KeyObjectE", !13, i64 0, !7, i64 16, !13, i64 24, !15, i64 40}
!13 = !{!"_ZTSN4ardb4DataE", !14, i64 0, !10, i64 8, !7, i64 12}
!14 = !{!"long", !7, i64 0}
!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", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!14, !14, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK4ardb9KeyObject13ComparePrefixERKS0_(ptr noundef nonnull align 8 dereferenceable(64), ptr noundef nonnull align 8 dereferenceable(64)) local_unnamed_addr #0 align 2

declare noundef i32 @_ZNK4ardb4Data7CompareERKS0_b(ptr noundef nonnull align 8 dereferenceable(13), ptr noundef nonnull align 8 dereferenceable(13), i1 noundef zeroext) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZNK4ardb9KeyObject7CompareERKS0_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZNK4ardb9KeyObject13ComparePrefixERKS0_(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef nonnull align 8 dereferenceable(64) %1)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %.loopexit

4:                                                ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i8, ptr %5, align 8, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = getelementptr inbounds i8, ptr %1, i64 16
  %9 = load i8, ptr %8, align 8, !tbaa !5
  %10 = zext i8 %9 to i32
  %11 = sub nsw i32 %7, %10
  %.not24 = icmp eq i32 %11, 0
  br i1 %.not24, label %12, label %.loopexit

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 40
  %14 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  %15 = getelementptr inbounds i8, ptr %1, i64 40
  %16 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %15) #3
  %17 = sub i64 %14, %16
  %18 = trunc i64 %17 to i32
  %.not25 = icmp eq i32 %18, 0
  br i1 %.not25, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %12
  %19 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  %.not2728.not = icmp eq i64 %19, 0
  br i1 %.not2728.not, label %.loopexit, label %.lr.ph

20:                                               ; preds = %.lr.ph
  %21 = add nuw i64 %.029, 1
  %22 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %13) #3
  %.not27 = icmp ult i64 %21, %22
  br i1 %.not27, label %.lr.ph, label %.loopexit, !llvm.loop !17

.lr.ph:                                           ; preds = %.preheader, %20
  %.029 = phi i64 [ %21, %20 ], [ 0, %.preheader ]
  %23 = tail call noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %13, i64 noundef %.029) #3
  %24 = tail call noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %.029) #3
  %25 = tail call noundef i32 @_ZNK4ardb4Data7CompareERKS0_b(ptr noundef nonnull align 8 dereferenceable(13) %23, ptr noundef nonnull align 8 dereferenceable(13) %24, i1 noundef zeroext false)
  %.not26 = icmp eq i32 %25, 0
  br i1 %.not26, label %20, label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %20, %.preheader, %12, %4, %2
  %.1 = phi i32 [ %3, %2 ], [ %11, %4 ], [ %18, %12 ], [ 0, %.preheader ], [ %25, %.lr.ph ], [ 0, %20 ]
  ret i32 %.1
}

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(13) ptr @_ZNKSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #2 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 = { "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 = { 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, !9, i64 16}
!6 = !{!"_ZTSN4ardb9KeyObjectE", !7, i64 0, !9, i64 16, !7, i64 24, !12, i64 40}
!7 = !{!"_ZTSN4ardb4DataE", !8, i64 0, !11, i64 8, !9, i64 12}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"_ZTSSt6vectorIN4ardb4DataESaIS1_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIN4ardb4DataESaIS1_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIN4ardb4DataESaIS1_EE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !9, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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