; LLVM IR from yinqiwen/ardb :: src/common/coro/coro_channel.ll (ZN4ardb15CoroRedisClient5ClearEv)

; 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::CoroRedisClient" = type { %"class.ardb::CoroChannel", %"class.ardb::ChannelUpstreamHandler.33", i64, %"class.std::vector.35", %"class.ardb::codec::RedisReplyDecoder", %"class.ardb::codec::RedisCommandEncoder", %"struct.ardb::codec::RedisReply" }
%"class.ardb::CoroChannel" = type { %"class.ardb::ChannelUpstreamHandler", %"class.ardb::Runnable", ptr, ptr, ptr, ptr, i8, ptr, i8, i32 }
%"class.ardb::ChannelUpstreamHandler" = type { %"class.ardb::AbstractChannelHandler" }
%"class.ardb::AbstractChannelHandler" = type { %"class.ardb::ChannelHandler" }
%"class.ardb::ChannelHandler" = type { ptr }
%"class.ardb::Runnable" = type { ptr }
%"class.ardb::ChannelUpstreamHandler.33" = type { %"class.ardb::AbstractChannelHandler.34" }
%"class.ardb::AbstractChannelHandler.34" = type { %"class.ardb::ChannelHandler" }
%"class.std::vector.35" = type { %"struct.std::_Vector_base.36" }
%"struct.std::_Vector_base.36" = type { %"struct.std::_Vector_base<ardb::codec::RedisReply *, std::allocator<ardb::codec::RedisReply *>>::_Vector_impl" }
%"struct.std::_Vector_base<ardb::codec::RedisReply *, std::allocator<ardb::codec::RedisReply *>>::_Vector_impl" = type { %"struct.std::_Vector_base<ardb::codec::RedisReply *, std::allocator<ardb::codec::RedisReply *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<ardb::codec::RedisReply *, std::allocator<ardb::codec::RedisReply *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.ardb::codec::RedisReplyDecoder" = type { %"class.ardb::codec::StackFrameDecoder" }
%"class.ardb::codec::StackFrameDecoder" = type { %"class.ardb::ChannelUpstreamHandler", %"class.ardb::Buffer" }
%"class.ardb::Buffer" = type <{ ptr, i64, i64, i64, i8, [7 x i8] }>
%"class.ardb::codec::RedisCommandEncoder" = type { %"class.ardb::ChannelDownstreamHandler" }
%"class.ardb::ChannelDownstreamHandler" = type { %"class.ardb::AbstractChannelHandler.40" }
%"class.ardb::AbstractChannelHandler.40" = type { %"class.ardb::ChannelHandler" }
%"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 nounwind uwtable
define dso_local void @_ZN4ardb15CoroRedisClient5ClearEv(ptr noundef nonnull align 8 dereferenceable(240) %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 %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 2
  %6 = load i64, ptr %5, align 8, !tbaa !9
  %7 = icmp ugt i64 %6, 1
  br i1 %7, label %8, label %44

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

9:                                                ; preds = %40, %8
  %10 = load i64, ptr %3, align 8, !tbaa !34
  %11 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 3
  %12 = call noundef i64 @_ZNKSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %11) #2
  %13 = icmp ult i64 %10, %12
  br i1 %13, label %15, label %14

14:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  br label %43

15:                                               ; preds = %9
  %16 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 3
  %17 = load i64, ptr %3, align 8, !tbaa !34
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %16, i64 noundef %17) #2
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  %20 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 6
  %21 = icmp ne ptr %19, %20
  br i1 %21, label %22, label %39

22:                                               ; preds = %15
  br label %23

23:                                               ; preds = %22
  %24 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 3
  %25 = load i64, ptr %3, align 8, !tbaa !34
  %26 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #2
  %27 = load ptr, ptr %26, align 8, !tbaa !5
  %28 = icmp eq ptr %27, null
  br i1 %28, label %33, label %29

29:                                               ; preds = %23
  %30 = load ptr, ptr %27, align 8, !tbaa !35
  %31 = getelementptr inbounds ptr, ptr %30, i64 1
  %32 = load ptr, ptr %31, align 8
  call void %32(ptr noundef nonnull align 8 dereferenceable(72) %27) #2
  br label %33

33:                                               ; preds = %29, %23
  %34 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 3
  %35 = load i64, ptr %3, align 8, !tbaa !34
  %36 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %34, i64 noundef %35) #2
  store ptr null, ptr %36, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %33
  br label %38

38:                                               ; preds = %37
  br label %39

39:                                               ; preds = %38, %15
  br label %40

40:                                               ; preds = %39
  %41 = load i64, ptr %3, align 8, !tbaa !34
  %42 = add i64 %41, 1
  store i64 %42, ptr %3, align 8, !tbaa !34
  br label %9, !llvm.loop !37

43:                                               ; preds = %14
  br label %44

44:                                               ; preds = %43, %1
  %45 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 3
  call void @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %45) #2
  %46 = getelementptr inbounds %"class.ardb::CoroRedisClient", ptr %4, i32 0, i32 2
  store i64 1, ptr %46, align 8, !tbaa !9
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

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 = { 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, !20, i64 80}
!10 = !{!"_ZTSN4ardb15CoroRedisClientE", !11, i64 0, !18, i64 72, !20, i64 80, !21, i64 88, !25, i64 112, !28, i64 160, !31, i64 168}
!11 = !{!"_ZTSN4ardb11CoroChannelE", !12, i64 0, !15, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !16, i64 48, !6, i64 56, !16, i64 64, !17, i64 68}
!12 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !13, i64 0}
!13 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !14, i64 0}
!14 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!15 = !{!"_ZTSN4ardb8RunnableE"}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_5codec10RedisReplyEEE", !19, i64 0}
!19 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_5codec10RedisReplyEEE", !14, i64 0}
!20 = !{!"long", !7, i64 0}
!21 = !{!"_ZTSSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE", !22, i64 0}
!22 = !{!"_ZTSSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE12_Vector_implE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!25 = !{!"_ZTSN4ardb5codec17RedisReplyDecoderE", !26, i64 0}
!26 = !{!"_ZTSN4ardb5codec17StackFrameDecoderINS0_10RedisReplyEEE", !12, i64 0, !27, i64 8}
!27 = !{!"_ZTSN4ardb6BufferE", !6, i64 0, !20, i64 8, !20, i64 16, !20, i64 24, !16, i64 32}
!28 = !{!"_ZTSN4ardb5codec19RedisCommandEncoderE", !29, i64 0}
!29 = !{!"_ZTSN4ardb24ChannelDownstreamHandlerINS_5codec17RedisCommandFrameEEE", !30, i64 0}
!30 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_5codec17RedisCommandFrameEEE", !14, i64 0}
!31 = !{!"_ZTSN4ardb5codec10RedisReplyE", !17, i64 8, !32, i64 16, !20, i64 48, !6, i64 56, !6, i64 64}
!32 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !33, i64 0, !20, i64 8, !7, i64 16}
!33 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!34 = !{!20, !20, i64 0}
!35 = !{!36, !36, i64 0}
!36 = !{!"vtable pointer", !8, i64 0}
!37 = distinct !{!37, !38}
!38 = !{!"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
define dso_local void @_ZN4ardb15CoroRedisClient5ClearEv(ptr noundef nonnull align 8 dereferenceable(240) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 80
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = icmp ugt i64 %3, 1
  br i1 %4, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 88
  %6 = tail call noundef i64 @_ZNKSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #1
  %.not7 = icmp eq i64 %6, 0
  br i1 %.not7, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %0, i64 168
  br label %8

8:                                                ; preds = %.lr.ph, %21
  %.06 = phi i64 [ 0, %.lr.ph ], [ %22, %21 ]
  %9 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.06) #1
  %10 = load ptr, ptr %9, align 8, !tbaa !33
  %.not = icmp eq ptr %10, %7
  br i1 %.not, label %21, label %11

11:                                               ; preds = %8
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.06) #1
  %13 = load ptr, ptr %12, align 8, !tbaa !33
  %14 = icmp eq ptr %13, null
  br i1 %14, label %19, label %15

15:                                               ; preds = %11
  %16 = load ptr, ptr %13, align 8, !tbaa !34
  %17 = getelementptr inbounds i8, ptr %16, i64 8
  %18 = load ptr, ptr %17, align 8
  tail call void %18(ptr noundef nonnull align 8 dereferenceable(72) %13) #1
  br label %19

19:                                               ; preds = %15, %11
  %20 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %5, i64 noundef %.06) #1
  store ptr null, ptr %20, align 8, !tbaa !33
  br label %21

21:                                               ; preds = %8, %19
  %22 = add nuw i64 %.06, 1
  %23 = tail call noundef i64 @_ZNKSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %5) #1
  %24 = icmp ult i64 %22, %23
  br i1 %24, label %8, label %.loopexit, !llvm.loop !36

.loopexit:                                        ; preds = %21, %.preheader, %1
  %25 = getelementptr inbounds i8, ptr %0, i64 88
  tail call void @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(24) %25) #1
  store i64 1, ptr %2, align 8, !tbaa !5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIPN4ardb5codec10RedisReplyESaIS3_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(8) ptr @_ZNSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

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

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 = { 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, !19, i64 80}
!6 = !{!"_ZTSN4ardb15CoroRedisClientE", !7, i64 0, !17, i64 72, !19, i64 80, !20, i64 88, !24, i64 112, !27, i64 160, !30, i64 168}
!7 = !{!"_ZTSN4ardb11CoroChannelE", !8, i64 0, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !12, i64 40, !15, i64 48, !12, i64 56, !15, i64 64, !16, i64 68}
!8 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !9, i64 0}
!9 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !10, i64 0}
!10 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!11 = !{!"_ZTSN4ardb8RunnableE"}
!12 = !{!"any pointer", !13, i64 0}
!13 = !{!"omnipotent char", !14, i64 0}
!14 = !{!"Simple C++ TBAA"}
!15 = !{!"bool", !13, i64 0}
!16 = !{!"int", !13, i64 0}
!17 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_5codec10RedisReplyEEE", !18, i64 0}
!18 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_5codec10RedisReplyEEE", !10, i64 0}
!19 = !{!"long", !13, i64 0}
!20 = !{!"_ZTSSt6vectorIPN4ardb5codec10RedisReplyESaIS3_EE", !21, i64 0}
!21 = !{!"_ZTSSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE12_Vector_implE", !23, i64 0}
!23 = !{!"_ZTSNSt12_Vector_baseIPN4ardb5codec10RedisReplyESaIS3_EE17_Vector_impl_dataE", !12, i64 0, !12, i64 8, !12, i64 16}
!24 = !{!"_ZTSN4ardb5codec17RedisReplyDecoderE", !25, i64 0}
!25 = !{!"_ZTSN4ardb5codec17StackFrameDecoderINS0_10RedisReplyEEE", !8, i64 0, !26, i64 8}
!26 = !{!"_ZTSN4ardb6BufferE", !12, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !15, i64 32}
!27 = !{!"_ZTSN4ardb5codec19RedisCommandEncoderE", !28, i64 0}
!28 = !{!"_ZTSN4ardb24ChannelDownstreamHandlerINS_5codec17RedisCommandFrameEEE", !29, i64 0}
!29 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_5codec17RedisCommandFrameEEE", !10, i64 0}
!30 = !{!"_ZTSN4ardb5codec10RedisReplyE", !16, i64 8, !31, i64 16, !19, i64 48, !12, i64 56, !12, i64 64}
!31 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !32, i64 0, !19, i64 8, !13, i64 16}
!32 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !12, i64 0}
!33 = !{!12, !12, i64 0}
!34 = !{!35, !35, i64 0}
!35 = !{!"vtable pointer", !14, i64 0}
!36 = distinct !{!36, !37}
!37 = !{!"llvm.loop.mustprogress"}


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