; LLVM IR from jdeokkim/ferox :: src (collision)

; 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.frTransform_ = type { %struct.frVector2_, %struct.anon, float }
%struct.frVector2_ = type { float, float }
%struct.anon = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @frComputeCollision(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca %struct.frTransform_, align 8
  %10 = alloca ptr, align 8
  %11 = alloca %struct.frTransform_, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %20, label %17

17:                                               ; preds = %3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %3
  store i1 false, ptr %4, align 1
  br label %72

21:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = call ptr @frGetBodyShape(ptr noundef %22)
  store ptr %23, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %9) #4
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  call void @frGetBodyTransform(ptr dead_on_unwind writable sret(%struct.frTransform_) align 4 %9, ptr noundef %24)
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = call ptr @frGetBodyShape(ptr noundef %25)
  store ptr %26, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 20, ptr %11) #4
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  call void @frGetBodyTransform(ptr dead_on_unwind writable sret(%struct.frTransform_) align 4 %11, ptr noundef %27)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = call i32 @frGetShapeType(ptr noundef %28)
  store i32 %29, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = call i32 @frGetShapeType(ptr noundef %30)
  store i32 %31, ptr %13, align 4, !tbaa !9
  %32 = load i32, ptr %12, align 4, !tbaa !9
  %33 = icmp eq i32 %32, 1
  br i1 %33, label %34, label %42

34:                                               ; preds = %21
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = icmp eq i32 %35, 1
  br i1 %36, label %37, label %42

37:                                               ; preds = %34
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load ptr, ptr %10, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call zeroext i1 @frComputeCollisionCircles(ptr noundef %38, ptr noundef byval(%struct.frTransform_) align 8 %9, ptr noundef %39, ptr noundef byval(%struct.frTransform_) align 8 %11, ptr noundef %40)
  store i1 %41, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %71

42:                                               ; preds = %34, %21
  %43 = load i32, ptr %12, align 4, !tbaa !9
  %44 = icmp eq i32 %43, 1
  br i1 %44, label %45, label %48

45:                                               ; preds = %42
  %46 = load i32, ptr %13, align 4, !tbaa !9
  %47 = icmp eq i32 %46, 2
  br i1 %47, label %54, label %48

48:                                               ; preds = %45, %42
  %49 = load i32, ptr %12, align 4, !tbaa !9
  %50 = icmp eq i32 %49, 2
  br i1 %50, label %51, label %59

51:                                               ; preds = %48
  %52 = load i32, ptr %13, align 4, !tbaa !9
  %53 = icmp eq i32 %52, 1
  br i1 %53, label %54, label %59

54:                                               ; preds = %51, %45
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = call zeroext i1 @frComputeCollisionCirclePoly(ptr noundef %55, ptr noundef byval(%struct.frTransform_) align 8 %9, ptr noundef %56, ptr noundef byval(%struct.frTransform_) align 8 %11, ptr noundef %57)
  store i1 %58, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %71

59:                                               ; preds = %51, %48
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %62, label %70

62:                                               ; preds = %59
  %63 = load i32, ptr %13, align 4, !tbaa !9
  %64 = icmp eq i32 %63, 2
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = load ptr, ptr %8, align 8, !tbaa !5
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call zeroext i1 @frComputeCollisionPolys(ptr noundef %66, ptr noundef byval(%struct.frTransform_) align 8 %9, ptr noundef %67, ptr noundef byval(%struct.frTransform_) align 8 %11, ptr noundef %68)
  store i1 %69, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %71

70:                                               ; preds = %62, %59
  store i1 false, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %71

71:                                               ; preds = %70, %65, %54, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %72

72:                                               ; preds = %71, %20
  %73 = load i1, ptr %4, align 1
  ret i1 %73
}

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

declare ptr @frGetBodyShape(ptr noundef) #2

declare void @frGetBodyTransform(ptr dead_on_unwind writable sret(%struct.frTransform_) align 4, ptr noundef) #2

declare i32 @frGetShapeType(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionCircles(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionCirclePoly(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionPolys(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) #3

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

attributes #0 = { 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 #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"="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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; 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.frTransform_ = type { %struct.frVector2_, %struct.anon, float }
%struct.frVector2_ = type { float, float }
%struct.anon = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @frComputeCollision(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = alloca %struct.frTransform_, align 8
  %5 = alloca %struct.frTransform_, align 8
  %6 = icmp eq ptr %0, null
  %7 = icmp eq ptr %1, null
  %or.cond = or i1 %6, %7
  br i1 %or.cond, label %27, label %8

8:                                                ; preds = %3
  %9 = tail call ptr @frGetBodyShape(ptr noundef nonnull %0) #4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %4) #4
  call void @frGetBodyTransform(ptr dead_on_unwind nonnull writable sret(%struct.frTransform_) align 4 %4, ptr noundef nonnull %0) #4
  %10 = call ptr @frGetBodyShape(ptr noundef nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %5) #4
  call void @frGetBodyTransform(ptr dead_on_unwind nonnull writable sret(%struct.frTransform_) align 4 %5, ptr noundef nonnull %1) #4
  %11 = call i32 @frGetShapeType(ptr noundef %9) #4
  %12 = call i32 @frGetShapeType(ptr noundef %10) #4
  %13 = icmp eq i32 %11, 1
  %14 = icmp eq i32 %12, 1
  %or.cond3 = select i1 %13, i1 %14, i1 false
  br i1 %or.cond3, label %15, label %17

15:                                               ; preds = %8
  %16 = call zeroext i1 @frComputeCollisionCircles(ptr noundef %9, ptr noundef nonnull byval(%struct.frTransform_) align 8 %4, ptr noundef %10, ptr noundef nonnull byval(%struct.frTransform_) align 8 %5, ptr noundef %2)
  br label %26

17:                                               ; preds = %8
  %18 = icmp eq i32 %12, 2
  %or.cond5 = select i1 %13, i1 %18, i1 false
  br i1 %or.cond5, label %21, label %19

19:                                               ; preds = %17
  %20 = icmp eq i32 %11, 2
  %or.cond7 = select i1 %20, i1 %14, i1 false
  br i1 %or.cond7, label %21, label %23

21:                                               ; preds = %19, %17
  %22 = call zeroext i1 @frComputeCollisionCirclePoly(ptr noundef %9, ptr noundef nonnull byval(%struct.frTransform_) align 8 %4, ptr noundef %10, ptr noundef nonnull byval(%struct.frTransform_) align 8 %5, ptr noundef %2)
  br label %26

23:                                               ; preds = %19
  %or.cond9 = select i1 %20, i1 %18, i1 false
  br i1 %or.cond9, label %24, label %26

24:                                               ; preds = %23
  %25 = call zeroext i1 @frComputeCollisionPolys(ptr noundef %9, ptr noundef nonnull byval(%struct.frTransform_) align 8 %4, ptr noundef %10, ptr noundef nonnull byval(%struct.frTransform_) align 8 %5, ptr noundef %2)
  br label %26

26:                                               ; preds = %23, %24, %21, %15
  %.0 = phi i1 [ %16, %15 ], [ %22, %21 ], [ %25, %24 ], [ false, %23 ]
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %4) #4
  br label %27

27:                                               ; preds = %3, %26
  %.1 = phi i1 [ %.0, %26 ], [ false, %3 ]
  ret i1 %.1
}

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

declare ptr @frGetBodyShape(ptr noundef) local_unnamed_addr #2

declare void @frGetBodyTransform(ptr dead_on_unwind writable sret(%struct.frTransform_) align 4, ptr noundef) local_unnamed_addr #2

declare i32 @frGetShapeType(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionCircles(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionCirclePoly(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @frComputeCollisionPolys(ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef, ptr noundef byval(%struct.frTransform_) align 8, ptr noundef) local_unnamed_addr #3

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

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


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