; LLVM IR from erincatto/box2d :: shared (determinism)

; 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.b2WorldId = type { i16, i16 }
%struct.b2BodyEvents = type { ptr, i32 }
%struct.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Vec2 = type { float, float }
%struct.b2Rot = type { float, float }
%struct.FallingHingeData = type { ptr, i32, i32, i32, i32 }
%struct.b2BodyId = type { i32, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.UpdateFallingHinges = external hidden unnamed_addr constant [57 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @UpdateFallingHinges(i32 %0, ptr noundef %1) #2 {
  %3 = alloca %struct.b2WorldId, align 2
  %4 = alloca ptr, align 8
  %5 = alloca %struct.b2BodyEvents, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.b2Transform, align 4
  store i32 %0, ptr %3, align 2
  store ptr %1, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.FallingHingeData, ptr %9, i32 0, i32 4
  %11 = load i32, ptr %10, align 4, !tbaa !9
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %69

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 16, ptr %5) #4
  %14 = load i32, ptr %3, align 2
  %15 = call { ptr, i32 } @b2World_GetBodyEvents(i32 %14)
  %16 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 0
  %17 = extractvalue { ptr, i32 } %15, 0
  store ptr %17, ptr %16, align 8
  %18 = getelementptr inbounds { ptr, i32 }, ptr %5, i32 0, i32 1
  %19 = extractvalue { ptr, i32 } %15, 1
  store i32 %19, ptr %18, align 8
  %20 = getelementptr inbounds %struct.b2BodyEvents, ptr %5, i32 0, i32 1
  %21 = load i32, ptr %20, align 8, !tbaa !12
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %68

23:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %24 = load i32, ptr %3, align 2
  %25 = call i32 @b2World_GetAwakeBodyCount(i32 %24)
  store i32 %25, ptr %6, align 4, !tbaa !14
  %26 = load i32, ptr %6, align 4, !tbaa !14
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %29

28:                                               ; preds = %23
  br label %30

29:                                               ; preds = %23
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i32 noundef 114, ptr noundef @__PRETTY_FUNCTION__.UpdateFallingHinges) #5
  unreachable

30:                                               ; preds = %28
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.FallingHingeData, ptr %31, i32 0, i32 4
  store i32 5381, ptr %32, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !14
  br label %33

33:                                               ; preds = %59, %30
  %34 = load i32, ptr %7, align 4, !tbaa !14
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.FallingHingeData, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 8, !tbaa !15
  %38 = icmp slt i32 %34, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %62

40:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.FallingHingeData, ptr %41, i32 0, i32 0
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = load i32, ptr %7, align 4, !tbaa !14
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds %struct.b2BodyId, ptr %43, i64 %45
  %47 = load i64, ptr %46, align 4
  %48 = call { <2 x float>, <2 x float> } @b2Body_GetTransform(i64 %47)
  %49 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 0
  %50 = extractvalue { <2 x float>, <2 x float> } %48, 0
  store <2 x float> %50, ptr %49, align 4
  %51 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %8, i32 0, i32 1
  %52 = extractvalue { <2 x float>, <2 x float> } %48, 1
  store <2 x float> %52, ptr %51, align 4
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.FallingHingeData, ptr %53, i32 0, i32 4
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = call i32 @b2Hash(i32 noundef %55, ptr noundef %8, i32 noundef 16)
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.FallingHingeData, ptr %57, i32 0, i32 4
  store i32 %56, ptr %58, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  br label %59

59:                                               ; preds = %40
  %60 = load i32, ptr %7, align 4, !tbaa !14
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %7, align 4, !tbaa !14
  br label %33, !llvm.loop !17

62:                                               ; preds = %39
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.FallingHingeData, ptr %63, i32 0, i32 2
  %65 = load i32, ptr %64, align 4, !tbaa !19
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.FallingHingeData, ptr %66, i32 0, i32 3
  store i32 %65, ptr %67, align 8, !tbaa !20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %68

68:                                               ; preds = %62, %13
  call void @llvm.lifetime.end.p0(i64 16, ptr %5) #4
  br label %69

69:                                               ; preds = %68, %2
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.FallingHingeData, ptr %70, i32 0, i32 2
  %72 = load i32, ptr %71, align 4, !tbaa !19
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %71, align 4, !tbaa !19
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.FallingHingeData, ptr %74, i32 0, i32 4
  %76 = load i32, ptr %75, align 4, !tbaa !9
  %77 = icmp ne i32 %76, 0
  ret i1 %77
}

