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

; 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.b2RayResult = type { %struct.b2ShapeId, %struct.b2Vec2, %struct.b2Vec2, float, i32, i32, i8 }
%struct.b2ShapeId = type { i32, i16, i16 }
%struct.b2Vec2 = type { float, float }
%struct.b2WorldId = type { i16, i16 }
%struct.b2QueryFilter = type { i64, i64 }
%struct.b2RayCastInput = type { %struct.b2Vec2, %struct.b2Vec2, float }
%struct.WorldRayCastContext = type { ptr, ptr, %struct.b2QueryFilter, float, ptr }
%struct.b2TreeStats = type { i32, i32 }
%struct.b2World = type { %struct.b2ArenaAllocator, %struct.b2BroadPhase, %struct.b2ConstraintGraph, %struct.b2IdPool, %struct.b2BodyArray, %struct.b2IdPool, %struct.b2SolverSetArray, %struct.b2IdPool, %struct.b2JointArray, %struct.b2IdPool, %struct.b2ContactArray, %struct.b2IdPool, %struct.b2IslandArray, %struct.b2IdPool, %struct.b2IdPool, %struct.b2ShapeArray, %struct.b2ChainShapeArray, %struct.b2SensorArray, %struct.b2TaskContextArray, %struct.b2SensorTaskContextArray, %struct.b2BodyMoveEventArray, %struct.b2SensorBeginTouchEventArray, %struct.b2ContactBeginTouchEventArray, [2 x %struct.b2SensorEndTouchEventArray], [2 x %struct.b2ContactEndTouchEventArray], i32, %struct.b2ContactHitEventArray, %struct.b2BitSet, %struct.b2BitSet, %struct.b2BitSet, %struct.b2BitSet, i64, i32, %struct.b2Vec2, float, float, float, float, float, float, float, float, ptr, ptr, i16, %struct.b2Profile, ptr, ptr, ptr, ptr, i32, ptr, ptr, ptr, ptr, ptr, float, i32, i32, i16, i8, i8, i8, i8, i8, i8 }
%struct.b2ArenaAllocator = type { ptr, i32, i32, i32, i32, %struct.b2ArenaEntryArray }
%struct.b2ArenaEntryArray = type { ptr, i32, i32 }
%struct.b2BroadPhase = type { [3 x %struct.b2DynamicTree], i32, %struct.b2HashSet, %struct.b2IntArray, ptr, ptr, i32, %struct.b2AtomicInt, %struct.b2HashSet }
%struct.b2DynamicTree = type { ptr, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, i32 }
%struct.b2IntArray = type { ptr, i32, i32 }
%struct.b2AtomicInt = type { i32 }
%struct.b2HashSet = type { ptr, i32, i32 }
%struct.b2ConstraintGraph = type { [12 x %struct.b2GraphColor] }
%struct.b2GraphColor = type { %struct.b2BitSet, %struct.b2ContactSimArray, %struct.b2JointSimArray, %union.anon }
%struct.b2ContactSimArray = type { ptr, i32, i32 }
%struct.b2JointSimArray = type { ptr, i32, i32 }
%union.anon = type { ptr }
%struct.b2BodyArray = type { ptr, i32, i32 }
%struct.b2SolverSetArray = type { ptr, i32, i32 }
%struct.b2JointArray = type { ptr, i32, i32 }
%struct.b2ContactArray = type { ptr, i32, i32 }
%struct.b2IslandArray = type { ptr, i32, i32 }
%struct.b2IdPool = type { %struct.b2IntArray, i32 }
%struct.b2ShapeArray = type { ptr, i32, i32 }
%struct.b2ChainShapeArray = type { ptr, i32, i32 }
%struct.b2SensorArray = type { ptr, i32, i32 }
%struct.b2TaskContextArray = type { ptr, i32, i32 }
%struct.b2SensorTaskContextArray = type { ptr, i32, i32 }
%struct.b2BodyMoveEventArray = type { ptr, i32, i32 }
%struct.b2SensorBeginTouchEventArray = type { ptr, i32, i32 }
%struct.b2ContactBeginTouchEventArray = type { ptr, i32, i32 }
%struct.b2SensorEndTouchEventArray = type { ptr, i32, i32 }
%struct.b2ContactEndTouchEventArray = type { ptr, i32, i32 }
%struct.b2ContactHitEventArray = type { ptr, i32, i32 }
%struct.b2BitSet = type { ptr, i32, i32 }
%struct.b2Profile = type { float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float }

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [29 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @b2GetWorldFromId(i32) #1

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

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

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

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

; 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) #5

declare zeroext i1 @b2IsValidVec2(<2 x float>) #2

declare i64 @b2DynamicTree_RayCast(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @b2World_CastRayClosest(ptr dead_on_unwind noalias writable sret(%struct.b2RayResult) align 4 %0, i32 %1, <2 x float> %2, <2 x float> %3, i64 %4, i64 %5) #6 {
  %7 = alloca %struct.b2WorldId, align 2
  %8 = alloca %struct.b2Vec2, align 4
  %9 = alloca %struct.b2Vec2, align 4
  %10 = alloca %struct.b2QueryFilter, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca %struct.b2RayCastInput, align 4
  %14 = alloca %struct.WorldRayCastContext, align 8
  %15 = alloca i32, align 4
  %16 = alloca %struct.b2TreeStats, align 4
  store i32 %1, ptr %7, align 2
  store <2 x float> %2, ptr %8, align 4
  store <2 x float> %3, ptr %9, align 4
  %17 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 0
  store i64 %4, ptr %17, align 8
  %18 = getelementptr inbounds { i64, i64 }, ptr %10, i32 0, i32 1
  store i64 %5, ptr %18, align 8
  call void @llvm.memset.p0.i64(ptr align 4 %0, i8 0, i64 40, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #7
  %19 = load i32, ptr %7, align 2
  %20 = call ptr @b2GetWorldFromId(i32 %19)
  store ptr %20, ptr %11, align 8, !tbaa !5
  br label %21

21:                                               ; preds = %6
  %22 = load ptr, ptr %11, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.b2World, ptr %22, i32 0, i32 61
  %24 = load i8, ptr %23, align 1, !tbaa !9, !range !26, !noundef !27
  %25 = trunc i8 %24 to i1
  %26 = zext i1 %25 to i32
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %32, label %28

28:                                               ; preds = %21
  %29 = call i32 @b2InternalAssertFcn(ptr noundef @.str.15, ptr noundef @.str.1, i32 noundef 2303)
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @llvm.trap()
  br label %32

32:                                               ; preds = %31, %28, %21
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.b2World, ptr %35, i32 0, i32 61
  %37 = load i8, ptr %36, align 1, !tbaa !9, !range !26, !noundef !27
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %40

39:                                               ; preds = %34
  store i32 1, ptr %12, align 4
  br label %113

40:                                               ; preds = %34
  br label %41

41:                                               ; preds = %40
  %42 = load <2 x float>, ptr %8, align 4
  %43 = call zeroext i1 @b2IsValidVec2(<2 x float> %42)
  br i1 %43, label %48, label %44

44:                                               ; preds = %41
  %45 = call i32 @b2InternalAssertFcn(ptr noundef @.str.64, ptr noundef @.str.1, i32 noundef 2309)
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %48

47:                                               ; preds = %44
  call void @llvm.trap()
  br label %48

48:                                               ; preds = %47, %44, %41
  br label %49

49:                                               ; preds = %48
  br label %50

50:                                               ; preds = %49
  br label %51

51:                                               ; preds = %50
  %52 = load <2 x float>, ptr %9, align 4
  %53 = call zeroext i1 @b2IsValidVec2(<2 x float> %52)
  br i1 %53, label %58, label %54

54:                                               ; preds = %51
  %55 = call i32 @b2InternalAssertFcn(ptr noundef @.str.65, ptr noundef @.str.1, i32 noundef 2310)
  %56 = icmp ne i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %54
  call void @llvm.trap()
  br label %58

58:                                               ; preds = %57, %54, %51
  br label %59

59:                                               ; preds = %58
  br label %60

60:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 20, ptr %13) #7
  %61 = getelementptr inbounds %struct.b2RayCastInput, ptr %13, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %61, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !28
  %62 = getelementptr inbounds %struct.b2RayCastInput, ptr %13, i32 0, i32 1
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %62, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !28
  %63 = getelementptr inbounds %struct.b2RayCastInput, ptr %13, i32 0, i32 2
  store float 1.000000e+00, ptr %63, align 4, !tbaa !30
  call void @llvm.lifetime.start.p0(i64 48, ptr %14) #7
  %64 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 0
  %65 = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %65, ptr %64, align 8, !tbaa !32
  %66 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 1
  store ptr @b2RayCastClosestFcn, ptr %66, align 8, !tbaa !35
  %67 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 2
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %67, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !36
  %68 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 3
  store float 1.000000e+00, ptr %68, align 8, !tbaa !38
  %69 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 4
  store ptr %0, ptr %69, align 8, !tbaa !39
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 0, ptr %15, align 4, !tbaa !40
  br label %70

70:                                               ; preds = %106, %60
  %71 = load i32, ptr %15, align 4, !tbaa !40
  %72 = icmp slt i32 %71, 3
  br i1 %72, label %74, label %73

73:                                               ; preds = %70
  store i32 8, ptr %12, align 4
  br label %109

74:                                               ; preds = %70
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #7
  %75 = load ptr, ptr %11, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.b2World, ptr %75, i32 0, i32 1
  %77 = getelementptr inbounds %struct.b2BroadPhase, ptr %76, i32 0, i32 0
  %78 = getelementptr inbounds [3 x %struct.b2DynamicTree], ptr %77, i64 0, i64 0
  %79 = load i32, ptr %15, align 4, !tbaa !40
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds %struct.b2DynamicTree, ptr %78, i64 %80
  %82 = getelementptr inbounds %struct.b2QueryFilter, ptr %10, i32 0, i32 1
  %83 = load i64, ptr %82, align 8, !tbaa !41
  %84 = call i64 @b2DynamicTree_RayCast(ptr noundef %81, ptr noundef %13, i64 noundef %83, ptr noundef @RayCastCallback, ptr noundef %14)
  store i64 %84, ptr %16, align 4
  %85 = getelementptr inbounds %struct.b2TreeStats, ptr %16, i32 0, i32 0
  %86 = load i32, ptr %85, align 4, !tbaa !42
  %87 = getelementptr inbounds %struct.b2RayResult, ptr %0, i32 0, i32 4
  %88 = load i32, ptr %87, align 4, !tbaa !44
  %89 = add nsw i32 %88, %86
  store i32 %89, ptr %87, align 4, !tbaa !44
  %90 = getelementptr inbounds %struct.b2TreeStats, ptr %16, i32 0, i32 1
  %91 = load i32, ptr %90, align 4, !tbaa !47
  %92 = getelementptr inbounds %struct.b2RayResult, ptr %0, i32 0, i32 5
  %93 = load i32, ptr %92, align 4, !tbaa !48
  %94 = add nsw i32 %93, %91
  store i32 %94, ptr %92, align 4, !tbaa !48
  %95 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 3
  %96 = load float, ptr %95, align 8, !tbaa !38
  %97 = fcmp oeq float %96, 0.000000e+00
  br i1 %97, label %98, label %99

98:                                               ; preds = %74
  store i32 1, ptr %12, align 4
  br label %103

99:                                               ; preds = %74
  %100 = getelementptr inbounds %struct.WorldRayCastContext, ptr %14, i32 0, i32 3
  %101 = load float, ptr %100, align 8, !tbaa !38
  %102 = getelementptr inbounds %struct.b2RayCastInput, ptr %13, i32 0, i32 2
  store float %101, ptr %102, align 4, !tbaa !30
  store i32 0, ptr %12, align 4
  br label %103

103:                                              ; preds = %99, %98
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #7
  %104 = load i32, ptr %12, align 4
  switch i32 %104, label %109 [
    i32 0, label %105
  ]

105:                                              ; preds = %103
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %15, align 4, !tbaa !40
  %108 = add nsw i32 %107, 1
  store i32 %108, ptr %15, align 4, !tbaa !40
  br label %70, !llvm.loop !49

109:                                              ; preds = %103, %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  %110 = load i32, ptr %12, align 4
  switch i32 %110, label %112 [
    i32 8, label %111
  ]

111:                                              ; preds = %109
  store i32 1, ptr %12, align 4
  br label %112

112:                                              ; preds = %111, %109
  call void @llvm.lifetime.end.p0(i64 48, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 20, ptr %13) #7
  br label %113

113:                                              ; preds = %112, %39
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #7
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @b2RayCastClosestFcn(i64, <2 x float>, <2 x float>, float noundef, ptr noundef) #6

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !25, i64 1799}
!10 = !{!"b2World", !11, i64 0, !14, i64 40, !17, i64 336, !18, i64 1008, !13, i64 1032, !18, i64 1048, !13, i64 1072, !18, i64 1088, !13, i64 1112, !18, i64 1128, !13, i64 1152, !18, i64 1168, !13, i64 1192, !18, i64 1208, !18, i64 1232, !13, i64 1256, !13, i64 1272, !13, i64 1288, !13, i64 1304, !13, i64 1320, !13, i64 1336, !13, i64 1352, !13, i64 1368, !7, i64 1384, !7, i64 1416, !12, i64 1448, !13, i64 1456, !19, i64 1472, !19, i64 1488, !19, i64 1504, !19, i64 1520, !20, i64 1536, !12, i64 1544, !21, i64 1548, !22, i64 1556, !22, i64 1560, !22, i64 1564, !22, i64 1568, !22, i64 1572, !22, i64 1576, !22, i64 1580, !22, i64 1584, !6, i64 1592, !6, i64 1600, !23, i64 1608, !24, i64 1612, !6, i64 1704, !6, i64 1712, !6, i64 1720, !6, i64 1728, !12, i64 1736, !6, i64 1744, !6, i64 1752, !6, i64 1760, !6, i64 1768, !6, i64 1776, !22, i64 1784, !12, i64 1788, !12, i64 1792, !23, i64 1796, !25, i64 1798, !25, i64 1799, !25, i64 1800, !25, i64 1801, !25, i64 1802, !25, i64 1803}
!11 = !{!"b2ArenaAllocator", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !13, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !6, i64 0, !12, i64 8, !12, i64 12}
!14 = !{!"b2BroadPhase", !7, i64 0, !12, i64 216, !15, i64 224, !13, i64 240, !6, i64 256, !6, i64 264, !12, i64 272, !16, i64 276, !15, i64 280}
!15 = !{!"b2HashSet", !6, i64 0, !12, i64 8, !12, i64 12}
!16 = !{!"b2AtomicInt", !12, i64 0}
!17 = !{!"b2ConstraintGraph", !7, i64 0}
!18 = !{!"b2IdPool", !13, i64 0, !12, i64 16}
!19 = !{!"b2BitSet", !6, i64 0, !12, i64 8, !12, i64 12}
!20 = !{!"long", !7, i64 0}
!21 = !{!"b2Vec2", !22, i64 0, !22, i64 4}
!22 = !{!"float", !7, i64 0}
!23 = !{!"short", !7, i64 0}
!24 = !{!"b2Profile", !22, i64 0, !22, i64 4, !22, i64 8, !22, i64 12, !22, i64 16, !22, i64 20, !22, i64 24, !22, i64 28, !22, i64 32, !22, i64 36, !22, i64 40, !22, i64 44, !22, i64 48, !22, i64 52, !22, i64 56, !22, i64 60, !22, i64 64, !22, i64 68, !22, i64 72, !22, i64 76, !22, i64 80, !22, i64 84}
!25 = !{!"_Bool", !7, i64 0}
!26 = !{i8 0, i8 2}
!27 = !{}
!28 = !{i64 0, i64 4, !29, i64 4, i64 4, !29}
!29 = !{!22, !22, i64 0}
!30 = !{!31, !22, i64 16}
!31 = !{!"b2RayCastInput", !21, i64 0, !21, i64 8, !22, i64 16}
!32 = !{!33, !6, i64 0}
!33 = !{!"WorldRayCastContext", !6, i64 0, !6, i64 8, !34, i64 16, !22, i64 32, !6, i64 40}
!34 = !{!"b2QueryFilter", !20, i64 0, !20, i64 8}
!35 = !{!33, !6, i64 8}
!36 = !{i64 0, i64 8, !37, i64 8, i64 8, !37}
!37 = !{!20, !20, i64 0}
!38 = !{!33, !22, i64 32}
!39 = !{!33, !6, i64 40}
!40 = !{!12, !12, i64 0}
!41 = !{!34, !20, i64 8}
!42 = !{!43, !12, i64 0}
!43 = !{!"b2TreeStats", !12, i64 0, !12, i64 4}
!44 = !{!45, !12, i64 28}
!45 = !{!"b2RayResult", !46, i64 0, !21, i64 8, !21, i64 16, !22, i64 24, !12, i64 28, !12, i64 32, !25, i64 36}
!46 = !{!"b2ShapeId", !12, i64 0, !23, i64 4, !23, i64 6}
!47 = !{!43, !12, i64 4}
!48 = !{!45, !12, i64 32}
!49 = distinct !{!49, !50}
!50 = !{!"llvm.loop.mustprogress"}


; 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.b2RayResult = type { %struct.b2ShapeId, %struct.b2Vec2, %struct.b2Vec2, float, i32, i32, i8 }
%struct.b2ShapeId = type { i32, i16, i16 }
%struct.b2Vec2 = type { float, float }
%struct.b2RayCastInput = type { %struct.b2Vec2, %struct.b2Vec2, float }
%struct.WorldRayCastContext = type { ptr, ptr, %struct.b2QueryFilter, float, ptr }
%struct.b2QueryFilter = type { i64, i64 }

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.65 = external hidden unnamed_addr constant [29 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @b2GetWorldFromId(i32) local_unnamed_addr #1

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

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

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

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

declare zeroext i1 @b2IsValidVec2(<2 x float>) local_unnamed_addr #2

declare i64 @b2DynamicTree_RayCast(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden float @RayCastCallback(ptr noundef, i32 noundef, i64 noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @b2World_CastRayClosest(ptr dead_on_unwind noalias writable sret(%struct.b2RayResult) align 4 %0, i32 %1, <2 x float> %2, <2 x float> %3, i64 %4, i64 %5) local_unnamed_addr #5 {
  %7 = alloca %struct.b2RayCastInput, align 8
  %8 = alloca %struct.WorldRayCastContext, align 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(40) %0, i8 0, i64 40, i1 false)
  %9 = tail call ptr @b2GetWorldFromId(i32 %1)
  %10 = getelementptr inbounds i8, ptr %9, i64 1799
  %11 = load i8, ptr %10, align 1, !tbaa !5, !range !25, !noundef !26
  %12 = icmp eq i8 %11, 0
  br i1 %12, label %.thread, label %13

13:                                               ; preds = %6
  %14 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.15, ptr noundef nonnull @.str.1, i32 noundef 2303) #6
  %.not = icmp eq i32 %14, 0
  br i1 %.not, label %16, label %15

15:                                               ; preds = %13
  tail call void @llvm.trap()
  unreachable

16:                                               ; preds = %13
  %.pre = load i8, ptr %10, align 1, !tbaa !5, !range !25
  %17 = trunc nuw i8 %.pre to i1
  br i1 %17, label %60, label %.thread

.thread:                                          ; preds = %6, %16
  %18 = tail call zeroext i1 @b2IsValidVec2(<2 x float> %2) #6
  br i1 %18, label %22, label %19

19:                                               ; preds = %.thread
  %20 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.64, ptr noundef nonnull @.str.1, i32 noundef 2309) #6
  %.not15 = icmp eq i32 %20, 0
  br i1 %.not15, label %22, label %21

21:                                               ; preds = %19
  tail call void @llvm.trap()
  unreachable

22:                                               ; preds = %.thread, %19
  %23 = tail call zeroext i1 @b2IsValidVec2(<2 x float> %3) #6
  br i1 %23, label %27, label %24

24:                                               ; preds = %22
  %25 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.65, ptr noundef nonnull @.str.1, i32 noundef 2310) #6
  %.not16 = icmp eq i32 %25, 0
  br i1 %.not16, label %27, label %26

26:                                               ; preds = %24
  tail call void @llvm.trap()
  unreachable

27:                                               ; preds = %24, %22
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %7) #6
  store <2 x float> %2, ptr %7, align 8
  %28 = getelementptr inbounds i8, ptr %7, i64 8
  store <2 x float> %3, ptr %28, align 8
  %29 = getelementptr inbounds i8, ptr %7, i64 16
  store float 1.000000e+00, ptr %29, align 8, !tbaa !27
  call void @llvm.lifetime.start.p0(i64 48, ptr nonnull %8) #6
  store ptr %9, ptr %8, align 8, !tbaa !29
  %30 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr @b2RayCastClosestFcn, ptr %30, align 8, !tbaa !32
  %31 = getelementptr inbounds i8, ptr %8, i64 16
  store i64 %4, ptr %31, align 8, !tbaa !33
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %8, i64 24
  store i64 %5, ptr %.sroa.2.0..sroa_idx, align 8, !tbaa !33
  %32 = getelementptr inbounds i8, ptr %8, i64 32
  store float 1.000000e+00, ptr %32, align 8, !tbaa !34
  %33 = getelementptr inbounds i8, ptr %8, i64 40
  store ptr %0, ptr %33, align 8, !tbaa !35
  %34 = getelementptr inbounds i8, ptr %9, i64 40
  %35 = getelementptr inbounds i8, ptr %0, i64 28
  %36 = getelementptr inbounds i8, ptr %0, i64 32
  %37 = call i64 @b2DynamicTree_RayCast(ptr noundef nonnull %34, ptr noundef nonnull %7, i64 noundef %5, ptr noundef nonnull @RayCastCallback, ptr noundef nonnull %8) #6
  %.sroa.0.0.extract.trunc = trunc i64 %37 to i32
  %.sroa.4.0.extract.shift = lshr i64 %37, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %38 = load i32, ptr %35, align 4, !tbaa !36
  %39 = add nsw i32 %38, %.sroa.0.0.extract.trunc
  store i32 %39, ptr %35, align 4, !tbaa !36
  %40 = load i32, ptr %36, align 4, !tbaa !39
  %41 = add nsw i32 %40, %.sroa.4.0.extract.trunc
  store i32 %41, ptr %36, align 4, !tbaa !39
  %42 = load float, ptr %32, align 8, !tbaa !34
  %43 = fcmp une float %42, 0.000000e+00
  br i1 %43, label %44, label %.critedge

44:                                               ; preds = %27
  store float %42, ptr %29, align 8, !tbaa !27
  %45 = getelementptr inbounds i8, ptr %9, i64 112
  %46 = call i64 @b2DynamicTree_RayCast(ptr noundef nonnull %45, ptr noundef nonnull %7, i64 noundef %5, ptr noundef nonnull @RayCastCallback, ptr noundef nonnull %8) #6
  %.sroa.0.0.extract.trunc.1 = trunc i64 %46 to i32
  %.sroa.4.0.extract.shift.1 = lshr i64 %46, 32
  %.sroa.4.0.extract.trunc.1 = trunc nuw i64 %.sroa.4.0.extract.shift.1 to i32
  %47 = load i32, ptr %35, align 4, !tbaa !36
  %48 = add nsw i32 %47, %.sroa.0.0.extract.trunc.1
  store i32 %48, ptr %35, align 4, !tbaa !36
  %49 = load i32, ptr %36, align 4, !tbaa !39
  %50 = add nsw i32 %49, %.sroa.4.0.extract.trunc.1
  store i32 %50, ptr %36, align 4, !tbaa !39
  %51 = load float, ptr %32, align 8, !tbaa !34
  %52 = fcmp une float %51, 0.000000e+00
  br i1 %52, label %53, label %.critedge

53:                                               ; preds = %44
  store float %51, ptr %29, align 8, !tbaa !27
  %54 = getelementptr inbounds i8, ptr %9, i64 184
  %55 = call i64 @b2DynamicTree_RayCast(ptr noundef nonnull %54, ptr noundef nonnull %7, i64 noundef %5, ptr noundef nonnull @RayCastCallback, ptr noundef nonnull %8) #6
  %.sroa.0.0.extract.trunc.2 = trunc i64 %55 to i32
  %.sroa.4.0.extract.shift.2 = lshr i64 %55, 32
  %.sroa.4.0.extract.trunc.2 = trunc nuw i64 %.sroa.4.0.extract.shift.2 to i32
  %56 = load i32, ptr %35, align 4, !tbaa !36
  %57 = add nsw i32 %56, %.sroa.0.0.extract.trunc.2
  store i32 %57, ptr %35, align 4, !tbaa !36
  %58 = load i32, ptr %36, align 4, !tbaa !39
  %59 = add nsw i32 %58, %.sroa.4.0.extract.trunc.2
  store i32 %59, ptr %36, align 4, !tbaa !39
  br label %.critedge

.critedge:                                        ; preds = %53, %44, %27
  call void @llvm.lifetime.end.p0(i64 48, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %7) #6
  br label %60

60:                                               ; preds = %16, %.critedge
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden float @b2RayCastClosestFcn(i64, <2 x float>, <2 x float>, float noundef, ptr noundef) #5

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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 = { "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 = { cold noreturn nounwind memory(inaccessiblemem: write) }
attributes #4 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !24, i64 1799}
!6 = !{!"b2World", !7, i64 0, !13, i64 40, !16, i64 336, !17, i64 1008, !12, i64 1032, !17, i64 1048, !12, i64 1072, !17, i64 1088, !12, i64 1112, !17, i64 1128, !12, i64 1152, !17, i64 1168, !12, i64 1192, !17, i64 1208, !17, i64 1232, !12, i64 1256, !12, i64 1272, !12, i64 1288, !12, i64 1304, !12, i64 1320, !12, i64 1336, !12, i64 1352, !12, i64 1368, !9, i64 1384, !9, i64 1416, !11, i64 1448, !12, i64 1456, !18, i64 1472, !18, i64 1488, !18, i64 1504, !18, i64 1520, !19, i64 1536, !11, i64 1544, !20, i64 1548, !21, i64 1556, !21, i64 1560, !21, i64 1564, !21, i64 1568, !21, i64 1572, !21, i64 1576, !21, i64 1580, !21, i64 1584, !8, i64 1592, !8, i64 1600, !22, i64 1608, !23, i64 1612, !8, i64 1704, !8, i64 1712, !8, i64 1720, !8, i64 1728, !11, i64 1736, !8, i64 1744, !8, i64 1752, !8, i64 1760, !8, i64 1768, !8, i64 1776, !21, i64 1784, !11, i64 1788, !11, i64 1792, !22, i64 1796, !24, i64 1798, !24, i64 1799, !24, i64 1800, !24, i64 1801, !24, i64 1802, !24, i64 1803}
!7 = !{!"b2ArenaAllocator", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !12, i64 24}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"int", !9, i64 0}
!12 = !{!"", !8, i64 0, !11, i64 8, !11, i64 12}
!13 = !{!"b2BroadPhase", !9, i64 0, !11, i64 216, !14, i64 224, !12, i64 240, !8, i64 256, !8, i64 264, !11, i64 272, !15, i64 276, !14, i64 280}
!14 = !{!"b2HashSet", !8, i64 0, !11, i64 8, !11, i64 12}
!15 = !{!"b2AtomicInt", !11, i64 0}
!16 = !{!"b2ConstraintGraph", !9, i64 0}
!17 = !{!"b2IdPool", !12, i64 0, !11, i64 16}
!18 = !{!"b2BitSet", !8, i64 0, !11, i64 8, !11, i64 12}
!19 = !{!"long", !9, i64 0}
!20 = !{!"b2Vec2", !21, i64 0, !21, i64 4}
!21 = !{!"float", !9, i64 0}
!22 = !{!"short", !9, i64 0}
!23 = !{!"b2Profile", !21, i64 0, !21, i64 4, !21, i64 8, !21, i64 12, !21, i64 16, !21, i64 20, !21, i64 24, !21, i64 28, !21, i64 32, !21, i64 36, !21, i64 40, !21, i64 44, !21, i64 48, !21, i64 52, !21, i64 56, !21, i64 60, !21, i64 64, !21, i64 68, !21, i64 72, !21, i64 76, !21, i64 80, !21, i64 84}
!24 = !{!"_Bool", !9, i64 0}
!25 = !{i8 0, i8 2}
!26 = !{}
!27 = !{!28, !21, i64 16}
!28 = !{!"b2RayCastInput", !20, i64 0, !20, i64 8, !21, i64 16}
!29 = !{!30, !8, i64 0}
!30 = !{!"WorldRayCastContext", !8, i64 0, !8, i64 8, !31, i64 16, !21, i64 32, !8, i64 40}
!31 = !{!"b2QueryFilter", !19, i64 0, !19, i64 8}
!32 = !{!30, !8, i64 8}
!33 = !{!19, !19, i64 0}
!34 = !{!30, !21, i64 32}
!35 = !{!30, !8, i64 40}
!36 = !{!37, !11, i64 28}
!37 = !{!"b2RayResult", !38, i64 0, !20, i64 8, !20, i64 16, !21, i64 24, !11, i64 28, !11, i64 32, !24, i64 36}
!38 = !{!"b2ShapeId", !11, i64 0, !22, i64 4, !22, i64 6}
!39 = !{!37, !11, i64 32}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass