; LLVM IR from mvr/jiggle :: src (Vector2)

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

; Function Attrs: nounwind uwtable
define dso_local float @jgVector2PositionAlong(<2 x float> %0, <2 x float> %1, <2 x float> %2) #0 {
  %4 = alloca float, align 4
  %5 = alloca %struct.jgVector2, align 4
  %6 = alloca %struct.jgVector2, align 4
  %7 = alloca %struct.jgVector2, align 4
  store <2 x float> %0, ptr %5, align 4
  store <2 x float> %1, ptr %6, align 4
  store <2 x float> %2, ptr %7, align 4
  %8 = load <2 x float>, ptr %7, align 4
  %9 = load <2 x float>, ptr %5, align 4
  %10 = call zeroext i1 @jgVector2Equal(<2 x float> %8, <2 x float> %9)
  br i1 %10, label %11, label %12

11:                                               ; preds = %3
  store float 0.000000e+00, ptr %4, align 4
  br label %48

12:                                               ; preds = %3
  %13 = load <2 x float>, ptr %7, align 4
  %14 = load <2 x float>, ptr %6, align 4
  %15 = call zeroext i1 @jgVector2Equal(<2 x float> %13, <2 x float> %14)
  br i1 %15, label %16, label %17

16:                                               ; preds = %12
  store float 1.000000e+00, ptr %4, align 4
  br label %48

17:                                               ; preds = %12
  %18 = getelementptr inbounds %struct.jgVector2, ptr %6, i32 0, i32 0
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = getelementptr inbounds %struct.jgVector2, ptr %5, i32 0, i32 0
  %21 = load float, ptr %20, align 4, !tbaa !5
  %22 = fsub float %19, %21
  %23 = fcmp une float %22, 0.000000e+00
  br i1 %23, label %24, label %36

24:                                               ; preds = %17
  %25 = getelementptr inbounds %struct.jgVector2, ptr %7, i32 0, i32 0
  %26 = load float, ptr %25, align 4, !tbaa !5
  %27 = getelementptr inbounds %struct.jgVector2, ptr %5, i32 0, i32 0
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = fsub float %26, %28
  %30 = getelementptr inbounds %struct.jgVector2, ptr %6, i32 0, i32 0
  %31 = load float, ptr %30, align 4, !tbaa !5
  %32 = getelementptr inbounds %struct.jgVector2, ptr %5, i32 0, i32 0
  %33 = load float, ptr %32, align 4, !tbaa !5
  %34 = fsub float %31, %33
  %35 = fdiv float %29, %34
  store float %35, ptr %4, align 4
  br label %48

36:                                               ; preds = %17
  %37 = getelementptr inbounds %struct.jgVector2, ptr %7, i32 0, i32 1
  %38 = load float, ptr %37, align 4, !tbaa !10
  %39 = getelementptr inbounds %struct.jgVector2, ptr %5, i32 0, i32 1
  %40 = load float, ptr %39, align 4, !tbaa !10
  %41 = fsub float %38, %40
  %42 = getelementptr inbounds %struct.jgVector2, ptr %6, i32 0, i32 1
  %43 = load float, ptr %42, align 4, !tbaa !10
  %44 = getelementptr inbounds %struct.jgVector2, ptr %5, i32 0, i32 1
  %45 = load float, ptr %44, align 4, !tbaa !10
  %46 = fsub float %43, %45
  %47 = fdiv float %41, %46
  store float %47, ptr %4, align 4
  br label %48

48:                                               ; preds = %36, %24, %16, %11
  %49 = load float, ptr %4, align 4
  ret float %49
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @jgVector2Equal(<2 x float>, <2 x float>) #1

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" }
attributes #1 = { inlinehint 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, !7, i64 0}
!6 = !{!"jgVector2", !7, i64 0, !7, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


; 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: nounwind uwtable
define dso_local float @jgVector2PositionAlong(<2 x float> %0, <2 x float> %1, <2 x float> %2) local_unnamed_addr #0 {
  %4 = tail call zeroext i1 @jgVector2Equal(<2 x float> %2, <2 x float> %0)
  br i1 %4, label %22, label %5

5:                                                ; preds = %3
  %6 = tail call zeroext i1 @jgVector2Equal(<2 x float> %2, <2 x float> %1)
  br i1 %6, label %22, label %7

7:                                                ; preds = %5
  %8 = fsub <2 x float> %1, %0
  %9 = extractelement <2 x float> %8, i64 0
  %10 = fcmp une float %9, 0.000000e+00
  br i1 %10, label %11, label %15

11:                                               ; preds = %7
  %12 = fsub <2 x float> %2, %0
  %13 = extractelement <2 x float> %12, i64 0
  %14 = fdiv float %13, %9
  br label %22

15:                                               ; preds = %7
  %16 = shufflevector <2 x float> %2, <2 x float> %1, <2 x i32> <i32 1, i32 3>
  %17 = shufflevector <2 x float> %0, <2 x float> poison, <2 x i32> <i32 1, i32 1>
  %18 = fsub <2 x float> %16, %17
  %19 = extractelement <2 x float> %18, i64 0
  %20 = extractelement <2 x float> %18, i64 1
  %21 = fdiv float %19, %20
  br label %22

22:                                               ; preds = %5, %3, %15, %11
  %.0 = phi float [ %14, %11 ], [ %21, %15 ], [ 0.000000e+00, %3 ], [ 1.000000e+00, %5 ]
  ret float %.0
}

; Function Attrs: inlinehint nounwind uwtable
declare hidden zeroext i1 @jgVector2Equal(<2 x float>, <2 x float>) local_unnamed_addr #1

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" }
attributes #1 = { inlinehint 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)"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass,VectorCombinePass