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

; 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"

%struct.d2Node = type { ptr, [2 x ptr], i8, %struct.d2AABB, ptr }
%struct.d2AABB = type { %struct.d2Vec2, %struct.d2Vec2, ptr, ptr }
%struct.d2Vec2 = type { float, float }

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6d2Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(72)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10d2AABBTree16UpdateNodeHelperEP6d2NodeRSt6vectorIS1_SaIS1_EE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8
  %8 = load ptr, ptr %5, align 8, !tbaa !5
  %9 = call noundef zeroext i1 @_ZNK6d2Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(72) %8)
  br i1 %9, label %10, label %20

10:                                               ; preds = %3
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.d2Node, ptr %11, i32 0, i32 3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.d2Node, ptr %13, i32 0, i32 4
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = call noundef zeroext i1 @_ZNK6d2AABB8ContainsERKS_(ptr noundef nonnull align 8 dereferenceable(32) %12, ptr noundef nonnull align 8 dereferenceable(32) %15)
  br i1 %16, label %19, label %17

17:                                               ; preds = %10
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZNSt6vectorIP6d2NodeSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %18, ptr noundef nonnull align 8 dereferenceable(8) %5)
  br label %19

19:                                               ; preds = %17, %10
  br label %31

20:                                               ; preds = %3
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.d2Node, ptr %21, i32 0, i32 1
  %23 = getelementptr inbounds [2 x ptr], ptr %22, i64 0, i64 0
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN10d2AABBTree16UpdateNodeHelperEP6d2NodeRSt6vectorIS1_SaIS1_EE(ptr noundef nonnull align 8 dereferenceable(72) %7, ptr noundef %24, ptr noundef nonnull align 8 dereferenceable(24) %25)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.d2Node, ptr %26, i32 0, i32 1
  %28 = getelementptr inbounds [2 x ptr], ptr %27, i64 0, i64 1
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZN10d2AABBTree16UpdateNodeHelperEP6d2NodeRSt6vectorIS1_SaIS1_EE(ptr noundef nonnull align 8 dereferenceable(72) %7, ptr noundef %29, ptr noundef nonnull align 8 dereferenceable(24) %30)
  br label %31

31:                                               ; preds = %20, %19
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6d2AABB8ContainsERKS_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #2 align 2

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

attributes #0 = { 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 #1 = { 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 #2 = { 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" }

!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 64}
!10 = !{!"_ZTS6d2Node", !6, i64 0, !7, i64 8, !11, i64 24, !12, i64 32, !6, i64 64}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTS6d2AABB", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"_ZTS6d2Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6d2Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(72)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN10d2AABBTree16UpdateNodeHelperEP6d2NodeRSt6vectorIS1_SaIS1_EE(ptr nocapture noundef nonnull readnone align 8 dereferenceable(72) %0, ptr noundef nonnull %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = tail call noundef zeroext i1 @_ZNK6d2Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(72) %1)
  br i1 %5, label %tailrecurse._crit_edge, label %tailrecurse

tailrecurse._crit_edge:                           ; preds = %tailrecurse, %3
  %.tr4.lcssa = phi ptr [ %1, %3 ], [ %14, %tailrecurse ]
  store ptr %.tr4.lcssa, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %.tr4.lcssa, i64 32
  %7 = getelementptr inbounds i8, ptr %.tr4.lcssa, i64 64
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %9 = tail call noundef zeroext i1 @_ZNK6d2AABB8ContainsERKS_(ptr noundef nonnull align 8 dereferenceable(32) %6, ptr noundef nonnull align 8 dereferenceable(32) %8)
  br i1 %9, label %16, label %10

10:                                               ; preds = %tailrecurse._crit_edge
  call void @_ZNSt6vectorIP6d2NodeSaIS1_EE9push_backERKS1_(ptr noundef nonnull align 8 dereferenceable(24) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  br label %16

tailrecurse:                                      ; preds = %3, %tailrecurse
  %.tr46 = phi ptr [ %14, %tailrecurse ], [ %1, %3 ]
  %11 = getelementptr inbounds i8, ptr %.tr46, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  tail call void @_ZN10d2AABBTree16UpdateNodeHelperEP6d2NodeRSt6vectorIS1_SaIS1_EE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef %12, ptr noundef nonnull align 8 dereferenceable(24) %2)
  %13 = getelementptr inbounds i8, ptr %.tr46, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = tail call noundef zeroext i1 @_ZNK6d2Node6IsLeafEv(ptr noundef nonnull align 8 dereferenceable(72) %14)
  br i1 %15, label %tailrecurse._crit_edge, label %tailrecurse

16:                                               ; preds = %tailrecurse._crit_edge, %10
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNK6d2AABB8ContainsERKS_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 2

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

attributes #0 = { 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 #1 = { 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 #2 = { 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" }

!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 64}
!10 = !{!"_ZTS6d2Node", !6, i64 0, !7, i64 8, !11, i64 24, !12, i64 32, !6, i64 64}
!11 = !{!"bool", !7, i64 0}
!12 = !{!"_ZTS6d2AABB", !13, i64 0, !13, i64 8, !6, i64 16, !6, i64 24}
!13 = !{!"_ZTS6d2Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass