; LLVM IR from erincatto/box2d :: src (dynamic_tree)

; 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.b2DynamicTree = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32 }
%struct.b2TreeNode = type { %struct.b2AABB, i64, %union.anon, %union.anon.0, i16, i16 }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%union.anon = type { i64 }
%union.anon.0 = type { i32 }
%struct.anon = type { i32, i32 }

@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [24 x i8], align 1

declare ptr @b2Alloc(i32 noundef) #0

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

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

declare void @b2Free(ptr noundef, i32 noundef) #0

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) #0

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #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) #3

; Function Attrs: nounwind uwtable
declare hidden void @b2FreeNode(ptr noundef, i32 noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local void @b2DynamicTree_Validate(ptr noundef) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @b2AABB_Center(<2 x float>, <2 x float>) #5

; Function Attrs: nounwind uwtable
define dso_local i32 @b2DynamicTree_Rebuild(ptr noundef %0, i1 noundef zeroext %1) #6 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca [1024 x i32], align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca %struct.b2Vec2, align 4
  %18 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %19 = zext i1 %1 to i8
  store i8 %19, ptr %5, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.b2DynamicTree, ptr %20, i32 0, i32 5
  %22 = load i32, ptr %21, align 8, !tbaa !11
  store i32 %22, ptr %6, align 4, !tbaa !14
  %23 = load i32, ptr %6, align 4, !tbaa !14
  %24 = icmp eq i32 %23, 0
  br i1 %24, label %25, label %26

25:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %197

26:                                               ; preds = %2
  %27 = load i32, ptr %6, align 4, !tbaa !14
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.b2DynamicTree, ptr %28, i32 0, i32 10
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %31 = icmp sgt i32 %27, %30
  br i1 %31, label %32, label %72

32:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  %33 = load i32, ptr %6, align 4, !tbaa !14
  %34 = load i32, ptr %6, align 4, !tbaa !14
  %35 = sdiv i32 %34, 2
  %36 = add nsw i32 %33, %35
  store i32 %36, ptr %8, align 4, !tbaa !14
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.b2DynamicTree, ptr %37, i32 0, i32 6
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.b2DynamicTree, ptr %40, i32 0, i32 10
  %42 = load i32, ptr %41, align 8, !tbaa !15
  %43 = sext i32 %42 to i64
  %44 = mul i64 %43, 4
  %45 = trunc i64 %44 to i32
  call void @b2Free(ptr noundef %39, i32 noundef %45)
  %46 = load i32, ptr %8, align 4, !tbaa !14
  %47 = sext i32 %46 to i64
  %48 = mul i64 %47, 4
  %49 = trunc i64 %48 to i32
  %50 = call ptr @b2Alloc(i32 noundef %49)
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.b2DynamicTree, ptr %51, i32 0, i32 6
  store ptr %50, ptr %52, align 8, !tbaa !16
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.b2DynamicTree, ptr %53, i32 0, i32 8
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.b2DynamicTree, ptr %56, i32 0, i32 10
  %58 = load i32, ptr %57, align 8, !tbaa !15
  %59 = sext i32 %58 to i64
  %60 = mul i64 %59, 8
  %61 = trunc i64 %60 to i32
  call void @b2Free(ptr noundef %55, i32 noundef %61)
  %62 = load i32, ptr %8, align 4, !tbaa !14
  %63 = sext i32 %62 to i64
  %64 = mul i64 %63, 8
  %65 = trunc i64 %64 to i32
  %66 = call ptr @b2Alloc(i32 noundef %65)
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.b2DynamicTree, ptr %67, i32 0, i32 8
  store ptr %66, ptr %68, align 8, !tbaa !17
  %69 = load i32, ptr %8, align 4, !tbaa !14
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.b2DynamicTree, ptr %70, i32 0, i32 10
  store i32 %69, ptr %71, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %72

72:                                               ; preds = %32, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 0, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4096, ptr %10) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  store i32 0, ptr %11, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.b2DynamicTree, ptr %73, i32 0, i32 1
  %75 = load i32, ptr %74, align 8, !tbaa !18
  store i32 %75, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #7
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.b2DynamicTree, ptr %76, i32 0, i32 0
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  store ptr %78, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %79 = load ptr, ptr %13, align 8, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !14
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds %struct.b2TreeNode, ptr %79, i64 %81
  store ptr %82, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #7
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.b2DynamicTree, ptr %83, i32 0, i32 6
  %85 = load ptr, ptr %84, align 8, !tbaa !16
  store ptr %85, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %86 = load ptr, ptr %4, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.b2DynamicTree, ptr %86, i32 0, i32 8
  %88 = load ptr, ptr %87, align 8, !tbaa !17
  store ptr %88, ptr %16, align 8, !tbaa !5
  br label %89

89:                                               ; preds = %168, %157, %72
  br label %90

90:                                               ; preds = %89
  %91 = load ptr, ptr %14, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.b2TreeNode, ptr %91, i32 0, i32 4
  %93 = load i16, ptr %92, align 4, !tbaa !20
  %94 = zext i16 %93 to i32
  %95 = icmp eq i32 %94, 0
  br i1 %95, label %108, label %96

96:                                               ; preds = %90
  %97 = load ptr, ptr %14, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.b2TreeNode, ptr %97, i32 0, i32 5
  %99 = load i16, ptr %98, align 2, !tbaa !27
  %100 = zext i16 %99 to i32
  %101 = and i32 %100, 2
  %102 = icmp eq i32 %101, 0
  br i1 %102, label %103, label %129

103:                                              ; preds = %96
  %104 = load i8, ptr %5, align 1, !tbaa !9, !range !28, !noundef !29
  %105 = trunc i8 %104 to i1
  %106 = zext i1 %105 to i32
  %107 = icmp eq i32 %106, 0
  br i1 %107, label %108, label %129

108:                                              ; preds = %103, %90
  %109 = load i32, ptr %12, align 4, !tbaa !14
  %110 = load ptr, ptr %15, align 8, !tbaa !5
  %111 = load i32, ptr %9, align 4, !tbaa !14
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds i32, ptr %110, i64 %112
  store i32 %109, ptr %113, align 4, !tbaa !14
  %114 = load ptr, ptr %16, align 8, !tbaa !5
  %115 = load i32, ptr %9, align 4, !tbaa !14
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds %struct.b2Vec2, ptr %114, i64 %116
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #7
  %118 = load ptr, ptr %14, align 8, !tbaa !5
  %119 = getelementptr inbounds %struct.b2TreeNode, ptr %118, i32 0, i32 0
  %120 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %119, i32 0, i32 0
  %121 = load <2 x float>, ptr %120, align 8
  %122 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %119, i32 0, i32 1
  %123 = load <2 x float>, ptr %122, align 8
  %124 = call <2 x float> @b2AABB_Center(<2 x float> %121, <2 x float> %123)
  store <2 x float> %124, ptr %17, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %117, ptr align 4 %17, i64 8, i1 false), !tbaa.struct !30
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #7
  %125 = load i32, ptr %9, align 4, !tbaa !14
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr %9, align 4, !tbaa !14
  %127 = load ptr, ptr %14, align 8, !tbaa !5
  %128 = getelementptr inbounds %struct.b2TreeNode, ptr %127, i32 0, i32 3
  store i32 -1, ptr %128, align 8, !tbaa !32
  br label %164

129:                                              ; preds = %103, %96
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #7
  %130 = load i32, ptr %12, align 4, !tbaa !14
  store i32 %130, ptr %18, align 4, !tbaa !14
  %131 = load ptr, ptr %14, align 8, !tbaa !5
  %132 = getelementptr inbounds %struct.b2TreeNode, ptr %131, i32 0, i32 2
  %133 = getelementptr inbounds %struct.anon, ptr %132, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !32
  store i32 %134, ptr %12, align 4, !tbaa !14
  %135 = load i32, ptr %11, align 4, !tbaa !14
  %136 = icmp slt i32 %135, 1024
  br i1 %136, label %137, label %146

137:                                              ; preds = %129
  %138 = load ptr, ptr %14, align 8, !tbaa !5
  %139 = getelementptr inbounds %struct.b2TreeNode, ptr %138, i32 0, i32 2
  %140 = getelementptr inbounds %struct.anon, ptr %139, i32 0, i32 1
  %141 = load i32, ptr %140, align 4, !tbaa !32
  %142 = load i32, ptr %11, align 4, !tbaa !14
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %11, align 4, !tbaa !14
  %144 = sext i32 %142 to i64
  %145 = getelementptr inbounds [1024 x i32], ptr %10, i64 0, i64 %144
  store i32 %141, ptr %145, align 4, !tbaa !14
  br label %157

146:                                              ; preds = %129
  br label %147

147:                                              ; preds = %146
  %148 = load i32, ptr %11, align 4, !tbaa !14
  %149 = icmp slt i32 %148, 1024
  br i1 %149, label %154, label %150

150:                                              ; preds = %147
  %151 = call i32 @b2InternalAssertFcn(ptr noundef @.str.19, ptr noundef @.str.1, i32 noundef 1951)
  %152 = icmp ne i32 %151, 0
  br i1 %152, label %153, label %154

153:                                              ; preds = %150
  call void @llvm.trap()
  br label %154

154:                                              ; preds = %153, %150, %147
  br label %155

155:                                              ; preds = %154
  br label %156

156:                                              ; preds = %155
  br label %157

157:                                              ; preds = %156, %137
  %158 = load ptr, ptr %13, align 8, !tbaa !5
  %159 = load i32, ptr %12, align 4, !tbaa !14
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds %struct.b2TreeNode, ptr %158, i64 %160
  store ptr %161, ptr %14, align 8, !tbaa !5
  %162 = load ptr, ptr %4, align 8, !tbaa !5
  %163 = load i32, ptr %18, align 4, !tbaa !14
  call void @b2FreeNode(ptr noundef %162, i32 noundef %163)
  store i32 2, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #7
  br label %89

164:                                              ; preds = %108
  %165 = load i32, ptr %11, align 4, !tbaa !14
  %166 = icmp eq i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %164
  br label %178

168:                                              ; preds = %164
  %169 = load i32, ptr %11, align 4, !tbaa !14
  %170 = add nsw i32 %169, -1
  store i32 %170, ptr %11, align 4, !tbaa !14
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [1024 x i32], ptr %10, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !14
  store i32 %173, ptr %12, align 4, !tbaa !14
  %174 = load ptr, ptr %13, align 8, !tbaa !5
  %175 = load i32, ptr %12, align 4, !tbaa !14
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds %struct.b2TreeNode, ptr %174, i64 %176
  store ptr %177, ptr %14, align 8, !tbaa !5
  br label %89

178:                                              ; preds = %167
  br label %179

179:                                              ; preds = %178
  %180 = load i32, ptr %9, align 4, !tbaa !14
  %181 = load i32, ptr %6, align 4, !tbaa !14
  %182 = icmp sle i32 %180, %181
  br i1 %182, label %187, label %183

183:                                              ; preds = %179
  %184 = call i32 @b2InternalAssertFcn(ptr noundef @.str.20, ptr noundef @.str.1, i32 noundef 1982)
  %185 = icmp ne i32 %184, 0
  br i1 %185, label %186, label %187

186:                                              ; preds = %183
  call void @llvm.trap()
  br label %187

187:                                              ; preds = %186, %183, %179
  br label %188

188:                                              ; preds = %187
  br label %189

189:                                              ; preds = %188
  %190 = load ptr, ptr %4, align 8, !tbaa !5
  %191 = load i32, ptr %9, align 4, !tbaa !14
  %192 = call i32 @b2BuildTree(ptr noundef %190, i32 noundef %191)
  %193 = load ptr, ptr %4, align 8, !tbaa !5
  %194 = getelementptr inbounds %struct.b2DynamicTree, ptr %193, i32 0, i32 1
  store i32 %192, ptr %194, align 8, !tbaa !18
  %195 = load ptr, ptr %4, align 8, !tbaa !5
  call void @b2DynamicTree_Validate(ptr noundef %195)
  %196 = load i32, ptr %9, align 4, !tbaa !14
  store i32 %196, ptr %3, align 4
  store i32 1, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.end.p0(i64 4096, ptr %10) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  br label %197

197:                                              ; preds = %189, %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  %198 = load i32, ptr %3, align 4
  ret i32 %198
}

; Function Attrs: nounwind uwtable
declare hidden i32 @b2BuildTree(ptr noundef, i32 noundef) #6

attributes #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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { inlinehint nounwind 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 #6 = { nounwind 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 #7 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !13, i64 24}
!12 = !{!"b2DynamicTree", !6, i64 0, !13, i64 8, !13, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !13, i64 64}
!13 = !{!"int", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 64}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 48}
!18 = !{!12, !13, i64 8}
!19 = !{!12, !6, i64 0}
!20 = !{!21, !26, i64 36}
!21 = !{!"b2TreeNode", !22, i64 0, !25, i64 16, !7, i64 24, !7, i64 32, !26, i64 36, !26, i64 38}
!22 = !{!"b2AABB", !23, i64 0, !23, i64 8}
!23 = !{!"b2Vec2", !24, i64 0, !24, i64 4}
!24 = !{!"float", !7, i64 0}
!25 = !{!"long", !7, i64 0}
!26 = !{!"short", !7, i64 0}
!27 = !{!21, !26, i64 38}
!28 = !{i8 0, i8 2}
!29 = !{}
!30 = !{i64 0, i64 4, !31, i64 4, i64 4, !31}
!31 = !{!24, !24, i64 0}
!32 = !{!7, !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.b2TreeNode = type { %struct.b2AABB, i64, %union.anon, %union.anon.0, i16, i16 }
%struct.b2AABB = type { %struct.b2Vec2, %struct.b2Vec2 }
%struct.b2Vec2 = type { float, float }
%union.anon = type { i64 }
%union.anon.0 = type { i32 }

@.str.1 = external hidden unnamed_addr constant [68 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [24 x i8], align 1

declare ptr @b2Alloc(i32 noundef) local_unnamed_addr #0

; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

declare void @b2Free(ptr noundef, i32 noundef) local_unnamed_addr #0

declare i32 @b2InternalAssertFcn(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write)
declare void @llvm.trap() #2

; Function Attrs: nounwind uwtable
declare hidden void @b2FreeNode(ptr noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @b2DynamicTree_Validate(ptr noundef) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden <2 x float> @b2AABB_Center(<2 x float>, <2 x float>) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local i32 @b2DynamicTree_Rebuild(ptr noundef %0, i1 noundef zeroext %1) local_unnamed_addr #5 {
  %3 = alloca [1024 x i32], align 16
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %113, label %7

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = load i32, ptr %8, align 8, !tbaa !11
  %10 = icmp sgt i32 %5, %9
  br i1 %10, label %11, label %._crit_edge95

._crit_edge95:                                    ; preds = %7
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 48
  %.pre = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !12
  br label %25

11:                                               ; preds = %7
  %12 = sdiv i32 %5, 2
  %13 = add nsw i32 %12, %5
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = shl i32 %9, 2
  tail call void @b2Free(ptr noundef %15, i32 noundef %16) #6
  %17 = shl i32 %13, 2
  %18 = tail call ptr @b2Alloc(i32 noundef %17) #6
  store ptr %18, ptr %14, align 8, !tbaa !13
  %19 = getelementptr inbounds i8, ptr %0, i64 48
  %20 = load ptr, ptr %19, align 8, !tbaa !12
  %21 = load i32, ptr %8, align 8, !tbaa !11
  %22 = shl i32 %21, 3
  tail call void @b2Free(ptr noundef %20, i32 noundef %22) #6
  %23 = shl i32 %13, 3
  %24 = tail call ptr @b2Alloc(i32 noundef %23) #6
  store ptr %24, ptr %19, align 8, !tbaa !12
  store i32 %13, ptr %8, align 8, !tbaa !11
  br label %25

25:                                               ; preds = %._crit_edge95, %11
  %26 = phi ptr [ %.pre, %._crit_edge95 ], [ %24, %11 ]
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %3) #6
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = load ptr, ptr %0, align 8, !tbaa !15
  %30 = sext i32 %28 to i64
  %31 = getelementptr inbounds %struct.b2TreeNode, ptr %29, i64 %30
  %32 = getelementptr inbounds i8, ptr %0, i64 32
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  br i1 %1, label %.outer.us, label %.outer

.outer.us:                                        ; preds = %25, %45
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %45 ], [ 0, %25 ]
  %.057.ph.us = phi i32 [ %49, %45 ], [ %28, %25 ]
  %.056.ph.us = phi ptr [ %51, %45 ], [ %31, %25 ]
  %.055.ph.us = phi i32 [ %46, %45 ], [ 0, %25 ]
  %34 = getelementptr inbounds i8, ptr %.056.ph.us, i64 36
  %35 = load i16, ptr %34, align 4, !tbaa !16
  %36 = icmp eq i16 %35, 0
  br i1 %36, label %._crit_edge72.split.us.us, label %.lr.ph.us

._crit_edge72.split.us.us:                        ; preds = %63, %.outer.us
  %.057.lcssa.us = phi i32 [ %.057.ph.us, %.outer.us ], [ %53, %63 ]
  %.056.lcssa.us = phi ptr [ %.056.ph.us, %.outer.us ], [ %65, %63 ]
  %.055.lcssa.us = phi i32 [ %.055.ph.us, %.outer.us ], [ %.1.us.us, %63 ]
  %37 = getelementptr inbounds i32, ptr %33, i64 %indvars.iv92
  store i32 %.057.lcssa.us, ptr %37, align 4, !tbaa !23
  %38 = getelementptr inbounds %struct.b2Vec2, ptr %26, i64 %indvars.iv92
  %39 = load <2 x float>, ptr %.056.lcssa.us, align 8
  %40 = getelementptr inbounds i8, ptr %.056.lcssa.us, i64 8
  %41 = load <2 x float>, ptr %40, align 8
  %42 = tail call <2 x float> @b2AABB_Center(<2 x float> %39, <2 x float> %41)
  store <2 x float> %42, ptr %38, align 4
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %43 = getelementptr inbounds i8, ptr %.056.lcssa.us, i64 32
  store i32 -1, ptr %43, align 8, !tbaa !24
  %44 = icmp eq i32 %.055.lcssa.us, 0
  br i1 %44, label %.split80.us, label %45

45:                                               ; preds = %._crit_edge72.split.us.us
  %46 = add nsw i32 %.055.lcssa.us, -1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1024 x i32], ptr %3, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !23
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds %struct.b2TreeNode, ptr %29, i64 %50
  br label %.outer.us

.lr.ph.us:                                        ; preds = %.outer.us, %63
  %.05569.us.us = phi i32 [ %.1.us.us, %63 ], [ %.055.ph.us, %.outer.us ]
  %.05668.us.us = phi ptr [ %65, %63 ], [ %.056.ph.us, %.outer.us ]
  %.05767.us.us = phi i32 [ %53, %63 ], [ %.057.ph.us, %.outer.us ]
  %52 = getelementptr inbounds i8, ptr %.05668.us.us, i64 24
  %53 = load i32, ptr %52, align 8, !tbaa !24
  %54 = icmp slt i32 %.05569.us.us, 1024
  br i1 %54, label %57, label %55

55:                                               ; preds = %.lr.ph.us
  %56 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i32 noundef 1951) #6
  %.not.us.us = icmp eq i32 %56, 0
  br i1 %.not.us.us, label %63, label %.split.us

57:                                               ; preds = %.lr.ph.us
  %58 = getelementptr inbounds i8, ptr %.05668.us.us, i64 28
  %59 = load i32, ptr %58, align 4, !tbaa !24
  %60 = add nsw i32 %.05569.us.us, 1
  %61 = sext i32 %.05569.us.us to i64
  %62 = getelementptr inbounds [1024 x i32], ptr %3, i64 0, i64 %61
  store i32 %59, ptr %62, align 4, !tbaa !23
  br label %63

63:                                               ; preds = %57, %55
  %.1.us.us = phi i32 [ %60, %57 ], [ %.05569.us.us, %55 ]
  %64 = sext i32 %53 to i64
  %65 = getelementptr inbounds %struct.b2TreeNode, ptr %29, i64 %64
  tail call void @b2FreeNode(ptr noundef nonnull %0, i32 noundef %.05767.us.us)
  %66 = getelementptr inbounds i8, ptr %65, i64 36
  %67 = load i16, ptr %66, align 4, !tbaa !16
  %68 = icmp eq i16 %67, 0
  br i1 %68, label %._crit_edge72.split.us.us, label %.lr.ph.us

.outer:                                           ; preds = %25, %101
  %indvars.iv = phi i64 [ %indvars.iv.next, %101 ], [ 0, %25 ]
  %.057.ph = phi i32 [ %105, %101 ], [ %28, %25 ]
  %.056.ph = phi ptr [ %107, %101 ], [ %31, %25 ]
  %.055.ph = phi i32 [ %102, %101 ], [ 0, %25 ]
  %69 = getelementptr inbounds i8, ptr %.056.ph, i64 36
  %70 = load i16, ptr %69, align 4, !tbaa !16
  %71 = icmp eq i16 %70, 0
  br i1 %71, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.outer, %95
  %.05569 = phi i32 [ %.1, %95 ], [ %.055.ph, %.outer ]
  %.05668 = phi ptr [ %97, %95 ], [ %.056.ph, %.outer ]
  %.05767 = phi i32 [ %85, %95 ], [ %.057.ph, %.outer ]
  %72 = getelementptr inbounds i8, ptr %.05668, i64 38
  %73 = load i16, ptr %72, align 2, !tbaa !25
  %74 = and i16 %73, 2
  %.not83 = icmp eq i16 %74, 0
  br i1 %.not83, label %._crit_edge, label %83

._crit_edge:                                      ; preds = %95, %.lr.ph, %.outer
  %.057.lcssa = phi i32 [ %.057.ph, %.outer ], [ %.05767, %.lr.ph ], [ %85, %95 ]
  %.056.lcssa = phi ptr [ %.056.ph, %.outer ], [ %.05668, %.lr.ph ], [ %97, %95 ]
  %.055.lcssa = phi i32 [ %.055.ph, %.outer ], [ %.05569, %.lr.ph ], [ %.1, %95 ]
  %75 = getelementptr inbounds i32, ptr %33, i64 %indvars.iv
  store i32 %.057.lcssa, ptr %75, align 4, !tbaa !23
  %76 = getelementptr inbounds %struct.b2Vec2, ptr %26, i64 %indvars.iv
  %77 = load <2 x float>, ptr %.056.lcssa, align 8
  %78 = getelementptr inbounds i8, ptr %.056.lcssa, i64 8
  %79 = load <2 x float>, ptr %78, align 8
  %80 = tail call <2 x float> @b2AABB_Center(<2 x float> %77, <2 x float> %79)
  store <2 x float> %80, ptr %76, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %81 = getelementptr inbounds i8, ptr %.056.lcssa, i64 32
  store i32 -1, ptr %81, align 8, !tbaa !24
  %82 = icmp eq i32 %.055.lcssa, 0
  br i1 %82, label %.split80.us, label %101

83:                                               ; preds = %.lr.ph
  %84 = getelementptr inbounds i8, ptr %.05668, i64 24
  %85 = load i32, ptr %84, align 8, !tbaa !24
  %86 = icmp slt i32 %.05569, 1024
  br i1 %86, label %87, label %93

87:                                               ; preds = %83
  %88 = getelementptr inbounds i8, ptr %.05668, i64 28
  %89 = load i32, ptr %88, align 4, !tbaa !24
  %90 = add nsw i32 %.05569, 1
  %91 = sext i32 %.05569 to i64
  %92 = getelementptr inbounds [1024 x i32], ptr %3, i64 0, i64 %91
  store i32 %89, ptr %92, align 4, !tbaa !23
  br label %95

93:                                               ; preds = %83
  %94 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i32 noundef 1951) #6
  %.not = icmp eq i32 %94, 0
  br i1 %.not, label %95, label %.split.us

.split.us:                                        ; preds = %93, %55
  tail call void @llvm.trap()
  unreachable

95:                                               ; preds = %93, %87
  %.1 = phi i32 [ %90, %87 ], [ %.05569, %93 ]
  %96 = sext i32 %85 to i64
  %97 = getelementptr inbounds %struct.b2TreeNode, ptr %29, i64 %96
  tail call void @b2FreeNode(ptr noundef nonnull %0, i32 noundef %.05767)
  %98 = getelementptr inbounds i8, ptr %97, i64 36
  %99 = load i16, ptr %98, align 4, !tbaa !16
  %100 = icmp eq i16 %99, 0
  br i1 %100, label %._crit_edge, label %.lr.ph

101:                                              ; preds = %._crit_edge
  %102 = add nsw i32 %.055.lcssa, -1
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1024 x i32], ptr %3, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !23
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds %struct.b2TreeNode, ptr %29, i64 %106
  br label %.outer

.split80.us:                                      ; preds = %._crit_edge, %._crit_edge72.split.us.us
  %.us-phi81.in = phi i64 [ %indvars.iv.next93, %._crit_edge72.split.us.us ], [ %indvars.iv.next, %._crit_edge ]
  %.us-phi82.in = phi i64 [ %indvars.iv92, %._crit_edge72.split.us.us ], [ %indvars.iv, %._crit_edge ]
  %.us-phi82 = trunc i64 %.us-phi82.in to i32
  %.us-phi81 = trunc i64 %.us-phi81.in to i32
  %.not60.not = icmp sgt i32 %5, %.us-phi82
  br i1 %.not60.not, label %111, label %108

108:                                              ; preds = %.split80.us
  %109 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.20, ptr noundef nonnull @.str.1, i32 noundef 1982) #6
  %.not61 = icmp eq i32 %109, 0
  br i1 %.not61, label %111, label %110

110:                                              ; preds = %108
  tail call void @llvm.trap()
  unreachable

111:                                              ; preds = %108, %.split80.us
  %112 = tail call i32 @b2BuildTree(ptr noundef nonnull %0, i32 noundef %.us-phi81)
  store i32 %112, ptr %27, align 8, !tbaa !14
  tail call void @b2DynamicTree_Validate(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #6
  br label %113

113:                                              ; preds = %2, %111
  %.0 = phi i32 [ %.us-phi81, %111 ], [ 0, %2 ]
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden i32 @b2BuildTree(ptr noundef, i32 noundef) local_unnamed_addr #5

attributes #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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #3 = { 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 nounwind 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 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 #6 = { 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, !10, i64 24}
!6 = !{!"b2DynamicTree", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 64}
!12 = !{!6, !7, i64 48}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!17, !22, i64 36}
!17 = !{!"b2TreeNode", !18, i64 0, !21, i64 16, !8, i64 24, !8, i64 32, !22, i64 36, !22, i64 38}
!18 = !{!"b2AABB", !19, i64 0, !19, i64 8}
!19 = !{!"b2Vec2", !20, i64 0, !20, i64 4}
!20 = !{!"float", !8, i64 0}
!21 = !{!"long", !8, i64 0}
!22 = !{!"short", !8, i64 0}
!23 = !{!10, !10, i64 0}
!24 = !{!8, !8, i64 0}
!25 = !{!17, !22, i64 38}


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