; LLVM IR from jrouwe/JoltPhysics :: TestFramework/UI/UIManager.ll (ZN9UIManagerD2Ev)

; 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.UIManager = type { %class.UIElement, ptr, ptr, %"class.JPH::Array.3", i8, %"class.std::unique_ptr", %"class.std::unique_ptr", %"class.std::function", i32, float }
%class.UIElement = type { %class.UIEventListener, i32, ptr, %"class.JPH::Array", %"class.UIElement::Position", %"class.UIElement::Position", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", %"class.UIElement::Size", i8, i8, i8, i8, i8, i8, i8, %"class.JPH::Array.0", ptr }
%class.UIEventListener = type { ptr }
%"class.JPH::Array" = type { i64, i64, ptr }
%"class.UIElement::Position" = type { i32, %"class.UIElement::Size" }
%"class.UIElement::Size" = type { i32, i32 }
%"class.JPH::Array.0" = type { i64, i64, ptr }
%"class.JPH::Array.3" = type { i64, i64, ptr }
%"class.std::unique_ptr" = type { %"struct.std::__uniq_ptr_data" }
%"struct.std::__uniq_ptr_data" = type { %"class.std::__uniq_ptr_impl" }
%"class.std::__uniq_ptr_impl" = type { %"class.std::tuple" }
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Head_base.7" }
%"struct.std::_Head_base.7" = type { ptr }
%"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 } }

@_ZTV9UIManager = external dso_local unnamed_addr constant { [17 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: nounwind
declare void @_ZN9UIElementD2Ev(ptr noundef nonnull align 8 dereferenceable(144)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9UIManagerD2Ev(ptr noundef nonnull align 8 dereferenceable(248) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %3 = load ptr, ptr %2, align 8
  store ptr getelementptr inbounds inrange(-16, 120) ({ [17 x ptr] }, ptr @_ZTV9UIManager, i32 0, i32 0, i32 2), ptr %3, align 8, !tbaa !9
  br label %4

4:                                                ; preds = %10, %1
  %5 = getelementptr inbounds %class.UIManager, ptr %3, i32 0, i32 3
  %6 = invoke noundef zeroext i1 @_ZNK3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %5)
          to label %7 unwind label %16

7:                                                ; preds = %4
  %8 = xor i1 %6, true
  br i1 %8, label %9, label %11

9:                                                ; preds = %7
  invoke void @_ZN9UIManager8PopLayerEv(ptr noundef nonnull align 8 dereferenceable(248) %3)
          to label %10 unwind label %16

10:                                               ; preds = %9
  br label %4, !llvm.loop !11

11:                                               ; preds = %7
  %12 = getelementptr inbounds %class.UIManager, ptr %3, i32 0, i32 7
  call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %12) #5
  %13 = getelementptr inbounds %class.UIManager, ptr %3, i32 0, i32 6
  call void @_ZNSt10unique_ptrI13PipelineStateSt14default_deleteIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %13) #5
  %14 = getelementptr inbounds %class.UIManager, ptr %3, i32 0, i32 5
  call void @_ZNSt10unique_ptrI13PipelineStateSt14default_deleteIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %14) #5
  %15 = getelementptr inbounds %class.UIManager, ptr %3, i32 0, i32 3
  call void @_ZN3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %15) #5
  call void @_ZN9UIElementD2Ev(ptr noundef nonnull align 8 dereferenceable(144) %3) #5
  ret void

16:                                               ; preds = %9, %4
  %17 = landingpad { ptr, i32 }
          catch ptr null
  %18 = extractvalue { ptr, i32 } %17, 0
  call void @__clang_call_terminate(ptr %18) #6
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9UIManager8PopLayerEv(ptr noundef nonnull align 8 dereferenceable(248)) #4 align 2

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { noinline noreturn nounwind uwtable "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"vtable pointer", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@_ZTV9UIManager = external dso_local unnamed_addr constant { [17 x ptr] }, align 8

declare i32 @__gxx_personality_v0(...)

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

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

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

; Function Attrs: nounwind
declare void @_ZN9UIElementD2Ev(ptr noundef nonnull align 8 dereferenceable(144)) unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN9UIManagerD2Ev(ptr noundef nonnull align 8 dereferenceable(248) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  store ptr getelementptr inbounds inrange(-16, 120) (i8, ptr @_ZTV9UIManager, i64 16), ptr %0, align 8, !tbaa !5
  %2 = getelementptr inbounds i8, ptr %0, i64 160
  br label %3

3:                                                ; preds = %5, %1
  %4 = tail call noundef zeroext i1 @_ZNK3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %2)
  br i1 %4, label %6, label %5

5:                                                ; preds = %3
  invoke void @_ZN9UIManager8PopLayerEv(ptr noundef nonnull align 8 dereferenceable(248) %0)
          to label %3 unwind label %10, !llvm.loop !8

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 208
  tail call void @_ZNSt14_Function_baseD2Ev(ptr noundef nonnull align 8 dereferenceable(32) %7) #5
  %8 = getelementptr inbounds i8, ptr %0, i64 200
  tail call void @_ZNSt10unique_ptrI13PipelineStateSt14default_deleteIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %8) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 192
  tail call void @_ZNSt10unique_ptrI13PipelineStateSt14default_deleteIS0_EED2Ev(ptr noundef nonnull align 8 dereferenceable(8) %9) #5
  tail call void @_ZN3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEED2Ev(ptr noundef nonnull align 8 dereferenceable(24) %2) #5
  tail call void @_ZN9UIElementD2Ev(ptr noundef nonnull align 8 dereferenceable(144) %0) #5
  ret void

10:                                               ; preds = %5
  %11 = landingpad { ptr, i32 }
          catch ptr null
  %12 = extractvalue { ptr, i32 } %11, 0
  tail call void @__clang_call_terminate(ptr %12) #6
  unreachable
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK3JPH5ArrayINS0_IP9UIElementNS_12STLAllocatorIS2_EEEENS3_IS5_EEE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: noinline noreturn nounwind uwtable
declare hidden void @__clang_call_terminate(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN9UIManager8PopLayerEv(ptr noundef nonnull align 8 dereferenceable(248)) local_unnamed_addr #4 align 2

attributes #0 = { 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 #1 = { 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 #2 = { 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 #3 = { noinline noreturn nounwind uwtable "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,LCSSAPass,LICMPass,SROAPass,SimplifyCFGPass,TailCallElimPass