; LLVM IR from scorelab/EtherBeat :: tools/EtherExtractor/src/rlp.ll (ZN3RLP10parseItemsEv)

; 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.RLP = type { ptr, i64, i64, i64, i64, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl" }
%"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl" = type { %"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl_data" }
%"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl_data" = type { ptr, ptr, 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
define dso_local void @_ZN3RLP10parseItemsEv(ptr noundef nonnull align 8 dereferenceable(64) %0) #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca %class.RLP, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %9 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 4
  %10 = load i64, ptr %9, align 8, !tbaa !9
  store i64 %10, ptr %3, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %11 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 2
  %12 = load i64, ptr %11, align 8, !tbaa !17
  store i64 %12, ptr %4, align 8, !tbaa !16
  br label %13

13:                                               ; preds = %22, %1
  %14 = load i64, ptr %3, align 8, !tbaa !16
  %15 = icmp ugt i64 %14, 0
  br i1 %15, label %16, label %37

16:                                               ; preds = %13
  %17 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 5
  call void @llvm.lifetime.start.p0(i64 64, ptr %5) #4
  %18 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !18
  %20 = load i64, ptr %4, align 8, !tbaa !16
  %21 = load i64, ptr %3, align 8, !tbaa !16
  call void @_ZN3RLPC1ERKSt6vectorIhSaIhEEmm(ptr noundef nonnull align 8 dereferenceable(64) %5, ptr noundef nonnull align 8 dereferenceable(24) %19, i64 noundef %20, i64 noundef %21)
  invoke void @_ZNSt6vectorI3RLPSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %17, ptr noundef nonnull align 8 dereferenceable(64) %5)
          to label %22 unwind label %33

22:                                               ; preds = %16
  call void @_ZN3RLPD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %5) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #4
  %23 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 5
  %24 = call noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %23) #4
  %25 = call noundef i64 @_ZNK3RLP11totalLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %24)
  %26 = load i64, ptr %3, align 8, !tbaa !16
  %27 = sub i64 %26, %25
  store i64 %27, ptr %3, align 8, !tbaa !16
  %28 = getelementptr inbounds %class.RLP, ptr %8, i32 0, i32 5
  %29 = call noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %28) #4
  %30 = call noundef i64 @_ZNK3RLP11totalLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %29)
  %31 = load i64, ptr %4, align 8, !tbaa !16
  %32 = add i64 %31, %30
  store i64 %32, ptr %4, align 8, !tbaa !16
  br label %13, !llvm.loop !19

33:                                               ; preds = %16
  %34 = landingpad { ptr, i32 }
          cleanup
  %35 = extractvalue { ptr, i32 } %34, 0
  store ptr %35, ptr %6, align 8
  %36 = extractvalue { ptr, i32 } %34, 1
  store i32 %36, ptr %7, align 4
  call void @_ZN3RLPD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %5) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  br label %38

37:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void

38:                                               ; preds = %33
  %39 = load ptr, ptr %6, align 8
  %40 = load i32, ptr %7, align 4
  %41 = insertvalue { ptr, i32 } poison, ptr %39, 0
  %42 = insertvalue { ptr, i32 } %41, i32 %40, 1
  resume { ptr, i32 } %42
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) #3 align 2

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

declare void @_ZN3RLPC1ERKSt6vectorIhSaIhEEmm(ptr, ptr, i64, i64)

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 = { 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 }

!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, !11, i64 32}
!10 = !{!"_ZTS3RLP", !6, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !12, i64 40}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_ZTSSt6vectorI3RLPSaIS0_EE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseI3RLPSaIS0_EE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseI3RLPSaIS0_EE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseI3RLPSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !11, i64 16}
!18 = !{!10, !6, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

%class.RLP = type { ptr, i64, i64, i64, i64, %"class.std::vector" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl" }
%"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl" = type { %"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl_data" }
%"struct.std::_Vector_base<RLP, std::allocator<RLP>>::_Vector_impl_data" = type { ptr, ptr, 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
define dso_local void @_ZN3RLP10parseItemsEv(ptr noundef nonnull align 8 dereferenceable(64) %0) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.RLP, align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %.not8 = icmp eq i64 %4, 0
  br i1 %.not8, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i64, ptr %5, align 8, !tbaa !15
  %7 = getelementptr inbounds i8, ptr %0, i64 40
  br label %8

8:                                                ; preds = %.lr.ph, %10
  %.010 = phi i64 [ %4, %.lr.ph ], [ %13, %10 ]
  %.079 = phi i64 [ %6, %.lr.ph ], [ %16, %10 ]
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %2) #4
  %9 = load ptr, ptr %0, align 8, !tbaa !16
  call void @_ZN3RLPC1ERKSt6vectorIhSaIhEEmm(ptr noundef nonnull align 8 dereferenceable(64) %2, ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %.079, i64 noundef %.010)
  invoke void @_ZNSt6vectorI3RLPSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %7, ptr noundef nonnull align 8 dereferenceable(64) %2)
          to label %10 unwind label %17

10:                                               ; preds = %8
  call void @_ZN3RLPD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %2) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  %11 = call noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %12 = call noundef i64 @_ZNK3RLP11totalLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %11)
  %13 = sub i64 %.010, %12
  %14 = call noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #4
  %15 = call noundef i64 @_ZNK3RLP11totalLengthEv(ptr noundef nonnull align 8 dereferenceable(64) %14)
  %16 = add i64 %15, %.079
  %.not = icmp eq i64 %13, 0
  br i1 %.not, label %._crit_edge, label %8, !llvm.loop !17

17:                                               ; preds = %8
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3RLPD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %2) #4
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %2) #4
  resume { ptr, i32 } %18

._crit_edge:                                      ; preds = %10, %1
  ret void
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(64) ptr @_ZNSt6vectorI3RLPSaIS0_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

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

declare void @_ZN3RLPC1ERKSt6vectorIhSaIhEEmm(ptr, ptr, i64, i64) 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 = { 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 = { 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 }

!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, !10, i64 32}
!6 = !{!"_ZTS3RLP", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"_ZTSSt6vectorI3RLPSaIS0_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseI3RLPSaIS0_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseI3RLPSaIS0_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseI3RLPSaIS0_EE17_Vector_impl_dataE", !7, i64 0, !7, i64 8, !7, i64 16}
!15 = !{!6, !10, i64 16}
!16 = !{!6, !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


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