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

; 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.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 }

@.str.1 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [38 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @b2SplitIslandTask(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %11 = call i64 @b2GetTicks()
  store i64 %11, ptr %9, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %12, ptr %10, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %4
  %14 = load ptr, ptr %10, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.b2World, ptr %14, i32 0, i32 32
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %22, label %18

18:                                               ; preds = %13
  %19 = call i32 @b2InternalAssertFcn(ptr noundef @.str.30, ptr noundef @.str.1, i32 noundef 858)
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %22

21:                                               ; preds = %18
  call void @llvm.trap()
  br label %22

22:                                               ; preds = %21, %18, %13
  br label %23

23:                                               ; preds = %22
  br label %24

24:                                               ; preds = %23
  %25 = load ptr, ptr %10, align 8, !tbaa !9
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.b2World, ptr %26, i32 0, i32 32
  %28 = load i32, ptr %27, align 8, !tbaa !13
  call void @b2SplitIsland(ptr noundef %25, i32 noundef %28)
  %29 = load i64, ptr %9, align 8, !tbaa !11
  %30 = call float @b2GetMilliseconds(i64 noundef %29)
  %31 = load ptr, ptr %10, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct.b2World, ptr %31, i32 0, i32 45
  %33 = getelementptr inbounds %struct.b2Profile, ptr %32, i32 0, i32 15
  %34 = load float, ptr %33, align 4, !tbaa !28
  %35 = fadd float %34, %30
  store float %35, ptr %33, align 4, !tbaa !28
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  ret void
}

declare i64 @b2GetTicks() #0

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


; 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"

@.str.1 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [38 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

; Function Attrs: nounwind uwtable
declare dso_local void @b2SplitIsland(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @b2SplitIslandTask(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #2 {
  %5 = tail call i64 @b2GetTicks() #3
  %6 = getelementptr inbounds i8, ptr %3, i64 1544
  %7 = load i32, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i32 %7, -1
  br i1 %.not, label %8, label %11

8:                                                ; preds = %4
  %9 = tail call i32 @b2InternalAssertFcn(ptr noundef nonnull @.str.30, ptr noundef nonnull @.str.1, i32 noundef 858) #3
  %.not5 = icmp eq i32 %9, 0
  br i1 %.not5, label %._crit_edge, label %10

._crit_edge:                                      ; preds = %8
  %.pre = load i32, ptr %6, align 8, !tbaa !5
  br label %11

10:                                               ; preds = %8
  tail call void @llvm.trap()
  unreachable

11:                                               ; preds = %._crit_edge, %4
  %12 = phi i32 [ %.pre, %._crit_edge ], [ %7, %4 ]
  tail call void @b2SplitIsland(ptr noundef nonnull %3, i32 noundef %12)
  %13 = tail call float @b2GetMilliseconds(i64 noundef %5) #3
  %14 = getelementptr inbounds i8, ptr %3, i64 1672
  %15 = load float, ptr %14, align 4, !tbaa !25
  %16 = fadd float %13, %15
  store float %16, ptr %14, align 4, !tbaa !25
  ret void
}

declare i64 @b2GetTicks() local_unnamed_addr #0

declare float @b2GetMilliseconds(i64 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 = { 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 }

!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, !11, i64 1544}
!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 = !{!6, !21, i64 1672}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass