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

; 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.b2ChainId = type { i32, i16, i16 }
%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.b2Vec2 = type { float, float }
%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 }
%struct.b2ChainShape = type { i32, i32, i32, i32, i32, ptr, ptr, i16 }
%struct.b2Body = type { [32 x i8], ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, i32, i32, i32, i16, i8, i8, i8, i8 }

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1

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

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

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

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

declare ptr @b2GetWorldLocked(i32 noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @b2BodyArray_Get(ptr noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @b2DestroyShapeInternal(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) #4

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

; Function Attrs: nounwind uwtable
define dso_local void @b2DestroyChain(i64 %0) #4 {
  %2 = alloca %struct.b2ChainId, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  store i64 %0, ptr %2, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %14 = getelementptr inbounds %struct.b2ChainId, ptr %2, i32 0, i32 1
  %15 = load i16, ptr %14, align 4, !tbaa !5
  %16 = zext i16 %15 to i32
  %17 = call ptr @b2GetWorldLocked(i32 noundef %16)
  store ptr %17, ptr %3, align 8, !tbaa !11
  %18 = load ptr, ptr %3, align 8, !tbaa !11
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %1
  store i32 1, ptr %4, align 4
  br label %117

21:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %22 = load ptr, ptr %3, align 8, !tbaa !11
  %23 = load i64, ptr %2, align 4
  %24 = call ptr @b2GetChainShape(ptr noundef %22, i64 %23)
  store ptr %24, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %25 = load ptr, ptr %3, align 8, !tbaa !11
  %26 = getelementptr inbounds %struct.b2World, ptr %25, i32 0, i32 4
  %27 = load ptr, ptr %5, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct.b2ChainShape, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = call ptr @b2BodyArray_Get(ptr noundef %26, i32 noundef %29)
  store ptr %30, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %31 = load ptr, ptr %6, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.b2Body, ptr %31, i32 0, i32 8
  store ptr %32, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #5
  store i8 0, ptr %8, align 1, !tbaa !15
  br label %33

33:                                               ; preds = %49, %21
  %34 = load ptr, ptr %7, align 8, !tbaa !11
  %35 = load i32, ptr %34, align 4, !tbaa !17
  %36 = icmp ne i32 %35, -1
  br i1 %36, label %37, label %59

37:                                               ; preds = %33
  %38 = load ptr, ptr %7, align 8, !tbaa !11
  %39 = load i32, ptr %38, align 4, !tbaa !17
  %40 = load ptr, ptr %5, align 8, !tbaa !11
  %41 = getelementptr inbounds %struct.b2ChainShape, ptr %40, i32 0, i32 0
  %42 = load i32, ptr %41, align 8, !tbaa !18
  %43 = icmp eq i32 %39, %42
  br i1 %43, label %44, label %49

44:                                               ; preds = %37
  %45 = load ptr, ptr %5, align 8, !tbaa !11
  %46 = getelementptr inbounds %struct.b2ChainShape, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !19
  %48 = load ptr, ptr %7, align 8, !tbaa !11
  store i32 %47, ptr %48, align 4, !tbaa !17
  store i8 1, ptr %8, align 1, !tbaa !15
  br label %59

49:                                               ; preds = %37
  %50 = load ptr, ptr %3, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.b2World, ptr %50, i32 0, i32 16
  %52 = getelementptr inbounds %struct.b2ChainShapeArray, ptr %51, i32 0, i32 0
  %53 = load ptr, ptr %52, align 8, !tbaa !20
  %54 = load ptr, ptr %7, align 8, !tbaa !11
  %55 = load i32, ptr %54, align 4, !tbaa !17
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds %struct.b2ChainShape, ptr %53, i64 %56
  %58 = getelementptr inbounds %struct.b2ChainShape, ptr %57, i32 0, i32 2
  store ptr %58, ptr %7, align 8, !tbaa !11
  br label %33, !llvm.loop !34

59:                                               ; preds = %44, %33
  br label %60

60:                                               ; preds = %59
  %61 = load i8, ptr %8, align 1, !tbaa !15, !range !36, !noundef !37
  %62 = trunc i8 %61 to i1
  %63 = zext i1 %62 to i32
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %69, label %65

65:                                               ; preds = %60
  %66 = call i32 @b2InternalAssertFcn(ptr noundef @.str.11, ptr noundef @.str.1, i32 noundef 515)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %68, label %69

68:                                               ; preds = %65
  call void @llvm.trap()
  br label %69

69:                                               ; preds = %68, %65, %60
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  %72 = load i8, ptr %8, align 1, !tbaa !15, !range !36, !noundef !37
  %73 = trunc i8 %72 to i1
  %74 = zext i1 %73 to i32
  %75 = icmp eq i32 %74, 0
  br i1 %75, label %76, label %77

76:                                               ; preds = %71
  store i32 1, ptr %4, align 4
  br label %116

77:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %78 = load ptr, ptr %5, align 8, !tbaa !11
  %79 = getelementptr inbounds %struct.b2ChainShape, ptr %78, i32 0, i32 3
  %80 = load i32, ptr %79, align 4, !tbaa !38
  store i32 %80, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 0, ptr %10, align 4, !tbaa !17
  br label %81

81:                                               ; preds = %103, %77
  %82 = load i32, ptr %10, align 4, !tbaa !17
  %83 = load i32, ptr %9, align 4, !tbaa !17
  %84 = icmp slt i32 %82, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  store i32 6, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %106

86:                                               ; preds = %81
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %87 = load ptr, ptr %5, align 8, !tbaa !11
  %88 = getelementptr inbounds %struct.b2ChainShape, ptr %87, i32 0, i32 5
  %89 = load ptr, ptr %88, align 8, !tbaa !39
  %90 = load i32, ptr %10, align 4, !tbaa !17
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i32, ptr %89, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !17
  store i32 %93, ptr %11, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %94 = load ptr, ptr %3, align 8, !tbaa !11
  %95 = getelementptr inbounds %struct.b2World, ptr %94, i32 0, i32 15
  %96 = load i32, ptr %11, align 4, !tbaa !17
  %97 = call ptr @b2ShapeArray_Get(ptr noundef %95, i32 noundef %96)
  store ptr %97, ptr %12, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  store i8 1, ptr %13, align 1, !tbaa !15
  %98 = load ptr, ptr %3, align 8, !tbaa !11
  %99 = load ptr, ptr %12, align 8, !tbaa !11
  %100 = load ptr, ptr %6, align 8, !tbaa !11
  %101 = load i8, ptr %13, align 1, !tbaa !15, !range !36, !noundef !37
  %102 = trunc i8 %101 to i1
  call void @b2DestroyShapeInternal(ptr noundef %98, ptr noundef %99, ptr noundef %100, i1 noundef zeroext %102)
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %103

103:                                              ; preds = %86
  %104 = load i32, ptr %10, align 4, !tbaa !17
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %10, align 4, !tbaa !17
  br label %81, !llvm.loop !40

106:                                              ; preds = %85
  %107 = load ptr, ptr %5, align 8, !tbaa !11
  call void @b2FreeChainData(ptr noundef %107)
  %108 = load ptr, ptr %3, align 8, !tbaa !11
  %109 = getelementptr inbounds %struct.b2World, ptr %108, i32 0, i32 14
  %110 = load ptr, ptr %5, align 8, !tbaa !11
  %111 = getelementptr inbounds %struct.b2ChainShape, ptr %110, i32 0, i32 0
  %112 = load i32, ptr %111, align 8, !tbaa !18
  call void @b2FreeId(ptr noundef %109, i32 noundef %112)
  %113 = load ptr, ptr %5, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.b2ChainShape, ptr %113, i32 0, i32 0
  store i32 -1, ptr %114, align 8, !tbaa !18
  %115 = load ptr, ptr %3, align 8, !tbaa !11
  call void @b2ValidateSolverSets(ptr noundef %115)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  store i32 0, ptr %4, align 4
  br label %116

116:                                              ; preds = %106, %76
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  br label %117

117:                                              ; preds = %116, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  %118 = load i32, ptr %4, align 4
  switch i32 %118, label %120 [
    i32 0, label %119
    i32 1, label %119
  ]

119:                                              ; preds = %117, %117
  ret void

120:                                              ; preds = %117
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden ptr @b2GetChainShape(ptr noundef, i64) #4

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @b2ShapeArray_Get(ptr noundef, i32 noundef) #3

declare void @b2FreeId(ptr noundef, i32 noundef) #1

declare void @b2ValidateSolverSets(ptr noundef) #1

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


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

@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [14 x i8], align 1

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() #1

declare ptr @b2GetWorldLocked(i32 noundef) local_unnamed_addr #0

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @b2BodyArray_Get(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @b2DestroyShapeInternal(ptr noundef, ptr noundef, ptr noundef, i1 noundef zeroext) local_unnamed_addr #3

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

; Function Attrs: nounwind uwtable
define dso_local void @b2DestroyChain(i64 %0) local_unnamed_addr #3 {
  %.sroa.2.0.extract.shift = lshr i64 %0, 32
  %2 = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %3 = and i32 %2, 65535
  %4 = tail call ptr @b2GetWorldLocked(i32 noundef %3) #4
  %5 = icmp eq ptr %4, null
  br i1 %5, label %40, label %6

6:                                                ; preds = %1
  %7 = tail call ptr @b2GetChainShape(ptr noundef nonnull %4, i64 %0)
  %8 = getelementptr inbounds i8, ptr %4, i64 1032
  %9 = getelementptr inbounds i8, ptr %7, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = tail call ptr @b2BodyArray_Get(ptr noundef nonnull %8, i32 noundef %10)
  %12 = getelementptr inbounds i8, ptr %11, i64 64
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %.not.not38 = icmp eq i32 %13, -1
  br i1 %.not.not38, label %.critedge, label %.lr.ph

.lr.ph:                                           ; preds = %6
  %14 = load i32, ptr %7, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %4, i64 1272
  %16 = icmp eq i32 %13, %14
  br i1 %16, label %.critedge36, label %.lr.ph46.preheader

.lr.ph46.preheader:                               ; preds = %.lr.ph
  %17 = load ptr, ptr %15, align 8, !tbaa !14
  br label %.lr.ph46

18:                                               ; preds = %.lr.ph46
  %19 = icmp eq i32 %23, %14
  br i1 %19, label %.critedge36, label %.lr.ph46, !llvm.loop !29

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %18
  %20 = phi i32 [ %23, %18 ], [ %13, %.lr.ph46.preheader ]
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds %struct.b2ChainShape, ptr %17, i64 %21, i32 2
  %23 = load i32, ptr %22, align 4, !tbaa !12
  %.not.not = icmp eq i32 %23, -1
  br i1 %.not.not, label %.critedge, label %18, !llvm.loop !29

.critedge:                                        ; preds = %.lr.ph46, %6
  %24 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.1, i32 noundef 515) #4
  %.not34 = icmp eq i32 %24, 0
  br i1 %.not34, label %40, label %25

25:                                               ; preds = %.critedge
  tail call void @llvm.trap()
  unreachable

.critedge36:                                      ; preds = %18, %.lr.ph
  %.039.lcssa = phi ptr [ %12, %.lr.ph ], [ %22, %18 ]
  %26 = getelementptr inbounds i8, ptr %7, i64 8
  %27 = load i32, ptr %26, align 8, !tbaa !31
  store i32 %27, ptr %.039.lcssa, align 4, !tbaa !12
  %28 = getelementptr inbounds i8, ptr %7, i64 12
  %29 = load i32, ptr %28, align 4, !tbaa !32
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %.lr.ph41, label %._crit_edge

.lr.ph41:                                         ; preds = %.critedge36
  %31 = getelementptr inbounds i8, ptr %7, i64 24
  %32 = getelementptr inbounds i8, ptr %4, i64 1256
  %wide.trip.count = zext nneg i32 %29 to i64
  br label %35

._crit_edge:                                      ; preds = %35, %.critedge36
  tail call void @b2FreeChainData(ptr noundef nonnull %7)
  %33 = getelementptr inbounds i8, ptr %4, i64 1232
  %34 = load i32, ptr %7, align 8, !tbaa !13
  tail call void @b2FreeId(ptr noundef nonnull %33, i32 noundef %34) #4
  store i32 -1, ptr %7, align 8, !tbaa !13
  tail call void @b2ValidateSolverSets(ptr noundef nonnull %4) #4
  br label %40

35:                                               ; preds = %.lr.ph41, %35
  %indvars.iv = phi i64 [ 0, %.lr.ph41 ], [ %indvars.iv.next, %35 ]
  %36 = load ptr, ptr %31, align 8, !tbaa !33
  %37 = getelementptr inbounds i32, ptr %36, i64 %indvars.iv
  %38 = load i32, ptr %37, align 4, !tbaa !12
  %39 = tail call ptr @b2ShapeArray_Get(ptr noundef nonnull %32, i32 noundef %38)
  tail call void @b2DestroyShapeInternal(ptr noundef nonnull %4, ptr noundef %39, ptr noundef %11, i1 noundef zeroext true)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %35, !llvm.loop !34

40:                                               ; preds = %.critedge, %._crit_edge, %1
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden ptr @b2GetChainShape(ptr noundef, i64) local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden ptr @b2ShapeArray_Get(ptr noundef, i32 noundef) local_unnamed_addr #2

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

declare void @b2ValidateSolverSets(ptr noundef) local_unnamed_addr #0

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


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