; LLVM IR from yinqiwen/ardb :: src/common/channel/codec (redis_reply)

; 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::codec::RedisReply" = type { ptr, i32, %"class.std::__cxx11::basic_string", i64, ptr, ptr }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

; 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 uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr noundef nonnull align 8 dereferenceable(72), i1 noundef zeroext) #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply8MemberAtEj(ptr noundef nonnull align 8 dereferenceable(72), i32 noundef) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb5codec17clone_redis_replyERNS0_10RedisReplyES2_(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(72) %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %8, i32 0, i32 3
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %11, i32 0, i32 3
  store i64 %10, ptr %12, align 8, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %13, i32 0, i32 1
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %16, i32 0, i32 1
  store i32 %15, ptr %17, align 8, !tbaa !15
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !15
  switch i32 %20, label %47 [
    i32 5, label %21
    i32 1, label %21
    i32 6, label %21
    i32 2, label %27
  ]

21:                                               ; preds = %2, %2, %2
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %24, i32 0, i32 2
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %25, ptr noundef nonnull align 8 dereferenceable(32) %23)
  br label %48

27:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 0, ptr %5, align 8, !tbaa !16
  br label %28

28:                                               ; preds = %43, %27
  %29 = load i64, ptr %5, align 8, !tbaa !16
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = call noundef i64 @_ZN4ardb5codec10RedisReply10MemberSizeEv(ptr noundef nonnull align 8 dereferenceable(72) %30)
  %32 = icmp ult i64 %29, %31
  br i1 %32, label %34, label %33

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

34:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = load i64, ptr %5, align 8, !tbaa !16
  %37 = trunc i64 %36 to i32
  %38 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply8MemberAtEj(ptr noundef nonnull align 8 dereferenceable(72) %35, i32 noundef %37)
  store ptr %38, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr noundef nonnull align 8 dereferenceable(72) %39, i1 noundef zeroext true)
  store ptr %40, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN4ardb5codec17clone_redis_replyERNS0_10RedisReplyES2_(ptr noundef nonnull align 8 dereferenceable(72) %41, ptr noundef nonnull align 8 dereferenceable(72) %42)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %43

43:                                               ; preds = %34
  %44 = load i64, ptr %5, align 8, !tbaa !16
  %45 = add i64 %44, 1
  store i64 %45, ptr %5, align 8, !tbaa !16
  br label %28, !llvm.loop !17

46:                                               ; preds = %33
  br label %48

47:                                               ; preds = %2
  br label %48

48:                                               ; preds = %47, %46, %21
  ret void
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !14, i64 48}
!10 = !{!"_ZTSN4ardb5codec10RedisReplyE", !11, i64 8, !12, i64 16, !14, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !13, i64 0, !14, i64 8, !7, i64 16}
!13 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!14, !14, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"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 nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr noundef nonnull align 8 dereferenceable(72), i1 noundef zeroext) local_unnamed_addr #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4ardb5codec17clone_redis_replyERNS0_10RedisReplyES2_(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(72) %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 48
  store i64 %4, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  store i32 %7, ptr %8, align 8, !tbaa !14
  switch i32 %7, label %.loopexit [
    i32 5, label %10
    i32 1, label %10
    i32 6, label %10
    i32 2, label %.preheader
  ]

.preheader:                                       ; preds = %2
  %9 = tail call noundef i64 @_ZN4ardb5codec10RedisReply10MemberSizeEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %.not = icmp eq i64 %9, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

10:                                               ; preds = %2, %2, %2
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = getelementptr inbounds i8, ptr %1, i64 16
  %13 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %11)
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.014 = phi i64 [ %17, %.lr.ph ], [ 0, %.preheader ]
  %14 = trunc i64 %.014 to i32
  %15 = tail call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply8MemberAtEj(ptr noundef nonnull align 8 dereferenceable(72) %0, i32 noundef %14)
  %16 = tail call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr noundef nonnull align 8 dereferenceable(72) %1, i1 noundef zeroext true)
  tail call void @_ZN4ardb5codec17clone_redis_replyERNS0_10RedisReplyES2_(ptr noundef nonnull align 8 dereferenceable(72) %15, ptr noundef nonnull align 8 dereferenceable(72) %16)
  %17 = add nuw i64 %.014, 1
  %18 = tail call noundef i64 @_ZN4ardb5codec10RedisReply10MemberSizeEv(ptr noundef nonnull align 8 dereferenceable(72) %0)
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %.lr.ph, label %.loopexit, !llvm.loop !15

.loopexit:                                        ; preds = %.lr.ph, %.preheader, %2, %10
  ret void
}

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSERKS4_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #0 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 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" }

!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, !13, i64 48}
!6 = !{!"_ZTSN4ardb5codec10RedisReplyE", !7, i64 8, !10, i64 16, !13, i64 48, !12, i64 56, !12, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !11, i64 0, !13, i64 8, !8, i64 16}
!11 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"long", !8, i64 0}
!14 = !{!6, !7, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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