declare { ptr, i32 } @b2World_GetBodyEvents(i32) #3

declare i32 @b2World_GetAwakeBodyCount(i32) #3

declare { <2 x float>, <2 x float> } @b2Body_GetTransform(i64) #3

declare i32 @b2Hash(i32 noundef, ptr noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { 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 #3 = { "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 }
attributes #5 = { noreturn 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, !11, i64 20}
!10 = !{!"FallingHingeData", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 8}
!13 = !{!"b2BodyEvents", !6, i64 0, !11, i64 8}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !11, i64 8}
!16 = !{!10, !6, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !11, i64 12}
!20 = !{!10, !11, i64 16}


; 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.b2Transform = type { %struct.b2Vec2, %struct.b2Rot }
%struct.b2Vec2 = type { float, float }
%struct.b2Rot = type { float, float }
%struct.b2BodyId = type { i32, i16, i16 }

@.str.1 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [16 x i8], align 1
@__PRETTY_FUNCTION__.UpdateFallingHinges = external hidden unnamed_addr constant [57 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @UpdateFallingHinges(i32 %0, ptr nocapture noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.b2Transform, align 8
  %4 = getelementptr inbounds i8, ptr %1, i64 20
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp eq i32 %5, 0
  br i1 %6, label %7, label %36

7:                                                ; preds = %2
  %8 = tail call { ptr, i32 } @b2World_GetBodyEvents(i32 %0) #4
  %9 = extractvalue { ptr, i32 } %8, 1
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %._crit_edge17

._crit_edge17:                                    ; preds = %7
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %36

11:                                               ; preds = %7
  %12 = tail call i32 @b2World_GetAwakeBodyCount(i32 %0) #4
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i32 noundef 114, ptr noundef nonnull @__PRETTY_FUNCTION__.UpdateFallingHinges) #5
  unreachable

15:                                               ; preds = %11
  store i32 5381, ptr %4, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 8
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %15
  %19 = getelementptr inbounds i8, ptr %3, i64 8
  br label %24

._crit_edge:                                      ; preds = %24, %15
  %20 = phi i32 [ 5381, %15 ], [ %32, %24 ]
  %21 = getelementptr inbounds i8, ptr %1, i64 12
  %22 = load i32, ptr %21, align 4, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %1, i64 16
  store i32 %22, ptr %23, align 8, !tbaa !13
  br label %36

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %3) #4
  %25 = load ptr, ptr %1, align 8, !tbaa !14
  %26 = getelementptr inbounds %struct.b2BodyId, ptr %25, i64 %indvars.iv
  %27 = load i64, ptr %26, align 4
  %28 = call { <2 x float>, <2 x float> } @b2Body_GetTransform(i64 %27) #4
  %29 = extractvalue { <2 x float>, <2 x float> } %28, 0
  store <2 x float> %29, ptr %3, align 8
  %30 = extractvalue { <2 x float>, <2 x float> } %28, 1
  store <2 x float> %30, ptr %19, align 8
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = call i32 @b2Hash(i32 noundef %31, ptr noundef nonnull %3, i32 noundef 16) #4
  store i32 %32, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %3) #4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %33 = load i32, ptr %16, align 8, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = icmp slt i64 %indvars.iv.next, %34
  br i1 %35, label %24, label %._crit_edge, !llvm.loop !15

36:                                               ; preds = %._crit_edge17, %._crit_edge, %2
  %37 = phi i32 [ %.pre, %._crit_edge17 ], [ %20, %._crit_edge ], [ %5, %2 ]
  %38 = getelementptr inbounds i8, ptr %1, i64 12
  %39 = load i32, ptr %38, align 4, !tbaa !12
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %38, align 4, !tbaa !12
  %41 = icmp ne i32 %37, 0
  ret i1 %41
}

declare { ptr, i32 } @b2World_GetBodyEvents(i32) local_unnamed_addr #3

declare i32 @b2World_GetAwakeBodyCount(i32) local_unnamed_addr #3

declare { <2 x float>, <2 x float> } @b2Body_GetTransform(i64) local_unnamed_addr #3

declare i32 @b2Hash(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #3

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


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