; LLVM IR from SOHNE/Dura2D :: src/collision (d2CollisionDetection)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN20d2CollisionDetection11IsCollidingEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef %0, ptr noundef %1, ptr noundef nonnull align 1 %2) #0 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %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
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %15)
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = getelementptr inbounds ptr, ptr %17, i64 2
  %19 = load ptr, ptr %18, align 8
  %20 = call noundef i32 %19(ptr noundef nonnull align 8 dereferenceable(8) %16)
  store i32 %20, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %21)
  %23 = load ptr, ptr %22, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 2
  %25 = load ptr, ptr %24, align 8
  %26 = call noundef i32 %25(ptr noundef nonnull align 8 dereferenceable(8) %22)
  store i32 %26, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %27 = load i32, ptr %8, align 4, !tbaa !11
  %28 = icmp eq i32 %27, 0
  %29 = zext i1 %28 to i8
  store i8 %29, ptr %10, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %30 = load i32, ptr %9, align 4, !tbaa !11
  %31 = icmp eq i32 %30, 0
  %32 = zext i1 %31 to i8
  store i8 %32, ptr %11, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  %33 = load i32, ptr %8, align 4, !tbaa !11
  %34 = icmp eq i32 %33, 1
  br i1 %34, label %38, label %35

35:                                               ; preds = %3
  %36 = load i32, ptr %8, align 4, !tbaa !11
  %37 = icmp eq i32 %36, 2
  br label %38

38:                                               ; preds = %35, %3
  %39 = phi i1 [ true, %3 ], [ %37, %35 ]
  %40 = zext i1 %39 to i8
  store i8 %40, ptr %12, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #4
  %41 = load i32, ptr %9, align 4, !tbaa !11
  %42 = icmp eq i32 %41, 1
  br i1 %42, label %46, label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %9, align 4, !tbaa !11
  %45 = icmp eq i32 %44, 2
  br label %46

46:                                               ; preds = %43, %38
  %47 = phi i1 [ true, %38 ], [ %45, %43 ]
  %48 = zext i1 %47 to i8
  store i8 %48, ptr %13, align 1, !tbaa !13
  %49 = load i8, ptr %10, align 1, !tbaa !13, !range !15, !noundef !16
  %50 = trunc i8 %49 to i1
  br i1 %50, label %51, label %59

51:                                               ; preds = %46
  %52 = load i8, ptr %11, align 1, !tbaa !13, !range !15, !noundef !16
  %53 = trunc i8 %52 to i1
  br i1 %53, label %54, label %59

54:                                               ; preds = %51
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = call noundef zeroext i1 @_ZN20d2CollisionDetection23IsCollidingCircleCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef %55, ptr noundef %56, ptr noundef nonnull align 1 %57)
  store i1 %58, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %93

59:                                               ; preds = %51, %46
  %60 = load i8, ptr %12, align 1, !tbaa !13, !range !15, !noundef !16
  %61 = trunc i8 %60 to i1
  br i1 %61, label %62, label %70

62:                                               ; preds = %59
  %63 = load i8, ptr %13, align 1, !tbaa !13, !range !15, !noundef !16
  %64 = trunc i8 %63 to i1
  br i1 %64, label %65, label %70

65:                                               ; preds = %62
  %66 = load ptr, ptr %5, align 8, !tbaa !5
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = call noundef zeroext i1 @_ZN20d2CollisionDetection25IsCollidingPolygonPolygonEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef %66, ptr noundef %67, ptr noundef nonnull align 1 %68)
  store i1 %69, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %93

70:                                               ; preds = %62, %59
  %71 = load i8, ptr %12, align 1, !tbaa !13, !range !15, !noundef !16
  %72 = trunc i8 %71 to i1
  br i1 %72, label %73, label %81

73:                                               ; preds = %70
  %74 = load i8, ptr %11, align 1, !tbaa !13, !range !15, !noundef !16
  %75 = trunc i8 %74 to i1
  br i1 %75, label %76, label %81

76:                                               ; preds = %73
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = call noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef %77, ptr noundef %78, ptr noundef nonnull align 1 %79)
  store i1 %80, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %93

81:                                               ; preds = %73, %70
  %82 = load i8, ptr %10, align 1, !tbaa !13, !range !15, !noundef !16
  %83 = trunc i8 %82 to i1
  br i1 %83, label %84, label %92

84:                                               ; preds = %81
  %85 = load i8, ptr %13, align 1, !tbaa !13, !range !15, !noundef !16
  %86 = trunc i8 %85 to i1
  br i1 %86, label %87, label %92

87:                                               ; preds = %84
  %88 = load ptr, ptr %6, align 8, !tbaa !5
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load ptr, ptr %7, align 8, !tbaa !5
  %91 = call noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef %88, ptr noundef %89, ptr noundef nonnull align 1 %90)
  store i1 %91, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %93

92:                                               ; preds = %84, %81
  store i1 false, ptr %4, align 1
  store i32 1, ptr %14, align 4
  br label %93

93:                                               ; preds = %92, %87, %76, %65, %54
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %94 = load i1, ptr %4, align 1
  ret i1 %94
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132)) #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection23IsCollidingCircleCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection25IsCollidingPolygonPolygonEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) #3 align 2

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

attributes #0 = { mustprogress 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 = { inlinehint mustprogress 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 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS11d2ShapeType", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!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"

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN20d2CollisionDetection11IsCollidingEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef nonnull %0, ptr noundef %1, ptr noundef nonnull align 1 %2) local_unnamed_addr #0 align 2 {
  %4 = tail call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %0)
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 16
  %7 = load ptr, ptr %6, align 8
  %8 = tail call noundef i32 %7(ptr noundef nonnull align 8 dereferenceable(8) %4)
  %9 = tail call noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132) %1)
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 16
  %12 = load ptr, ptr %11, align 8
  %13 = tail call noundef i32 %12(ptr noundef nonnull align 8 dereferenceable(8) %9)
  %14 = icmp ne i32 %8, 0
  %15 = icmp ne i32 %13, 0
  %16 = or i32 %13, %8
  %brmerge.not = icmp eq i32 %16, 0
  br i1 %brmerge.not, label %17, label %19

17:                                               ; preds = %3
  %18 = tail call noundef zeroext i1 @_ZN20d2CollisionDetection23IsCollidingCircleCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 1 %2)
  br label %32

19:                                               ; preds = %3
  %20 = add i32 %13, -3
  %21 = icmp ult i32 %20, -2
  %22 = add i32 %8, -3
  %23 = icmp ult i32 %22, -2
  %brmerge31 = or i1 %23, %21
  br i1 %brmerge31, label %26, label %24

24:                                               ; preds = %19
  %25 = tail call noundef zeroext i1 @_ZN20d2CollisionDetection25IsCollidingPolygonPolygonEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 1 %2)
  br label %32

26:                                               ; preds = %19
  %brmerge34 = or i1 %23, %15
  br i1 %brmerge34, label %29, label %27

27:                                               ; preds = %26
  %28 = tail call noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef nonnull %0, ptr noundef nonnull %1, ptr noundef nonnull align 1 %2)
  br label %32

29:                                               ; preds = %26
  %brmerge37 = or i1 %14, %21
  br i1 %brmerge37, label %32, label %30

30:                                               ; preds = %29
  %31 = tail call noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef nonnull %1, ptr noundef nonnull %0, ptr noundef nonnull align 1 %2)
  br label %32

32:                                               ; preds = %29, %30, %27, %24, %17
  %.0 = phi i1 [ %18, %17 ], [ %25, %24 ], [ %28, %27 ], [ %31, %30 ], [ false, %29 ]
  ret i1 %.0
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK6d2Body8GetShapeEv(ptr noundef nonnull align 8 dereferenceable(132)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection23IsCollidingCircleCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection25IsCollidingPolygonPolygonEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZN20d2CollisionDetection24IsCollidingPolygonCircleEP6d2BodyS1_RSt6vectorI9d2ContactSaIS3_EE(ptr noundef, ptr noundef, ptr noundef nonnull align 1) local_unnamed_addr #2 align 2

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}


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