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

; 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.b2Vec2 = type { float, float }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%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 }
%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: 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) #1

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %1, i32 noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca %struct.b2Vec2, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca %struct.b2Vec2, align 4
  %18 = alloca i8, align 1
  %19 = alloca float, align 4
  %20 = alloca i32, align 4
  %21 = alloca %struct.b2AABB, align 4
  %22 = alloca float, align 4
  %23 = alloca i32, align 4
  %24 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %25 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %6, align 4, !tbaa !9
  %28 = sub nsw i32 %26, %27
  store i32 %28, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %255

32:                                               ; preds = %3
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %35, label %42

35:                                               ; preds = %32
  %36 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !11
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds ptr, ptr %37, i64 %39
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  store ptr %41, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %255

42:                                               ; preds = %32
  %43 = load i32, ptr %8, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 2
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %9, align 4, !tbaa !9
  br label %218

48:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %49 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %50, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.b2TreeNode, ptr %54, i32 0, i32 4
  %56 = call <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137) %25, ptr noundef nonnull align 4 dereferenceable(16) %55)
  store <2 x float> %56, ptr %11, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %57 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 0
  %58 = load float, ptr %57, align 4, !tbaa !19
  store float %58, ptr %12, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %59 = load float, ptr %12, align 4, !tbaa !20
  store float %59, ptr %13, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %60 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 1
  %61 = load float, ptr %60, align 4, !tbaa !21
  store float %61, ptr %14, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %62 = load float, ptr %14, align 4, !tbaa !20
  store float %62, ptr %15, align 4, !tbaa !20
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %63 = load i32, ptr %6, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %16, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %95, %48
  %66 = load i32, ptr %16, align 4, !tbaa !9
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = icmp slt i32 %66, %67
  br i1 %68, label %70, label %69

69:                                               ; preds = %65
  store i32 2, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  br label %98

70:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %71 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %72 = load ptr, ptr %71, align 8, !tbaa !11
  %73 = load i32, ptr %16, align 4, !tbaa !9
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds ptr, ptr %72, i64 %74
  %76 = load ptr, ptr %75, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.b2TreeNode, ptr %76, i32 0, i32 4
  %78 = call <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137) %25, ptr noundef nonnull align 4 dereferenceable(16) %77)
  store <2 x float> %78, ptr %17, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %17, i64 8, i1 false), !tbaa.struct !22
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  %79 = load float, ptr %12, align 4, !tbaa !20
  %80 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 0
  %81 = load float, ptr %80, align 4, !tbaa !19
  %82 = call noundef float @_Z5b2MinIfET_S0_S0_(float noundef %79, float noundef %81)
  store float %82, ptr %12, align 4, !tbaa !20
  %83 = load float, ptr %14, align 4, !tbaa !20
  %84 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 1
  %85 = load float, ptr %84, align 4, !tbaa !21
  %86 = call noundef float @_Z5b2MinIfET_S0_S0_(float noundef %83, float noundef %85)
  store float %86, ptr %14, align 4, !tbaa !20
  %87 = load float, ptr %13, align 4, !tbaa !20
  %88 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 0
  %89 = load float, ptr %88, align 4, !tbaa !19
  %90 = call noundef float @_Z5b2MaxIfET_S0_S0_(float noundef %87, float noundef %89)
  store float %90, ptr %13, align 4, !tbaa !20
  %91 = load float, ptr %15, align 4, !tbaa !20
  %92 = getelementptr inbounds %struct.b2Vec2, ptr %11, i32 0, i32 1
  %93 = load float, ptr %92, align 4, !tbaa !21
  %94 = call noundef float @_Z5b2MaxIfET_S0_S0_(float noundef %91, float noundef %93)
  store float %94, ptr %15, align 4, !tbaa !20
  br label %95

95:                                               ; preds = %70
  %96 = load i32, ptr %16, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %16, align 4, !tbaa !9
  br label %65, !llvm.loop !23

98:                                               ; preds = %69
  %99 = load float, ptr %13, align 4, !tbaa !20
  %100 = load float, ptr %12, align 4, !tbaa !20
  %101 = fsub float %99, %100
  %102 = call noundef float @_Z5b2AbsIfET_S0_(float noundef %101)
  %103 = fcmp olt float %102, 0x3E80000000000000
  br i1 %103, label %104, label %115

104:                                              ; preds = %98
  %105 = load float, ptr %15, align 4, !tbaa !20
  %106 = load float, ptr %14, align 4, !tbaa !20
  %107 = fsub float %105, %106
  %108 = call noundef float @_Z5b2AbsIfET_S0_(float noundef %107)
  %109 = fcmp olt float %108, 0x3E80000000000000
  br i1 %109, label %110, label %115

110:                                              ; preds = %104
  %111 = load i32, ptr %6, align 4, !tbaa !9
  %112 = load i32, ptr %7, align 4, !tbaa !9
  %113 = add nsw i32 %111, %112
  %114 = sdiv i32 %113, 2
  store i32 %114, ptr %9, align 4, !tbaa !9
  br label %217

115:                                              ; preds = %104, %98
  call void @llvm.lifetime.start.p0(i64 1, ptr %18) #5
  %116 = load float, ptr %13, align 4, !tbaa !20
  %117 = load float, ptr %12, align 4, !tbaa !20
  %118 = fsub float %116, %117
  %119 = load float, ptr %15, align 4, !tbaa !20
  %120 = load float, ptr %14, align 4, !tbaa !20
  %121 = fsub float %119, %120
  %122 = fcmp ogt float %118, %121
  %123 = zext i1 %122 to i8
  store i8 %123, ptr %18, align 1, !tbaa !25
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %124 = load i8, ptr %18, align 1, !tbaa !25, !range !26, !noundef !27
  %125 = trunc i8 %124 to i1
  br i1 %125, label %126, label %131

126:                                              ; preds = %115
  %127 = load float, ptr %12, align 4, !tbaa !20
  %128 = load float, ptr %13, align 4, !tbaa !20
  %129 = fadd float %127, %128
  %130 = fdiv float %129, 2.000000e+00
  br label %136

131:                                              ; preds = %115
  %132 = load float, ptr %14, align 4, !tbaa !20
  %133 = load float, ptr %15, align 4, !tbaa !20
  %134 = fadd float %132, %133
  %135 = fdiv float %134, 2.000000e+00
  br label %136

136:                                              ; preds = %131, %126
  %137 = phi float [ %130, %126 ], [ %135, %131 ]
  store float %137, ptr %19, align 4, !tbaa !20
  %138 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %138, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  %139 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %139, ptr %20, align 4, !tbaa !9
  br label %140

140:                                              ; preds = %189, %136
  %141 = load i32, ptr %20, align 4, !tbaa !9
  %142 = load i32, ptr %7, align 4, !tbaa !9
  %143 = icmp slt i32 %141, %142
  br i1 %143, label %145, label %144

144:                                              ; preds = %140
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  br label %192

145:                                              ; preds = %140
  call void @llvm.lifetime.start.p0(i64 16, ptr %21) #5
  %146 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %147 = load ptr, ptr %146, align 8, !tbaa !11
  %148 = load i32, ptr %20, align 4, !tbaa !9
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds ptr, ptr %147, i64 %149
  %151 = load ptr, ptr %150, align 8, !tbaa !5
  %152 = getelementptr inbounds %struct.b2TreeNode, ptr %151, i32 0, i32 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 8 %152, i64 16, i1 false), !tbaa.struct !28
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #5
  %153 = load i8, ptr %18, align 1, !tbaa !25, !range !26, !noundef !27
  %154 = trunc i8 %153 to i1
  br i1 %154, label %155, label %163

155:                                              ; preds = %145
  %156 = getelementptr inbounds %struct.b2AABB, ptr %21, i32 0, i32 0
  %157 = getelementptr inbounds %struct.b2Vec2, ptr %156, i32 0, i32 0
  %158 = load float, ptr %157, align 4, !tbaa !29
  %159 = getelementptr inbounds %struct.b2AABB, ptr %21, i32 0, i32 1
  %160 = getelementptr inbounds %struct.b2Vec2, ptr %159, i32 0, i32 0
  %161 = load float, ptr %160, align 4, !tbaa !30
  %162 = fadd float %158, %161
  br label %171

163:                                              ; preds = %145
  %164 = getelementptr inbounds %struct.b2AABB, ptr %21, i32 0, i32 0
  %165 = getelementptr inbounds %struct.b2Vec2, ptr %164, i32 0, i32 1
  %166 = load float, ptr %165, align 4, !tbaa !31
  %167 = getelementptr inbounds %struct.b2AABB, ptr %21, i32 0, i32 1
  %168 = getelementptr inbounds %struct.b2Vec2, ptr %167, i32 0, i32 1
  %169 = load float, ptr %168, align 4, !tbaa !32
  %170 = fadd float %166, %169
  br label %171

171:                                              ; preds = %163, %155
  %172 = phi float [ %162, %155 ], [ %170, %163 ]
  store float %172, ptr %22, align 4, !tbaa !20
  %173 = load float, ptr %22, align 4, !tbaa !20
  %174 = load float, ptr %19, align 4, !tbaa !20
  %175 = fcmp olt float %173, %174
  br i1 %175, label %176, label %188

176:                                              ; preds = %171
  %177 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %178 = load ptr, ptr %177, align 8, !tbaa !11
  %179 = load i32, ptr %20, align 4, !tbaa !9
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds ptr, ptr %178, i64 %180
  %182 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 1
  %183 = load ptr, ptr %182, align 8, !tbaa !11
  %184 = load i32, ptr %9, align 4, !tbaa !9
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %9, align 4, !tbaa !9
  %186 = sext i32 %184 to i64
  %187 = getelementptr inbounds ptr, ptr %183, i64 %186
  call void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8) %181, ptr noundef nonnull align 8 dereferenceable(8) %187)
  br label %188

188:                                              ; preds = %176, %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %21) #5
  br label %189

189:                                              ; preds = %188
  %190 = load i32, ptr %20, align 4, !tbaa !9
  %191 = add nsw i32 %190, 1
  store i32 %191, ptr %20, align 4, !tbaa !9
  br label %140, !llvm.loop !33

192:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #5
  %193 = load i32, ptr %8, align 4, !tbaa !9
  %194 = sdiv i32 %193, 16
  %195 = call noundef i32 @_Z5b2MaxIiET_S0_S0_(i32 noundef %194, i32 noundef 1)
  store i32 %195, ptr %23, align 4, !tbaa !9
  %196 = load i32, ptr %9, align 4, !tbaa !9
  %197 = load i32, ptr %6, align 4, !tbaa !9
  %198 = load i32, ptr %23, align 4, !tbaa !9
  %199 = add nsw i32 %197, %198
  %200 = icmp slt i32 %196, %199
  br i1 %200, label %201, label %205

201:                                              ; preds = %192
  %202 = load i32, ptr %6, align 4, !tbaa !9
  %203 = load i32, ptr %23, align 4, !tbaa !9
  %204 = add nsw i32 %202, %203
  store i32 %204, ptr %9, align 4, !tbaa !9
  br label %216

205:                                              ; preds = %192
  %206 = load i32, ptr %9, align 4, !tbaa !9
  %207 = load i32, ptr %7, align 4, !tbaa !9
  %208 = load i32, ptr %23, align 4, !tbaa !9
  %209 = sub nsw i32 %207, %208
  %210 = icmp sgt i32 %206, %209
  br i1 %210, label %211, label %215

211:                                              ; preds = %205
  %212 = load i32, ptr %7, align 4, !tbaa !9
  %213 = load i32, ptr %23, align 4, !tbaa !9
  %214 = sub nsw i32 %212, %213
  store i32 %214, ptr %9, align 4, !tbaa !9
  br label %215

215:                                              ; preds = %211, %205
  br label %216

216:                                              ; preds = %215, %201
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %18) #5
  br label %217

217:                                              ; preds = %216, %110
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %218

218:                                              ; preds = %217, %45
  br label %219

219:                                              ; preds = %218
  br label %220

220:                                              ; preds = %219
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %221 = getelementptr inbounds %class.b2BroadPhase, ptr %25, i32 0, i32 2
  %222 = load ptr, ptr %221, align 8, !tbaa !34
  %223 = getelementptr inbounds %struct.b2TreeNode, ptr %222, i32 1
  store ptr %223, ptr %221, align 8, !tbaa !34
  store ptr %222, ptr %24, align 8, !tbaa !5
  %224 = load i32, ptr %6, align 4, !tbaa !9
  %225 = load i32, ptr %9, align 4, !tbaa !9
  %226 = call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %25, i32 noundef %224, i32 noundef %225)
  %227 = load ptr, ptr %24, align 8, !tbaa !5
  %228 = getelementptr inbounds %struct.b2TreeNode, ptr %227, i32 0, i32 0
  store ptr %226, ptr %228, align 8, !tbaa !35
  %229 = load i32, ptr %9, align 4, !tbaa !9
  %230 = load i32, ptr %7, align 4, !tbaa !9
  %231 = call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %25, i32 noundef %229, i32 noundef %230)
  %232 = load ptr, ptr %24, align 8, !tbaa !5
  %233 = getelementptr inbounds %struct.b2TreeNode, ptr %232, i32 0, i32 1
  store ptr %231, ptr %233, align 8, !tbaa !36
  %234 = load ptr, ptr %24, align 8, !tbaa !5
  %235 = load ptr, ptr %24, align 8, !tbaa !5
  %236 = getelementptr inbounds %struct.b2TreeNode, ptr %235, i32 0, i32 0
  %237 = load ptr, ptr %236, align 8, !tbaa !35
  %238 = getelementptr inbounds %struct.b2TreeNode, ptr %237, i32 0, i32 2
  store ptr %234, ptr %238, align 8, !tbaa !37
  %239 = load ptr, ptr %24, align 8, !tbaa !5
  %240 = load ptr, ptr %24, align 8, !tbaa !5
  %241 = getelementptr inbounds %struct.b2TreeNode, ptr %240, i32 0, i32 1
  %242 = load ptr, ptr %241, align 8, !tbaa !36
  %243 = getelementptr inbounds %struct.b2TreeNode, ptr %242, i32 0, i32 2
  store ptr %239, ptr %243, align 8, !tbaa !37
  %244 = load ptr, ptr %24, align 8, !tbaa !5
  %245 = getelementptr inbounds %struct.b2TreeNode, ptr %244, i32 0, i32 4
  %246 = load ptr, ptr %24, align 8, !tbaa !5
  %247 = getelementptr inbounds %struct.b2TreeNode, ptr %246, i32 0, i32 0
  %248 = load ptr, ptr %247, align 8, !tbaa !35
  %249 = getelementptr inbounds %struct.b2TreeNode, ptr %248, i32 0, i32 4
  %250 = load ptr, ptr %24, align 8, !tbaa !5
  %251 = getelementptr inbounds %struct.b2TreeNode, ptr %250, i32 0, i32 1
  %252 = load ptr, ptr %251, align 8, !tbaa !36
  %253 = getelementptr inbounds %struct.b2TreeNode, ptr %252, i32 0, i32 4
  call void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16) %245, ptr noundef nonnull align 4 dereferenceable(16) %249, ptr noundef nonnull align 4 dereferenceable(16) %253)
  %254 = load ptr, ptr %24, align 8, !tbaa !5
  store ptr %254, ptr %4, align 8
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  br label %255

255:                                              ; preds = %220, %35, %31
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %256 = load ptr, ptr %4, align 8
  ret ptr %256
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137), ptr noundef nonnull align 4 dereferenceable(16)) #4 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2MinIfET_S0_S0_(float noundef, float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2MaxIfET_S0_S0_(float noundef, float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2AbsIfET_S0_(float noundef) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5b2MaxIiET_S0_S0_(i32 noundef, i32 noundef) #3

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

; 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 #0 align 2

; 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 #1

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = sub nsw i32 %2, %1
  %5 = icmp eq i32 %2, %1
  br i1 %5, label %common.ret137, label %6

