; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/DistanceFunctions (arm_correlation_distance_f32)

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

; Function Attrs: nounwind uwtable
define dso_local float @arm_correlation_distance_f32(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_mean_f32(ptr noundef %13, i32 noundef %14, ptr noundef %7)
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_mean_f32(ptr noundef %15, i32 noundef %16, ptr noundef %8)
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load float, ptr %7, align 4, !tbaa !11
  %19 = fneg float %18
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_offset_f32(ptr noundef %17, float noundef %19, ptr noundef %20, i32 noundef %21)
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load float, ptr %8, align 4, !tbaa !11
  %24 = fneg float %23
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_offset_f32(ptr noundef %22, float noundef %24, ptr noundef %25, i32 noundef %26)
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_power_f32(ptr noundef %27, i32 noundef %28, ptr noundef %9)
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_power_f32(ptr noundef %29, i32 noundef %30, ptr noundef %10)
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  call void @arm_dot_prod_f32(ptr noundef %31, ptr noundef %32, i32 noundef %33, ptr noundef %11)
  %34 = load float, ptr %11, align 4, !tbaa !11
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = uitofp i32 %35 to float
  %37 = fdiv float %34, %36
  store float %37, ptr %11, align 4, !tbaa !11
  %38 = load float, ptr %9, align 4, !tbaa !11
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = uitofp i32 %39 to float
  %41 = fdiv float %38, %40
  store float %41, ptr %9, align 4, !tbaa !11
  %42 = load float, ptr %10, align 4, !tbaa !11
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = uitofp i32 %43 to float
  %45 = fdiv float %42, %44
  store float %45, ptr %10, align 4, !tbaa !11
  %46 = load float, ptr %9, align 4, !tbaa !11
  %47 = load float, ptr %10, align 4, !tbaa !11
  %48 = fmul float %46, %47
  %49 = call i32 @arm_sqrt_f32(float noundef %48, ptr noundef %12)
  %50 = load float, ptr %11, align 4, !tbaa !11
  %51 = load float, ptr %12, align 4, !tbaa !11
  %52 = fdiv float %50, %51
  %53 = fsub float 1.000000e+00, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret float %53
}

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

declare void @arm_mean_f32(ptr noundef, i32 noundef, ptr noundef) #2

declare void @arm_offset_f32(ptr noundef, float noundef, ptr noundef, i32 noundef) #2

declare void @arm_power_f32(ptr noundef, i32 noundef, ptr noundef) #2

declare void @arm_dot_prod_f32(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_sqrt_f32(float noundef, ptr noundef) #3

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "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 = { alwaysinline 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 #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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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: nounwind uwtable
define dso_local float @arm_correlation_distance_f32(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  call void @arm_mean_f32(ptr noundef %0, i32 noundef %2, ptr noundef nonnull %4) #4
  call void @arm_mean_f32(ptr noundef %1, i32 noundef %2, ptr noundef nonnull %5) #4
  %10 = load float, ptr %4, align 4, !tbaa !5
  %11 = fneg float %10
  call void @arm_offset_f32(ptr noundef %0, float noundef %11, ptr noundef %0, i32 noundef %2) #4
  %12 = load float, ptr %5, align 4, !tbaa !5
  %13 = fneg float %12
  call void @arm_offset_f32(ptr noundef %1, float noundef %13, ptr noundef %1, i32 noundef %2) #4
  call void @arm_power_f32(ptr noundef %0, i32 noundef %2, ptr noundef nonnull %6) #4
  call void @arm_power_f32(ptr noundef %1, i32 noundef %2, ptr noundef nonnull %7) #4
  call void @arm_dot_prod_f32(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef nonnull %8) #4
  %14 = load float, ptr %8, align 4, !tbaa !5
  %15 = uitofp i32 %2 to float
  %16 = fdiv float %14, %15
  store float %16, ptr %8, align 4, !tbaa !5
  %17 = load float, ptr %6, align 4, !tbaa !5
  %18 = load float, ptr %7, align 4, !tbaa !5
  %19 = insertelement <2 x float> poison, float %17, i64 0
  %20 = insertelement <2 x float> %19, float %18, i64 1
  %21 = insertelement <2 x float> poison, float %15, i64 0
  %22 = shufflevector <2 x float> %21, <2 x float> poison, <2 x i32> zeroinitializer
  %23 = fdiv <2 x float> %20, %22
  %24 = extractelement <2 x float> %23, i64 0
  store float %24, ptr %6, align 4, !tbaa !5
  %25 = extractelement <2 x float> %23, i64 1
  store float %25, ptr %7, align 4, !tbaa !5
  %26 = fmul float %24, %25
  %27 = call i32 @arm_sqrt_f32(float noundef %26, ptr noundef nonnull %9)
  %28 = load float, ptr %8, align 4, !tbaa !5
  %29 = load float, ptr %9, align 4, !tbaa !5
  %30 = fdiv float %28, %29
  %31 = fsub float 1.000000e+00, %30
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret float %31
}

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

declare void @arm_mean_f32(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @arm_offset_f32(ptr noundef, float noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_power_f32(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

declare void @arm_dot_prod_f32(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @arm_sqrt_f32(float noundef, ptr noundef) local_unnamed_addr #3

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

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass