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

@.str.21 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @HelloWorld() #0

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @EmptyWorld() #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @DestroyAllBodiesWorld() #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @TestWorldRecycle() #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @TestWorldCoverage() #0

; Function Attrs: nounwind uwtable
define dso_local i32 @WorldTest() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  br label %10

10:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %11 = call i32 @HelloWorld()
  store i32 %11, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %16

14:                                               ; preds = %10
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %19

16:                                               ; preds = %10
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  br label %18

18:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  br label %19

19:                                               ; preds = %18, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %20 = load i32, ptr %3, align 4
  switch i32 %20, label %103 [
    i32 0, label %21
    i32 1, label %101
  ]

21:                                               ; preds = %19
  br label %22

22:                                               ; preds = %21
  br label %23

23:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %24 = call i32 @EmptyWorld()
  store i32 %24, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.23)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %32

29:                                               ; preds = %23
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.24)
  br label %31

31:                                               ; preds = %29
  store i32 0, ptr %3, align 4
  br label %32

32:                                               ; preds = %31, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  %33 = load i32, ptr %3, align 4
  switch i32 %33, label %103 [
    i32 0, label %34
    i32 1, label %101
  ]

34:                                               ; preds = %32
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %37 = call i32 @DestroyAllBodiesWorld()
  store i32 %37, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = icmp eq i32 %38, 1
  br i1 %39, label %40, label %42

40:                                               ; preds = %36
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.25)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %45

42:                                               ; preds = %36
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.26)
  br label %44

44:                                               ; preds = %42
  store i32 0, ptr %3, align 4
  br label %45

45:                                               ; preds = %44, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %46 = load i32, ptr %3, align 4
  switch i32 %46, label %103 [
    i32 0, label %47
    i32 1, label %101
  ]

47:                                               ; preds = %45
  br label %48

48:                                               ; preds = %47
  br label %49

49:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %50 = call i32 @TestIsValid()
  store i32 %50, ptr %6, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = icmp eq i32 %51, 1
  br i1 %52, label %53, label %55

53:                                               ; preds = %49
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.27)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %58

55:                                               ; preds = %49
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.28)
  br label %57

57:                                               ; preds = %55
  store i32 0, ptr %3, align 4
  br label %58

58:                                               ; preds = %57, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %59 = load i32, ptr %3, align 4
  switch i32 %59, label %103 [
    i32 0, label %60
    i32 1, label %101
  ]

60:                                               ; preds = %58
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %63 = call i32 @TestWorldRecycle()
  store i32 %63, ptr %7, align 4, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %66, label %68

66:                                               ; preds = %62
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.29)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %71

68:                                               ; preds = %62
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.30)
  br label %70

70:                                               ; preds = %68
  store i32 0, ptr %3, align 4
  br label %71

71:                                               ; preds = %70, %66
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %72 = load i32, ptr %3, align 4
  switch i32 %72, label %103 [
    i32 0, label %73
    i32 1, label %101
  ]

73:                                               ; preds = %71
  br label %74

74:                                               ; preds = %73
  br label %75

75:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %76 = call i32 @TestWorldCoverage()
  store i32 %76, ptr %8, align 4, !tbaa !5
  %77 = load i32, ptr %8, align 4, !tbaa !5
  %78 = icmp eq i32 %77, 1
  br i1 %78, label %79, label %81

79:                                               ; preds = %75
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.31)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %84

81:                                               ; preds = %75
  %82 = call i32 (ptr, ...) @printf(ptr noundef @.str.32)
  br label %83

83:                                               ; preds = %81
  store i32 0, ptr %3, align 4
  br label %84

84:                                               ; preds = %83, %79
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %85 = load i32, ptr %3, align 4
  switch i32 %85, label %103 [
    i32 0, label %86
    i32 1, label %101
  ]

86:                                               ; preds = %84
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %89 = call i32 @TestSensor()
  store i32 %89, ptr %9, align 4, !tbaa !5
  %90 = load i32, ptr %9, align 4, !tbaa !5
  %91 = icmp eq i32 %90, 1
  br i1 %91, label %92, label %94

92:                                               ; preds = %88
  %93 = call i32 (ptr, ...) @printf(ptr noundef @.str.33)
  store i32 1, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %97

94:                                               ; preds = %88
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.34)
  br label %96

96:                                               ; preds = %94
  store i32 0, ptr %3, align 4
  br label %97

97:                                               ; preds = %96, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %98 = load i32, ptr %3, align 4
  switch i32 %98, label %103 [
    i32 0, label %99
    i32 1, label %101
  ]

99:                                               ; preds = %97
  br label %100

100:                                              ; preds = %99
  store i32 0, ptr %1, align 4
  br label %101

101:                                              ; preds = %100, %97, %84, %71, %58, %45, %32, %19
  %102 = load i32, ptr %1, align 4
  ret i32 %102

103:                                              ; preds = %97, %84, %71, %58, %45, %32, %19
  unreachable
}

; Function Attrs: nounwind uwtable
declare hidden i32 @TestIsValid() #3

; Function Attrs: nounwind uwtable
declare hidden i32 @TestSensor() #0

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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"}


; 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.21 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.26 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.27 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.28 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.32 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.33 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [30 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local i32 @HelloWorld() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @EmptyWorld() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @DestroyAllBodiesWorld() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @TestWorldRecycle() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @TestWorldCoverage() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @WorldTest() local_unnamed_addr #2 {
  %1 = tail call i32 @HelloWorld()
  %2 = icmp eq i32 %1, 1
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  br label %39

5:                                                ; preds = %0
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  %7 = tail call i32 @EmptyWorld()
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %9, label %11

9:                                                ; preds = %5
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.23)
  br label %39

11:                                               ; preds = %5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.24)
  %13 = tail call i32 @DestroyAllBodiesWorld()
  %14 = icmp eq i32 %13, 1
  br i1 %14, label %15, label %17

15:                                               ; preds = %11
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.25)
  br label %39

17:                                               ; preds = %11
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.26)
  %19 = tail call i32 @TestIsValid()
  %20 = icmp eq i32 %19, 1
  br i1 %20, label %21, label %23

21:                                               ; preds = %17
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.27)
  br label %39

23:                                               ; preds = %17
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.28)
  %25 = tail call i32 @TestWorldRecycle()
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %29

27:                                               ; preds = %23
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.29)
  br label %39

29:                                               ; preds = %23
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.30)
  %31 = tail call i32 @TestWorldCoverage()
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %35

33:                                               ; preds = %29
  %34 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.31)
  br label %39

35:                                               ; preds = %29
  %36 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.32)
  %37 = tail call i32 @TestSensor()
  %.not = icmp eq i32 %37, 1
  %.str.33..str.34 = select i1 %.not, ptr @.str.33, ptr @.str.34
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.33..str.34)
  %spec.select = zext i1 %.not to i32
  br label %39

39:                                               ; preds = %33, %27, %21, %15, %9, %3, %35
  %.7 = phi i32 [ 1, %3 ], [ 1, %9 ], [ 1, %15 ], [ 1, %21 ], [ 1, %27 ], [ 1, %33 ], [ %spec.select, %35 ]
  ret i32 %.7
}

; Function Attrs: nounwind uwtable
declare hidden i32 @TestIsValid() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden i32 @TestSensor() local_unnamed_addr #0

attributes #0 = { 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 #1 = { 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 #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" }

!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)"}


; Effective O3 passes: GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass