; LLVM IR from cieslarmichal/rpg :: src/Inventory.ll (ZN9InventoryC2Ev)

; 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.Item = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i32, i32, i32, i32, i32, i8, i8, i8, i32 }
%"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] }
%class.Inventory = type { %"class.std::vector", i32, %"class.std::vector", i32, i32, i8, i32, %class.TimeHandler }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<Item, std::allocator<Item>>::_Vector_impl" }
%"struct.std::_Vector_base<Item, std::allocator<Item>>::_Vector_impl" = type { %"struct.std::_Vector_base<Item, std::allocator<Item>>::_Vector_impl_data" }
%"struct.std::_Vector_base<Item, std::allocator<Item>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.TimeHandler = type { %"class.sf::Clock", %"class.sf::Time" }
%"class.sf::Clock" = type { %"class.sf::Time" }
%"class.sf::Time" = type { i64 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9InventoryC2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %class.Item, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  %8 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 0
  call void @_ZNSt6vectorI4ItemSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  %9 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 1
  store i32 7, ptr %9, align 8, !tbaa !9
  %10 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 2
  call void @_ZNSt6vectorI4ItemSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #5
  %11 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 3
  store i32 0, ptr %11, align 8, !tbaa !21
  %12 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 4
  store i32 8, ptr %12, align 4, !tbaa !22
  %13 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 5
  store i8 0, ptr %13, align 8, !tbaa !23
  %14 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 6
  store i32 0, ptr %14, align 4, !tbaa !24
  %15 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 7
  invoke void @_ZN11TimeHandlerC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %15)
          to label %16 unwind label %23

16:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 0, ptr %5, align 4, !tbaa !25
  br label %17

17:                                               ; preds = %31, %16
  %18 = load i32, ptr %5, align 4, !tbaa !25
  %19 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = icmp slt i32 %18, %20
  br i1 %21, label %27, label %22

22:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %43

23:                                               ; preds = %1
  %24 = landingpad { ptr, i32 }
          cleanup
  %25 = extractvalue { ptr, i32 } %24, 0
  store ptr %25, ptr %3, align 8
  %26 = extractvalue { ptr, i32 } %24, 1
  store i32 %26, ptr %4, align 4
  br label %44

27:                                               ; preds = %17
  %28 = getelementptr inbounds %class.Inventory, ptr %7, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 96, ptr %6) #5
  invoke void @_ZN4ItemC1Ev(ptr noundef nonnull align 8 dereferenceable(96) %6)
          to label %29 unwind label %34

29:                                               ; preds = %27
  invoke void @_ZNSt6vectorI4ItemSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %28, ptr noundef nonnull align 8 dereferenceable(96) %6)
          to label %30 unwind label %38

30:                                               ; preds = %29
  call void @_ZN4ItemD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %6) #5
  call void @llvm.lifetime.end.p0(i64 96, ptr %6) #5
  br label %31

31:                                               ; preds = %30
  %32 = load i32, ptr %5, align 4, !tbaa !25
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !25
  br label %17, !llvm.loop !26

34:                                               ; preds = %27
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %3, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %4, align 4
  br label %42

38:                                               ; preds = %29
  %39 = landingpad { ptr, i32 }
          cleanup
  %40 = extractvalue { ptr, i32 } %39, 0
  store ptr %40, ptr %3, align 8
  %41 = extractvalue { ptr, i32 } %39, 1
  store i32 %41, ptr %4, align 4
  call void @_ZN4ItemD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %6) #5
  br label %42

42:                                               ; preds = %38, %34
  call void @llvm.lifetime.end.p0(i64 96, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %44

43:                                               ; preds = %22
  ret void

44:                                               ; preds = %42, %23
  call void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %10) #5
  call void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %8) #5
  br label %45

45:                                               ; preds = %44
  %46 = load ptr, ptr %3, align 8
  %47 = load i32, ptr %4, align 4
  %48 = insertvalue { ptr, i32 } poison, ptr %46, 0
  %49 = insertvalue { ptr, i32 } %48, i32 %47, 1
  resume { ptr, i32 } %49
}

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

declare void @_ZN11TimeHandlerC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

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) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI4ItemSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(96)) #0 align 2

