; 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 @vrOBBContains(<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 = fcmp olt float %14, %17
  br i1 %18, label %19, label %60

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

35:                                               ; preds = %19
  %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 = fcmp olt float %38, %41
  br i1 %42, label %43, label %60

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

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

60:                                               ; preds = %43, %35, %19, %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 @vrOBBContains(<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 = fcmp olt float %.sroa.05.0.vec.extract, %.sroa.0.0.vec.extract
  %6 = fadd <2 x float> %0, %1
  %7 = extractelement <2 x float> %6, i64 0
  %8 = fadd <2 x float> %2, %3
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp ogt float %7, %9
  %or.cond = select i1 %5, i1 %10, i1 false
  %.sroa.05.4.vec.extract = extractelement <2 x float> %0, i64 1
  %.sroa.0.4.vec.extract = extractelement <2 x float> %2, i64 1
  %11 = fcmp olt float %.sroa.05.4.vec.extract, %.sroa.0.4.vec.extract
  %or.cond13 = select i1 %or.cond, i1 %11, i1 false
  br i1 %or.cond13, label %12, label %17

12:                                               ; preds = %4
  %13 = fadd <2 x float> %0, %1
  %14 = fadd <2 x float> %2, %3
  %15 = fcmp ogt <2 x float> %13, %14
  %16 = extractelement <2 x i1> %15, i64 1
  br i1 %16, label %18, label %17

17:                                               ; preds = %12, %4
  br label %18

18:                                               ; preds = %12, %17
  %.0 = phi i32 [ 0, %17 ], [ 1, %12 ]
  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