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

; 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
define dso_local void @_ZN4ardb5codec10RedisReply5ClearEv(ptr noundef nonnull align 8 dereferenceable(72) %0) #1 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
  %5 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 5
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = icmp eq ptr null, %6
  br i1 %7, label %8, label %43

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  %11 = icmp ne ptr null, %10
  br i1 %11, label %12, label %43

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

13:                                               ; preds = %39, %12
  %14 = load i64, ptr %3, align 8, !tbaa !16
  %15 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = call noundef i64 @_ZNKSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %16) #4
  %18 = icmp ult i64 %14, %17
  br i1 %18, label %20, label %19

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

20:                                               ; preds = %13
  br label %21

21:                                               ; preds = %20
  %22 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load i64, ptr %3, align 8, !tbaa !16
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80) %23, i64 noundef %24)
  %26 = load ptr, ptr %25, align 8, !tbaa !5
  %27 = icmp eq ptr %26, null
  br i1 %27, label %32, label %28

28:                                               ; preds = %21
  %29 = load ptr, ptr %26, align 8, !tbaa !17
  %30 = getelementptr inbounds ptr, ptr %29, i64 1
  %31 = load ptr, ptr %30, align 8
  call void %31(ptr noundef nonnull align 8 dereferenceable(72) %26) #4
  br label %32

32:                                               ; preds = %28, %21
  %33 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i64, ptr %3, align 8, !tbaa !16
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80) %34, i64 noundef %35)
  store ptr null, ptr %36, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %32
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38
  %40 = load i64, ptr %3, align 8, !tbaa !16
  %41 = add i64 %40, 1
  store i64 %41, ptr %3, align 8, !tbaa !16
  br label %13, !llvm.loop !19

42:                                               ; preds = %19
  br label %43

43:                                               ; preds = %42, %8, %1
  br label %44

44:                                               ; preds = %43
  %45 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !15
  %47 = icmp eq ptr %46, null
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %46) #4
  call void @_ZdlPvm(ptr noundef %46, i64 noundef 80) #5
  br label %49

49:                                               ; preds = %48, %44
  %50 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 4
  store ptr null, ptr %50, align 8, !tbaa !15
  br label %51

51:                                               ; preds = %49
  %52 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 1
  store i32 4, ptr %52, align 8, !tbaa !21
  %53 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 3
  store i64 0, ptr %53, align 8, !tbaa !22
  %54 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %4, i32 0, i32 2
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %54) #4
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 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 = { nobuiltin 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 #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 }
attributes #5 = { builtin 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, !6, i64 64}
!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, !6, i64 56}
!16 = !{!14, !14, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"vtable pointer", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!10, !11, i64 8}
!22 = !{!10, !14, i64 48}


; 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
define dso_local void @_ZN4ardb5codec10RedisReply5ClearEv(ptr noundef nonnull align 8 dereferenceable(72) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 64
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  br i1 %4, label %5, label %.loopexit

5:                                                ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = load ptr, ptr %6, align 8, !tbaa !14
  %.not = icmp eq ptr %7, null
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %5
  %8 = tail call noundef i64 @_ZNKSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %7) #3
  %.not7 = icmp eq i64 %8, 0
  br i1 %.not7, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %17
  %.06 = phi i64 [ %20, %17 ], [ 0, %.preheader ]
  %9 = load ptr, ptr %6, align 8, !tbaa !14
  %10 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80) %9, i64 noundef %.06)
  %11 = load ptr, ptr %10, align 8, !tbaa !15
  %12 = icmp eq ptr %11, null
  br i1 %12, label %17, label %13

13:                                               ; preds = %.lr.ph
  %14 = load ptr, ptr %11, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  %16 = load ptr, ptr %15, align 8
  tail call void %16(ptr noundef nonnull align 8 dereferenceable(72) %11) #3
  br label %17

17:                                               ; preds = %13, %.lr.ph
  %18 = load ptr, ptr %6, align 8, !tbaa !14
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80) %18, i64 noundef %.06)
  store ptr null, ptr %19, align 8, !tbaa !15
  %20 = add nuw i64 %.06, 1
  %21 = load ptr, ptr %6, align 8, !tbaa !14
  %22 = tail call noundef i64 @_ZNKSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %21) #3
  %23 = icmp ult i64 %20, %22
  br i1 %23, label %.lr.ph, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %17, %.preheader, %1, %5
  %24 = getelementptr inbounds i8, ptr %0, i64 56
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  %26 = icmp eq ptr %25, null
  br i1 %26, label %28, label %27

27:                                               ; preds = %.loopexit
  tail call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %25) #3
  tail call void @_ZdlPvm(ptr noundef nonnull %25, i64 noundef 80) #4
  br label %28

28:                                               ; preds = %27, %.loopexit
  store ptr null, ptr %24, align 8, !tbaa !14
  %29 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 4, ptr %29, align 8, !tbaa !20
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  store i64 0, ptr %30, align 8, !tbaa !21
  %31 = getelementptr inbounds i8, ptr %0, i64 16
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32) %31) #3
  ret void
}

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE2atEm(ptr noundef nonnull align 8 dereferenceable(80), i64 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5clearEv(ptr noundef nonnull align 8 dereferenceable(32)) 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 = { nobuiltin 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 #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 }
attributes #4 = { builtin 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, !12, i64 64}
!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, !12, i64 56}
!15 = !{!12, !12, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"vtable pointer", !9, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!6, !7, i64 8}
!21 = !{!6, !13, i64 48}


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