declare void @_ZN4ItemC1Ev(ptr noundef nonnull align 8 dereferenceable(96)) unnamed_addr #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) 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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !15, i64 24}
!10 = !{!"_ZTS9Inventory", !11, i64 0, !15, i64 24, !11, i64 32, !15, i64 56, !15, i64 60, !16, i64 64, !15, i64 68, !17, i64 72}
!11 = !{!"_ZTSSt6vectorI4ItemSaIS0_EE", !12, i64 0}
!12 = !{!"_ZTSSt12_Vector_baseI4ItemSaIS0_EE", !13, i64 0}
!13 = !{!"_ZTSNSt12_Vector_baseI4ItemSaIS0_EE12_Vector_implE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseI4ItemSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!15 = !{!"int", !7, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"_ZTS11TimeHandler", !18, i64 0, !19, i64 8}
!18 = !{!"_ZTSN2sf5ClockE", !19, i64 0}
!19 = !{!"_ZTSN2sf4TimeE", !20, i64 0}
!20 = !{!"long long", !7, i64 0}
!21 = !{!10, !15, i64 56}
!22 = !{!10, !15, i64 60}
!23 = !{!10, !16, i64 64}
!24 = !{!10, !15, i64 68}
!25 = !{!15, !15, i64 0}
!26 = distinct !{!26, !27}
!27 = !{!"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.Item = type { %"class.std::__cxx11::basic_string", %"class.std::__cxx11::basic_string", i32, i32, i32, i32, i32, i32, i8, i8, i8, i32 }
%"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] }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9InventoryC2Ev(ptr noundef nonnull align 8 dereferenceable(88) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca %class.Item, align 8
  tail call void @_ZNSt6vectorI4ItemSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  %3 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 7, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  tail call void @_ZNSt6vectorI4ItemSaIS0_EEC2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  store i32 0, ptr %5, align 8, !tbaa !20
  %6 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 8, ptr %6, align 4, !tbaa !21
  %7 = getelementptr inbounds i8, ptr %0, i64 64
  store i8 0, ptr %7, align 8, !tbaa !22
  %8 = getelementptr inbounds i8, ptr %0, i64 68
  store i32 0, ptr %8, align 4, !tbaa !23
  %9 = getelementptr inbounds i8, ptr %0, i64 72
  invoke void @_ZN11TimeHandlerC1Ev(ptr noundef nonnull align 8 dereferenceable(16) %9)
          to label %.preheader unwind label %12

.preheader:                                       ; preds = %1
  %10 = load i32, ptr %3, align 8, !tbaa !5
  %11 = icmp sgt i32 %10, 0
  br i1 %11, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %15, %.preheader
  ret void

12:                                               ; preds = %1
  %13 = landingpad { ptr, i32 }
          cleanup
  br label %24

.lr.ph:                                           ; preds = %.preheader, %15
  %.09 = phi i32 [ %16, %15 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 96, ptr nonnull %2) #5
  invoke void @_ZN4ItemC1Ev(ptr noundef nonnull align 8 dereferenceable(96) %2)
          to label %14 unwind label %19

14:                                               ; preds = %.lr.ph
  invoke void @_ZNSt6vectorI4ItemSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef nonnull align 8 dereferenceable(96) %2)
          to label %15 unwind label %21

15:                                               ; preds = %14
  call void @_ZN4ItemD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %2) #5
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %2) #5
  %16 = add nuw nsw i32 %.09, 1
  %17 = load i32, ptr %3, align 8, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !24

19:                                               ; preds = %.lr.ph
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %23

21:                                               ; preds = %14
  %22 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN4ItemD2Ev(ptr noundef nonnull align 8 dereferenceable(96) %2) #5
  br label %23

23:                                               ; preds = %21, %19
  %.pn = phi { ptr, i32 } [ %22, %21 ], [ %20, %19 ]
  call void @llvm.lifetime.end.p0(i64 96, ptr nonnull %2) #5
  br label %24

24:                                               ; preds = %23, %12
  %.pn.pn = phi { ptr, i32 } [ %.pn, %23 ], [ %13, %12 ]
  call void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %4) #5
  call void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %0) #5
  resume { ptr, i32 } %.pn.pn
}

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

declare void @_ZN11TimeHandlerC1Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #2

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) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorI4ItemSaIS0_EE9push_backEOS0_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 8 dereferenceable(96)) local_unnamed_addr #0 align 2

declare void @_ZN4ItemC1Ev(ptr noundef nonnull align 8 dereferenceable(96)) unnamed_addr #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorI4ItemSaIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(24)) 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 = { "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #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, !14, i64 24}
!6 = !{!"_ZTS9Inventory", !7, i64 0, !14, i64 24, !7, i64 32, !14, i64 56, !14, i64 60, !15, i64 64, !14, i64 68, !16, i64 72}
!7 = !{!"_ZTSSt6vectorI4ItemSaIS0_EE", !8, i64 0}
!8 = !{!"_ZTSSt12_Vector_baseI4ItemSaIS0_EE", !9, i64 0}
!9 = !{!"_ZTSNSt12_Vector_baseI4ItemSaIS0_EE12_Vector_implE", !10, i64 0}
!10 = !{!"_ZTSNSt12_Vector_baseI4ItemSaIS0_EE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!11 = !{!"any pointer", !12, i64 0}
!12 = !{!"omnipotent char", !13, i64 0}
!13 = !{!"Simple C++ TBAA"}
!14 = !{!"int", !12, i64 0}
!15 = !{!"bool", !12, i64 0}
!16 = !{!"_ZTS11TimeHandler", !17, i64 0, !18, i64 8}
!17 = !{!"_ZTSN2sf5ClockE", !18, i64 0}
!18 = !{!"_ZTSN2sf4TimeE", !19, i64 0}
!19 = !{!"long long", !12, i64 0}
!20 = !{!6, !14, i64 56}
!21 = !{!6, !14, i64 60}
!22 = !{!6, !15, i64 64}
!23 = !{!6, !14, i64 68}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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