6:                                                ; preds = %3
  switch i32 %4, label %15 [
    i32 1, label %7
    i32 2, label %13
  ]

7:                                                ; preds = %6
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = sext i32 %1 to i64
  %11 = getelementptr inbounds ptr, ptr %9, i64 %10
  %12 = load ptr, ptr %11, align 8, !tbaa !17
  br label %common.ret137

13:                                               ; preds = %6
  %14 = add nsw i32 %1, 1
  br label %76

15:                                               ; preds = %6
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = sext i32 %1 to i64
  %19 = getelementptr inbounds ptr, ptr %17, i64 %18
  %20 = load ptr, ptr %19, align 8, !tbaa !17
  %21 = getelementptr inbounds i8, ptr %20, i64 32
  %22 = tail call <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137) %0, ptr noundef nonnull align 4 dereferenceable(16) %21)
  %.sroa.043.0.vec.extract = extractelement <2 x float> %22, i64 0
  %.sroa.043.4.vec.extract = extractelement <2 x float> %22, i64 1
  %.08792 = add nsw i32 %1, 1
  %23 = icmp slt i32 %.08792, %2
  br i1 %23, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %15
  %24 = sext i32 %.08792 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %15
  %.086.lcssa = phi float [ %.sroa.043.4.vec.extract, %15 ], [ %37, %.lr.ph ]
  %.084.lcssa = phi float [ %.sroa.043.4.vec.extract, %15 ], [ %35, %.lr.ph ]
  %.083.lcssa = phi float [ %.sroa.043.0.vec.extract, %15 ], [ %36, %.lr.ph ]
  %.082.lcssa = phi float [ %.sroa.043.0.vec.extract, %15 ], [ %34, %.lr.ph ]
  %25 = fsub float %.083.lcssa, %.082.lcssa
  %26 = tail call noundef float @_Z5b2AbsIfET_S0_(float noundef %25)
  %27 = fcmp olt float %26, 0x3E80000000000000
  %28 = fsub float %.086.lcssa, %.084.lcssa
  br i1 %27, label %38, label %._crit_edge._crit_edge

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %24, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.08296 = phi float [ %.sroa.043.0.vec.extract, %.lr.ph.preheader ], [ %34, %.lr.ph ]
  %.08395 = phi float [ %.sroa.043.0.vec.extract, %.lr.ph.preheader ], [ %36, %.lr.ph ]
  %.08494 = phi float [ %.sroa.043.4.vec.extract, %.lr.ph.preheader ], [ %35, %.lr.ph ]
  %.08693 = phi float [ %.sroa.043.4.vec.extract, %.lr.ph.preheader ], [ %37, %.lr.ph ]
  %29 = load ptr, ptr %16, align 8, !tbaa !5
  %30 = getelementptr inbounds ptr, ptr %29, i64 %indvars.iv
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = getelementptr inbounds i8, ptr %31, i64 32
  %33 = tail call <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137) %0, ptr noundef nonnull align 4 dereferenceable(16) %32)
  %.sroa.043.0.vec.extract45 = extractelement <2 x float> %33, i64 0
  %34 = tail call noundef float @_Z5b2MinIfET_S0_S0_(float noundef %.08296, float noundef %.sroa.043.0.vec.extract45)
  %.sroa.043.4.vec.extract49 = extractelement <2 x float> %33, i64 1
  %35 = tail call noundef float @_Z5b2MinIfET_S0_S0_(float noundef %.08494, float noundef %.sroa.043.4.vec.extract49)
  %36 = tail call noundef float @_Z5b2MaxIfET_S0_S0_(float noundef %.08395, float noundef %.sroa.043.0.vec.extract45)
  %37 = tail call noundef float @_Z5b2MaxIfET_S0_S0_(float noundef %.08693, float noundef %.sroa.043.4.vec.extract49)
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %lftr.wideiv, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !18

38:                                               ; preds = %._crit_edge
  %39 = tail call noundef float @_Z5b2AbsIfET_S0_(float noundef %28)
  %40 = fcmp olt float %39, 0x3E80000000000000
  br i1 %40, label %41, label %._crit_edge._crit_edge

41:                                               ; preds = %38
  %42 = add nsw i32 %2, %1
  %43 = sdiv i32 %42, 2
  br label %76

._crit_edge._crit_edge:                           ; preds = %._crit_edge, %38
  %44 = fcmp ogt float %25, %28
  %45 = fadd float %.083.lcssa, %.082.lcssa
  %46 = fadd float %.086.lcssa, %.084.lcssa
  %.in = select i1 %44, float %45, float %46
  %47 = fmul float %.in, 5.000000e-01
  %48 = icmp slt i32 %1, %2
  br i1 %48, label %.lr.ph104, label %._crit_edge105

.lr.ph104:                                        ; preds = %._crit_edge._crit_edge
  br i1 %44, label %.lr.ph104.split.us, label %.lr.ph104.split

.lr.ph104.split.us:                               ; preds = %.lr.ph104, %59
  %indvars.iv117 = phi i64 [ %indvars.iv.next118, %59 ], [ %18, %.lr.ph104 ]
  %.081102.us = phi i32 [ %.1.us, %59 ], [ %1, %.lr.ph104 ]
  %49 = load ptr, ptr %16, align 8, !tbaa !5
  %50 = getelementptr inbounds ptr, ptr %49, i64 %indvars.iv117
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = getelementptr inbounds i8, ptr %51, i64 32
  %.sroa.5.0..sroa_idx.us = getelementptr inbounds i8, ptr %51, i64 40
  %.sroa.5.0.copyload.us = load float, ptr %.sroa.5.0..sroa_idx.us, align 8, !tbaa !20
  %.sroa.0.0.copyload.us = load float, ptr %52, align 8, !tbaa !20
  %53 = fadd float %.sroa.5.0.copyload.us, %.sroa.0.0.copyload.us
  %54 = fcmp olt float %53, %47
  br i1 %54, label %55, label %59

55:                                               ; preds = %.lr.ph104.split.us
  %56 = add nsw i32 %.081102.us, 1
  %57 = sext i32 %.081102.us to i64
  %58 = getelementptr inbounds ptr, ptr %49, i64 %57
  tail call void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8) %50, ptr noundef nonnull align 8 dereferenceable(8) %58)
  br label %59

59:                                               ; preds = %55, %.lr.ph104.split.us
  %.1.us = phi i32 [ %56, %55 ], [ %.081102.us, %.lr.ph104.split.us ]
  %indvars.iv.next118 = add nsw i64 %indvars.iv117, 1
  %lftr.wideiv120 = trunc i64 %indvars.iv.next118 to i32
  %exitcond121.not = icmp eq i32 %lftr.wideiv120, %2
  br i1 %exitcond121.not, label %._crit_edge105, label %.lr.ph104.split.us, !llvm.loop !21

._crit_edge105:                                   ; preds = %73, %59, %._crit_edge._crit_edge
  %.081.lcssa = phi i32 [ %1, %._crit_edge._crit_edge ], [ %.1.us, %59 ], [ %.1, %73 ]
  %60 = sdiv i32 %4, 16
  %61 = tail call noundef i32 @_Z5b2MaxIiET_S0_S0_(i32 noundef %60, i32 noundef 1)
  %62 = add nsw i32 %61, %1
  %63 = icmp slt i32 %.081.lcssa, %62
  br i1 %63, label %76, label %74

.lr.ph104.split:                                  ; preds = %.lr.ph104, %73
  %indvars.iv112 = phi i64 [ %indvars.iv.next113, %73 ], [ %18, %.lr.ph104 ]
  %.081102 = phi i32 [ %.1, %73 ], [ %1, %.lr.ph104 ]
  %64 = load ptr, ptr %16, align 8, !tbaa !5
  %65 = getelementptr inbounds ptr, ptr %64, i64 %indvars.iv112
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %.sroa.6.0..sroa_idx = getelementptr inbounds i8, ptr %66, i64 44
  %.sroa.6.0.copyload = load float, ptr %.sroa.6.0..sroa_idx, align 4, !tbaa !20
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %66, i64 36
  %.sroa.4.0.copyload = load float, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !20
  %67 = fadd float %.sroa.6.0.copyload, %.sroa.4.0.copyload
  %68 = fcmp olt float %67, %47
  br i1 %68, label %69, label %73

69:                                               ; preds = %.lr.ph104.split
  %70 = add nsw i32 %.081102, 1
  %71 = sext i32 %.081102 to i64
  %72 = getelementptr inbounds ptr, ptr %64, i64 %71
  tail call void @_Z6b2SwapIP10b2TreeNodeEvRT_S3_(ptr noundef nonnull align 8 dereferenceable(8) %65, ptr noundef nonnull align 8 dereferenceable(8) %72)
  br label %73

73:                                               ; preds = %69, %.lr.ph104.split
  %.1 = phi i32 [ %70, %69 ], [ %.081102, %.lr.ph104.split ]
  %indvars.iv.next113 = add nsw i64 %indvars.iv112, 1
  %lftr.wideiv115 = trunc i64 %indvars.iv.next113 to i32
  %exitcond116.not = icmp eq i32 %lftr.wideiv115, %2
  br i1 %exitcond116.not, label %._crit_edge105, label %.lr.ph104.split, !llvm.loop !21

74:                                               ; preds = %._crit_edge105
  %75 = sub nsw i32 %2, %61
  %spec.select = tail call i32 @llvm.smin.i32(i32 %.081.lcssa, i32 %75)
  br label %76

common.ret137:                                    ; preds = %3, %7, %76
  %common.ret137.op = phi ptr [ %78, %76 ], [ %12, %7 ], [ null, %3 ]
  ret ptr %common.ret137.op

76:                                               ; preds = %74, %41, %._crit_edge105, %13
  %.4 = phi i32 [ %14, %13 ], [ %43, %41 ], [ %62, %._crit_edge105 ], [ %spec.select, %74 ]
  %77 = getelementptr inbounds i8, ptr %0, i64 16
  %78 = load ptr, ptr %77, align 8, !tbaa !22
  %79 = getelementptr inbounds i8, ptr %78, i64 48
  store ptr %79, ptr %77, align 8, !tbaa !22
  %80 = tail call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %1, i32 noundef %.4)
  store ptr %80, ptr %78, align 8, !tbaa !23
  %81 = tail call noundef ptr @_ZN12b2BroadPhase5BuildEii(ptr noundef nonnull align 8 dereferenceable(137) %0, i32 noundef %.4, i32 noundef %2)
  %82 = getelementptr inbounds i8, ptr %78, i64 8
  store ptr %81, ptr %82, align 8, !tbaa !24
  %83 = load ptr, ptr %78, align 8, !tbaa !23
  %84 = getelementptr inbounds i8, ptr %83, i64 16
  store ptr %78, ptr %84, align 8, !tbaa !25
  %85 = getelementptr inbounds i8, ptr %81, i64 16
  store ptr %78, ptr %85, align 8, !tbaa !25
  %86 = getelementptr inbounds i8, ptr %78, i64 32
  %87 = getelementptr inbounds i8, ptr %83, i64 32
  %88 = getelementptr inbounds i8, ptr %81, i64 32
  tail call void @_ZN6b2AABB7CombineERKS_S1_(ptr noundef nonnull align 4 dereferenceable(16) %86, ptr noundef nonnull align 4 dereferenceable(16) %87, ptr noundef nonnull align 4 dereferenceable(16) %88)
  br label %common.ret137
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZN12b2BroadPhase10GetCenter2ERK6b2AABB(ptr noundef nonnull align 8 dereferenceable(137), ptr noundef nonnull align 4 dereferenceable(16)) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2MinIfET_S0_S0_(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2MaxIfET_S0_S0_(float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_Z5b2AbsIfET_S0_(float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z5b2MaxIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #3

attributes #0 = { 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 #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 = { inlinehint 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !7, i64 8}
!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 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!13, !13, i64 0}
!21 = distinct !{!21, !19}
!22 = !{!6, !7, i64 16}
!23 = !{!10, !7, i64 0}
!24 = !{!10, !7, i64 8}
!25 = !{!10, !7, i64 16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass