; LLVM IR from erincatto/box2d :: test (test_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.b2WorldDef = type { %struct.b2Vec2, float, float, float, float, float, float, float, float, ptr, ptr, i8, i8, i32, ptr, ptr, ptr, ptr, i32 }
%struct.b2Vec2 = type { float, float }
%struct.b2WorldId = type { i16, i16 }

@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [53 x i8], align 1
@__PRETTY_FUNCTION__.EmptyWorld = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [54 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

declare void @b2DefaultWorldDef(ptr dead_on_unwind writable sret(%struct.b2WorldDef) align 8) #1

declare i32 @b2CreateWorld(ptr noundef) #1

declare zeroext i1 @b2World_IsValid(i32) #1

declare i32 @printf(ptr noundef, ...) #1

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

declare void @b2World_Step(i32, float noundef, i32 noundef) #1

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

declare void @b2DestroyWorld(i32) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @EmptyWorld() #3 {
  %1 = alloca %struct.b2WorldDef, align 8
  %2 = alloca %struct.b2WorldId, align 2
  %3 = alloca float, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 104, ptr %1) #4
  call void @b2DefaultWorldDef(ptr dead_on_unwind writable sret(%struct.b2WorldDef) align 8 %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %6 = call i32 @b2CreateWorld(ptr noundef %1)
  store i32 %6, ptr %2, align 2
  br label %7

7:                                                ; preds = %0
  %8 = load i32, ptr %2, align 2
  %9 = call zeroext i1 @b2World_IsValid(i32 %8)
  %10 = zext i1 %9 to i32
  %11 = icmp eq i32 %10, 1
  %12 = zext i1 %11 to i32
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %14, label %16

14:                                               ; preds = %7
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 105, ptr noundef @__PRETTY_FUNCTION__.EmptyWorld) #5
  unreachable

16:                                               ; preds = %7
  br label %17

17:                                               ; preds = %16
  br label %18

18:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store float 0x3F91111120000000, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %27, %18
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = icmp slt i32 %20, 60
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %30

23:                                               ; preds = %19
  %24 = load float, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = load i32, ptr %2, align 2
  call void @b2World_Step(i32 %26, float noundef %24, i32 noundef %25)
  br label %27

27:                                               ; preds = %23
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = add nsw i32 %28, 1
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %19, !llvm.loop !11

30:                                               ; preds = %22
  %31 = load i32, ptr %2, align 2
  call void @b2DestroyWorld(i32 %31)
  br label %32

32:                                               ; preds = %30
  %33 = load i32, ptr %2, align 2
  %34 = call zeroext i1 @b2World_IsValid(i32 %33)
  %35 = zext i1 %34 to i32
  %36 = icmp eq i32 %35, 0
  %37 = zext i1 %36 to i32
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %41

39:                                               ; preds = %32
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @__assert_fail(ptr noundef @.str.1, ptr noundef @.str.2, i32 noundef 117, ptr noundef @__PRETTY_FUNCTION__.EmptyWorld) #5
  unreachable

41:                                               ; preds = %32
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 104, ptr %1) #4
  ret i32 0
}

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 = { 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 #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 }
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 = !{!"float", !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 = distinct !{!11, !12}
!12 = !{!"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.b2WorldDef = type { %struct.b2Vec2, float, float, float, float, float, float, float, float, ptr, ptr, i8, i8, i32, ptr, ptr, ptr, ptr, i32 }
%struct.b2Vec2 = type { float, float }

@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [67 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [53 x i8], align 1
@__PRETTY_FUNCTION__.EmptyWorld = external hidden unnamed_addr constant [21 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [54 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

declare void @b2DefaultWorldDef(ptr dead_on_unwind writable sret(%struct.b2WorldDef) align 8) local_unnamed_addr #1

declare i32 @b2CreateWorld(ptr noundef) local_unnamed_addr #1

declare zeroext i1 @b2World_IsValid(i32) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #2

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

declare void @b2World_Step(i32, float noundef, i32 noundef) local_unnamed_addr #1

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

declare void @b2DestroyWorld(i32) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @EmptyWorld() local_unnamed_addr #4 {
  %1 = alloca %struct.b2WorldDef, align 8
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %1) #5
  call void @b2DefaultWorldDef(ptr dead_on_unwind nonnull writable sret(%struct.b2WorldDef) align 8 %1) #5
  %2 = call i32 @b2CreateWorld(ptr noundef nonnull %1) #5
  %3 = call zeroext i1 @b2World_IsValid(i32 %2) #5
  br i1 %3, label %.preheader, label %4

4:                                                ; preds = %0
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 105, ptr noundef nonnull @__PRETTY_FUNCTION__.EmptyWorld) #6
  unreachable

6:                                                ; preds = %.preheader
  call void @b2DestroyWorld(i32 %2) #5
  %7 = call zeroext i1 @b2World_IsValid(i32 %2) #5
  br i1 %7, label %9, label %11

.preheader:                                       ; preds = %0, %.preheader
  %.06 = phi i32 [ %8, %.preheader ], [ 0, %0 ]
  call void @b2World_Step(i32 %2, float noundef 0x3F91111120000000, i32 noundef 1) #5
  %8 = add nuw nsw i32 %.06, 1
  %exitcond.not = icmp eq i32 %8, 60
  br i1 %exitcond.not, label %6, label %.preheader, !llvm.loop !5

9:                                                ; preds = %6
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  call void @__assert_fail(ptr noundef nonnull @.str.1, ptr noundef nonnull @.str.2, i32 noundef 117, ptr noundef nonnull @__PRETTY_FUNCTION__.EmptyWorld) #6
  unreachable

11:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %1) #5
  ret i32 0
}

attributes #0 = { mustprogress 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 = { nofree 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 #3 = { 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 #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 }
attributes #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass