; LLVM IR from ashishzero/karma :: src/modules/core/lin_maths.ll (Z17intersect_ray_ray4Vec2S_S_S_PfS0_PS_)

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

%union.Vec2 = type { %struct.anon.1 }
%struct.anon.1 = type { float, float }

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z17intersect_ray_ray4Vec2S_S_S_PfS0_PS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, ptr noundef %4, ptr noundef %5, ptr noundef %6) #2 {
  %8 = alloca i1, align 1
  %9 = alloca %union.Vec2, align 4
  %10 = alloca %union.Vec2, align 4
  %11 = alloca %union.Vec2, align 4
  %12 = alloca %union.Vec2, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca float, align 4
  %21 = alloca float, align 4
  %22 = alloca float, align 4
  %23 = alloca i32, align 4
  %24 = getelementptr inbounds %union.Vec2, ptr %9, i32 0, i32 0
  store <2 x float> %0, ptr %24, align 4
  %25 = getelementptr inbounds %union.Vec2, ptr %10, i32 0, i32 0
  store <2 x float> %1, ptr %25, align 4
  %26 = getelementptr inbounds %union.Vec2, ptr %11, i32 0, i32 0
  store <2 x float> %2, ptr %26, align 4
  %27 = getelementptr inbounds %union.Vec2, ptr %12, i32 0, i32 0
  store <2 x float> %3, ptr %27, align 4
  store ptr %4, ptr %13, align 8, !tbaa !5
  store ptr %5, ptr %14, align 8, !tbaa !5
  store ptr %6, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %28 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 0
  %29 = load float, ptr %28, align 4, !tbaa !9
  %30 = getelementptr inbounds %struct.anon.1, ptr %10, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !9
  %32 = fsub float %29, %31
  store float %32, ptr %16, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %33 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 1
  %34 = load float, ptr %33, align 4, !tbaa !9
  %35 = getelementptr inbounds %struct.anon.1, ptr %10, i32 0, i32 1
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = fsub float %34, %36
  store float %37, ptr %17, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %38 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 0
  %39 = load float, ptr %38, align 4, !tbaa !9
  %40 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 0
  %41 = load float, ptr %40, align 4, !tbaa !9
  %42 = fsub float %39, %41
  store float %42, ptr %18, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %43 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 1
  %44 = load float, ptr %43, align 4, !tbaa !9
  %45 = getelementptr inbounds %struct.anon.1, ptr %12, i32 0, i32 1
  %46 = load float, ptr %45, align 4, !tbaa !9
  %47 = fsub float %44, %46
  store float %47, ptr %19, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #3
  %48 = load float, ptr %16, align 4, !tbaa !10
  %49 = load float, ptr %19, align 4, !tbaa !10
  %50 = load float, ptr %17, align 4, !tbaa !10
  %51 = load float, ptr %18, align 4, !tbaa !10
  %52 = fmul float %50, %51
  %53 = fneg float %52
  %54 = call float @llvm.fmuladd.f32(float %48, float %49, float %53)
  store float %54, ptr %20, align 4, !tbaa !10
  %55 = load float, ptr %20, align 4, !tbaa !10
  %56 = fcmp une float %55, 0.000000e+00
  br i1 %56, label %57, label %114

57:                                               ; preds = %7
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #3
  %58 = load float, ptr %16, align 4, !tbaa !10
  %59 = fneg float %58
  %60 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 1
  %61 = load float, ptr %60, align 4, !tbaa !9
  %62 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 1
  %63 = load float, ptr %62, align 4, !tbaa !9
  %64 = fsub float %61, %63
  %65 = load float, ptr %17, align 4, !tbaa !10
  %66 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 0
  %67 = load float, ptr %66, align 4, !tbaa !9
  %68 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 0
  %69 = load float, ptr %68, align 4, !tbaa !9
  %70 = fsub float %67, %69
  %71 = fmul float %65, %70
  %72 = call float @llvm.fmuladd.f32(float %59, float %64, float %71)
  store float %72, ptr %21, align 4, !tbaa !10
  %73 = load float, ptr %21, align 4, !tbaa !10
  %74 = load float, ptr %20, align 4, !tbaa !10
  %75 = fdiv float %73, %74
  %76 = load ptr, ptr %14, align 8, !tbaa !5
  store float %75, ptr %76, align 4, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #3
  %77 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 0
  %78 = load float, ptr %77, align 4, !tbaa !9
  %79 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 0
  %80 = load float, ptr %79, align 4, !tbaa !9
  %81 = fsub float %78, %80
  %82 = load float, ptr %19, align 4, !tbaa !10
  %83 = getelementptr inbounds %struct.anon.1, ptr %9, i32 0, i32 1
  %84 = load float, ptr %83, align 4, !tbaa !9
  %85 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 1
  %86 = load float, ptr %85, align 4, !tbaa !9
  %87 = fsub float %84, %86
  %88 = load float, ptr %18, align 4, !tbaa !10
  %89 = fmul float %87, %88
  %90 = fneg float %89
  %91 = call float @llvm.fmuladd.f32(float %81, float %82, float %90)
  store float %91, ptr %22, align 4, !tbaa !10
  %92 = load float, ptr %22, align 4, !tbaa !10
  %93 = load float, ptr %20, align 4, !tbaa !10
  %94 = fdiv float %92, %93
  %95 = load ptr, ptr %13, align 8, !tbaa !5
  store float %94, ptr %95, align 4, !tbaa !10
  %96 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 0
  %97 = load float, ptr %96, align 4, !tbaa !9
  %98 = load ptr, ptr %14, align 8, !tbaa !5
  %99 = load float, ptr %98, align 4, !tbaa !10
  %100 = load float, ptr %18, align 4, !tbaa !10
  %101 = fneg float %99
  %102 = call float @llvm.fmuladd.f32(float %101, float %100, float %97)
  %103 = load ptr, ptr %15, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.anon.1, ptr %103, i32 0, i32 0
  store float %102, ptr %104, align 4, !tbaa !9
  %105 = getelementptr inbounds %struct.anon.1, ptr %11, i32 0, i32 1
  %106 = load float, ptr %105, align 4, !tbaa !9
  %107 = load ptr, ptr %14, align 8, !tbaa !5
  %108 = load float, ptr %107, align 4, !tbaa !10
  %109 = load float, ptr %19, align 4, !tbaa !10
  %110 = fneg float %108
  %111 = call float @llvm.fmuladd.f32(float %110, float %109, float %106)
  %112 = load ptr, ptr %15, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.anon.1, ptr %112, i32 0, i32 1
  store float %111, ptr %113, align 4, !tbaa !9
  store i1 true, ptr %8, align 1
  store i32 1, ptr %23, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  br label %115

114:                                              ; preds = %7
  store i1 false, ptr %8, align 1
  store i32 1, ptr %23, align 4
  br label %115

115:                                              ; preds = %114, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  %116 = load i1, ptr %8, align 1
  ret i1 %116
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !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"

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local noundef zeroext i1 @_Z17intersect_ray_ray4Vec2S_S_S_PfS0_PS_(<2 x float> %0, <2 x float> %1, <2 x float> %2, <2 x float> %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef %5, ptr nocapture noundef writeonly %6) local_unnamed_addr #1 {
  %8 = fsub <2 x float> %0, %1
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fsub <2 x float> %0, %1
  %11 = extractelement <2 x float> %10, i64 1
  %12 = fsub <2 x float> %2, %3
  %13 = extractelement <2 x float> %12, i64 0
  %14 = fsub <2 x float> %2, %3
  %15 = extractelement <2 x float> %14, i64 1
  %16 = fneg float %11
  %17 = fmul float %13, %16
  %18 = tail call float @llvm.fmuladd.f32(float %9, float %15, float %17)
  %19 = fcmp une float %18, 0.000000e+00
  br i1 %19, label %20, label %39

20:                                               ; preds = %7
  %.sroa.021.4.vec.extract = extractelement <2 x float> %2, i64 1
  %.sroa.021.0.vec.extract = extractelement <2 x float> %2, i64 0
  %.sroa.035.4.vec.extract = extractelement <2 x float> %0, i64 1
  %21 = fneg float %9
  %22 = fsub float %.sroa.035.4.vec.extract, %.sroa.021.4.vec.extract
  %23 = fsub <2 x float> %0, %2
  %24 = extractelement <2 x float> %23, i64 0
  %25 = fmul float %11, %24
  %26 = tail call float @llvm.fmuladd.f32(float %21, float %22, float %25)
  %27 = fdiv float %26, %18
  store float %27, ptr %5, align 4, !tbaa !5
  %28 = fneg float %22
  %29 = fmul float %13, %28
  %30 = tail call float @llvm.fmuladd.f32(float %24, float %15, float %29)
  %31 = fdiv float %30, %18
  store float %31, ptr %4, align 4, !tbaa !5
  %32 = load float, ptr %5, align 4, !tbaa !5
  %33 = fneg float %32
  %34 = tail call float @llvm.fmuladd.f32(float %33, float %13, float %.sroa.021.0.vec.extract)
  store float %34, ptr %6, align 4, !tbaa !9
  %35 = load float, ptr %5, align 4, !tbaa !5
  %36 = fneg float %35
  %37 = tail call float @llvm.fmuladd.f32(float %36, float %15, float %.sroa.021.4.vec.extract)
  %38 = getelementptr inbounds i8, ptr %6, i64 4
  store float %37, ptr %38, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %7, %20
  ret i1 %19
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}


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