; LLVM IR from AsyncAlgoTrading/aat :: aat/cpp/src/core/order_book/collector.ll (ZN3aat4core9Collector5resetEv)

; 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.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"class.aat::core::Collector" = type { %"class.std::function", double, double, %"class.std::deque", %"class.std::shared_ptr", %"class.std::deque.183", %"class.std::deque.189" }
%"class.std::function" = type { %"class.std::_Function_base", ptr }
%"class.std::_Function_base" = type { %"union.std::_Any_data", ptr }
%"union.std::_Any_data" = type { %"union.std::_Nocopy_types" }
%"union.std::_Nocopy_types" = type { { i64, i64 } }
%"class.std::deque" = type { %"class.std::_Deque_base" }
%"class.std::_Deque_base" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::Event>, std::allocator<std::shared_ptr<aat::core::Event>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::Event>, std::allocator<std::shared_ptr<aat::core::Event>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::Event>, std::allocator<std::shared_ptr<aat::core::Event>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::Event>, std::allocator<std::shared_ptr<aat::core::Event>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator", %"struct.std::_Deque_iterator" }
%"struct.std::_Deque_iterator" = type { ptr, ptr, ptr, ptr }
%"class.std::deque.183" = type { %"class.std::_Deque_base.184" }
%"class.std::_Deque_base.184" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::Order>, std::allocator<std::shared_ptr<aat::core::Order>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::Order>, std::allocator<std::shared_ptr<aat::core::Order>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::Order>, std::allocator<std::shared_ptr<aat::core::Order>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::Order>, std::allocator<std::shared_ptr<aat::core::Order>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.188", %"struct.std::_Deque_iterator.188" }
%"struct.std::_Deque_iterator.188" = type { ptr, ptr, ptr, ptr }
%"class.std::deque.189" = type { %"class.std::_Deque_base.190" }
%"class.std::_Deque_base.190" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::PriceLevel>, std::allocator<std::shared_ptr<aat::core::PriceLevel>>>::_Deque_impl" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::PriceLevel>, std::allocator<std::shared_ptr<aat::core::PriceLevel>>>::_Deque_impl" = type { %"struct.std::_Deque_base<std::shared_ptr<aat::core::PriceLevel>, std::allocator<std::shared_ptr<aat::core::PriceLevel>>>::_Deque_impl_data" }
%"struct.std::_Deque_base<std::shared_ptr<aat::core::PriceLevel>, std::allocator<std::shared_ptr<aat::core::PriceLevel>>>::_Deque_impl_data" = type { ptr, i64, %"struct.std::_Deque_iterator.194", %"struct.std::_Deque_iterator.194" }
%"struct.std::_Deque_iterator.194" = type { ptr, ptr, ptr, ptr }

; 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 @_ZN3aat4core9Collector5resetEv(ptr noundef nonnull align 8 dereferenceable(304) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.std::shared_ptr", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 3
  call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %5) #2
  %6 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 1
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  %7 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 2
  store double 0.000000e+00, ptr %7, align 8, !tbaa !33
  %8 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 5
  call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %8) #2
  %9 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 6
  call void @_ZNSt5dequeISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %9) #2
  call void @llvm.lifetime.start.p0(i64 16, ptr %3) #2
  call void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %3, ptr null) #2
  %10 = getelementptr inbounds %"class.aat::core::Collector", ptr %4, i32 0, i32 4
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN3aat4core5OrderEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 8 dereferenceable(16) %3) #2
  call void @_ZNSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %3) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr %3) #2
  ret void
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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, !13, i64 32}
!10 = !{!"_ZTSN3aat4core9CollectorE", !11, i64 0, !13, i64 32, !13, i64 40, !14, i64 48, !20, i64 128, !23, i64 144, !28, i64 224}
!11 = !{!"_ZTSSt8functionIFvSt10shared_ptrIN3aat4core5EventEEEE", !12, i64 0, !6, i64 24}
!12 = !{!"_ZTSSt14_Function_base", !7, i64 0, !6, i64 16}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_ZTSSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EE", !15, i64 0}
!15 = !{!"_ZTSSt11_Deque_baseISt10shared_ptrIN3aat4core5EventEESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core5EventEESaIS4_EE11_Deque_implE", !17, i64 0}
!17 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core5EventEESaIS4_EE16_Deque_impl_dataE", !6, i64 0, !18, i64 8, !19, i64 16, !19, i64 48}
!18 = !{!"long", !7, i64 0}
!19 = !{!"_ZTSSt15_Deque_iteratorISt10shared_ptrIN3aat4core5EventEERS4_PS4_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!20 = !{!"_ZTSSt10shared_ptrIN3aat4core5OrderEE", !21, i64 0}
!21 = !{!"_ZTSSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !22, i64 8}
!22 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0}
!23 = !{!"_ZTSSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EE", !24, i64 0}
!24 = !{!"_ZTSSt11_Deque_baseISt10shared_ptrIN3aat4core5OrderEESaIS4_EE", !25, i64 0}
!25 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core5OrderEESaIS4_EE11_Deque_implE", !26, i64 0}
!26 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core5OrderEESaIS4_EE16_Deque_impl_dataE", !6, i64 0, !18, i64 8, !27, i64 16, !27, i64 48}
!27 = !{!"_ZTSSt15_Deque_iteratorISt10shared_ptrIN3aat4core5OrderEERS4_PS4_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!28 = !{!"_ZTSSt5dequeISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE", !29, i64 0}
!29 = !{!"_ZTSSt11_Deque_baseISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE", !30, i64 0}
!30 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE11_Deque_implE", !31, i64 0}
!31 = !{!"_ZTSNSt11_Deque_baseISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE16_Deque_impl_dataE", !6, i64 0, !18, i64 8, !32, i64 16, !32, i64 48}
!32 = !{!"_ZTSSt15_Deque_iteratorISt10shared_ptrIN3aat4core10PriceLevelEERS4_PS4_E", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!33 = !{!10, !13, i64 40}


; 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.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 nounwind uwtable
define dso_local void @_ZN3aat4core9Collector5resetEv(ptr noundef nonnull align 8 dereferenceable(304) %0) local_unnamed_addr #1 align 2 {
  %2 = alloca %"class.std::shared_ptr", align 8
  %3 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %3) #3
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = getelementptr inbounds i8, ptr %0, i64 144
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %4, i8 0, i64 16, i1 false)
  tail call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %5) #3
  %6 = getelementptr inbounds i8, ptr %0, i64 224
  tail call void @_ZNSt5dequeISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EE5clearEv(ptr noundef nonnull align 8 dereferenceable(80) %6) #3
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #3
  call void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr null) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 128
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN3aat4core5OrderEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 8 dereferenceable(16) %2) #3
  call void @_ZNSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %2) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #3
  ret void
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN3aat4core5OrderEEaSEOS3_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

attributes #0 = { mustprogress 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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)"}


; Effective O3 passes: GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,TailCallElimPass