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

; 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: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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

declare noundef zeroext i1 @_ZNK4ardb4Data8IsStringEv(ptr noundef nonnull align 8 dereferenceable(13)) #2

declare noundef ptr @_ZN4ardb4Data12ToMutableStrEv(ptr noundef nonnull align 8 dereferenceable(13)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11ValueObject15CloneStringPartEv(ptr noundef nonnull align 8 dereferenceable(80) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store i64 0, ptr %3, align 8, !tbaa !9
  br label %5

5:                                                ; preds = %22, %1
  %6 = load i64, ptr %3, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.ardb::ValueObject", ptr %4, i32 0, i32 3
  %8 = call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %9 = icmp ult i64 %6, %8
  br i1 %9, label %11, label %10

10:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %25

11:                                               ; preds = %5
  %12 = getelementptr inbounds %"class.ardb::ValueObject", ptr %4, i32 0, i32 3
  %13 = load i64, ptr %3, align 8, !tbaa !9
  %14 = call noundef nonnull align 8 dereferenceable(13) ptr @_ZNSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %13) #4
  %15 = call noundef zeroext i1 @_ZNK4ardb4Data8IsStringEv(ptr noundef nonnull align 8 dereferenceable(13) %14)
  br i1 %15, label %16, label %21

16:                                               ; preds = %11
  %17 = getelementptr inbounds %"class.ardb::ValueObject", ptr %4, i32 0, i32 3
  %18 = load i64, ptr %3, align 8, !tbaa !9
  %19 = call noundef nonnull align 8 dereferenceable(13) ptr @_ZNSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %17, i64 noundef %18) #4
  %20 = call noundef ptr @_ZN4ardb4Data12ToMutableStrEv(ptr noundef nonnull align 8 dereferenceable(13) %19)
  br label %21

21:                                               ; preds = %16, %11
  br label %22

22:                                               ; preds = %21
  %23 = load i64, ptr %3, align 8, !tbaa !9
  %24 = add i64 %23, 1
  store i64 %24, ptr %3, align 8, !tbaa !9
  br label %5, !llvm.loop !11

25:                                               ; preds = %10
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = { 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 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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 nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #0 align 2

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

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

declare noundef ptr @_ZN4ardb4Data12ToMutableStrEv(ptr noundef nonnull align 8 dereferenceable(13)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb11ValueObject15CloneStringPartEv(ptr noundef nonnull align 8 dereferenceable(80) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 56
  %3 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %.not = icmp eq i64 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %9, %1
  ret void

.lr.ph:                                           ; preds = %1, %9
  %.04 = phi i64 [ %10, %9 ], [ 0, %1 ]
  %4 = tail call noundef nonnull align 8 dereferenceable(13) ptr @_ZNSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.04) #3
  %5 = tail call noundef zeroext i1 @_ZNK4ardb4Data8IsStringEv(ptr noundef nonnull align 8 dereferenceable(13) %4)
  br i1 %5, label %6, label %9

6:                                                ; preds = %.lr.ph
  %7 = tail call noundef nonnull align 8 dereferenceable(13) ptr @_ZNSt6vectorIN4ardb4DataESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %.04) #3
  %8 = tail call noundef ptr @_ZN4ardb4Data12ToMutableStrEv(ptr noundef nonnull align 8 dereferenceable(13) %7)
  br label %9

9:                                                ; preds = %.lr.ph, %6
  %10 = add nuw i64 %.04, 1
  %11 = tail call noundef i64 @_ZNKSt6vectorIN4ardb4DataESaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %12 = icmp ult i64 %10, %11
  br i1 %12, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

attributes #0 = { 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 #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 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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