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

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

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3aat4core9CollectorC2ESt8functionIFvSt10shared_ptrINS0_5EventEEEE(ptr noundef nonnull align 8 dereferenceable(304) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  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
  %8 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 0
  call void @_ZNSt8functionIFvSt10shared_ptrIN3aat4core5EventEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32) %8, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %9 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 1
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 2
  store double 0.000000e+00, ptr %10, align 8, !tbaa !33
  %11 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 3
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %11)
          to label %12 unwind label %18

12:                                               ; preds = %2
  %13 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 4
  call void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #2
  %14 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 5
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14)
          to label %15 unwind label %22

15:                                               ; preds = %12
  %16 = getelementptr inbounds %"class.aat::core::Collector", ptr %7, i32 0, i32 6
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %16)
          to label %17 unwind label %26

17:                                               ; preds = %15
  ret void

18:                                               ; preds = %2
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %5, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %6, align 4
  br label %31

22:                                               ; preds = %12
  %23 = landingpad { ptr, i32 }
          cleanup
  %24 = extractvalue { ptr, i32 } %23, 0
  store ptr %24, ptr %5, align 8
  %25 = extractvalue { ptr, i32 } %23, 1
  store i32 %25, ptr %6, align 4
  br label %30

26:                                               ; preds = %15
  %27 = landingpad { ptr, i32 }
          cleanup
  %28 = extractvalue { ptr, i32 } %27, 0
  store ptr %28, ptr %5, align 8
  %29 = extractvalue { ptr, i32 } %27, 1
  store i32 %29, ptr %6, align 4
  call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %14) #2
  br label %30

30:                                               ; preds = %26, %22
  call void @_ZNSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %13) #2
  call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %11) #2
  br label %31

31:                                               ; preds = %30, %18
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %8) #2
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %5, align 8
  %34 = load i32, ptr %6, align 4
  %35 = insertvalue { ptr, i32 } poison, ptr %33, 0
  %36 = insertvalue { ptr, i32 } %35, i32 %34, 1
  resume { ptr, i32 } %36
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt8functionIFvSt10shared_ptrIN3aat4core5EventEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 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 = { 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 = { 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"

declare i32 @__gxx_personality_v0(...)

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

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

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

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3aat4core9CollectorC2ESt8functionIFvSt10shared_ptrINS0_5EventEEEE(ptr noundef nonnull align 8 dereferenceable(304) %0, ptr noundef nonnull %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZNSt8functionIFvSt10shared_ptrIN3aat4core5EventEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32) %0, ptr noundef nonnull align 8 dereferenceable(32) %1)
  %3 = getelementptr inbounds i8, ptr %0, i64 32
  %4 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %3, i8 0, i64 16, i1 false)
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4)
          to label %5 unwind label %11

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 128
  tail call void @_ZNSt10shared_ptrIN3aat4core5OrderEEC2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 144
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %7)
          to label %8 unwind label %13

8:                                                ; preds = %5
  %9 = getelementptr inbounds i8, ptr %0, i64 224
  invoke void @_ZNSt5dequeISt10shared_ptrIN3aat4core10PriceLevelEESaIS4_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(80) %9)
          to label %10 unwind label %15

10:                                               ; preds = %8
  ret void

11:                                               ; preds = %2
  %12 = landingpad { ptr, i32 }
          cleanup
  br label %18

13:                                               ; preds = %5
  %14 = landingpad { ptr, i32 }
          cleanup
  br label %17

15:                                               ; preds = %8
  %16 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5OrderEESaIS4_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %7) #3
  br label %17

17:                                               ; preds = %15, %13
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %14, %13 ]
  tail call void @_ZNSt12__shared_ptrIN3aat4core5OrderELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %6) #3
  tail call void @_ZNSt5dequeISt10shared_ptrIN3aat4core5EventEESaIS4_EED2Ev(ptr noundef nonnull align 8 dereferenceable(80) %4) #3
  br label %18

18:                                               ; preds = %17, %11
  %.pn.pn = phi { ptr, i32 } [ %.pn, %17 ], [ %12, %11 ]
  tail call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %0) #3
  resume { ptr, i32 } %.pn.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt8functionIFvSt10shared_ptrIN3aat4core5EventEEEEC2ERKS6_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) unnamed_addr #0 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 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 = { 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: EarlyCSEPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass