; LLVM IR from ESPboy-edu/ESPboy_tinyphysicsengine :: programs (hello)

; 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.TPE_Vec3 = type { i32, i32, i32 }
%struct.TPE_Joint = type { %struct.TPE_Vec3, [3 x i16], i8 }

@_TPE_collisionCallback = external dso_local global ptr, align 8
@_TPE_body1Index = external dso_local global i16, align 2
@_TPE_body2Index = external dso_local global i16, align 2
@_TPE_joint1Index = external dso_local global i16, align 2
@_TPE_joint2Index = external dso_local global i16, align 2

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Len(i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Minus(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local void @TPE_vec3Normalize(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Plus(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Project(i64, i32, i64, i32) #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Times(i64, i32, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @TPE_jointEnvironmentResolveCollision(ptr noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i8, align 1
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca %struct.TPE_Vec3, align 4
  %11 = alloca %struct.TPE_Vec3, align 4
  %12 = alloca { i64, i32 }, align 4
  %13 = alloca { i64, i32 }, align 8
  %14 = alloca { i64, i32 }, align 4
  %15 = alloca { i64, i32 }, align 4
  %16 = alloca { i64, i32 }, align 8
  %17 = alloca i32, align 4
  %18 = alloca { i64, i32 }, align 4
  %19 = alloca %struct.TPE_Vec3, align 4
  %20 = alloca { i64, i32 }, align 4
  %21 = alloca { i64, i32 }, align 4
  %22 = alloca { i64, i32 }, align 8
  %23 = alloca { i64, i32 }, align 4
  %24 = alloca i32, align 4
  %25 = alloca %struct.TPE_Vec3, align 4
  %26 = alloca %struct.TPE_Vec3, align 4
  %27 = alloca i8, align 1
  %28 = alloca i32, align 4
  %29 = alloca %struct.TPE_Vec3, align 4
  %30 = alloca { i64, i32 }, align 4
  %31 = alloca { i64, i32 }, align 8
  %32 = alloca %struct.TPE_Vec3, align 4
  %33 = alloca { i64, i32 }, align 4
  %34 = alloca { i64, i32 }, align 4
  %35 = alloca { i64, i32 }, align 8
  %36 = alloca %struct.TPE_Vec3, align 4
  %37 = alloca %struct.TPE_Vec3, align 4
  %38 = alloca { i64, i32 }, align 4
  %39 = alloca { i64, i32 }, align 8
  %40 = alloca { i64, i32 }, align 4
  %41 = alloca { i64, i32 }, align 4
  %42 = alloca { i64, i32 }, align 8
  %43 = alloca { i64, i32 }, align 4
  %44 = alloca %struct.TPE_Vec3, align 4
  %45 = alloca { i64, i32 }, align 8
  %46 = alloca i32, align 4
  %47 = alloca %struct.TPE_Vec3, align 4
  %48 = alloca { i64, i32 }, align 4
  %49 = alloca { i64, i32 }, align 4
  %50 = alloca { i64, i32 }, align 8
  %51 = alloca %struct.TPE_Vec3, align 4
  %52 = alloca %struct.TPE_Vec3, align 4
  %53 = alloca { i64, i32 }, align 4
  %54 = alloca { i64, i32 }, align 8
  %55 = alloca { i64, i32 }, align 4
  %56 = alloca { i64, i32 }, align 4
  %57 = alloca { i64, i32 }, align 8
  %58 = alloca { i64, i32 }, align 4
  %59 = alloca %struct.TPE_Vec3, align 4
  %60 = alloca { i64, i32 }, align 8
  %61 = alloca %struct.TPE_Vec3, align 4
  %62 = alloca { i64, i32 }, align 4
  %63 = alloca { i64, i32 }, align 4
  %64 = alloca { i64, i32 }, align 8
  %65 = alloca %struct.TPE_Vec3, align 4
  %66 = alloca %struct.TPE_Vec3, align 4
  %67 = alloca { i64, i32 }, align 8
  %68 = alloca { i64, i32 }, align 4
  %69 = alloca { i64, i32 }, align 4
  %70 = alloca { i64, i32 }, align 8
  %71 = alloca %struct.TPE_Vec3, align 4
  %72 = alloca { i64, i32 }, align 4
  %73 = alloca { i64, i32 }, align 8
  %74 = alloca %struct.TPE_Vec3, align 4
  %75 = alloca { i64, i32 }, align 4
  %76 = alloca { i64, i32 }, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %10) #3
  %77 = load ptr, ptr %6, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.TPE_Joint, ptr %77, i32 0, i32 0
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.TPE_Joint, ptr %80, i32 0, i32 0
  %82 = load ptr, ptr %6, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.TPE_Joint, ptr %82, i32 0, i32 2
  %84 = load i8, ptr %83, align 2, !tbaa !11
  %85 = zext i8 %84 to i32
  %86 = mul nsw i32 %85, 32
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %81, i64 12, i1 false)
  %87 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 0
  %88 = load i64, ptr %87, align 4
  %89 = getelementptr inbounds { i64, i32 }, ptr %12, i32 0, i32 1
  %90 = load i32, ptr %89, align 4
  %91 = call { i64, i32 } %79(i64 %88, i32 %90, i32 noundef %86)
  store { i64, i32 } %91, ptr %13, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 8 %13, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %78, i64 12, i1 false)
  %92 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 0
  %93 = load i64, ptr %92, align 4
  %94 = getelementptr inbounds { i64, i32 }, ptr %14, i32 0, i32 1
  %95 = load i32, ptr %94, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %11, i64 12, i1 false)
  %96 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 0
  %97 = load i64, ptr %96, align 4
  %98 = getelementptr inbounds { i64, i32 }, ptr %15, i32 0, i32 1
  %99 = load i32, ptr %98, align 4
  %100 = call { i64, i32 } @TPE_vec3Minus(i64 %93, i32 %95, i64 %97, i32 %99)
  store { i64, i32 } %100, ptr %16, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %16, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %10, i64 12, i1 false)
  %101 = getelementptr inbounds { i64, i32 }, ptr %18, i32 0, i32 0
  %102 = load i64, ptr %101, align 4
  %103 = getelementptr inbounds { i64, i32 }, ptr %18, i32 0, i32 1
  %104 = load i32, ptr %103, align 4
  %105 = call i32 @TPE_vec3Len(i64 %102, i32 %104)
  store i32 %105, ptr %17, align 4, !tbaa !9
  %106 = load i32, ptr %17, align 4, !tbaa !9
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.TPE_Joint, ptr %107, i32 0, i32 2
  %109 = load i8, ptr %108, align 2, !tbaa !11
  %110 = zext i8 %109 to i32
  %111 = mul nsw i32 %110, 32
  %112 = icmp sle i32 %106, %111
  br i1 %112, label %113, label %431

113:                                              ; preds = %4
  %114 = load ptr, ptr @_TPE_collisionCallback, align 8, !tbaa !5
  %115 = icmp ne ptr %114, null
  br i1 %115, label %116, label %141

116:                                              ; preds = %113
  %117 = load ptr, ptr @_TPE_collisionCallback, align 8, !tbaa !5
  %118 = load i16, ptr @_TPE_body1Index, align 2, !tbaa !14
  %119 = load i16, ptr @_TPE_joint1Index, align 2, !tbaa !14
  %120 = load i16, ptr @_TPE_body2Index, align 2, !tbaa !14
  %121 = load i16, ptr @_TPE_joint2Index, align 2, !tbaa !14
  %122 = load ptr, ptr %6, align 8, !tbaa !5
  %123 = getelementptr inbounds %struct.TPE_Joint, ptr %122, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %20, ptr align 4 %123, i64 12, i1 false)
  %124 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 0
  %125 = load i64, ptr %124, align 4
  %126 = getelementptr inbounds { i64, i32 }, ptr %20, i32 0, i32 1
  %127 = load i32, ptr %126, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %10, i64 12, i1 false)
  %128 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 0
  %129 = load i64, ptr %128, align 4
  %130 = getelementptr inbounds { i64, i32 }, ptr %21, i32 0, i32 1
  %131 = load i32, ptr %130, align 4
  %132 = call { i64, i32 } @TPE_vec3Minus(i64 %125, i32 %127, i64 %129, i32 %131)
  store { i64, i32 } %132, ptr %22, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 8 %22, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %23, ptr align 4 %19, i64 12, i1 false)
  %133 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 0
  %134 = load i64, ptr %133, align 4
  %135 = getelementptr inbounds { i64, i32 }, ptr %23, i32 0, i32 1
  %136 = load i32, ptr %135, align 4
  %137 = call zeroext i8 %117(i16 noundef zeroext %118, i16 noundef zeroext %119, i16 noundef zeroext %120, i16 noundef zeroext %121, i64 %134, i32 %136)
  %138 = icmp ne i8 %137, 0
  br i1 %138, label %140, label %139

139:                                              ; preds = %116
  store i8 0, ptr %5, align 1
  store i32 1, ptr %24, align 4
  br label %432

140:                                              ; preds = %116
  br label %141

141:                                              ; preds = %140, %113
  call void @llvm.lifetime.start.p0(i64 12, ptr %25) #3
  %142 = load ptr, ptr %6, align 8, !tbaa !5
  %143 = getelementptr inbounds %struct.TPE_Joint, ptr %142, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %25, ptr align 4 %143, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.start.p0(i64 12, ptr %26) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %27) #3
  store i8 0, ptr %27, align 1, !tbaa !17
  %144 = load i32, ptr %17, align 4, !tbaa !9
  %145 = icmp sgt i32 %144, 0
  br i1 %145, label %146, label %221

146:                                              ; preds = %141
  call void @llvm.lifetime.start.p0(i64 4, ptr %28) #3
  store i32 0, ptr %28, align 4, !tbaa !9
  br label %147

147:                                              ; preds = %216, %146
  %148 = load i32, ptr %28, align 4, !tbaa !9
  %149 = icmp slt i32 %148, 16
  br i1 %149, label %151, label %150

150:                                              ; preds = %147
  store i32 2, ptr %24, align 4
  br label %219

151:                                              ; preds = %147
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %10, i64 12, i1 false), !tbaa.struct !16
  call void @TPE_vec3Normalize(ptr noundef %26)
  call void @llvm.lifetime.start.p0(i64 12, ptr %29) #3
  %152 = load ptr, ptr %6, align 8, !tbaa !5
  %153 = getelementptr inbounds %struct.TPE_Joint, ptr %152, i32 0, i32 2
  %154 = load i8, ptr %153, align 2, !tbaa !11
  %155 = zext i8 %154 to i32
  %156 = mul nsw i32 %155, 32
  %157 = load i32, ptr %17, align 4, !tbaa !9
  %158 = sub nsw i32 %156, %157
  %159 = add nsw i32 %158, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 4 %26, i64 12, i1 false)
  %160 = getelementptr inbounds { i64, i32 }, ptr %30, i32 0, i32 0
  %161 = load i64, ptr %160, align 4
  %162 = getelementptr inbounds { i64, i32 }, ptr %30, i32 0, i32 1
  %163 = load i32, ptr %162, align 4
  %164 = call { i64, i32 } @TPE_vec3Times(i64 %161, i32 %163, i32 noundef %159)
  store { i64, i32 } %164, ptr %31, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 8 %31, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %29, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %29) #3
  %165 = load ptr, ptr %6, align 8, !tbaa !5
  %166 = getelementptr inbounds %struct.TPE_Joint, ptr %165, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 12, ptr %32) #3
  %167 = load ptr, ptr %6, align 8, !tbaa !5
  %168 = getelementptr inbounds %struct.TPE_Joint, ptr %167, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %33, ptr align 4 %168, i64 12, i1 false)
  %169 = getelementptr inbounds { i64, i32 }, ptr %33, i32 0, i32 0
  %170 = load i64, ptr %169, align 4
  %171 = getelementptr inbounds { i64, i32 }, ptr %33, i32 0, i32 1
  %172 = load i32, ptr %171, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %34, ptr align 4 %26, i64 12, i1 false)
  %173 = getelementptr inbounds { i64, i32 }, ptr %34, i32 0, i32 0
  %174 = load i64, ptr %173, align 4
  %175 = getelementptr inbounds { i64, i32 }, ptr %34, i32 0, i32 1
  %176 = load i32, ptr %175, align 4
  %177 = call { i64, i32 } @TPE_vec3Plus(i64 %170, i32 %172, i64 %174, i32 %176)
  store { i64, i32 } %177, ptr %35, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %32, ptr align 8 %35, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %166, ptr align 4 %32, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %32) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %36) #3
  %178 = load ptr, ptr %6, align 8, !tbaa !5
  %179 = getelementptr inbounds %struct.TPE_Joint, ptr %178, i32 0, i32 0
  %180 = load ptr, ptr %9, align 8, !tbaa !5
  %181 = load ptr, ptr %6, align 8, !tbaa !5
  %182 = getelementptr inbounds %struct.TPE_Joint, ptr %181, i32 0, i32 0
  %183 = load ptr, ptr %6, align 8, !tbaa !5
  %184 = getelementptr inbounds %struct.TPE_Joint, ptr %183, i32 0, i32 2
  %185 = load i8, ptr %184, align 2, !tbaa !11
  %186 = zext i8 %185 to i32
  %187 = mul nsw i32 %186, 32
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %38, ptr align 4 %182, i64 12, i1 false)
  %188 = getelementptr inbounds { i64, i32 }, ptr %38, i32 0, i32 0
  %189 = load i64, ptr %188, align 4
  %190 = getelementptr inbounds { i64, i32 }, ptr %38, i32 0, i32 1
  %191 = load i32, ptr %190, align 4
  %192 = call { i64, i32 } %180(i64 %189, i32 %191, i32 noundef %187)
  store { i64, i32 } %192, ptr %39, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %37, ptr align 8 %39, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %40, ptr align 4 %179, i64 12, i1 false)
  %193 = getelementptr inbounds { i64, i32 }, ptr %40, i32 0, i32 0
  %194 = load i64, ptr %193, align 4
  %195 = getelementptr inbounds { i64, i32 }, ptr %40, i32 0, i32 1
  %196 = load i32, ptr %195, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %41, ptr align 4 %37, i64 12, i1 false)
  %197 = getelementptr inbounds { i64, i32 }, ptr %41, i32 0, i32 0
  %198 = load i64, ptr %197, align 4
  %199 = getelementptr inbounds { i64, i32 }, ptr %41, i32 0, i32 1
  %200 = load i32, ptr %199, align 4
  %201 = call { i64, i32 } @TPE_vec3Minus(i64 %194, i32 %196, i64 %198, i32 %200)
  store { i64, i32 } %201, ptr %42, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %36, ptr align 8 %42, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %36, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %36) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %43, ptr align 4 %10, i64 12, i1 false)
  %202 = getelementptr inbounds { i64, i32 }, ptr %43, i32 0, i32 0
  %203 = load i64, ptr %202, align 4
  %204 = getelementptr inbounds { i64, i32 }, ptr %43, i32 0, i32 1
  %205 = load i32, ptr %204, align 4
  %206 = call i32 @TPE_vec3Len(i64 %203, i32 %205)
  store i32 %206, ptr %17, align 4, !tbaa !9
  %207 = load i32, ptr %17, align 4, !tbaa !9
  %208 = load ptr, ptr %6, align 8, !tbaa !5
  %209 = getelementptr inbounds %struct.TPE_Joint, ptr %208, i32 0, i32 2
  %210 = load i8, ptr %209, align 2, !tbaa !11
  %211 = zext i8 %210 to i32
  %212 = mul nsw i32 %211, 32
  %213 = icmp sge i32 %207, %212
  br i1 %213, label %214, label %215

