; LLVM IR from erayzesen/QuarkPhysics :: QuarkPhysics/qcollision.ll (ZN10QCollision20LineIntersectionLineE7QVectorS0_S0_S0_)

; 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.QVector = type { float, float }

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) #3 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZN10QCollision20LineIntersectionLineE7QVectorS0_S0_S0_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) #2 align 2 {
  %5 = alloca %struct.QVector, align 4
  %6 = alloca %struct.QVector, align 4
  %7 = alloca %struct.QVector, align 4
  %8 = alloca %struct.QVector, align 4
  %9 = alloca %struct.QVector, align 4
  %10 = alloca %struct.QVector, align 4
  %11 = alloca %struct.QVector, align 4
  %12 = alloca %struct.QVector, align 4
  %13 = alloca %struct.QVector, align 4
  %14 = alloca %struct.QVector, align 4
  %15 = alloca %struct.QVector, align 4
  %16 = alloca %struct.QVector, align 4
  %17 = alloca %struct.QVector, align 4
  %18 = alloca %struct.QVector, align 4
  %19 = alloca %struct.QVector, align 4
  %20 = alloca float, align 4
  %21 = alloca %struct.QVector, align 4
  %22 = alloca %struct.QVector, align 4
  %23 = alloca i32, align 4
  %24 = alloca %struct.QVector, align 4
  %25 = alloca float, align 4
  %26 = alloca %struct.QVector, align 4
  %27 = alloca %struct.QVector, align 4
  %28 = alloca %struct.QVector, align 4
  %29 = alloca %struct.QVector, align 4
  %30 = alloca %struct.QVector, align 4
  store <2 x float> %0, ptr %6, align 4
  store <2 x float> %1, ptr %7, align 4
  store <2 x float> %2, ptr %8, align 4
  store <2 x float> %3, ptr %9, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %7, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !5
  %31 = load <2 x float>, ptr %11, align 4
  %32 = load <2 x float>, ptr %12, align 4
  %33 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %31, <2 x float> %32)
  store <2 x float> %33, ptr %10, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %14, ptr align 4 %9, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !5
  %34 = load <2 x float>, ptr %14, align 4
  %35 = load <2 x float>, ptr %15, align 4
  %36 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %34, <2 x float> %35)
  store <2 x float> %36, ptr %13, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %37 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %13)
  store <2 x float> %37, ptr %16, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %18, ptr align 4 %8, i64 8, i1 false), !tbaa.struct !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %19, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !5
  %38 = load <2 x float>, ptr %18, align 4
  %39 = load <2 x float>, ptr %19, align 4
  %40 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %38, <2 x float> %39)
  store <2 x float> %40, ptr %17, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %21, ptr align 4 %16, i64 8, i1 false), !tbaa.struct !5
  %41 = load <2 x float>, ptr %21, align 4
  %42 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %17, <2 x float> %41)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %22, ptr align 4 %16, i64 8, i1 false), !tbaa.struct !5
  %43 = load <2 x float>, ptr %22, align 4
  %44 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %10, <2 x float> %43)
  %45 = fdiv float %42, %44
  store float %45, ptr %20, align 4, !tbaa !6
  %46 = load float, ptr %20, align 4, !tbaa !6
  %47 = fcmp olt float %46, 0.000000e+00
  br i1 %47, label %54, label %48

48:                                               ; preds = %4
  %49 = load float, ptr %20, align 4, !tbaa !6
  %50 = fcmp ogt float %49, 1.000000e+00
  br i1 %50, label %54, label %51

51:                                               ; preds = %48
  %52 = load float, ptr %20, align 4, !tbaa !6
  %53 = fcmp oeq float %52, 0.000000e+00
  br i1 %53, label %54, label %56

54:                                               ; preds = %51, %48, %4
  %55 = call <2 x float> @_ZN7QVector3NaNEv()
  store <2 x float> %55, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %79

56:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #5
  %57 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %10)
  store <2 x float> %57, ptr %24, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %26, ptr align 4 %24, i64 8, i1 false), !tbaa.struct !5
  %58 = load <2 x float>, ptr %26, align 4
  %59 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %17, <2 x float> %58)
  %60 = fneg float %59
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %27, ptr align 4 %24, i64 8, i1 false), !tbaa.struct !5
  %61 = load <2 x float>, ptr %27, align 4
  %62 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %13, <2 x float> %61)
  %63 = fdiv float %60, %62
  store float %63, ptr %25, align 4, !tbaa !6
  %64 = load float, ptr %25, align 4, !tbaa !6
  %65 = fcmp olt float %64, 0.000000e+00
  br i1 %65, label %69, label %66

66:                                               ; preds = %56
  %67 = load float, ptr %25, align 4, !tbaa !6
  %68 = fcmp ogt float %67, 1.000000e+00
  br i1 %68, label %69, label %71

69:                                               ; preds = %66, %56
  %70 = call <2 x float> @_ZN7QVector3NaNEv()
  store <2 x float> %70, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %78

71:                                               ; preds = %66
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %28, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !5
  %72 = load float, ptr %20, align 4, !tbaa !6
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !5
  %73 = load <2 x float>, ptr %30, align 4
  %74 = call <2 x float> @_Zmlf7QVector(float noundef %72, <2 x float> %73)
  store <2 x float> %74, ptr %29, align 4
  %75 = load <2 x float>, ptr %28, align 4
  %76 = load <2 x float>, ptr %29, align 4
  %77 = call <2 x float> @_Zpl7QVectorS_(<2 x float> %75, <2 x float> %76)
  store <2 x float> %77, ptr %5, align 4
  store i32 1, ptr %23, align 4
  br label %78

78:                                               ; preds = %71, %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #5
  br label %79

79:                                               ; preds = %78, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  %80 = load <2 x float>, ptr %5, align 4
  ret <2 x float> %80
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zpl7QVectorS_(<2 x float>, <2 x float>) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8)) #4 align 2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) #2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZN7QVector3NaNEv() #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #3 = { inlinehint mustprogress 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 = { inlinehint 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 #5 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple 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"

%struct.QVector = type { float, float }

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

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmi7QVectorS_(<2 x float>, <2 x float>) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8), <2 x float>) local_unnamed_addr #2 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local <2 x float> @_ZN10QCollision20LineIntersectionLineE7QVectorS0_S0_S0_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %struct.QVector, align 8
  %6 = alloca %struct.QVector, align 8
  %7 = alloca %struct.QVector, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #4
  %8 = tail call <2 x float> @_Zmi7QVectorS_(<2 x float> %1, <2 x float> %0)
  store <2 x float> %8, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %9 = tail call <2 x float> @_Zmi7QVectorS_(<2 x float> %3, <2 x float> %2)
  store <2 x float> %9, ptr %6, align 8
  %10 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %6)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #4
  %11 = call <2 x float> @_Zmi7QVectorS_(<2 x float> %2, <2 x float> %0)
  store <2 x float> %11, ptr %7, align 8
  %12 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %7, <2 x float> %10)
  %13 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %5, <2 x float> %10)
  %14 = fdiv float %12, %13
  %15 = fcmp olt float %14, 0.000000e+00
  %16 = fcmp ogt float %14, 1.000000e+00
  %or.cond = or i1 %15, %16
  %17 = fcmp oeq float %14, 0.000000e+00
  %or.cond3 = or i1 %17, %or.cond
  br i1 %or.cond3, label %18, label %20

18:                                               ; preds = %4
  %19 = call <2 x float> @_ZN7QVector3NaNEv()
  br label %33

20:                                               ; preds = %4
  %21 = call <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8) %5)
  %22 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %7, <2 x float> %21)
  %23 = fneg float %22
  %24 = call noundef float @_ZNK7QVector3DotES_(ptr noundef nonnull align 4 dereferenceable(8) %6, <2 x float> %21)
  %25 = fdiv float %23, %24
  %26 = fcmp olt float %25, 0.000000e+00
  %27 = fcmp ogt float %25, 1.000000e+00
  %or.cond5 = or i1 %26, %27
  br i1 %or.cond5, label %28, label %30

28:                                               ; preds = %20
  %29 = call <2 x float> @_ZN7QVector3NaNEv()
  br label %33

30:                                               ; preds = %20
  %.sroa.0.0.copyload = load <2 x float>, ptr %5, align 8
  %31 = call <2 x float> @_Zmlf7QVector(float noundef %14, <2 x float> %.sroa.0.0.copyload)
  %32 = call <2 x float> @_Zpl7QVectorS_(<2 x float> %0, <2 x float> %31)
  br label %33

33:                                               ; preds = %28, %30, %18
  %.sroa.034.1 = phi <2 x float> [ %19, %18 ], [ %29, %28 ], [ %32, %30 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #4
  ret <2 x float> %.sroa.034.1
}

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zpl7QVectorS_(<2 x float>, <2 x float>) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local <2 x float> @_ZNK7QVector13PerpendicularEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_Zmlf7QVector(float noundef, <2 x float>) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local <2 x float> @_ZN7QVector3NaNEv() local_unnamed_addr #1 align 2

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


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