; LLVM IR from gazebosim/gz-physics :: tpe/lib/src/aabb_tree/AABB.ll (ZNK4aabb4AABB8overlapsERKS0_b)

; 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.aabb::AABB" = type { %"class.std::vector", %"class.std::vector", %"class.std::vector", double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4aabb4AABB8overlapsERKS0_b = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #0

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

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4aabb4AABB8overlapsERKS0_b(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, i1 noundef zeroext %2) #1 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = zext i1 %2 to i8
  store i8 %11, ptr %6, align 1, !tbaa !9
  %12 = load ptr, ptr %4, align 8
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"class.aabb::AABB", ptr %13, i32 0, i32 0
  %15 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %14) #3
  %16 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 0
  %17 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #3
  %18 = icmp eq i64 %15, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %3
  br label %22

20:                                               ; preds = %3
  call void @__assert_fail(ptr noundef @.str.6, ptr noundef @.str.1, i32 noundef 133, ptr noundef @__PRETTY_FUNCTION__._ZNK4aabb4AABB8overlapsERKS0_b) #4
  unreachable

21:                                               ; No predecessors!
  br label %22

22:                                               ; preds = %21, %19
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #3
  store i8 1, ptr %7, align 1, !tbaa !9
  %23 = load i8, ptr %6, align 1, !tbaa !9, !range !11, !noundef !12
  %24 = trunc i8 %23 to i1
  br i1 %24, label %25, label %66

25:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !13
  br label %26

26:                                               ; preds = %61, %25
  %27 = load i32, ptr %8, align 4, !tbaa !13
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 0
  %30 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %29) #3
  %31 = icmp ult i64 %28, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %26
  store i32 2, ptr %9, align 4
  br label %64

33:                                               ; preds = %26
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %"class.aabb::AABB", ptr %34, i32 0, i32 1
  %36 = load i32, ptr %8, align 4, !tbaa !13
  %37 = zext i32 %36 to i64
  %38 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %35, i64 noundef %37) #3
  %39 = load double, ptr %38, align 8, !tbaa !15
  %40 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 0
  %41 = load i32, ptr %8, align 4, !tbaa !13
  %42 = zext i32 %41 to i64
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %42) #3
  %44 = load double, ptr %43, align 8, !tbaa !15
  %45 = fcmp olt double %39, %44
  br i1 %45, label %59, label %46

46:                                               ; preds = %33
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %"class.aabb::AABB", ptr %47, i32 0, i32 0
  %49 = load i32, ptr %8, align 4, !tbaa !13
  %50 = zext i32 %49 to i64
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %48, i64 noundef %50) #3
  %52 = load double, ptr %51, align 8, !tbaa !15
  %53 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 1
  %54 = load i32, ptr %8, align 4, !tbaa !13
  %55 = zext i32 %54 to i64
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %53, i64 noundef %55) #3
  %57 = load double, ptr %56, align 8, !tbaa !15
  %58 = fcmp ogt double %52, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %46, %33
  store i8 0, ptr %7, align 1, !tbaa !9
  store i32 2, ptr %9, align 4
  br label %64

60:                                               ; preds = %46
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %8, align 4, !tbaa !13
  %63 = add i32 %62, 1
  store i32 %63, ptr %8, align 4, !tbaa !13
  br label %26, !llvm.loop !17

64:                                               ; preds = %59, %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %65

65:                                               ; preds = %64
  br label %107

66:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !13
  br label %67

67:                                               ; preds = %102, %66
  %68 = load i32, ptr %10, align 4, !tbaa !13
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 0
  %71 = call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %70) #3
  %72 = icmp ult i64 %69, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %67
  store i32 5, ptr %9, align 4
  br label %105

74:                                               ; preds = %67
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %"class.aabb::AABB", ptr %75, i32 0, i32 1
  %77 = load i32, ptr %10, align 4, !tbaa !13
  %78 = zext i32 %77 to i64
  %79 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %76, i64 noundef %78) #3
  %80 = load double, ptr %79, align 8, !tbaa !15
  %81 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 0
  %82 = load i32, ptr %10, align 4, !tbaa !13
  %83 = zext i32 %82 to i64
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %81, i64 noundef %83) #3
  %85 = load double, ptr %84, align 8, !tbaa !15
  %86 = fcmp ole double %80, %85
  br i1 %86, label %100, label %87

87:                                               ; preds = %74
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %"class.aabb::AABB", ptr %88, i32 0, i32 0
  %90 = load i32, ptr %10, align 4, !tbaa !13
  %91 = zext i32 %90 to i64
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %89, i64 noundef %91) #3
  %93 = load double, ptr %92, align 8, !tbaa !15
  %94 = getelementptr inbounds %"class.aabb::AABB", ptr %12, i32 0, i32 1
  %95 = load i32, ptr %10, align 4, !tbaa !13
  %96 = zext i32 %95 to i64
  %97 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %94, i64 noundef %96) #3
  %98 = load double, ptr %97, align 8, !tbaa !15
  %99 = fcmp oge double %93, %98
  br i1 %99, label %100, label %101

100:                                              ; preds = %87, %74
  store i8 0, ptr %7, align 1, !tbaa !9
  store i32 5, ptr %9, align 4
  br label %105

101:                                              ; preds = %87
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %10, align 4, !tbaa !13
  %104 = add i32 %103, 1
  store i32 %104, ptr %10, align 4, !tbaa !13
  br label %67, !llvm.loop !19

105:                                              ; preds = %100, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %106

106:                                              ; preds = %105
  br label %107

107:                                              ; preds = %106, %65
  %108 = load i8, ptr %7, align 1, !tbaa !9, !range !11, !noundef !12
  %109 = trunc i8 %108 to i1
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #3
  ret i1 %109
}

attributes #0 = { noreturn 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 #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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }
attributes #4 = { 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 = !{!"bool", !7, i64 0}
!11 = !{i8 0, i8 2}
!12 = !{}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

@.str.1 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [44 x i8], align 1
@__PRETTY_FUNCTION__._ZNK4aabb4AABB8overlapsERKS0_b = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZNK4aabb4AABB8overlapsERKS0_b(ptr noundef nonnull align 8 dereferenceable(80) %0, ptr noundef nonnull align 8 dereferenceable(80) %1, i1 noundef zeroext %2) local_unnamed_addr #1 align 2 {
  %4 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #2
  %5 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %6 = icmp eq i64 %4, %5
  br i1 %6, label %8, label %7

7:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.6, ptr noundef nonnull @.str.1, i32 noundef 133, ptr noundef nonnull @__PRETTY_FUNCTION__._ZNK4aabb4AABB8overlapsERKS0_b) #3
  unreachable

8:                                                ; preds = %3
  %9 = getelementptr inbounds i8, ptr %1, i64 24
  %10 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %.not2333.not = icmp eq i64 %10, 0
  br i1 %2, label %.preheader, label %.preheader24

.preheader24:                                     ; preds = %8
  br i1 %.not2333.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader24
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  br label %34

.preheader:                                       ; preds = %8
  br i1 %.not2333.not, label %.loopexit, label %.lr.ph35

.lr.ph35:                                         ; preds = %.preheader
  %12 = getelementptr inbounds i8, ptr %0, i64 24
  br label %17

13:                                               ; preds = %24
  %14 = add i32 %.01934, 1
  %15 = zext i32 %14 to i64
  %16 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %.not23 = icmp ugt i64 %16, %15
  br i1 %.not23, label %17, label %.loopexit, !llvm.loop !5

17:                                               ; preds = %.lr.ph35, %13
  %18 = phi i64 [ 0, %.lr.ph35 ], [ %15, %13 ]
  %.01934 = phi i32 [ 0, %.lr.ph35 ], [ %14, %13 ]
  %19 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %18) #2
  %20 = load double, ptr %19, align 8, !tbaa !7
  %21 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %18) #2
  %22 = load double, ptr %21, align 8, !tbaa !7
  %23 = fcmp olt double %20, %22
  br i1 %23, label %.loopexit, label %24

24:                                               ; preds = %17
  %25 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %18) #2
  %26 = load double, ptr %25, align 8, !tbaa !7
  %27 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %18) #2
  %28 = load double, ptr %27, align 8, !tbaa !7
  %29 = fcmp ogt double %26, %28
  br i1 %29, label %.loopexit, label %13

30:                                               ; preds = %41
  %31 = add i32 %.028, 1
  %32 = zext i32 %31 to i64
  %33 = tail call noundef i64 @_ZNKSt6vectorIdSaIdEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #2
  %.not = icmp ugt i64 %33, %32
  br i1 %.not, label %34, label %.loopexit, !llvm.loop !11

34:                                               ; preds = %.lr.ph, %30
  %35 = phi i64 [ 0, %.lr.ph ], [ %32, %30 ]
  %.028 = phi i32 [ 0, %.lr.ph ], [ %31, %30 ]
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %35) #2
  %37 = load double, ptr %36, align 8, !tbaa !7
  %38 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %35) #2
  %39 = load double, ptr %38, align 8, !tbaa !7
  %40 = fcmp ugt double %37, %39
  br i1 %40, label %41, label %.loopexit

41:                                               ; preds = %34
  %42 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %35) #2
  %43 = load double, ptr %42, align 8, !tbaa !7
  %44 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt6vectorIdSaIdEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %35) #2
  %45 = load double, ptr %44, align 8, !tbaa !7
  %46 = fcmp ult double %43, %45
  br i1 %46, label %30, label %.loopexit

.loopexit:                                        ; preds = %34, %41, %30, %17, %24, %13, %.preheader24, %.preheader
  %.2 = phi i1 [ true, %.preheader ], [ true, %.preheader24 ], [ false, %17 ], [ false, %24 ], [ true, %13 ], [ false, %34 ], [ false, %41 ], [ true, %30 ]
  ret i1 %.2
}

attributes #0 = { noreturn 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 #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 }
attributes #3 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"double", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


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