214:                                              ; preds = %151
  store i8 1, ptr %27, align 1, !tbaa !17
  store i32 2, ptr %24, align 4
  br label %219

215:                                              ; preds = %151
  br label %216

216:                                              ; preds = %215
  %217 = load i32, ptr %28, align 4, !tbaa !9
  %218 = add nsw i32 %217, 1
  store i32 %218, ptr %28, align 4, !tbaa !9
  br label %147, !llvm.loop !18

219:                                              ; preds = %214, %150
  call void @llvm.lifetime.end.p0(i64 4, ptr %28) #3
  br label %220

220:                                              ; preds = %219
  br label %221

221:                                              ; preds = %220, %141
  %222 = load i8, ptr %27, align 1, !tbaa !17
  %223 = icmp ne i8 %222, 0
  br i1 %223, label %314, label %224

224:                                              ; preds = %221
  call void @llvm.lifetime.start.p0(i64 12, ptr %44) #3
  %225 = load ptr, ptr %6, align 8, !tbaa !5
  %226 = getelementptr inbounds %struct.TPE_Joint, ptr %225, i32 0, i32 1
  %227 = getelementptr inbounds [3 x i16], ptr %226, i64 0, i64 0
  %228 = load i16, ptr %227, align 4, !tbaa !14
  %229 = sext i16 %228 to i32
  %230 = mul nsw i32 -1, %229
  %231 = load ptr, ptr %6, align 8, !tbaa !5
  %232 = getelementptr inbounds %struct.TPE_Joint, ptr %231, i32 0, i32 1
  %233 = getelementptr inbounds [3 x i16], ptr %232, i64 0, i64 1
  %234 = load i16, ptr %233, align 2, !tbaa !14
  %235 = sext i16 %234 to i32
  %236 = mul nsw i32 -1, %235
  %237 = load ptr, ptr %6, align 8, !tbaa !5
  %238 = getelementptr inbounds %struct.TPE_Joint, ptr %237, i32 0, i32 1
  %239 = getelementptr inbounds [3 x i16], ptr %238, i64 0, i64 2
  %240 = load i16, ptr %239, align 4, !tbaa !14
  %241 = sext i16 %240 to i32
  %242 = mul nsw i32 -1, %241
  %243 = call { i64, i32 } @TPE_vec3(i32 noundef %230, i32 noundef %236, i32 noundef %242)
  store { i64, i32 } %243, ptr %45, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %44, ptr align 8 %45, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %44, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %44) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %46) #3
  store i32 0, ptr %46, align 4, !tbaa !9
  br label %244

244:                                              ; preds = %309, %224
  %245 = load i32, ptr %46, align 4, !tbaa !9
  %246 = icmp slt i32 %245, 16
  br i1 %246, label %248, label %247

247:                                              ; preds = %244
  store i32 5, ptr %24, align 4
  br label %312

248:                                              ; preds = %244
  %249 = load ptr, ptr %6, align 8, !tbaa !5
  %250 = getelementptr inbounds %struct.TPE_Joint, ptr %249, i32 0, i32 0
  call void @llvm.lifetime.start.p0(i64 12, ptr %47) #3
  %251 = load ptr, ptr %6, align 8, !tbaa !5
  %252 = getelementptr inbounds %struct.TPE_Joint, ptr %251, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %48, ptr align 4 %252, i64 12, i1 false)
  %253 = getelementptr inbounds { i64, i32 }, ptr %48, i32 0, i32 0
  %254 = load i64, ptr %253, align 4
  %255 = getelementptr inbounds { i64, i32 }, ptr %48, i32 0, i32 1
  %256 = load i32, ptr %255, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %49, ptr align 4 %26, i64 12, i1 false)
  %257 = getelementptr inbounds { i64, i32 }, ptr %49, i32 0, i32 0
  %258 = load i64, ptr %257, align 4
  %259 = getelementptr inbounds { i64, i32 }, ptr %49, i32 0, i32 1
  %260 = load i32, ptr %259, align 4
  %261 = call { i64, i32 } @TPE_vec3Plus(i64 %254, i32 %256, i64 %258, i32 %260)
  store { i64, i32 } %261, ptr %50, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %47, ptr align 8 %50, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %250, ptr align 4 %47, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %47) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %51) #3
  %262 = load ptr, ptr %6, align 8, !tbaa !5
  %263 = getelementptr inbounds %struct.TPE_Joint, ptr %262, i32 0, i32 0
  %264 = load ptr, ptr %9, align 8, !tbaa !5
  %265 = load ptr, ptr %6, align 8, !tbaa !5
  %266 = getelementptr inbounds %struct.TPE_Joint, ptr %265, i32 0, i32 0
  %267 = load ptr, ptr %6, align 8, !tbaa !5
  %268 = getelementptr inbounds %struct.TPE_Joint, ptr %267, i32 0, i32 2
  %269 = load i8, ptr %268, align 2, !tbaa !11
  %270 = zext i8 %269 to i32
  %271 = mul nsw i32 %270, 32
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %53, ptr align 4 %266, i64 12, i1 false)
  %272 = getelementptr inbounds { i64, i32 }, ptr %53, i32 0, i32 0
  %273 = load i64, ptr %272, align 4
  %274 = getelementptr inbounds { i64, i32 }, ptr %53, i32 0, i32 1
  %275 = load i32, ptr %274, align 4
  %276 = call { i64, i32 } %264(i64 %273, i32 %275, i32 noundef %271)
  store { i64, i32 } %276, ptr %54, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %52, ptr align 8 %54, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %55, ptr align 4 %263, i64 12, i1 false)
  %277 = getelementptr inbounds { i64, i32 }, ptr %55, i32 0, i32 0
  %278 = load i64, ptr %277, align 4
  %279 = getelementptr inbounds { i64, i32 }, ptr %55, i32 0, i32 1
  %280 = load i32, ptr %279, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %56, ptr align 4 %52, i64 12, i1 false)
  %281 = getelementptr inbounds { i64, i32 }, ptr %56, i32 0, i32 0
  %282 = load i64, ptr %281, align 4
  %283 = getelementptr inbounds { i64, i32 }, ptr %56, i32 0, i32 1
  %284 = load i32, ptr %283, align 4
  %285 = call { i64, i32 } @TPE_vec3Minus(i64 %278, i32 %280, i64 %282, i32 %284)
  store { i64, i32 } %285, ptr %57, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %51, ptr align 8 %57, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %51, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %51) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %58, ptr align 4 %10, i64 12, i1 false)
  %286 = getelementptr inbounds { i64, i32 }, ptr %58, i32 0, i32 0
  %287 = load i64, ptr %286, align 4
  %288 = getelementptr inbounds { i64, i32 }, ptr %58, i32 0, i32 1
  %289 = load i32, ptr %288, align 4
  %290 = call i32 @TPE_vec3Len(i64 %287, i32 %289)
  store i32 %290, ptr %17, align 4, !tbaa !9
  %291 = load i32, ptr %17, align 4, !tbaa !9
  %292 = load ptr, ptr %6, align 8, !tbaa !5
  %293 = getelementptr inbounds %struct.TPE_Joint, ptr %292, i32 0, i32 2
  %294 = load i8, ptr %293, align 2, !tbaa !11
  %295 = zext i8 %294 to i32
  %296 = mul nsw i32 %295, 32
  %297 = icmp sge i32 %291, %296
  br i1 %297, label %298, label %299

298:                                              ; preds = %248
  store i8 1, ptr %27, align 1, !tbaa !17
  store i32 5, ptr %24, align 4
  br label %312

299:                                              ; preds = %248
  %300 = getelementptr inbounds %struct.TPE_Vec3, ptr %26, i32 0, i32 0
  %301 = load i32, ptr %300, align 4, !tbaa !20
  %302 = sdiv i32 %301, 2
  store i32 %302, ptr %300, align 4, !tbaa !20
  %303 = getelementptr inbounds %struct.TPE_Vec3, ptr %26, i32 0, i32 1
  %304 = load i32, ptr %303, align 4, !tbaa !21
  %305 = sdiv i32 %304, 2
  store i32 %305, ptr %303, align 4, !tbaa !21
  %306 = getelementptr inbounds %struct.TPE_Vec3, ptr %26, i32 0, i32 2
  %307 = load i32, ptr %306, align 4, !tbaa !22
  %308 = sdiv i32 %307, 2
  store i32 %308, ptr %306, align 4, !tbaa !22
  br label %309

309:                                              ; preds = %299
  %310 = load i32, ptr %46, align 4, !tbaa !9
  %311 = add nsw i32 %310, 1
  store i32 %311, ptr %46, align 4, !tbaa !9
  br label %244, !llvm.loop !23

312:                                              ; preds = %298, %247
  call void @llvm.lifetime.end.p0(i64 4, ptr %46) #3
  br label %313

313:                                              ; preds = %312
  br label %314

314:                                              ; preds = %313, %221
  %315 = load i8, ptr %27, align 1, !tbaa !17
  %316 = icmp ne i8 %315, 0
  br i1 %316, label %317, label %417

317:                                              ; preds = %314
  call void @llvm.lifetime.start.p0(i64 12, ptr %59) #3
  %318 = load ptr, ptr %6, align 8, !tbaa !5
  %319 = getelementptr inbounds %struct.TPE_Joint, ptr %318, i32 0, i32 1
  %320 = getelementptr inbounds [3 x i16], ptr %319, i64 0, i64 0
  %321 = load i16, ptr %320, align 4, !tbaa !14
  %322 = sext i16 %321 to i32
  %323 = load ptr, ptr %6, align 8, !tbaa !5
  %324 = getelementptr inbounds %struct.TPE_Joint, ptr %323, i32 0, i32 1
  %325 = getelementptr inbounds [3 x i16], ptr %324, i64 0, i64 1
  %326 = load i16, ptr %325, align 2, !tbaa !14
  %327 = sext i16 %326 to i32
  %328 = load ptr, ptr %6, align 8, !tbaa !5
  %329 = getelementptr inbounds %struct.TPE_Joint, ptr %328, i32 0, i32 1
  %330 = getelementptr inbounds [3 x i16], ptr %329, i64 0, i64 2
  %331 = load i16, ptr %330, align 4, !tbaa !14
  %332 = sext i16 %331 to i32
  %333 = call { i64, i32 } @TPE_vec3(i32 noundef %322, i32 noundef %327, i32 noundef %332)
  store { i64, i32 } %333, ptr %60, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 8 %60, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %61) #3
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %62, ptr align 4 %59, i64 12, i1 false)
  %334 = getelementptr inbounds { i64, i32 }, ptr %62, i32 0, i32 0
  %335 = load i64, ptr %334, align 4
  %336 = getelementptr inbounds { i64, i32 }, ptr %62, i32 0, i32 1
  %337 = load i32, ptr %336, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %63, ptr align 4 %26, i64 12, i1 false)
  %338 = getelementptr inbounds { i64, i32 }, ptr %63, i32 0, i32 0
  %339 = load i64, ptr %338, align 4
  %340 = getelementptr inbounds { i64, i32 }, ptr %63, i32 0, i32 1
  %341 = load i32, ptr %340, align 4
  %342 = call { i64, i32 } @TPE_vec3Project(i64 %335, i32 %337, i64 %339, i32 %341)
  store { i64, i32 } %342, ptr %64, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %61, ptr align 8 %64, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 4 %61, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %61) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %65) #3
  %343 = load ptr, ptr %6, align 8, !tbaa !5
  %344 = getelementptr inbounds %struct.TPE_Joint, ptr %343, i32 0, i32 1
  %345 = getelementptr inbounds [3 x i16], ptr %344, i64 0, i64 0
  %346 = load i16, ptr %345, align 4, !tbaa !14
  %347 = sext i16 %346 to i32
  %348 = load ptr, ptr %6, align 8, !tbaa !5
  %349 = getelementptr inbounds %struct.TPE_Joint, ptr %348, i32 0, i32 1
  %350 = getelementptr inbounds [3 x i16], ptr %349, i64 0, i64 1
  %351 = load i16, ptr %350, align 2, !tbaa !14
  %352 = sext i16 %351 to i32
  %353 = load ptr, ptr %6, align 8, !tbaa !5
  %354 = getelementptr inbounds %struct.TPE_Joint, ptr %353, i32 0, i32 1
  %355 = getelementptr inbounds [3 x i16], ptr %354, i64 0, i64 2
  %356 = load i16, ptr %355, align 4, !tbaa !14
  %357 = sext i16 %356 to i32
  %358 = call { i64, i32 } @TPE_vec3(i32 noundef %347, i32 noundef %352, i32 noundef %357)
  store { i64, i32 } %358, ptr %67, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %66, ptr align 8 %67, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %68, ptr align 4 %66, i64 12, i1 false)
  %359 = getelementptr inbounds { i64, i32 }, ptr %68, i32 0, i32 0
  %360 = load i64, ptr %359, align 4
  %361 = getelementptr inbounds { i64, i32 }, ptr %68, i32 0, i32 1
  %362 = load i32, ptr %361, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %69, ptr align 4 %59, i64 12, i1 false)
  %363 = getelementptr inbounds { i64, i32 }, ptr %69, i32 0, i32 0
  %364 = load i64, ptr %363, align 4
  %365 = getelementptr inbounds { i64, i32 }, ptr %69, i32 0, i32 1
  %366 = load i32, ptr %365, align 4
  %367 = call { i64, i32 } @TPE_vec3Minus(i64 %360, i32 %362, i64 %364, i32 %366)
  store { i64, i32 } %367, ptr %70, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %65, ptr align 8 %70, i64 12, i1 false)
  call void @llvm.lifetime.start.p0(i64 12, ptr %71) #3
  %368 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %72, ptr align 4 %65, i64 12, i1 false)
  %369 = getelementptr inbounds { i64, i32 }, ptr %72, i32 0, i32 0
  %370 = load i64, ptr %369, align 4
  %371 = getelementptr inbounds { i64, i32 }, ptr %72, i32 0, i32 1
  %372 = load i32, ptr %371, align 4
  %373 = call { i64, i32 } @TPE_vec3Times(i64 %370, i32 %372, i32 noundef %368)
  store { i64, i32 } %373, ptr %73, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %71, ptr align 8 %73, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %65, ptr align 4 %71, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %71) #3
  call void @llvm.lifetime.start.p0(i64 12, ptr %74) #3
  %374 = load i32, ptr %7, align 4, !tbaa !9
  %375 = add nsw i32 512, %374
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %75, ptr align 4 %59, i64 12, i1 false)
  %376 = getelementptr inbounds { i64, i32 }, ptr %75, i32 0, i32 0
  %377 = load i64, ptr %376, align 4
  %378 = getelementptr inbounds { i64, i32 }, ptr %75, i32 0, i32 1
  %379 = load i32, ptr %378, align 4
  %380 = call { i64, i32 } @TPE_vec3Times(i64 %377, i32 %379, i32 noundef %375)
  store { i64, i32 } %380, ptr %76, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %74, ptr align 8 %76, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %59, ptr align 4 %74, i64 12, i1 false), !tbaa.struct !16
  call void @llvm.lifetime.end.p0(i64 12, ptr %74) #3
  %381 = getelementptr inbounds %struct.TPE_Vec3, ptr %59, i32 0, i32 0
  %382 = load i32, ptr %381, align 4, !tbaa !20
  %383 = getelementptr inbounds %struct.TPE_Vec3, ptr %65, i32 0, i32 0
  %384 = load i32, ptr %383, align 4, !tbaa !20
  %385 = add nsw i32 %382, %384
  %386 = load ptr, ptr %6, align 8, !tbaa !5
  %387 = getelementptr inbounds %struct.TPE_Joint, ptr %386, i32 0, i32 1
  %388 = getelementptr inbounds [3 x i16], ptr %387, i64 0, i64 0
  %389 = load i16, ptr %388, align 4, !tbaa !14
  %390 = sext i16 %389 to i32
  %391 = sub nsw i32 %390, %385
  %392 = trunc i32 %391 to i16
  store i16 %392, ptr %388, align 4, !tbaa !14
  %393 = getelementptr inbounds %struct.TPE_Vec3, ptr %59, i32 0, i32 1
  %394 = load i32, ptr %393, align 4, !tbaa !21
  %395 = getelementptr inbounds %struct.TPE_Vec3, ptr %65, i32 0, i32 1
  %396 = load i32, ptr %395, align 4, !tbaa !21
  %397 = add nsw i32 %394, %396
  %398 = load ptr, ptr %6, align 8, !tbaa !5
  %399 = getelementptr inbounds %struct.TPE_Joint, ptr %398, i32 0, i32 1
  %400 = getelementptr inbounds [3 x i16], ptr %399, i64 0, i64 1
  %401 = load i16, ptr %400, align 2, !tbaa !14
  %402 = sext i16 %401 to i32
  %403 = sub nsw i32 %402, %397
  %404 = trunc i32 %403 to i16
  store i16 %404, ptr %400, align 2, !tbaa !14
  %405 = getelementptr inbounds %struct.TPE_Vec3, ptr %59, i32 0, i32 2
  %406 = load i32, ptr %405, align 4, !tbaa !22
  %407 = getelementptr inbounds %struct.TPE_Vec3, ptr %65, i32 0, i32 2
  %408 = load i32, ptr %407, align 4, !tbaa !22
  %409 = add nsw i32 %406, %408
  %410 = load ptr, ptr %6, align 8, !tbaa !5
  %411 = getelementptr inbounds %struct.TPE_Joint, ptr %410, i32 0, i32 1
  %412 = getelementptr inbounds [3 x i16], ptr %411, i64 0, i64 2
  %413 = load i16, ptr %412, align 4, !tbaa !14
  %414 = sext i16 %413 to i32
  %415 = sub nsw i32 %414, %409
  %416 = trunc i32 %415 to i16
  store i16 %416, ptr %412, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 12, ptr %65) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %59) #3
  br label %429

417:                                              ; preds = %314
  %418 = load ptr, ptr %6, align 8, !tbaa !5
  %419 = getelementptr inbounds %struct.TPE_Joint, ptr %418, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %419, ptr align 4 %25, i64 12, i1 false), !tbaa.struct !16
  %420 = load ptr, ptr %6, align 8, !tbaa !5
  %421 = getelementptr inbounds %struct.TPE_Joint, ptr %420, i32 0, i32 1
  %422 = getelementptr inbounds [3 x i16], ptr %421, i64 0, i64 0
  store i16 0, ptr %422, align 4, !tbaa !14
  %423 = load ptr, ptr %6, align 8, !tbaa !5
  %424 = getelementptr inbounds %struct.TPE_Joint, ptr %423, i32 0, i32 1
  %425 = getelementptr inbounds [3 x i16], ptr %424, i64 0, i64 1
  store i16 0, ptr %425, align 2, !tbaa !14
  %426 = load ptr, ptr %6, align 8, !tbaa !5
  %427 = getelementptr inbounds %struct.TPE_Joint, ptr %426, i32 0, i32 1
  %428 = getelementptr inbounds [3 x i16], ptr %427, i64 0, i64 2
  store i16 0, ptr %428, align 4, !tbaa !14
  store i8 2, ptr %5, align 1
  store i32 1, ptr %24, align 4
  br label %430

429:                                              ; preds = %317
  store i8 1, ptr %5, align 1
  store i32 1, ptr %24, align 4
  br label %430

430:                                              ; preds = %429, %417
  call void @llvm.lifetime.end.p0(i64 1, ptr %27) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %26) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %25) #3
  br label %432

431:                                              ; preds = %4
  store i8 0, ptr %5, align 1
  store i32 1, ptr %24, align 4
  br label %432

432:                                              ; preds = %431, %430, %139
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr %10) #3
  %433 = load i8, ptr %5, align 1
  ret i8 %433
}

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !7, i64 18}
!12 = !{!"", !13, i64 0, !7, i64 12, !7, i64 18}
!13 = !{!"", !10, i64 0, !10, i64 4, !10, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{i64 0, i64 4, !9, i64 4, i64 4, !9, i64 8, i64 4, !9}
!17 = !{!7, !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!13, !10, i64 0}
!21 = !{!13, !10, i64 4}
!22 = !{!13, !10, i64 8}
!23 = distinct !{!23, !19}


; 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.TPE_Vec3 = type { i32, i32, i32 }

@_TPE_collisionCallback = external dso_local local_unnamed_addr global ptr, align 8
@_TPE_body1Index = external dso_local local_unnamed_addr global i16, align 2
@_TPE_body2Index = external dso_local local_unnamed_addr global i16, align 2
@_TPE_joint1Index = external dso_local local_unnamed_addr global i16, align 2
@_TPE_joint2Index = external dso_local local_unnamed_addr global i16, align 2

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @TPE_vec3Len(i64, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Minus(i64, i32, i64, i32) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Plus(i64, i32, i64, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Project(i64, i32, i64, i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local { i64, i32 } @TPE_vec3Times(i64, i32, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 3) i8 @TPE_jointEnvironmentResolveCollision(ptr nocapture noundef %0, i32 noundef %1, i32 noundef %2, ptr nocapture noundef readonly %3) local_unnamed_addr #1 {
  %5 = alloca %struct.TPE_Vec3, align 4
  %6 = alloca %struct.TPE_Vec3, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 18
  %8 = load i8, ptr %7, align 2, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = shl nuw nsw i32 %9, 5
  %.sroa.0160.0.copyload = load i64, ptr %0, align 4
  %.sroa.2161.0..sroa_idx = getelementptr inbounds i8, ptr %0, i64 8
  %.sroa.2161.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %11 = tail call { i64, i32 } %3(i64 %.sroa.0160.0.copyload, i32 %.sroa.2161.0.copyload, i32 noundef %10) #3
  %.fca.0.extract156 = extractvalue { i64, i32 } %11, 0
  %.fca.1.extract157 = extractvalue { i64, i32 } %11, 1
  %.sroa.0154.0.copyload = load i64, ptr %0, align 4
  %.sroa.2155.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %12 = tail call { i64, i32 } @TPE_vec3Minus(i64 %.sroa.0154.0.copyload, i32 %.sroa.2155.0.copyload, i64 %.fca.0.extract156, i32 %.fca.1.extract157)
  %.fca.0.extract148 = extractvalue { i64, i32 } %12, 0
  %.fca.1.extract149 = extractvalue { i64, i32 } %12, 1
  %13 = tail call i32 @TPE_vec3Len(i64 %.fca.0.extract148, i32 %.fca.1.extract149)
  %14 = load i8, ptr %7, align 2, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = shl nuw nsw i32 %15, 5
  %.not = icmp sgt i32 %13, %16
  br i1 %.not, label %109, label %17

17:                                               ; preds = %4
  %18 = load ptr, ptr @_TPE_collisionCallback, align 8, !tbaa !11
  %.not217 = icmp eq ptr %18, null
  br i1 %.not217, label %26, label %19

19:                                               ; preds = %17
  %20 = load i16, ptr @_TPE_body1Index, align 2, !tbaa !13
  %21 = load i16, ptr @_TPE_joint1Index, align 2, !tbaa !13
  %22 = load i16, ptr @_TPE_body2Index, align 2, !tbaa !13
  %23 = load i16, ptr @_TPE_joint2Index, align 2, !tbaa !13
  %.sroa.0137.0.copyload = load i64, ptr %0, align 4
  %.sroa.2138.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %24 = tail call { i64, i32 } @TPE_vec3Minus(i64 %.sroa.0137.0.copyload, i32 %.sroa.2138.0.copyload, i64 %.fca.0.extract148, i32 %.fca.1.extract149)
  %.fca.0.extract131 = extractvalue { i64, i32 } %24, 0
  %.fca.1.extract132 = extractvalue { i64, i32 } %24, 1
  %25 = tail call zeroext i8 %18(i16 noundef zeroext %20, i16 noundef zeroext %21, i16 noundef zeroext %22, i16 noundef zeroext %23, i64 %.fca.0.extract131, i32 %.fca.1.extract132) #3
  %.not218 = icmp eq i8 %25, 0
  br i1 %.not218, label %109, label %26

26:                                               ; preds = %19, %17
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %5)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %5, ptr noundef nonnull align 4 dereferenceable(12) %0, i64 12, i1 false), !tbaa.struct !15
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %6) #3
  %27 = icmp sgt i32 %13, 0
  br i1 %27, label %.preheader, label %.critedge

.preheader:                                       ; preds = %26
  %.sroa.10165.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  br label %30

28:                                               ; preds = %30
  %29 = add nuw nsw i32 %.0212231, 1
  %exitcond = icmp eq i32 %29, 16
  br i1 %exitcond, label %.critedge, label %30, !llvm.loop !17

30:                                               ; preds = %.preheader, %28
  %.sroa.10165.0234 = phi i32 [ %.fca.1.extract149, %.preheader ], [ %.fca.1.extract90, %28 ]
  %.sroa.0164.0233 = phi i64 [ %.fca.0.extract148, %.preheader ], [ %.fca.0.extract89, %28 ]
  %.0209232 = phi i32 [ %13, %.preheader ], [ %42, %28 ]
  %.0212231 = phi i32 [ 0, %.preheader ], [ %29, %28 ]
  store i64 %.sroa.0164.0233, ptr %6, align 8
  store i32 %.sroa.10165.0234, ptr %.sroa.10165.0..sroa_idx, align 8, !tbaa !16
  call void @TPE_vec3Normalize(ptr noundef nonnull %6)
  %31 = load i8, ptr %7, align 2, !tbaa !5
  %32 = zext i8 %31 to i32
  %33 = shl nuw nsw i32 %32, 5
  %reass.sub = sub i32 %33, %.0209232
  %34 = add i32 %reass.sub, 8
  %.sroa.0121.0.copyload = load i64, ptr %6, align 8
  %.sroa.2122.0.copyload = load i32, ptr %.sroa.10165.0..sroa_idx, align 8
  %35 = call { i64, i32 } @TPE_vec3Times(i64 %.sroa.0121.0.copyload, i32 %.sroa.2122.0.copyload, i32 noundef %34)
  %.fca.0.extract117 = extractvalue { i64, i32 } %35, 0
  %.fca.1.extract118 = extractvalue { i64, i32 } %35, 1
  store i64 %.fca.0.extract117, ptr %6, align 8
  store i32 %.fca.1.extract118, ptr %.sroa.10165.0..sroa_idx, align 8, !tbaa !16
  %.sroa.0113.0.copyload = load i64, ptr %0, align 4
  %.sroa.2114.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %36 = call { i64, i32 } @TPE_vec3Plus(i64 %.sroa.0113.0.copyload, i32 %.sroa.2114.0.copyload, i64 %.fca.0.extract117, i32 %.fca.1.extract118)
  %.fca.0.extract107 = extractvalue { i64, i32 } %36, 0
  %.fca.1.extract108 = extractvalue { i64, i32 } %36, 1
  store i64 %.fca.0.extract107, ptr %0, align 4
  store i32 %.fca.1.extract108, ptr %.sroa.2161.0..sroa_idx, align 4, !tbaa !16
  %37 = load i8, ptr %7, align 2, !tbaa !5
  %38 = zext i8 %37 to i32
  %39 = shl nuw nsw i32 %38, 5
  %40 = call { i64, i32 } %3(i64 %.fca.0.extract107, i32 %.fca.1.extract108, i32 noundef %39) #3
  %.fca.0.extract97 = extractvalue { i64, i32 } %40, 0
  %.fca.1.extract98 = extractvalue { i64, i32 } %40, 1
  %.sroa.095.0.copyload = load i64, ptr %0, align 4
  %.sroa.296.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %41 = call { i64, i32 } @TPE_vec3Minus(i64 %.sroa.095.0.copyload, i32 %.sroa.296.0.copyload, i64 %.fca.0.extract97, i32 %.fca.1.extract98)
  %.fca.0.extract89 = extractvalue { i64, i32 } %41, 0
  %.fca.1.extract90 = extractvalue { i64, i32 } %41, 1
  %42 = call i32 @TPE_vec3Len(i64 %.fca.0.extract89, i32 %.fca.1.extract90)
  %43 = load i8, ptr %7, align 2, !tbaa !5
  %44 = zext i8 %43 to i32
  %45 = shl nuw nsw i32 %44, 5
  %.not219 = icmp slt i32 %42, %45
  br i1 %.not219, label %28, label %.critedge226

.critedge:                                        ; preds = %28, %26
  %46 = getelementptr inbounds i8, ptr %0, i64 12
  %47 = load i16, ptr %46, align 4, !tbaa !13
  %48 = sext i16 %47 to i32
  %49 = sub nsw i32 0, %48
  %50 = getelementptr inbounds i8, ptr %0, i64 14
  %51 = load i16, ptr %50, align 2, !tbaa !13
  %52 = sext i16 %51 to i32
  %53 = sub nsw i32 0, %52
  %54 = getelementptr inbounds i8, ptr %0, i64 16
  %55 = load i16, ptr %54, align 4, !tbaa !13
  %56 = sext i16 %55 to i32
  %57 = sub nsw i32 0, %56
  %58 = call { i64, i32 } @TPE_vec3(i32 noundef %49, i32 noundef %53, i32 noundef %57)
  %.fca.0.extract81 = extractvalue { i64, i32 } %58, 0
  %.fca.1.extract82 = extractvalue { i64, i32 } %58, 1
  store i64 %.fca.0.extract81, ptr %6, align 8
  %.sroa.486.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  store i32 %.fca.1.extract82, ptr %.sroa.486.0..sroa_idx, align 8, !tbaa !16
  br label %59

59:                                               ; preds = %.critedge, %70
  %.sroa.275.0.copyload = phi i32 [ %.fca.1.extract82, %.critedge ], [ %74, %70 ]
  %.0213235 = phi i32 [ 0, %.critedge ], [ %75, %70 ]
  %.sroa.076.0.copyload = load i64, ptr %0, align 4
  %.sroa.277.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %.sroa.074.0.copyload = load i64, ptr %6, align 8
  %60 = call { i64, i32 } @TPE_vec3Plus(i64 %.sroa.076.0.copyload, i32 %.sroa.277.0.copyload, i64 %.sroa.074.0.copyload, i32 %.sroa.275.0.copyload)
  %.fca.0.extract70 = extractvalue { i64, i32 } %60, 0
  %.fca.1.extract71 = extractvalue { i64, i32 } %60, 1
  store i64 %.fca.0.extract70, ptr %0, align 4
  store i32 %.fca.1.extract71, ptr %.sroa.2161.0..sroa_idx, align 4, !tbaa !16
  %61 = load i8, ptr %7, align 2, !tbaa !5
  %62 = zext i8 %61 to i32
  %63 = shl nuw nsw i32 %62, 5
  %64 = call { i64, i32 } %3(i64 %.fca.0.extract70, i32 %.fca.1.extract71, i32 noundef %63) #3
  %.fca.0.extract60 = extractvalue { i64, i32 } %64, 0
  %.fca.1.extract61 = extractvalue { i64, i32 } %64, 1
  %.sroa.058.0.copyload = load i64, ptr %0, align 4
  %.sroa.259.0.copyload = load i32, ptr %.sroa.2161.0..sroa_idx, align 4
  %65 = call { i64, i32 } @TPE_vec3Minus(i64 %.sroa.058.0.copyload, i32 %.sroa.259.0.copyload, i64 %.fca.0.extract60, i32 %.fca.1.extract61)
  %.fca.0.extract52 = extractvalue { i64, i32 } %65, 0
  %.fca.1.extract53 = extractvalue { i64, i32 } %65, 1
  %66 = call i32 @TPE_vec3Len(i64 %.fca.0.extract52, i32 %.fca.1.extract53)
  %67 = load i8, ptr %7, align 2, !tbaa !5
  %68 = zext i8 %67 to i32
  %69 = shl nuw nsw i32 %68, 5
  %.not221 = icmp slt i32 %66, %69
  br i1 %.not221, label %70, label %.critedge226

70:                                               ; preds = %59
  %71 = load <2 x i32>, ptr %6, align 8, !tbaa !16
  %72 = sdiv <2 x i32> %71, <i32 2, i32 2>
  store <2 x i32> %72, ptr %6, align 8, !tbaa !16
  %73 = load i32, ptr %.sroa.486.0..sroa_idx, align 8, !tbaa !19
  %74 = sdiv i32 %73, 2
  store i32 %74, ptr %.sroa.486.0..sroa_idx, align 8, !tbaa !19
  %75 = add nuw nsw i32 %.0213235, 1
  %exitcond237 = icmp eq i32 %75, 16
  br i1 %exitcond237, label %.critedge228, label %59, !llvm.loop !20

.critedge226:                                     ; preds = %30, %59
  %76 = getelementptr inbounds i8, ptr %0, i64 12
  %77 = load i16, ptr %76, align 4, !tbaa !13
  %78 = sext i16 %77 to i32
  %79 = getelementptr inbounds i8, ptr %0, i64 14
  %80 = load i16, ptr %79, align 2, !tbaa !13
  %81 = sext i16 %80 to i32
  %82 = getelementptr inbounds i8, ptr %0, i64 16
  %83 = load i16, ptr %82, align 4, !tbaa !13
  %84 = sext i16 %83 to i32
  %85 = call { i64, i32 } @TPE_vec3(i32 noundef %78, i32 noundef %81, i32 noundef %84)
  %.fca.0.extract39 = extractvalue { i64, i32 } %85, 0
  %.fca.1.extract40 = extractvalue { i64, i32 } %85, 1
  %.sroa.033.0.copyload = load i64, ptr %6, align 8
  %.sroa.234.0..sroa_idx = getelementptr inbounds i8, ptr %6, i64 8
  %.sroa.234.0.copyload = load i32, ptr %.sroa.234.0..sroa_idx, align 8
  %86 = call { i64, i32 } @TPE_vec3Project(i64 %.fca.0.extract39, i32 %.fca.1.extract40, i64 %.sroa.033.0.copyload, i32 %.sroa.234.0.copyload)
  %.fca.0.extract29 = extractvalue { i64, i32 } %86, 0
  %.fca.1.extract30 = extractvalue { i64, i32 } %86, 1
  %87 = load i16, ptr %76, align 4, !tbaa !13
  %88 = sext i16 %87 to i32
  %89 = load i16, ptr %79, align 2, !tbaa !13
  %90 = sext i16 %89 to i32
  %91 = load i16, ptr %82, align 4, !tbaa !13
  %92 = sext i16 %91 to i32
  %93 = call { i64, i32 } @TPE_vec3(i32 noundef %88, i32 noundef %90, i32 noundef %92)
  %.fca.0.extract20 = extractvalue { i64, i32 } %93, 0
  %.fca.1.extract21 = extractvalue { i64, i32 } %93, 1
  %94 = call { i64, i32 } @TPE_vec3Minus(i64 %.fca.0.extract20, i32 %.fca.1.extract21, i64 %.fca.0.extract29, i32 %.fca.1.extract30)
  %.fca.0.extract12 = extractvalue { i64, i32 } %94, 0
  %.fca.1.extract13 = extractvalue { i64, i32 } %94, 1
  %95 = call { i64, i32 } @TPE_vec3Times(i64 %.fca.0.extract12, i32 %.fca.1.extract13, i32 noundef %2)
  %.fca.0.extract4 = extractvalue { i64, i32 } %95, 0
  %.fca.1.extract5 = extractvalue { i64, i32 } %95, 1
  %96 = add nsw i32 %1, 512
  %97 = call { i64, i32 } @TPE_vec3Times(i64 %.fca.0.extract29, i32 %.fca.1.extract30, i32 noundef %96)
  %.fca.0.extract = extractvalue { i64, i32 } %97, 0
  %.fca.1.extract = extractvalue { i64, i32 } %97, 1
  %.sroa.043.0.extract.trunc = trunc i64 %.fca.0.extract to i16
  %.sroa.026.0.extract.trunc = trunc i64 %.fca.0.extract4 to i16
  %98 = load i16, ptr %76, align 4, !tbaa !13
  %99 = add i16 %.sroa.026.0.extract.trunc, %.sroa.043.0.extract.trunc
  %100 = sub i16 %98, %99
  store i16 %100, ptr %76, align 4, !tbaa !13
  %.sroa.043.4.extract.shift = lshr i64 %.fca.0.extract, 32
  %.sroa.043.4.extract.trunc = trunc i64 %.sroa.043.4.extract.shift to i16
  %.sroa.026.4.extract.shift = lshr i64 %.fca.0.extract4, 32
  %.sroa.026.4.extract.trunc = trunc i64 %.sroa.026.4.extract.shift to i16
  %101 = add i16 %.sroa.043.4.extract.trunc, %.sroa.026.4.extract.trunc
  %102 = add nsw i32 %.fca.1.extract, %.fca.1.extract5
  %103 = trunc i32 %102 to i16
  %104 = load <2 x i16>, ptr %79, align 2, !tbaa !13
  %105 = insertelement <2 x i16> poison, i16 %101, i64 0
  %106 = insertelement <2 x i16> %105, i16 %103, i64 1
  %107 = sub <2 x i16> %104, %106
  store <2 x i16> %107, ptr %79, align 2, !tbaa !13
  br label %108

.critedge228:                                     ; preds = %70
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(12) %0, ptr noundef nonnull align 4 dereferenceable(12) %5, i64 12, i1 false), !tbaa.struct !15
  store i16 0, ptr %46, align 4, !tbaa !13
  store i16 0, ptr %50, align 2, !tbaa !13
  store i16 0, ptr %54, align 4, !tbaa !13
  br label %108

108:                                              ; preds = %.critedge226, %.critedge228
  %.0 = phi i8 [ 1, %.critedge226 ], [ 2, %.critedge228 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %5)
  br label %109

109:                                              ; preds = %4, %19, %108
  %.1 = phi i8 [ %.0, %108 ], [ 0, %19 ], [ 0, %4 ]
  ret i8 %.1
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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, !9, i64 18}
!6 = !{!"", !7, i64 0, !9, i64 12, !9, i64 18}
!7 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"short", !9, i64 0}
!15 = !{i64 0, i64 4, !16, i64 4, i64 4, !16, i64 8, i64 4, !16}
!16 = !{!8, !8, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!7, !8, i64 8}
!20 = distinct !{!20, !18}


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