; LLVM IR from Mithreindeir/VelocityRaptor :: VelocityRaptor/src (vrBoundingBox)

; 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.vrOrientedBoundingBox = type { %struct.vrVec2, %struct.vrVec2 }
%struct.vrVec2 = type { float, float }

; Function Attrs: nounwind uwtable
define dso_local i32 @vrOBBOverlaps(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca %struct.vrOrientedBoundingBox, align 4
  %7 = alloca %struct.vrOrientedBoundingBox, align 4
  %8 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 0
  store <2 x float> %0, ptr %8, align 4
  %9 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %6, i32 0, i32 1
  store <2 x float> %1, ptr %9, align 4
  %10 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 0
  store <2 x float> %2, ptr %10, align 4
  %11 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %7, i32 0, i32 1
  store <2 x float> %3, ptr %11, align 4
  %12 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 0
  %13 = getelementptr inbounds %struct.vrVec2, ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 0
  %16 = getelementptr inbounds %struct.vrVec2, ptr %15, i32 0, i32 0
  %17 = load float, ptr %16, align 4, !tbaa !5
  %18 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 1
  %19 = getelementptr inbounds %struct.vrVec2, ptr %18, i32 0, i32 0
  %20 = load float, ptr %19, align 4, !tbaa !11
  %21 = fadd float %17, %20
  %22 = fcmp olt float %14, %21
  br i1 %22, label %23, label %60

23:                                               ; preds = %4
  %24 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 0
  %25 = getelementptr inbounds %struct.vrVec2, ptr %24, i32 0, i32 0
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 1
  %28 = getelementptr inbounds %struct.vrVec2, ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = fadd float %26, %29
  %31 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 0
  %32 = getelementptr inbounds %struct.vrVec2, ptr %31, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fcmp ogt float %30, %33
  br i1 %34, label %35, label %60

35:                                               ; preds = %23
  %36 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 0
  %37 = getelementptr inbounds %struct.vrVec2, ptr %36, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !12
  %39 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 0
  %40 = getelementptr inbounds %struct.vrVec2, ptr %39, i32 0, i32 1
  %41 = load float, ptr %40, align 4, !tbaa !12
  %42 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 1
  %43 = getelementptr inbounds %struct.vrVec2, ptr %42, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !13
  %45 = fadd float %41, %44
  %46 = fcmp olt float %38, %45
  br i1 %46, label %47, label %60

47:                                               ; preds = %35
  %48 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 0
  %49 = getelementptr inbounds %struct.vrVec2, ptr %48, i32 0, i32 1
  %50 = load float, ptr %49, align 4, !tbaa !12
  %51 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %6, i32 0, i32 1
  %52 = getelementptr inbounds %struct.vrVec2, ptr %51, i32 0, i32 1
  %53 = load float, ptr %52, align 4, !tbaa !13
  %54 = fadd float %50, %53
  %55 = getelementptr inbounds %struct.vrOrientedBoundingBox, ptr %7, i32 0, i32 0
  %56 = getelementptr inbounds %struct.vrVec2, ptr %55, i32 0, i32 1
  %57 = load float, ptr %56, align 4, !tbaa !12
  %58 = fcmp ogt float %54, %57
  br i1 %58, label %59, label %60

59:                                               ; preds = %47
  store i32 1, ptr %5, align 4
  br label %61

60:                                               ; preds = %47, %35, %23, %4
  store i32 0, ptr %5, align 4
  br label %61

61:                                               ; preds = %60, %59
  %62 = load i32, ptr %5, align 4
  ret i32 %62
}

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

!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, !8, i64 0}
!6 = !{!"vrOrientedBoundingBox", !7, i64 0, !7, i64 8}
!7 = !{!"vrVec2", !8, i64 0, !8, i64 4}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!6, !8, i64 4}
!13 = !{!6, !8, i64 12}


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local range(i32 0, 2) i32 @vrOBBOverlaps(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #0 {
  %.sroa.05.0.vec.extract = extractelement <2 x float> %0, i64 0
  %.sroa.0.0.vec.extract = extractelement <2 x float> %2, i64 0
  %5 = fadd <2 x float> %2, %3
  %6 = extractelement <2 x float> %5, i64 0
  %7 = fcmp olt float %.sroa.05.0.vec.extract, %6
  %8 = fadd <2 x float> %0, %1
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp ogt float %9, %.sroa.0.0.vec.extract
  %or.cond = select i1 %7, i1 %10, i1 false
  br i1 %or.cond, label %11, label %18

11:                                               ; preds = %4
  %.sroa.0.4.vec.extract = extractelement <2 x float> %2, i64 1
  %12 = fadd <2 x float> %2, %3
  %13 = fcmp ogt <2 x float> %12, %0
  %14 = extractelement <2 x i1> %13, i64 1
  %15 = fadd <2 x float> %0, %1
  %16 = extractelement <2 x float> %15, i64 1
  %17 = fcmp ogt float %16, %.sroa.0.4.vec.extract
  %or.cond13 = select i1 %14, i1 %17, i1 false
  br i1 %or.cond13, label %19, label %18

18:                                               ; preds = %11, %4
  br label %19

19:                                               ; preds = %11, %18
  %.0 = phi i32 [ 0, %18 ], [ 1, %11 ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,VectorCombinePass