; LLVM IR from SOHNE/Dura2D :: src/collision/d2AABBTree.ll (ZN10d2AABBTree3AddEP6d2Body)

; 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.d2AABBTree = type { %class.d2Broadphase, ptr, %"class.std::__cxx11::list", float, %"class.std::vector" }
%class.d2Broadphase = type { ptr }
%"class.std::__cxx11::list" = type { %"class.std::__cxx11::_List_base" }
%"class.std::__cxx11::_List_base" = type { %"struct.std::__cxx11::_List_base<std::pair<d2Body *, d2Body *>, std::allocator<std::pair<d2Body *, d2Body *>>>::_List_impl" }
%"struct.std::__cxx11::_List_base<std::pair<d2Body *, d2Body *>, std::allocator<std::pair<d2Body *, d2Body *>>>::_List_impl" = type { %"struct.std::__detail::_List_node_header" }
%"struct.std::__detail::_List_node_header" = type { %"struct.std::__detail::_List_node_base", i64 }
%"struct.std::__detail::_List_node_base" = type { ptr, ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<d2Node *, std::allocator<d2Node *>>::_Vector_impl" }
%"struct.std::_Vector_base<d2Node *, std::allocator<d2Node *>>::_Vector_impl" = type { %"struct.std::_Vector_base<d2Node *, std::allocator<d2Node *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<d2Node *, std::allocator<d2Node *>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10d2AABBTree3AddEP6d2Body(ptr noundef nonnull align 8 dereferenceable(72) %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
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 1
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %28, label %12

12:                                               ; preds = %2
  %13 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 72) #6
  invoke void @_ZN6d2NodeC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %13)
          to label %14 unwind label %24

14:                                               ; preds = %12
  %15 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 1
  store ptr %13, ptr %15, align 8, !tbaa !9
  %16 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132) %18)
  call void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72) %17, ptr noundef %19)
  %20 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 1
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 3
  %23 = load float, ptr %22, align 8, !tbaa !23
  call void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72) %21, float noundef %23)
  br label %43

24:                                               ; preds = %12
  %25 = landingpad { ptr, i32 }
          cleanup
  %26 = extractvalue { ptr, i32 } %25, 0
  store ptr %26, ptr %5, align 8
  %27 = extractvalue { ptr, i32 } %25, 1
  store i32 %27, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 72) #7
  br label %44

28:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %29 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 72) #6
  invoke void @_ZN6d2NodeC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %29)
          to label %30 unwind label %39

30:                                               ; preds = %28
  store ptr %29, ptr %7, align 8, !tbaa !5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = call noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132) %32)
  call void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72) %31, ptr noundef %33)
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 3
  %36 = load float, ptr %35, align 8, !tbaa !23
  call void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72) %34, float noundef %36)
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %class.d2AABBTree, ptr %8, i32 0, i32 1
  call void @_ZN10d2AABBTree10InsertNodeEP6d2NodePS1_(ptr noundef nonnull align 8 dereferenceable(72) %8, ptr noundef %37, ptr noundef %38)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %43

39:                                               ; preds = %28
  %40 = landingpad { ptr, i32 }
          cleanup
  %41 = extractvalue { ptr, i32 } %40, 0
  store ptr %41, ptr %5, align 8
  %42 = extractvalue { ptr, i32 } %40, 1
  store i32 %42, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %29, i64 noundef 72) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %44

43:                                               ; preds = %30, %14
  ret void

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #1

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72), float noundef) #4 align 2

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

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

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

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 = { nobuiltin allocsize(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 = { nobuiltin 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 = { 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 #4 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { builtin allocsize(0) }
attributes #7 = { builtin nounwind }
attributes #8 = { 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, !6, i64 8}
!10 = !{!"_ZTS10d2AABBTree", !11, i64 0, !6, i64 8, !12, i64 16, !18, i64 40, !19, i64 48}
!11 = !{!"_ZTS12d2Broadphase"}
!12 = !{!"_ZTSNSt7__cxx114listISt4pairIP6d2BodyS3_ESaIS4_EEE", !13, i64 0}
!13 = !{!"_ZTSNSt7__cxx1110_List_baseISt4pairIP6d2BodyS3_ESaIS4_EEE", !14, i64 0}
!14 = !{!"_ZTSNSt7__cxx1110_List_baseISt4pairIP6d2BodyS3_ESaIS4_EE10_List_implE", !15, i64 0}
!15 = !{!"_ZTSNSt8__detail17_List_node_headerE", !16, i64 0, !17, i64 16}
!16 = !{!"_ZTSNSt8__detail15_List_node_baseE", !6, i64 0, !6, i64 8}
!17 = !{!"long", !7, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!"_ZTSSt6vectorIP6d2NodeSaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSSt12_Vector_baseIP6d2NodeSaIS1_EE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIP6d2NodeSaIS1_EE12_Vector_implE", !22, i64 0}
!22 = !{!"_ZTSNSt12_Vector_baseIP6d2NodeSaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!23 = !{!10, !18, 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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10d2AABBTree3AddEP6d2Body(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  %5 = tail call noalias noundef nonnull dereferenceable(72) ptr @_Znwm(i64 noundef 72) #5
  br i1 %.not, label %6, label %14

6:                                                ; preds = %2
  invoke void @_ZN6d2NodeC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5)
          to label %7 unwind label %12

7:                                                ; preds = %6
  store ptr %5, ptr %3, align 8, !tbaa !5
  %8 = tail call noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  tail call void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %8)
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load float, ptr %10, align 8, !tbaa !22
  tail call void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72) %9, float noundef %11)
  br label %21

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

14:                                               ; preds = %2
  invoke void @_ZN6d2NodeC2Ev(ptr noundef nonnull align 8 dereferenceable(72) %5)
          to label %15 unwind label %19

15:                                               ; preds = %14
  %16 = tail call noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  tail call void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72) %5, ptr noundef %16)
  %17 = getelementptr inbounds i8, ptr %0, i64 40
  %18 = load float, ptr %17, align 8, !tbaa !22
  tail call void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72) %5, float noundef %18)
  tail call void @_ZN10d2AABBTree10InsertNodeEP6d2NodePS1_(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull %5, ptr noundef nonnull %3)
  br label %21

19:                                               ; preds = %14
  %20 = landingpad { ptr, i32 }
          cleanup
  br label %22

21:                                               ; preds = %15, %7
  ret void

22:                                               ; preds = %19, %12
  %.pn = phi { ptr, i32 } [ %20, %19 ], [ %13, %12 ]
  tail call void @_ZdlPvm(ptr noundef nonnull %5, i64 noundef 72) #6
  resume { ptr, i32 } %.pn
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #1

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

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN6d2Node7SetLeafEP6d2AABB(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body7GetAABBEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6d2Node10UpdateAABBEf(ptr noundef nonnull align 8 dereferenceable(72), float noundef) local_unnamed_addr #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN10d2AABBTree10InsertNodeEP6d2NodePS1_(ptr noundef nonnull align 8 dereferenceable(72), ptr noundef, ptr noundef) local_unnamed_addr #0 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 = { nobuiltin allocsize(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 = { nobuiltin 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 = { 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 #4 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = { builtin allocsize(0) }
attributes #6 = { builtin 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, !8, i64 8}
!6 = !{!"_ZTS10d2AABBTree", !7, i64 0, !8, i64 8, !11, i64 16, !17, i64 40, !18, i64 48}
!7 = !{!"_ZTS12d2Broadphase"}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSNSt7__cxx114listISt4pairIP6d2BodyS3_ESaIS4_EEE", !12, i64 0}
!12 = !{!"_ZTSNSt7__cxx1110_List_baseISt4pairIP6d2BodyS3_ESaIS4_EEE", !13, i64 0}
!13 = !{!"_ZTSNSt7__cxx1110_List_baseISt4pairIP6d2BodyS3_ESaIS4_EE10_List_implE", !14, i64 0}
!14 = !{!"_ZTSNSt8__detail17_List_node_headerE", !15, i64 0, !16, i64 16}
!15 = !{!"_ZTSNSt8__detail15_List_node_baseE", !8, i64 0, !8, i64 8}
!16 = !{!"long", !9, i64 0}
!17 = !{!"float", !9, i64 0}
!18 = !{!"_ZTSSt6vectorIP6d2NodeSaIS1_EE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIP6d2NodeSaIS1_EE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIP6d2NodeSaIS1_EE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIP6d2NodeSaIS1_EE17_Vector_impl_dataE", !8, i64 0, !8, i64 8, !8, i64 16}
!22 = !{!6, !17, i64 40}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass