; LLVM IR from mtsamis/box2d-optimized :: src/collision/b2_broad_phase.ll (ZN12b2BroadPhase5BuildEv)

; 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.b2BroadPhase = type <{ ptr, ptr, ptr, ptr, %struct.b2TreeNode, ptr, ptr, ptr, i32, i32, %class.b2IntHashTable, i32, i32, i8, [7 x i8] }>
%struct.b2TreeNode = type { ptr, ptr, ptr, ptr, %struct.b2AABB }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Vec2 = type { float, float }
%class.b2IntHashTable = type <{ ptr, i32, [4 x i8] }>

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6b2Body7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(208)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) #2 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12b2BroadPhase5BuildEv(ptr noundef nonnull align 8 dereferenceable(137) %0) #3 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  %7 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 13
  store i8 0, ptr %7, align 8, !tbaa !9
  %8 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 12
  %9 = load i32, ptr %8, align 4, !tbaa !18
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %15

11:                                               ; preds = %1
  %12 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  store ptr null, ptr %12, align 8, !tbaa !19
  %13 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  store ptr null, ptr %13, align 8, !tbaa !20
  %14 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  store ptr null, ptr %14, align 8, !tbaa !21
  br label %154

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

16:                                               ; preds = %59, %15
  %17 = load i32, ptr %4, align 4, !tbaa !22
  %18 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 12
  %19 = load i32, ptr %18, align 4, !tbaa !18
  %20 = icmp slt i32 %17, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %62

22:                                               ; preds = %16
  %23 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !23
  %25 = load i32, ptr %4, align 4, !tbaa !22
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds %struct.b2TreeNode, ptr %24, i64 %26
  %28 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !24
  %30 = load i32, ptr %4, align 4, !tbaa !22
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds ptr, ptr %29, i64 %31
  store ptr %27, ptr %32, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %33 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 1
  %34 = load ptr, ptr %33, align 8, !tbaa !24
  %35 = load i32, ptr %4, align 4, !tbaa !22
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.b2TreeNode, ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !25
  store ptr %40, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = call noundef ptr @_ZN9b2Fixture7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(84) %41)
  %43 = call noundef i32 @_ZNK6b2Body7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(208) %42)
  %44 = icmp eq i32 %43, 0
  br i1 %44, label %45, label %58

45:                                               ; preds = %22
  %46 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 1
  %47 = load ptr, ptr %46, align 8, !tbaa !24
  %48 = load i32, ptr %4, align 4, !tbaa !22
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  %51 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 1
  %52 = load ptr, ptr %51, align 8, !tbaa !24
  %53 = load i32, ptr %3, align 4, !tbaa !22
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  call void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8) %50, ptr noundef nonnull align 8 dereferenceable(8) %55)
  %56 = load i32, ptr %3, align 4, !tbaa !22
  %57 = add nsw i32 %56, 1
  store i32 %57, ptr %3, align 4, !tbaa !22
  br label %58

58:                                               ; preds = %45, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %4, align 4, !tbaa !22
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !22
  br label %16, !llvm.loop !26

62:                                               ; preds = %21
  %63 = load i32, ptr %3, align 4, !tbaa !22
  %64 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 12
  %65 = load i32, ptr %64, align 4, !tbaa !18
  %66 = sdiv i32 %65, 8
  %67 = icmp sle i32 %63, %66
  br i1 %67, label %68, label %70

68:                                               ; preds = %62
  store i32 0, ptr %3, align 4, !tbaa !22
  %69 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  store ptr null, ptr %69, align 8, !tbaa !20
  br label %86

70:                                               ; preds = %62
  %71 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %72 = load ptr, ptr %71, align 8, !tbaa !20
  %73 = icmp eq ptr %72, null
  br i1 %73, label %74, label %85

74:                                               ; preds = %70
  %75 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 0
  %76 = load ptr, ptr %75, align 8, !tbaa !23
  %77 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 11
  %78 = load i32, ptr %77, align 8, !tbaa !28
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds %struct.b2TreeNode, ptr %76, i64 %79
  %81 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 2
  store ptr %80, ptr %81, align 8, !tbaa !29
  %82 = load i32, ptr %3, align 4, !tbaa !22
  %83 = call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %6, i32 noundef 0, i32 noundef %82)
  %84 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  store ptr %83, ptr %84, align 8, !tbaa !20
  br label %85

85:                                               ; preds = %74, %70
  br label %86

86:                                               ; preds = %85, %68
  %87 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 0
  %88 = load ptr, ptr %87, align 8, !tbaa !23
  %89 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 11
  %90 = load i32, ptr %89, align 8, !tbaa !28
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.b2TreeNode, ptr %88, i64 %91
  %93 = load i32, ptr %3, align 4, !tbaa !22
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %struct.b2TreeNode, ptr %92, i64 %94
  %96 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 2
  store ptr %95, ptr %96, align 8, !tbaa !29
  %97 = load i32, ptr %3, align 4, !tbaa !22
  %98 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 12
  %99 = load i32, ptr %98, align 4, !tbaa !18
  %100 = call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %6, i32 noundef %97, i32 noundef %99)
  %101 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  store ptr %100, ptr %101, align 8, !tbaa !19
  %102 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  %103 = load ptr, ptr %102, align 8, !tbaa !19
  %104 = icmp eq ptr %103, null
  br i1 %104, label %105, label %109

105:                                              ; preds = %86
  %106 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %107 = load ptr, ptr %106, align 8, !tbaa !20
  %108 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  store ptr %107, ptr %108, align 8, !tbaa !21
  br label %150

109:                                              ; preds = %86
  %110 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %111 = load ptr, ptr %110, align 8, !tbaa !20
  %112 = icmp eq ptr %111, null
  br i1 %112, label %113, label %117

113:                                              ; preds = %109
  %114 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  %115 = load ptr, ptr %114, align 8, !tbaa !19
  %116 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  store ptr %115, ptr %116, align 8, !tbaa !21
  br label %149

117:                                              ; preds = %109
  %118 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 4
  %119 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  store ptr %118, ptr %119, align 8, !tbaa !21
  %120 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %121 = load ptr, ptr %120, align 8, !tbaa !21
  %122 = getelementptr inbounds %struct.b2TreeNode, ptr %121, i32 0, i32 4
  %123 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %124 = load ptr, ptr %123, align 8, !tbaa !20
  %125 = getelementptr inbounds %struct.b2TreeNode, ptr %124, i32 0, i32 4
  %126 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  %127 = load ptr, ptr %126, align 8, !tbaa !19
  %128 = getelementptr inbounds %struct.b2TreeNode, ptr %127, i32 0, i32 4
  call void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16) %122, ptr noundef nonnull align 4 dereferenceable(16) %125, ptr noundef nonnull align 4 dereferenceable(16) %128)
  %129 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %130 = load ptr, ptr %129, align 8, !tbaa !20
  %131 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %132 = load ptr, ptr %131, align 8, !tbaa !21
  %133 = getelementptr inbounds %struct.b2TreeNode, ptr %132, i32 0, i32 0
  store ptr %130, ptr %133, align 8, !tbaa !30
  %134 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  %135 = load ptr, ptr %134, align 8, !tbaa !19
  %136 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %137 = load ptr, ptr %136, align 8, !tbaa !21
  %138 = getelementptr inbounds %struct.b2TreeNode, ptr %137, i32 0, i32 1
  store ptr %135, ptr %138, align 8, !tbaa !31
  %139 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %140 = load ptr, ptr %139, align 8, !tbaa !21
  %141 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 6
  %142 = load ptr, ptr %141, align 8, !tbaa !20
  %143 = getelementptr inbounds %struct.b2TreeNode, ptr %142, i32 0, i32 2
  store ptr %140, ptr %143, align 8, !tbaa !32
  %144 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %145 = load ptr, ptr %144, align 8, !tbaa !21
  %146 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 5
  %147 = load ptr, ptr %146, align 8, !tbaa !19
  %148 = getelementptr inbounds %struct.b2TreeNode, ptr %147, i32 0, i32 2
  store ptr %145, ptr %148, align 8, !tbaa !32
  br label %149

149:                                              ; preds = %117, %113
  br label %150

150:                                              ; preds = %149, %105
  %151 = getelementptr inbounds %class.b2BroadPhase, ptr %6, i32 0, i32 3
  %152 = load ptr, ptr %151, align 8, !tbaa !21
  %153 = getelementptr inbounds %struct.b2TreeNode, ptr %152, i32 0, i32 2
  store ptr null, ptr %153, align 8, !tbaa !32
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %154

154:                                              ; preds = %150, %11
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137), i32 noundef, i32 noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { 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 #4 = { 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, !17, i64 136}
!10 = !{!"_ZTS12b2BroadPhase", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !11, i64 32, !6, i64 80, !6, i64 88, !6, i64 96, !15, i64 104, !15, i64 108, !16, i64 112, !15, i64 128, !15, i64 132, !17, i64 136}
!11 = !{!"_ZTS10b2TreeNode", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!12 = !{!"_ZTS6b2AABB", !13, i64 0, !13, i64 8}
!13 = !{!"_ZTS6b2Vec2", !14, i64 0, !14, i64 4}
!14 = !{!"float", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS14b2IntHashTable", !6, i64 0, !15, i64 8}
!17 = !{!"bool", !7, i64 0}
!18 = !{!10, !15, i64 132}
!19 = !{!10, !6, i64 80}
!20 = !{!10, !6, i64 88}
!21 = !{!10, !6, i64 24}
!22 = !{!15, !15, i64 0}
!23 = !{!10, !6, i64 0}
!24 = !{!10, !6, i64 8}
!25 = !{!11, !6, i64 24}
!26 = distinct !{!26, !27}
!27 = !{!"llvm.loop.mustprogress"}
!28 = !{!10, !15, i64 128}
!29 = !{!10, !6, i64 16}
!30 = !{!11, !6, i64 0}
!31 = !{!11, !6, i64 8}
!32 = !{!11, !6, i64 16}


; 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.b2TreeNode = type { ptr, ptr, ptr, ptr, %struct.b2AABB }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Vec2 = type { float, float }

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZNK6b2Body7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(208)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12b2BroadPhase5BuildEv(ptr noundef nonnull align 8 dereferenceable(137) %0) local_unnamed_addr #2 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 136
  store i8 0, ptr %2, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 132
  %4 = load i32, ptr %3, align 4, !tbaa !17
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %8, label %.preheader

.preheader:                                       ; preds = %1
  %6 = icmp sgt i32 %4, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  br label %13

8:                                                ; preds = %1
  %9 = getelementptr inbounds i8, ptr %0, i64 80
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr null, ptr %10, align 8, !tbaa !18
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %9, i8 0, i64 16, i1 false)
  br label %84

._crit_edge:                                      ; preds = %32, %.preheader
  %.0.lcssa = phi i32 [ 0, %.preheader ], [ %.1, %32 ]
  %.lcssa = phi i32 [ %4, %.preheader ], [ %33, %32 ]
  %11 = sdiv i32 %.lcssa, 8
  %.not = icmp sgt i32 %.0.lcssa, %11
  %12 = getelementptr inbounds i8, ptr %0, i64 88
  br i1 %.not, label %37, label %36

13:                                               ; preds = %.lr.ph, %32
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %32 ]
  %.017 = phi i32 [ 0, %.lr.ph ], [ %.1, %32 ]
  %14 = load ptr, ptr %0, align 8, !tbaa !19
  %15 = getelementptr inbounds %struct.b2TreeNode, ptr %14, i64 %indvars.iv
  %16 = load ptr, ptr %7, align 8, !tbaa !20
  %17 = getelementptr inbounds ptr, ptr %16, i64 %indvars.iv
  store ptr %15, ptr %17, align 8, !tbaa !21
  %18 = load ptr, ptr %7, align 8, !tbaa !20
  %19 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = getelementptr inbounds i8, ptr %20, i64 24
  %22 = load ptr, ptr %21, align 8, !tbaa !22
  %23 = tail call noundef ptr @_ZN9b2Fixture7GetBodyEv(ptr noundef nonnull align 8 dereferenceable(84) %22)
  %24 = tail call noundef i32 @_ZNK6b2Body7GetTypeEv(ptr noundef nonnull align 8 dereferenceable(208) %23)
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %32

26:                                               ; preds = %13
  %27 = load ptr, ptr %7, align 8, !tbaa !20
  %28 = getelementptr inbounds ptr, ptr %27, i64 %indvars.iv
  %29 = sext i32 %.017 to i64
  %30 = getelementptr inbounds ptr, ptr %27, i64 %29
  tail call void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull align 8 dereferenceable(8) %30)
  %31 = add nsw i32 %.017, 1
  br label %32

32:                                               ; preds = %26, %13
  %.1 = phi i32 [ %31, %26 ], [ %.017, %13 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = load i32, ptr %3, align 4, !tbaa !17
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next, %34
  br i1 %35, label %13, label %._crit_edge, !llvm.loop !23

36:                                               ; preds = %._crit_edge
  store ptr null, ptr %12, align 8, !tbaa !25
  br label %48

37:                                               ; preds = %._crit_edge
  %38 = load ptr, ptr %12, align 8, !tbaa !25
  %39 = icmp eq ptr %38, null
  br i1 %39, label %40, label %48

40:                                               ; preds = %37
  %41 = load ptr, ptr %0, align 8, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %0, i64 128
  %43 = load i32, ptr %42, align 8, !tbaa !26
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.b2TreeNode, ptr %41, i64 %44
  %46 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %45, ptr %46, align 8, !tbaa !27
  %47 = tail call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef 0, i32 noundef %.0.lcssa)
  store ptr %47, ptr %12, align 8, !tbaa !25
  %.pre = load i32, ptr %3, align 4, !tbaa !17
  br label %48

48:                                               ; preds = %37, %40, %36
  %49 = phi i32 [ %.lcssa, %36 ], [ %.pre, %40 ], [ %.lcssa, %37 ]
  %.2 = phi i32 [ 0, %36 ], [ %.0.lcssa, %40 ], [ %.0.lcssa, %37 ]
  %50 = load ptr, ptr %0, align 8, !tbaa !19
  %51 = getelementptr inbounds i8, ptr %0, i64 128
  %52 = load i32, ptr %51, align 8, !tbaa !26
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %struct.b2TreeNode, ptr %50, i64 %53
  %55 = sext i32 %.2 to i64
  %56 = getelementptr inbounds %struct.b2TreeNode, ptr %54, i64 %55
  %57 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %56, ptr %57, align 8, !tbaa !27
  %58 = tail call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %.2, i32 noundef %49)
  %59 = getelementptr inbounds i8, ptr %0, i64 80
  store ptr %58, ptr %59, align 8, !tbaa !28
  %60 = icmp eq ptr %58, null
  %61 = getelementptr inbounds i8, ptr %0, i64 88
  %62 = load ptr, ptr %61, align 8, !tbaa !25
  br i1 %60, label %63, label %65

63:                                               ; preds = %48
  %64 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %62, ptr %64, align 8, !tbaa !18
  br label %81

65:                                               ; preds = %48
  %66 = icmp eq ptr %62, null
  br i1 %66, label %67, label %69

67:                                               ; preds = %65
  %68 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %58, ptr %68, align 8, !tbaa !18
  br label %81

69:                                               ; preds = %65
  %70 = getelementptr inbounds i8, ptr %0, i64 32
  %71 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %70, ptr %71, align 8, !tbaa !18
  %72 = getelementptr inbounds i8, ptr %0, i64 64
  %73 = getelementptr inbounds i8, ptr %62, i64 32
  %74 = getelementptr inbounds i8, ptr %58, i64 32
  tail call void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16) %72, ptr noundef nonnull align 4 dereferenceable(16) %73, ptr noundef nonnull align 4 dereferenceable(16) %74)
  %75 = load ptr, ptr %61, align 8, !tbaa !25
  %76 = load ptr, ptr %71, align 8, !tbaa !18
  store ptr %75, ptr %76, align 8, !tbaa !29
  %77 = load ptr, ptr %59, align 8, !tbaa !28
  %78 = getelementptr inbounds i8, ptr %76, i64 8
  store ptr %77, ptr %78, align 8, !tbaa !30
  %79 = getelementptr inbounds i8, ptr %75, i64 16
  store ptr %76, ptr %79, align 8, !tbaa !31
  %80 = getelementptr inbounds i8, ptr %77, i64 16
  store ptr %76, ptr %80, align 8, !tbaa !31
  br label %81

81:                                               ; preds = %67, %69, %63
  %82 = phi ptr [ %58, %67 ], [ %76, %69 ], [ %62, %63 ]
  %83 = getelementptr inbounds i8, ptr %82, i64 16
  store ptr null, ptr %83, align 8, !tbaa !31
  br label %84

84:                                               ; preds = %81, %8
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137), i32 noundef, i32 noundef) local_unnamed_addr #1 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

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"="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 #2 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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, !16, i64 136}
!6 = !{!"_ZTS12b2BroadPhase", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !10, i64 32, !7, i64 80, !7, i64 88, !7, i64 96, !14, i64 104, !14, i64 108, !15, i64 112, !14, i64 128, !14, i64 132, !16, i64 136}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS10b2TreeNode", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !11, i64 32}
!11 = !{!"_ZTS6b2AABB", !12, i64 0, !12, i64 8}
!12 = !{!"_ZTS6b2Vec2", !13, i64 0, !13, i64 4}
!13 = !{!"float", !8, i64 0}
!14 = !{!"int", !8, i64 0}
!15 = !{!"_ZTS14b2IntHashTable", !7, i64 0, !14, i64 8}
!16 = !{!"bool", !8, i64 0}
!17 = !{!6, !14, i64 132}
!18 = !{!6, !7, i64 24}
!19 = !{!6, !7, i64 0}
!20 = !{!6, !7, i64 8}
!21 = !{!7, !7, i64 0}
!22 = !{!10, !7, i64 24}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}
!25 = !{!6, !7, i64 88}
!26 = !{!6, !14, i64 128}
!27 = !{!6, !7, i64 16}
!28 = !{!6, !7, i64 80}
!29 = !{!10, !7, i64 0}
!30 = !{!10, !7, i64 8}
!31 = !{!10, !7, i64 16}


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