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

; 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] }

@_ZTISt9bad_alloc = external constant ptr

declare i32 @__gxx_personality_v0(...)

; 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 @_ZN4ardb5codec14RedisReplyPool8AllocateEv(ptr noundef nonnull align 8 dereferenceable(112)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr noundef nonnull align 8 dereferenceable(72) %0, i1 noundef zeroext %1) #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %9 = zext i1 %1 to i8
  store i8 %9, ptr %4, align 1, !tbaa !9
  %10 = load ptr, ptr %3, align 8
  %11 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 1
  store i32 2, ptr %11, align 8, !tbaa !11
  %12 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 4
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %14 = icmp eq ptr null, %13
  br i1 %14, label %15, label %23

15:                                               ; preds = %2
  %16 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 80) #5
  invoke void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %16)
          to label %17 unwind label %19

17:                                               ; preds = %15
  %18 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 4
  store ptr %16, ptr %18, align 8, !tbaa !17
  br label %23

19:                                               ; preds = %15
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %5, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %16, i64 noundef 80) #6
  br label %66

23:                                               ; preds = %17, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  store ptr null, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 5
  %25 = load ptr, ptr %24, align 8, !tbaa !18
  %26 = icmp eq ptr null, %25
  br i1 %26, label %27, label %50

27:                                               ; preds = %23
  br label %28

28:                                               ; preds = %27
  %29 = invoke noalias noundef nonnull ptr @_Znwm(i64 noundef 72) #5
          to label %30 unwind label %32

30:                                               ; preds = %28
  invoke void @_ZN4ardb5codec10RedisReplyC1Ev(ptr noundef nonnull align 8 dereferenceable(72) %29)
          to label %31 unwind label %36

31:                                               ; preds = %30
  store ptr %29, ptr %7, align 8, !tbaa !5
  br label %47

32:                                               ; preds = %28
  %33 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9bad_alloc
  %34 = extractvalue { ptr, i32 } %33, 0
  store ptr %34, ptr %5, align 8
  %35 = extractvalue { ptr, i32 } %33, 1
  store i32 %35, ptr %6, align 4
  br label %40

36:                                               ; preds = %30
  %37 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9bad_alloc
  %38 = extractvalue { ptr, i32 } %37, 0
  store ptr %38, ptr %5, align 8
  %39 = extractvalue { ptr, i32 } %37, 1
  store i32 %39, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %29, i64 noundef 72) #6
  br label %40

40:                                               ; preds = %36, %32
  %41 = load i32, ptr %6, align 4
  %42 = call i32 @llvm.eh.typeid.for.p0(ptr @_ZTISt9bad_alloc) #7
  %43 = icmp eq i32 %41, %42
  br i1 %43, label %44, label %65

44:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %45 = load ptr, ptr %5, align 8
  %46 = call ptr @__cxa_begin_catch(ptr %45) #7
  store ptr %46, ptr %8, align 8
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @__cxa_end_catch()
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  br label %47

47:                                               ; preds = %44, %31
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  br label %54

50:                                               ; preds = %23
  %51 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 5
  %52 = load ptr, ptr %51, align 8, !tbaa !18
  %53 = call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec14RedisReplyPool8AllocateEv(ptr noundef nonnull align 8 dereferenceable(112) %52)
  store ptr %53, ptr %7, align 8, !tbaa !5
  br label %54

54:                                               ; preds = %50, %49
  %55 = load i8, ptr %4, align 1, !tbaa !9, !range !19, !noundef !20
  %56 = trunc i8 %55 to i1
  br i1 %56, label %57, label %60

57:                                               ; preds = %54
  %58 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 4
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(80) %59, ptr noundef nonnull align 8 dereferenceable(8) %7)
  br label %63

60:                                               ; preds = %54
  %61 = getelementptr inbounds %"struct.ardb::codec::RedisReply", ptr %10, i32 0, i32 4
  %62 = load ptr, ptr %61, align 8, !tbaa !17
  call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE10push_frontERKS3_(ptr noundef nonnull align 8 dereferenceable(80) %62, ptr noundef nonnull align 8 dereferenceable(8) %7)
  br label %63

63:                                               ; preds = %60, %57
  %64 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  ret ptr %64

65:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %66

66:                                               ; preds = %65, %19
  %67 = load ptr, ptr %5, align 8
  %68 = load i32, ptr %6, align 4
  %69 = insertvalue { ptr, i32 } poison, ptr %67, 0
  %70 = insertvalue { ptr, i32 } %69, i32 %68, 1
  resume { ptr, i32 } %70
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #2

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

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

; Function Attrs: nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #4

declare ptr @__cxa_begin_catch(ptr)

declare void @__cxa_end_catch()

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

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

declare void @_ZN4ardb5codec10RedisReplyC1Ev(ptr)

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 allocsize(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 = { 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 #4 = { nounwind memory(none) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { builtin nounwind }
attributes #7 = { 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 = !{!12, !13, i64 8}
!12 = !{!"_ZTSN4ardb5codec10RedisReplyE", !13, i64 8, !14, i64 16, !16, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !7, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!12, !6, i64 56}
!18 = !{!12, !6, i64 64}
!19 = !{i8 0, i8 2}
!20 = !{}


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

@_ZTISt9bad_alloc = external constant ptr

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: mustprogress 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 @_ZN4ardb5codec14RedisReplyPool8AllocateEv(ptr noundef nonnull align 8 dereferenceable(112)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec10RedisReply9AddMemberEb(ptr nocapture noundef nonnull align 8 dereferenceable(72) %0, i1 noundef zeroext %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 2, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  %6 = load ptr, ptr %5, align 8, !tbaa !14
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %13

8:                                                ; preds = %2
  %9 = tail call noalias noundef nonnull dereferenceable(80) ptr @_Znwm(i64 noundef 80) #5
  invoke void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %10 unwind label %11

10:                                               ; preds = %8
  store ptr %9, ptr %5, align 8, !tbaa !14
  br label %13

11:                                               ; preds = %8
  %12 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZdlPvm(ptr noundef nonnull %9, i64 noundef 80) #6
  br label %39

13:                                               ; preds = %10, %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  %14 = getelementptr inbounds i8, ptr %0, i64 64
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %30

17:                                               ; preds = %13
  %18 = invoke noalias noundef nonnull dereferenceable(72) ptr @_Znwm(i64 noundef 72) #5
          to label %19 unwind label %21

19:                                               ; preds = %17
  invoke void @_ZN4ardb5codec10RedisReplyC1Ev(ptr noundef nonnull align 8 dereferenceable(72) %18)
          to label %20 unwind label %23

20:                                               ; preds = %19
  store ptr %18, ptr %3, align 8, !tbaa !16
  br label %32

21:                                               ; preds = %17
  %22 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9bad_alloc
  br label %25

23:                                               ; preds = %19
  %24 = landingpad { ptr, i32 }
          cleanup
          catch ptr @_ZTISt9bad_alloc
  tail call void @_ZdlPvm(ptr noundef nonnull %18, i64 noundef 72) #6
  br label %25

25:                                               ; preds = %23, %21
  %.pn = phi { ptr, i32 } [ %24, %23 ], [ %22, %21 ]
  %.05 = extractvalue { ptr, i32 } %.pn, 1
  %26 = tail call i32 @llvm.eh.typeid.for.p0(ptr nonnull @_ZTISt9bad_alloc) #7
  %27 = icmp eq i32 %.05, %26
  br i1 %27, label %28, label %38

28:                                               ; preds = %25
  %.0 = extractvalue { ptr, i32 } %.pn, 0
  %29 = tail call ptr @__cxa_begin_catch(ptr %.0) #7
  store ptr null, ptr %3, align 8, !tbaa !16
  tail call void @__cxa_end_catch()
  br label %32

30:                                               ; preds = %13
  %31 = tail call noundef nonnull align 8 dereferenceable(72) ptr @_ZN4ardb5codec14RedisReplyPool8AllocateEv(ptr noundef nonnull align 8 dereferenceable(112) %15)
  store ptr %31, ptr %3, align 8, !tbaa !16
  br label %32

32:                                               ; preds = %20, %28, %30
  %33 = load ptr, ptr %5, align 8, !tbaa !14
  br i1 %1, label %34, label %35

34:                                               ; preds = %32
  call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE9push_backERKS3_(ptr noundef nonnull align 8 dereferenceable(80) %33, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %36

35:                                               ; preds = %32
  call void @_ZNSt5dequeIPN4ardb5codec10RedisReplyESaIS3_EE10push_frontERKS3_(ptr noundef nonnull align 8 dereferenceable(80) %33, ptr noundef nonnull align 8 dereferenceable(8) %3)
  br label %36

36:                                               ; preds = %35, %34
  %37 = load ptr, ptr %3, align 8, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  ret ptr %37

38:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %39

39:                                               ; preds = %38, %11
  %.merged = phi { ptr, i32 } [ %.pn, %38 ], [ %12, %11 ]
  resume { ptr, i32 } %.merged
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

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

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

; Function Attrs: nofree nosync nounwind memory(none)
declare i32 @llvm.eh.typeid.for.p0(ptr) #4

declare ptr @__cxa_begin_catch(ptr) local_unnamed_addr

declare void @__cxa_end_catch() local_unnamed_addr

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

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

declare void @_ZN4ardb5codec10RedisReplyC1Ev(ptr) local_unnamed_addr

attributes #0 = { mustprogress 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 allocsize(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 = { 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 #4 = { nofree nosync nounwind memory(none) }
attributes #5 = { builtin allocsize(0) }
attributes #6 = { builtin nounwind }
attributes #7 = { 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, !7, i64 8}
!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 = !{!6, !12, i64 64}
!16 = !{!12, !12, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass