; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_core_3d.ll (ZN6SoLoud7dopplerENS_4vec3ERKS0_S2_ff)

; 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.SoLoud::vec3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN6SoLoud7dopplerENS_4vec3ERKS0_S2_ff(<2 x float> %0, float %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %4, float noundef %5) #0 {
  %7 = alloca float, align 4
  %8 = alloca %"struct.SoLoud::vec3", align 4
  %9 = alloca { <2 x float>, float }, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  %19 = getelementptr inbounds { <2 x float>, float }, ptr %9, i32 0, i32 0
  store <2 x float> %0, ptr %19, align 4
  %20 = getelementptr inbounds { <2 x float>, float }, ptr %9, i32 0, i32 1
  store float %1, ptr %20, align 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %9, i64 12, i1 false)
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store float %4, ptr %12, align 4, !tbaa !9
  store float %5, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %21 = call noundef float @_ZN6SoLoud4vec33magEv(ptr noundef nonnull align 4 dereferenceable(12) %8)
  store float %21, ptr %14, align 4, !tbaa !9
  %22 = load float, ptr %14, align 4, !tbaa !9
  %23 = fcmp oeq float %22, 0.000000e+00
  br i1 %23, label %24, label %25

24:                                               ; preds = %6
  store float 1.000000e+00, ptr %7, align 4
  store i32 1, ptr %15, align 4
  br label %66

25:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = call noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %26)
  %28 = load float, ptr %14, align 4, !tbaa !9
  %29 = fdiv float %27, %28
  store float %29, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = call noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %8, ptr noundef nonnull align 4 dereferenceable(12) %30)
  %32 = load float, ptr %14, align 4, !tbaa !9
  %33 = fdiv float %31, %32
  store float %33, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %34 = load float, ptr %13, align 4, !tbaa !9
  %35 = load float, ptr %12, align 4, !tbaa !9
  %36 = fdiv float %34, %35
  store float %36, ptr %18, align 4, !tbaa !9
  %37 = load float, ptr %17, align 4, !tbaa !9
  %38 = load float, ptr %18, align 4, !tbaa !9
  %39 = fcmp olt float %37, %38
  br i1 %39, label %40, label %42

40:                                               ; preds = %25
  %41 = load float, ptr %17, align 4, !tbaa !9
  br label %44

42:                                               ; preds = %25
  %43 = load float, ptr %18, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %42, %40
  %45 = phi float [ %41, %40 ], [ %43, %42 ]
  store float %45, ptr %17, align 4, !tbaa !9
  %46 = load float, ptr %16, align 4, !tbaa !9
  %47 = load float, ptr %18, align 4, !tbaa !9
  %48 = fcmp olt float %46, %47
  br i1 %48, label %49, label %51

49:                                               ; preds = %44
  %50 = load float, ptr %16, align 4, !tbaa !9
  br label %53

51:                                               ; preds = %44
  %52 = load float, ptr %18, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %51, %49
  %54 = phi float [ %50, %49 ], [ %52, %51 ]
  store float %54, ptr %16, align 4, !tbaa !9
  %55 = load float, ptr %13, align 4, !tbaa !9
  %56 = load float, ptr %12, align 4, !tbaa !9
  %57 = load float, ptr %16, align 4, !tbaa !9
  %58 = fneg float %56
  %59 = call float @llvm.fmuladd.f32(float %58, float %57, float %55)
  %60 = load float, ptr %13, align 4, !tbaa !9
  %61 = load float, ptr %12, align 4, !tbaa !9
  %62 = load float, ptr %17, align 4, !tbaa !9
  %63 = fneg float %61
  %64 = call float @llvm.fmuladd.f32(float %63, float %62, float %60)
  %65 = fdiv float %59, %64
  store float %65, ptr %7, align 4
  store i32 1, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %66

66:                                               ; preds = %53, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  %67 = load float, ptr %7, align 4
  ret float %67
}

; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN6SoLoud4vec33magEv(ptr noundef nonnull align 4 dereferenceable(12)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) #4 align 2

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

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

attributes #0 = { 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 #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { 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 = !{!10, !10, i64 0}
!10 = !{!"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"

%"struct.SoLoud::vec3" = type { float, float, float }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN6SoLoud7dopplerENS_4vec3ERKS0_S2_ff(<2 x float> %0, float %1, ptr noundef nonnull align 4 dereferenceable(12) %2, ptr noundef nonnull align 4 dereferenceable(12) %3, float noundef %4, float noundef %5) local_unnamed_addr #0 {
  %7 = alloca %"struct.SoLoud::vec3", align 8
  store <2 x float> %0, ptr %7, align 8
  %.sroa.2.0..sroa_idx = getelementptr inbounds i8, ptr %7, i64 8
  store float %1, ptr %.sroa.2.0..sroa_idx, align 8
  %8 = call noundef float @_ZN6SoLoud4vec33magEv(ptr noundef nonnull align 4 dereferenceable(12) %7)
  %9 = fcmp oeq float %8, 0.000000e+00
  br i1 %9, label %32, label %10

10:                                               ; preds = %6
  %11 = call noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %3)
  %12 = call noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12) %7, ptr noundef nonnull align 4 dereferenceable(12) %2)
  %13 = fdiv float %5, %4
  %14 = fneg float %4
  %15 = insertelement <2 x float> poison, float %11, i64 0
  %16 = insertelement <2 x float> %15, float %12, i64 1
  %17 = insertelement <2 x float> poison, float %8, i64 0
  %18 = shufflevector <2 x float> %17, <2 x float> poison, <2 x i32> zeroinitializer
  %19 = fdiv <2 x float> %16, %18
  %20 = insertelement <2 x float> poison, float %13, i64 0
  %21 = shufflevector <2 x float> %20, <2 x float> poison, <2 x i32> zeroinitializer
  %22 = fcmp olt <2 x float> %19, %21
  %23 = select <2 x i1> %22, <2 x float> %19, <2 x float> %21
  %24 = insertelement <2 x float> poison, float %14, i64 0
  %25 = shufflevector <2 x float> %24, <2 x float> poison, <2 x i32> zeroinitializer
  %26 = insertelement <2 x float> poison, float %5, i64 0
  %27 = shufflevector <2 x float> %26, <2 x float> poison, <2 x i32> zeroinitializer
  %28 = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> %25, <2 x float> %23, <2 x float> %27)
  %29 = extractelement <2 x float> %28, i64 0
  %30 = extractelement <2 x float> %28, i64 1
  %31 = fdiv float %29, %30
  br label %32

32:                                               ; preds = %6, %10
  %.0 = phi float [ %31, %10 ], [ 1.000000e+00, %6 ]
  ret float %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local noundef float @_ZN6SoLoud4vec33magEv(ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef float @_ZN6SoLoud4vec33dotERKS0_(ptr noundef nonnull align 4 dereferenceable(12), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x float> @llvm.fmuladd.v2f32(<2 x float>, <2 x float>, <2 x float>) #3

attributes #0 = { 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 #1 = { mustprogress uwtable "min-legal-vector-width"="0" "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 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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,GlobalDCEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass