; LLVM IR from jonpena/Cirobb :: cirobb/Scene.ll (ZN5Scene10BroadPhaseEv)

; 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.ManifoldKey = type { ptr, ptr }
%struct.Manifold = type { i32, [2 x %struct.Contact], %struct.PostPosition, float, float, ptr, ptr, %struct.Vec2 }
%struct.Contact = type { %struct.Vec2, %struct.Vec2, float, float, float, float, float, float, float }
%struct.PostPosition = type { float, float, [2 x %struct.Vec2], [2 x %struct.Vec2] }
%struct.Vec2 = type { float, float }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair.3" = type { %struct.ManifoldKey, %struct.Manifold }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_iterator", i8, [7 x i8] }>
%struct.Scene = type { %struct.Vec2, i32, i32, %"class.std::vector", %"class.std::map" }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<RigidBody *, std::allocator<RigidBody *>>::_Vector_impl" }
%"struct.std::_Vector_base<RigidBody *, std::allocator<RigidBody *>>::_Vector_impl" = type { %"struct.std::_Vector_base<RigidBody *, std::allocator<RigidBody *>>::_Vector_impl_data" }
%"struct.std::_Vector_base<RigidBody *, std::allocator<RigidBody *>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<ManifoldKey, std::pair<const ManifoldKey, Manifold>, std::_Select1st<std::pair<const ManifoldKey, Manifold>>, std::less<ManifoldKey>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<ManifoldKey, std::pair<const ManifoldKey, Manifold>, std::_Select1st<std::pair<const ManifoldKey, Manifold>>, std::less<ManifoldKey>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%struct.RigidBody = type { %struct.Vec2, %struct.Vec2, %struct.Vec2, float, float, float, float, float, float, float, float, float, float, float, float, ptr }
%"struct.std::pair.5" = type { %struct.ManifoldKey, %struct.Manifold }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Scene10BroadPhaseEv(ptr noundef nonnull align 8 dereferenceable(88) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca %struct.ManifoldKey, align 8
  %10 = alloca %struct.Manifold, align 8
  %11 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %12 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %13 = alloca %"struct.std::pair.3", align 8
  %14 = alloca %"struct.std::pair", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %15 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %16 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 3
  %17 = call noundef i64 @_ZNKSt6vectorIP9RigidBodySaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %16) #5
  %18 = trunc i64 %17 to i32
  store i32 %18, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %111, %1
  %20 = load i32, ptr %4, align 4, !tbaa !9
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %114

24:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 3
  %26 = load i32, ptr %4, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP9RigidBodySaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %25, i64 noundef %27) #5
  %29 = load ptr, ptr %28, align 8, !tbaa !5
  store ptr %29, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %30 = load i32, ptr %4, align 4, !tbaa !9
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %7, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %107, %24
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = load i32, ptr %3, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %110

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %38 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 3
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP9RigidBodySaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %40) #5
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  store ptr %42, ptr %8, align 8, !tbaa !5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.RigidBody, ptr %43, i32 0, i32 6
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.RigidBody, ptr %46, i32 0, i32 6
  %48 = load float, ptr %47, align 4, !tbaa !11
  %49 = fadd float %45, %48
  %50 = fcmp oeq float %49, 0.000000e+00
  br i1 %50, label %51, label %52

51:                                               ; preds = %37
  store i32 7, ptr %5, align 4
  br label %104

52:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #5
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  %54 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN11ManifoldKeyC2EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef %53, ptr noundef %54)
  call void @llvm.lifetime.start.p0(i64 168, ptr %10) #5
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_ZN8ManifoldC1EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(168) %10, ptr noundef %55, ptr noundef %56)
  %57 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 0
  %58 = load i32, ptr %57, align 8, !tbaa !15
  %59 = icmp sgt i32 %58, 0
  br i1 %59, label %60, label %100

60:                                               ; preds = %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %61 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 4
  %62 = call ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(48) %61, ptr noundef nonnull align 8 dereferenceable(16) %9)
  %63 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %11, i32 0, i32 0
  store ptr %62, ptr %63, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %64 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 4
  %65 = call ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %64) #5
  %66 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %12, i32 0, i32 0
  store ptr %65, ptr %66, align 8
  %67 = call noundef zeroext i1 @_ZSteqRKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEES7_(ptr noundef nonnull align 8 dereferenceable(8) %11, ptr noundef nonnull align 8 dereferenceable(8) %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br i1 %67, label %68, label %75

68:                                               ; preds = %60
  %69 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 184, ptr %13) #5
  call void @_ZNSt4pairI11ManifoldKey8ManifoldEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(184) %13, ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 8 dereferenceable(168) %10)
  %70 = call { ptr, i8 } @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE6insertIS4_IS0_S1_EEENSt9enable_ifIXsr16is_constructibleIS6_T_EE5valueES4_ISt17_Rb_tree_iteratorIS6_EbEE4typeEOSC_(ptr noundef nonnull align 8 dereferenceable(48) %69, ptr noundef nonnull align 8 dereferenceable(184) %13)
  %71 = getelementptr inbounds { ptr, i8 }, ptr %14, i32 0, i32 0
  %72 = extractvalue { ptr, i8 } %70, 0
  store ptr %72, ptr %71, align 8
  %73 = getelementptr inbounds { ptr, i8 }, ptr %14, i32 0, i32 1
  %74 = extractvalue { ptr, i8 } %70, 1
  store i8 %74, ptr %73, align 8
  call void @llvm.lifetime.end.p0(i64 184, ptr %13) #5
  br label %99

75:                                               ; preds = %60
  %76 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 7
  %77 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %78 = getelementptr inbounds %"struct.std::pair.5", ptr %77, i32 0, i32 1
  %79 = getelementptr inbounds %struct.Manifold, ptr %78, i32 0, i32 7
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %79, ptr align 8 %76, i64 8, i1 false), !tbaa.struct !18
  %80 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 5
  %81 = load ptr, ptr %80, align 8, !tbaa !20
  %82 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %83 = getelementptr inbounds %"struct.std::pair.5", ptr %82, i32 0, i32 1
  %84 = getelementptr inbounds %struct.Manifold, ptr %83, i32 0, i32 5
  store ptr %81, ptr %84, align 8, !tbaa !21
  %85 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 6
  %86 = load ptr, ptr %85, align 8, !tbaa !24
  %87 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %88 = getelementptr inbounds %"struct.std::pair.5", ptr %87, i32 0, i32 1
  %89 = getelementptr inbounds %struct.Manifold, ptr %88, i32 0, i32 6
  store ptr %86, ptr %89, align 8, !tbaa !25
  %90 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 2
  %91 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %92 = getelementptr inbounds %"struct.std::pair.5", ptr %91, i32 0, i32 1
  %93 = getelementptr inbounds %struct.Manifold, ptr %92, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %93, ptr align 4 %90, i64 40, i1 false), !tbaa.struct !26
  %94 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %11) #5
  %95 = getelementptr inbounds %"struct.std::pair.5", ptr %94, i32 0, i32 1
  %96 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 1
  %97 = getelementptr inbounds [2 x %struct.Contact], ptr %96, i64 0, i64 0
  %98 = getelementptr inbounds %struct.Manifold, ptr %10, i32 0, i32 0
  call void @_ZN8Manifold6UpdateEP7ContactRKi(ptr noundef nonnull align 8 dereferenceable(168) %95, ptr noundef %97, ptr noundef nonnull align 4 dereferenceable(4) %98)
  br label %99

99:                                               ; preds = %75, %68
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %103

100:                                              ; preds = %52
  %101 = getelementptr inbounds %struct.Scene, ptr %15, i32 0, i32 4
  %102 = call noundef i64 @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE5eraseERS5_(ptr noundef nonnull align 8 dereferenceable(48) %101, ptr noundef nonnull align 8 dereferenceable(16) %9)
  br label %103

103:                                              ; preds = %100, %99
  call void @llvm.lifetime.end.p0(i64 168, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #5
  store i32 0, ptr %5, align 4
  br label %104

104:                                              ; preds = %103, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %105 = load i32, ptr %5, align 4
  switch i32 %105, label %115 [
    i32 0, label %106
    i32 7, label %107
  ]

106:                                              ; preds = %104
  br label %107

107:                                              ; preds = %106, %104
  %108 = load i32, ptr %7, align 4, !tbaa !9
  %109 = add nsw i32 %108, 1
  store i32 %109, ptr %7, align 4, !tbaa !9
  br label %32, !llvm.loop !28

110:                                              ; preds = %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %4, align 4, !tbaa !9
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %4, align 4, !tbaa !9
  br label %19, !llvm.loop !30

114:                                              ; preds = %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void

115:                                              ; preds = %104
  unreachable
}

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

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

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

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

declare void @_ZN8ManifoldC1EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, ptr noundef) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE6insertIS4_IS0_S1_EEENSt9enable_ifIXsr16is_constructibleIS6_T_EE5valueES4_ISt17_Rb_tree_iteratorIS6_EbEE4typeEOSC_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(184)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairI11ManifoldKey8ManifoldEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(168)) unnamed_addr #2 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @_ZN8Manifold6UpdateEP7ContactRKi(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE5eraseERS5_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !14, i64 36}
!12 = !{!"_ZTS9RigidBody", !13, i64 0, !13, i64 8, !13, i64 16, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !6, i64 72}
!13 = !{!"_ZTS4Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"_ZTS8Manifold", !10, i64 0, !7, i64 4, !17, i64 92, !14, i64 132, !14, i64 136, !6, i64 144, !6, i64 152, !13, i64 160}
!17 = !{!"_ZTS12PostPosition", !14, i64 0, !14, i64 4, !7, i64 8, !7, i64 24}
!18 = !{i64 0, i64 4, !19, i64 4, i64 4, !19}
!19 = !{!14, !14, i64 0}
!20 = !{!16, !6, i64 144}
!21 = !{!22, !6, i64 160}
!22 = !{!"_ZTSSt4pairIK11ManifoldKey8ManifoldE", !23, i64 0, !16, i64 16}
!23 = !{!"_ZTS11ManifoldKey", !6, i64 0, !6, i64 8}
!24 = !{!16, !6, i64 152}
!25 = !{!22, !6, i64 168}
!26 = !{i64 0, i64 4, !19, i64 4, i64 4, !19, i64 8, i64 16, !27, i64 24, i64 16, !27}
!27 = !{!7, !7, i64 0}
!28 = distinct !{!28, !29}
!29 = !{!"llvm.loop.mustprogress"}
!30 = distinct !{!30, !29}


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

%struct.ManifoldKey = type { ptr, ptr }
%struct.Manifold = type { i32, [2 x %struct.Contact], %struct.PostPosition, float, float, ptr, ptr, %struct.Vec2 }
%struct.Contact = type { %struct.Vec2, %struct.Vec2, float, float, float, float, float, float, float }
%struct.PostPosition = type { float, float, [2 x %struct.Vec2], [2 x %struct.Vec2] }
%struct.Vec2 = type { float, float }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.std::pair.3" = type { %struct.ManifoldKey, %struct.Manifold }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5Scene10BroadPhaseEv(ptr noundef nonnull align 8 dereferenceable(88) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %struct.ManifoldKey, align 8
  %3 = alloca %struct.Manifold, align 8
  %4 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %5 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %6 = alloca %"struct.std::pair.3", align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = tail call noundef i64 @_ZNKSt6vectorIP9RigidBodySaIS1_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %7) #5
  %9 = trunc i64 %8 to i32
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph19, label %._crit_edge

.lr.ph19:                                         ; preds = %1
  %11 = getelementptr inbounds i8, ptr %0, i64 40
  %12 = getelementptr inbounds i8, ptr %3, i64 160
  %13 = getelementptr inbounds i8, ptr %3, i64 144
  %14 = getelementptr inbounds i8, ptr %3, i64 152
  %15 = getelementptr inbounds i8, ptr %3, i64 92
  %16 = getelementptr inbounds i8, ptr %3, i64 4
  %17 = and i64 %8, 2147483647
  %wide.trip.count26 = and i64 %8, 2147483647
  br label %18

.loopexit:                                        ; preds = %58, %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond27.not = icmp eq i64 %indvars.iv.next24, %wide.trip.count26
  br i1 %exitcond27.not, label %._crit_edge, label %18, !llvm.loop !5

._crit_edge:                                      ; preds = %.loopexit, %1
  ret void

18:                                               ; preds = %.lr.ph19, %.loopexit
  %indvars.iv23 = phi i64 [ 0, %.lr.ph19 ], [ %indvars.iv.next24, %.loopexit ]
  %indvars.iv = phi i64 [ 1, %.lr.ph19 ], [ %indvars.iv.next, %.loopexit ]
  %19 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP9RigidBodySaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %indvars.iv23) #5
  %20 = load ptr, ptr %19, align 8, !tbaa !7
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %21 = icmp ult i64 %indvars.iv.next24, %17
  br i1 %21, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %18
  %22 = getelementptr inbounds i8, ptr %20, i64 36
  br label %23

23:                                               ; preds = %.lr.ph, %58
  %indvars.iv20 = phi i64 [ %indvars.iv, %.lr.ph ], [ %indvars.iv.next21, %58 ]
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIP9RigidBodySaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %7, i64 noundef %indvars.iv20) #5
  %25 = load ptr, ptr %24, align 8, !tbaa !7
  %26 = load float, ptr %22, align 4, !tbaa !11
  %27 = getelementptr inbounds i8, ptr %25, i64 36
  %28 = load float, ptr %27, align 4, !tbaa !11
  %29 = fadd float %26, %28
  %30 = fcmp oeq float %29, 0.000000e+00
  br i1 %30, label %58, label %31

31:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %2) #5
  call void @_ZN11ManifoldKeyC2EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull %20, ptr noundef nonnull %25)
  call void @llvm.lifetime.start.p0(i64 168, ptr nonnull %3) #5
  call void @_ZN8ManifoldC1EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(168) %3, ptr noundef nonnull %20, ptr noundef nonnull %25)
  %32 = load i32, ptr %3, align 8, !tbaa !15
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %34, label %55

34:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %35 = call ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(48) %11, ptr noundef nonnull align 8 dereferenceable(16) %2)
  store ptr %35, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %36 = call ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) %11) #5
  store ptr %36, ptr %5, align 8
  %37 = call noundef zeroext i1 @_ZSteqRKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEES7_(ptr noundef nonnull align 8 dereferenceable(8) %4, ptr noundef nonnull align 8 dereferenceable(8) %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br i1 %37, label %38, label %40

38:                                               ; preds = %34
  call void @llvm.lifetime.start.p0(i64 184, ptr nonnull %6) #5
  call void @_ZNSt4pairI11ManifoldKey8ManifoldEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(184) %6, ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 8 dereferenceable(168) %3)
  %39 = call { ptr, i8 } @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE6insertIS4_IS0_S1_EEENSt9enable_ifIXsr16is_constructibleIS6_T_EE5valueES4_ISt17_Rb_tree_iteratorIS6_EbEE4typeEOSC_(ptr noundef nonnull align 8 dereferenceable(48) %11, ptr noundef nonnull align 8 dereferenceable(184) %6)
  call void @llvm.lifetime.end.p0(i64 184, ptr nonnull %6) #5
  br label %54

40:                                               ; preds = %34
  %41 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %42 = getelementptr inbounds i8, ptr %41, i64 176
  %43 = load i64, ptr %12, align 8
  store i64 %43, ptr %42, align 8
  %44 = load ptr, ptr %13, align 8, !tbaa !19
  %45 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %46 = getelementptr inbounds i8, ptr %45, i64 160
  store ptr %44, ptr %46, align 8, !tbaa !20
  %47 = load ptr, ptr %14, align 8, !tbaa !23
  %48 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %49 = getelementptr inbounds i8, ptr %48, i64 168
  store ptr %47, ptr %49, align 8, !tbaa !24
  %50 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %51 = getelementptr inbounds i8, ptr %50, i64 108
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(40) %51, ptr noundef nonnull align 4 dereferenceable(40) %15, i64 40, i1 false), !tbaa.struct !25
  %52 = call noundef ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIK11ManifoldKey8ManifoldEEptEv(ptr noundef nonnull align 8 dereferenceable(8) %4) #5
  %53 = getelementptr inbounds i8, ptr %52, i64 16
  call void @_ZN8Manifold6UpdateEP7ContactRKi(ptr noundef nonnull align 8 dereferenceable(168) %53, ptr noundef nonnull %16, ptr noundef nonnull align 4 dereferenceable(4) %3)
  br label %54

54:                                               ; preds = %40, %38
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %57

55:                                               ; preds = %31
  %56 = call noundef i64 @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE5eraseERS5_(ptr noundef nonnull align 8 dereferenceable(48) %11, ptr noundef nonnull align 8 dereferenceable(16) %2)
  br label %57

57:                                               ; preds = %55, %54
  call void @llvm.lifetime.end.p0(i64 168, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %2) #5
  br label %58

58:                                               ; preds = %23, %57
  %indvars.iv.next21 = add nuw nsw i64 %indvars.iv20, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next21, %wide.trip.count26
  br i1 %exitcond.not, label %.loopexit, label %23, !llvm.loop !28
}

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

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

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

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

declare void @_ZN8ManifoldC1EP9RigidBodyS1_(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, ptr noundef) unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE4findERS5_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE6insertIS4_IS0_S1_EEENSt9enable_ifIXsr16is_constructibleIS6_T_EE5valueES4_ISt17_Rb_tree_iteratorIS6_EbEE4typeEOSC_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(184)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt4pairI11ManifoldKey8ManifoldEC2IRS0_RS1_TnNSt9enable_ifIXaaclsr5_PCCPE22_MoveConstructiblePairIT_T0_EEclsr5_PCCPE30_ImplicitlyMoveConvertiblePairIS7_S8_EEEbE4typeELb1EEEOS7_OS8_(ptr noundef nonnull align 8 dereferenceable(184), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(168)) unnamed_addr #2 align 2

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

declare void @_ZN8Manifold6UpdateEP7ContactRKi(ptr noundef nonnull align 8 dereferenceable(168), ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZNSt3mapI11ManifoldKey8ManifoldSt4lessIS0_ESaISt4pairIKS0_S1_EEE5eraseERS5_(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(16)) 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!12, !14, i64 36}
!12 = !{!"_ZTS9RigidBody", !13, i64 0, !13, i64 8, !13, i64 16, !14, i64 24, !14, i64 28, !14, i64 32, !14, i64 36, !14, i64 40, !14, i64 44, !14, i64 48, !14, i64 52, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !8, i64 72}
!13 = !{!"_ZTS4Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !9, i64 0}
!15 = !{!16, !17, i64 0}
!16 = !{!"_ZTS8Manifold", !17, i64 0, !9, i64 4, !18, i64 92, !14, i64 132, !14, i64 136, !8, i64 144, !8, i64 152, !13, i64 160}
!17 = !{!"int", !9, i64 0}
!18 = !{!"_ZTS12PostPosition", !14, i64 0, !14, i64 4, !9, i64 8, !9, i64 24}
!19 = !{!16, !8, i64 144}
!20 = !{!21, !8, i64 160}
!21 = !{!"_ZTSSt4pairIK11ManifoldKey8ManifoldE", !22, i64 0, !16, i64 16}
!22 = !{!"_ZTS11ManifoldKey", !8, i64 0, !8, i64 8}
!23 = !{!16, !8, i64 152}
!24 = !{!21, !8, i64 168}
!25 = !{i64 0, i64 4, !26, i64 4, i64 4, !26, i64 8, i64 16, !27, i64 24, i64 16, !27}
!26 = !{!14, !14, i64 0}
!27 = !{!9, !9, i64 0}
!28 = distinct !{!28, !6}


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