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

; 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::codec::RedisCommandDecoder" = type <{ %"class.ardb::codec::StackFrameDecoder", i8, [7 x i8] }>
%"class.ardb::codec::StackFrameDecoder" = type { %"class.ardb::ChannelUpstreamHandler", %"class.ardb::Buffer" }
%"class.ardb::ChannelUpstreamHandler" = type { %"class.ardb::AbstractChannelHandler" }
%"class.ardb::AbstractChannelHandler" = type { %"class.ardb::ChannelHandler" }
%"class.ardb::ChannelHandler" = type { ptr }
%"class.ardb::Buffer" = type <{ ptr, i64, i64, i64, i8, [7 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: mustprogress uwtable
declare dso_local void @_ZN4ardb5codec17RedisCommandFrame5ClearEv(ptr noundef nonnull align 8 dereferenceable(160)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33)) #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb6Buffer16AdvanceReadIndexEi(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef) #2 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 8 dereferenceable(160)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeERNS_21ChannelHandlerContextEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr noundef nonnull align 8 dereferenceable(49) %0, ptr noundef nonnull align 8 dereferenceable(66) %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(33) %3, ptr noundef nonnull align 8 dereferenceable(160) %4) unnamed_addr #1 align 2 {
  %6 = alloca i1, align 1
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  %14 = load ptr, ptr %7, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  store i8 0, ptr %12, align 1, !tbaa !9
  br label %15

15:                                               ; preds = %36, %5
  %16 = load ptr, ptr %10, align 8, !tbaa !5
  %17 = call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %16)
  br i1 %17, label %18, label %34

18:                                               ; preds = %15
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %19)
  %21 = getelementptr inbounds i8, ptr %20, i64 0
  %22 = load i8, ptr %21, align 1, !tbaa !11
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 13
  br i1 %24, label %32, label %25

25:                                               ; preds = %18
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %26)
  %28 = getelementptr inbounds i8, ptr %27, i64 0
  %29 = load i8, ptr %28, align 1, !tbaa !11
  %30 = sext i8 %29 to i32
  %31 = icmp eq i32 %30, 10
  br label %32

32:                                               ; preds = %25, %18
  %33 = phi i1 [ true, %18 ], [ %31, %25 ]
  br label %34

34:                                               ; preds = %32, %15
  %35 = phi i1 [ false, %15 ], [ %33, %32 ]
  br i1 %35, label %36, label %38

36:                                               ; preds = %34
  %37 = load ptr, ptr %10, align 8, !tbaa !5
  call void @_ZN4ardb6Buffer16AdvanceReadIndexEi(ptr noundef nonnull align 8 dereferenceable(33) %37, i32 noundef 1)
  store i8 1, ptr %12, align 1, !tbaa !9
  br label %15, !llvm.loop !12

38:                                               ; preds = %34
  %39 = getelementptr inbounds %"class.ardb::codec::RedisCommandDecoder", ptr %14, i32 0, i32 1
  %40 = load i8, ptr %39, align 8, !tbaa !14, !range !22, !noundef !23
  %41 = trunc i8 %40 to i1
  br i1 %41, label %47, label %42

42:                                               ; preds = %38
  %43 = load i8, ptr %12, align 1, !tbaa !9, !range !22, !noundef !23
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %47

45:                                               ; preds = %42
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  call void @_ZN4ardb5codec17RedisCommandFrame5ClearEv(ptr noundef nonnull align 8 dereferenceable(160) %46)
  store i1 true, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %52

47:                                               ; preds = %42, %38
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = load ptr, ptr %10, align 8, !tbaa !5
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = call noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr noundef %48, ptr noundef nonnull align 8 dereferenceable(33) %49, ptr noundef nonnull align 8 dereferenceable(160) %50)
  store i1 %51, ptr %6, align 1
  store i32 1, ptr %13, align 4
  br label %52

52:                                               ; preds = %47, %45
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  %53 = load i1, ptr %6, align 1
  ret i1 %53
}

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 = { inlinehint 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, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !10, i64 48}
!15 = !{!"_ZTSN4ardb5codec19RedisCommandDecoderE", !16, i64 0, !10, i64 48}
!16 = !{!"_ZTSN4ardb5codec17StackFrameDecoderINS0_17RedisCommandFrameEEE", !17, i64 0, !20, i64 8}
!17 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !18, i64 0}
!18 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !19, i64 0}
!19 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!20 = !{!"_ZTSN4ardb6BufferE", !6, i64 0, !21, i64 8, !21, i64 16, !21, i64 24, !10, i64 32}
!21 = !{!"long", !7, i64 0}
!22 = !{i8 0, i8 2}
!23 = !{}


; 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 void @_ZN4ardb5codec17RedisCommandFrame5ClearEv(ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN4ardb6Buffer16AdvanceReadIndexEi(ptr noundef nonnull align 8 dereferenceable(33), i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr noundef, ptr noundef nonnull align 8 dereferenceable(33), ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeERNS_21ChannelHandlerContextEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr nocapture noundef nonnull readonly align 8 dereferenceable(49) %0, ptr nocapture noundef nonnull readnone align 8 dereferenceable(66) %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(33) %3, ptr noundef nonnull align 8 dereferenceable(160) %4) unnamed_addr #0 align 2 {
  %6 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  br i1 %6, label %.lr.ph.preheader, label %.critedge.thread

.lr.ph.preheader:                                 ; preds = %5
  %7 = tail call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 13
  br i1 %9, label %.critedge2.peel, label %10

10:                                               ; preds = %.lr.ph.preheader
  %11 = tail call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = icmp eq i8 %12, 10
  br i1 %13, label %.critedge2.peel, label %.critedge.thread

.critedge2.peel:                                  ; preds = %10, %.lr.ph.preheader
  tail call void @_ZN4ardb6Buffer16AdvanceReadIndexEi(ptr noundef nonnull align 8 dereferenceable(33) %3, i32 noundef 1)
  %14 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  br i1 %14, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.critedge2.peel, %.critedge2
  %15 = tail call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = icmp eq i8 %16, 13
  br i1 %17, label %.critedge2, label %18

18:                                               ; preds = %.lr.ph
  %19 = tail call noundef ptr @_ZNK4ardb6Buffer16GetRawReadBufferEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  %20 = load i8, ptr %19, align 1, !tbaa !5
  %21 = icmp eq i8 %20, 10
  br i1 %21, label %.critedge2, label %.critedge

.critedge2:                                       ; preds = %.lr.ph, %18
  tail call void @_ZN4ardb6Buffer16AdvanceReadIndexEi(ptr noundef nonnull align 8 dereferenceable(33) %3, i32 noundef 1)
  %22 = tail call noundef zeroext i1 @_ZNK4ardb6Buffer8ReadableEv(ptr noundef nonnull align 8 dereferenceable(33) %3)
  br i1 %22, label %.lr.ph, label %.critedge, !llvm.loop !8

.critedge:                                        ; preds = %18, %.critedge2, %.critedge2.peel
  %23 = getelementptr inbounds i8, ptr %0, i64 48
  %24 = load i8, ptr %23, align 8, !tbaa !11, !range !21, !noundef !22
  %25 = trunc nuw i8 %24 to i1
  br i1 %25, label %.critedge.thread, label %26

26:                                               ; preds = %.critedge
  tail call void @_ZN4ardb5codec17RedisCommandFrame5ClearEv(ptr noundef nonnull align 8 dereferenceable(160) %4)
  br label %28

.critedge.thread:                                 ; preds = %10, %5, %.critedge
  %27 = tail call noundef zeroext i1 @_ZN4ardb5codec19RedisCommandDecoder6DecodeEPNS_7ChannelERNS_6BufferERNS0_17RedisCommandFrameE(ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(33) %3, ptr noundef nonnull align 8 dereferenceable(160) %4)
  br label %28

28:                                               ; preds = %.critedge.thread, %26
  %.012 = phi i1 [ %27, %.critedge.thread ], [ true, %26 ]
  ret i1 %.012
}

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 = { inlinehint 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, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9, !10}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.peeled.count", i32 1}
!11 = !{!12, !20, i64 48}
!12 = !{!"_ZTSN4ardb5codec19RedisCommandDecoderE", !13, i64 0, !20, i64 48}
!13 = !{!"_ZTSN4ardb5codec17StackFrameDecoderINS0_17RedisCommandFrameEEE", !14, i64 0, !17, i64 8}
!14 = !{!"_ZTSN4ardb22ChannelUpstreamHandlerINS_6BufferEEE", !15, i64 0}
!15 = !{!"_ZTSN4ardb22AbstractChannelHandlerINS_6BufferEEE", !16, i64 0}
!16 = !{!"_ZTSN4ardb14ChannelHandlerE"}
!17 = !{!"_ZTSN4ardb6BufferE", !18, i64 0, !19, i64 8, !19, i64 16, !19, i64 24, !20, i64 32}
!18 = !{!"any pointer", !6, i64 0}
!19 = !{!"long", !6, i64 0}
!20 = !{!"bool", !6, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}


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