; 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"

@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1

; 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 noundef zeroext i1 @_ZN4ardb5codec19RedisCommandEncoder6EncodeERNS_6BufferERKNS0_17RedisCommandFrameE(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull align 8 dereferenceable(160) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK4ardb5codec17RedisCommandFrame12GetArgumentsB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %8)
  %10 = call noundef i64 @_ZNKSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %9) #5
  %11 = add i64 %10, 1
  %12 = call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %7, ptr noundef @.str.12, i64 noundef %11)
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %14)
  %16 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %15) #5
  %17 = call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %13, ptr noundef @.str.13, i64 noundef %16)
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %19)
  %21 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32) %20) #5
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %22)
  %24 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %23) #5
  %25 = call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %18, ptr noundef %21, i64 noundef %24)
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %26, ptr noundef @.str.14, i64 noundef 2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %52, %2
  %29 = load i32, ptr %5, align 4, !tbaa !9
  %30 = zext i32 %29 to i64
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK4ardb5codec17RedisCommandFrame12GetArgumentsB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %31)
  %33 = call noundef i64 @_ZNKSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %32) #5
  %34 = icmp ult i64 %30, %33
  br i1 %34, label %36, label %35

35:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %55

36:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !9
  %39 = call noundef ptr @_ZNK4ardb5codec17RedisCommandFrame11GetArgumentB5cxx11Ej(ptr noundef nonnull align 8 dereferenceable(160) %37, i32 noundef %38)
  store ptr %39, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %41) #5
  %43 = call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %40, ptr noundef @.str.13, i64 noundef %42)
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32) %45) #5
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %47) #5
  %49 = call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %44, ptr noundef %46, i64 noundef %48)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %50, ptr noundef @.str.14, i64 noundef 2)
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %52

52:                                               ; preds = %36
  %53 = load i32, ptr %5, align 4, !tbaa !9
  %54 = add i32 %53, 1
  store i32 %54, ptr %5, align 4, !tbaa !9
  br label %28, !llvm.loop !11

55:                                               ; preds = %35
  ret i1 true
}

declare noundef i32 @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160)) #3 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i64 noundef) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4ardb5codec17RedisCommandFrame11GetArgumentB5cxx11Ej(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) #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 = { "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 = { inlinehint 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 #5 = { 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 = !{!"int", !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"

@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN4ardb5codec19RedisCommandEncoder6EncodeERNS_6BufferERKNS0_17RedisCommandFrameE(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull align 8 dereferenceable(160) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK4ardb5codec17RedisCommandFrame12GetArgumentsB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %4 = tail call noundef i64 @_ZNKSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %3) #4
  %5 = add i64 %4, 1
  %6 = tail call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull @.str.12, i64 noundef %5)
  %7 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %8 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %7) #4
  %9 = tail call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull @.str.13, i64 noundef %8)
  %10 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %11 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32) %10) #4
  %12 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %13 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %12) #4
  %14 = tail call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %11, i64 noundef %13)
  %15 = tail call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull @.str.14, i64 noundef 2)
  %16 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK4ardb5codec17RedisCommandFrame12GetArgumentsB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %17 = tail call noundef i64 @_ZNKSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %16) #4
  %.not = icmp eq i64 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %2
  ret i1 true

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.018 = phi i32 [ %25, %.lr.ph ], [ 0, %2 ]
  %18 = tail call noundef ptr @_ZNK4ardb5codec17RedisCommandFrame11GetArgumentB5cxx11Ej(ptr noundef nonnull align 8 dereferenceable(160) %1, i32 noundef %.018)
  %19 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #4
  %20 = tail call noundef i32 (ptr, ptr, ...) @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull @.str.13, i64 noundef %19)
  %21 = tail call noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #4
  %22 = tail call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(32) %18) #4
  %23 = tail call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef %21, i64 noundef %22)
  %24 = tail call noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33) %0, ptr noundef nonnull @.str.14, i64 noundef 2)
  %25 = add i32 %.018, 1
  %26 = zext i32 %25 to i64
  %27 = tail call noundef nonnull align 8 dereferenceable(80) ptr @_ZNK4ardb5codec17RedisCommandFrame12GetArgumentsB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160) %1)
  %28 = tail call noundef i64 @_ZNKSt5dequeINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESaIS5_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(80) %27) #4
  %29 = icmp ugt i64 %28, %26
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !5
}

declare noundef i32 @_ZN4ardb6Buffer6PrintfEPKcz(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, ...) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNK4ardb5codec17RedisCommandFrame10GetCommandB5cxx11Ev(ptr noundef nonnull align 8 dereferenceable(160)) local_unnamed_addr #2 align 2

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_ZN4ardb6Buffer5WriteEPKvm(ptr noundef nonnull align 8 dereferenceable(33), ptr noundef, i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE4dataEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK4ardb5codec17RedisCommandFrame11GetArgumentB5cxx11Ej(ptr noundef nonnull align 8 dereferenceable(160), i32 noundef) 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 = { "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 = { inlinehint 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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