; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/BayesFunctions (arm_gaussian_naive_bayes_predict_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"

%struct.arm_gaussian_naive_bayes_instance_f32 = type { i32, i32, ptr, ptr, ptr, float }

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_gaussian_naive_bayes_predict_f32(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %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 i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %22, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store ptr %24, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %25, i32 0, i32 2
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  store ptr %27, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  store ptr %30, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %31, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %32, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %34, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !13
  store ptr %36, ptr %12, align 8, !tbaa !5
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %37, i32 0, i32 3
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  store ptr %39, ptr %13, align 8, !tbaa !5
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %40

40:                                               ; preds = %105, %4
  %41 = load i32, ptr %9, align 4, !tbaa !15
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %42, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !16
  %45 = icmp ult i32 %41, %44
  br i1 %45, label %46, label %108

46:                                               ; preds = %40
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %47, ptr %15, align 8, !tbaa !5
  store float 0.000000e+00, ptr %18, align 4, !tbaa !17
  store float 0.000000e+00, ptr %19, align 4, !tbaa !17
  store float 0.000000e+00, ptr %20, align 4, !tbaa !17
  store i32 0, ptr %10, align 4, !tbaa !15
  br label %48

48:                                               ; preds = %87, %46
  %49 = load i32, ptr %10, align 4, !tbaa !15
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %50, i32 0, i32 0
  %52 = load i32, ptr %51, align 8, !tbaa !18
  %53 = icmp ult i32 %49, %52
  br i1 %53, label %54, label %90

54:                                               ; preds = %48
  %55 = load ptr, ptr %13, align 8, !tbaa !5
  %56 = load float, ptr %55, align 4, !tbaa !17
  %57 = load ptr, ptr %5, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %57, i32 0, i32 5
  %59 = load float, ptr %58, align 8, !tbaa !19
  %60 = fadd float %56, %59
  store float %60, ptr %17, align 4, !tbaa !17
  %61 = load float, ptr %17, align 4, !tbaa !17
  %62 = fmul float 0x401921FB60000000, %61
  %63 = call float @logf(float noundef %62) #5
  %64 = load float, ptr %19, align 4, !tbaa !17
  %65 = fadd float %64, %63
  store float %65, ptr %19, align 4, !tbaa !17
  %66 = load ptr, ptr %15, align 8, !tbaa !5
  %67 = load float, ptr %66, align 4, !tbaa !17
  %68 = load ptr, ptr %12, align 8, !tbaa !5
  %69 = load float, ptr %68, align 4, !tbaa !17
  %70 = fsub float %67, %69
  %71 = load ptr, ptr %15, align 8, !tbaa !5
  %72 = load float, ptr %71, align 4, !tbaa !17
  %73 = load ptr, ptr %12, align 8, !tbaa !5
  %74 = load float, ptr %73, align 4, !tbaa !17
  %75 = fsub float %72, %74
  %76 = fmul float %70, %75
  %77 = load float, ptr %17, align 4, !tbaa !17
  %78 = fdiv float %76, %77
  %79 = load float, ptr %20, align 4, !tbaa !17
  %80 = fadd float %79, %78
  store float %80, ptr %20, align 4, !tbaa !17
  %81 = load ptr, ptr %15, align 8, !tbaa !5
  %82 = getelementptr inbounds float, ptr %81, i32 1
  store ptr %82, ptr %15, align 8, !tbaa !5
  %83 = load ptr, ptr %12, align 8, !tbaa !5
  %84 = getelementptr inbounds float, ptr %83, i32 1
  store ptr %84, ptr %12, align 8, !tbaa !5
  %85 = load ptr, ptr %13, align 8, !tbaa !5
  %86 = getelementptr inbounds float, ptr %85, i32 1
  store ptr %86, ptr %13, align 8, !tbaa !5
  br label %87

87:                                               ; preds = %54
  %88 = load i32, ptr %10, align 4, !tbaa !15
  %89 = add i32 %88, 1
  store i32 %89, ptr %10, align 4, !tbaa !15
  br label %48, !llvm.loop !20

90:                                               ; preds = %48
  %91 = load float, ptr %19, align 4, !tbaa !17
  %92 = fmul float -5.000000e-01, %91
  store float %92, ptr %18, align 4, !tbaa !17
  %93 = load float, ptr %20, align 4, !tbaa !17
  %94 = load float, ptr %18, align 4, !tbaa !17
  %95 = call float @llvm.fmuladd.f32(float -5.000000e-01, float %93, float %94)
  store float %95, ptr %18, align 4, !tbaa !17
  %96 = load float, ptr %18, align 4, !tbaa !17
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  %98 = getelementptr inbounds float, ptr %97, i32 1
  store ptr %98, ptr %11, align 8, !tbaa !5
  %99 = load float, ptr %97, align 4, !tbaa !17
  %100 = call float @logf(float noundef %99) #5
  %101 = fadd float %96, %100
  %102 = load ptr, ptr %14, align 8, !tbaa !5
  store float %101, ptr %102, align 4, !tbaa !17
  %103 = load ptr, ptr %14, align 8, !tbaa !5
  %104 = getelementptr inbounds float, ptr %103, i32 1
  store ptr %104, ptr %14, align 8, !tbaa !5
  br label %105

105:                                              ; preds = %90
  %106 = load i32, ptr %9, align 4, !tbaa !15
  %107 = add i32 %106, 1
  store i32 %107, ptr %9, align 4, !tbaa !15
  br label %40, !llvm.loop !22

108:                                              ; preds = %40
  %109 = load ptr, ptr %7, align 8, !tbaa !5
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.arm_gaussian_naive_bayes_instance_f32, ptr %110, i32 0, i32 1
  %112 = load i32, ptr %111, align 4, !tbaa !16
  call void @arm_max_f32(ptr noundef %109, i32 noundef %112, ptr noundef %16, ptr noundef %21)
  %113 = load i32, ptr %21, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret i32 %113
}

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

; Function Attrs: nounwind
declare float @logf(float noundef) #2

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

declare void @arm_max_f32(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #4

; 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 = { nounwind "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) }
attributes #4 = { "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 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 24}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 4}
!17 = !{!12, !12, i64 0}
!18 = !{!10, !11, i64 0}
!19 = !{!10, !12, i64 32}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


; 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 i32 @arm_gaussian_naive_bayes_predict_f32(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2, ptr nocapture noundef readnone %3) local_unnamed_addr #0 {
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = load i32, ptr %9, align 4, !tbaa !12
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %._crit_edge60, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %0, i64 32
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %.03759 = phi i32 [ 0, %.preheader.lr.ph ], [ %42, %._crit_edge ]
  %.03958 = phi ptr [ %2, %.preheader.lr.ph ], [ %41, %._crit_edge ]
  %.04057 = phi ptr [ %12, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %.04156 = phi ptr [ %14, %.preheader.lr.ph ], [ %.142.lcssa, %._crit_edge ]
  %.04355 = phi ptr [ %8, %.preheader.lr.ph ], [ %37, %._crit_edge ]
  %16 = load i32, ptr %0, align 8, !tbaa !15
  %.not62 = icmp eq i32 %16, 0
  br i1 %.not62, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.051 = phi float [ %28, %.lr.ph ], [ 0.000000e+00, %.preheader ]
  %.03650 = phi float [ %22, %.lr.ph ], [ 0.000000e+00, %.preheader ]
  %.03849 = phi ptr [ %29, %.lr.ph ], [ %1, %.preheader ]
  %.148 = phi ptr [ %31, %.lr.ph ], [ %.04057, %.preheader ]
  %.14247 = phi ptr [ %30, %.lr.ph ], [ %.04156, %.preheader ]
  %.04446 = phi i32 [ %32, %.lr.ph ], [ 0, %.preheader ]
  %17 = load float, ptr %.148, align 4, !tbaa !16
  %18 = load float, ptr %15, align 8, !tbaa !17
  %19 = fadd float %17, %18
  %20 = fmul float %19, 0x401921FB60000000
  %21 = tail call float @logf(float noundef %20) #5
  %22 = fadd float %.03650, %21
  %23 = load float, ptr %.03849, align 4, !tbaa !16
  %24 = load float, ptr %.14247, align 4, !tbaa !16
  %25 = fsub float %23, %24
  %26 = fmul float %25, %25
  %27 = fdiv float %26, %19
  %28 = fadd float %.051, %27
  %29 = getelementptr inbounds i8, ptr %.03849, i64 4
  %30 = getelementptr inbounds i8, ptr %.14247, i64 4
  %31 = getelementptr inbounds i8, ptr %.148, i64 4
  %32 = add nuw i32 %.04446, 1
  %33 = load i32, ptr %0, align 8, !tbaa !15
  %34 = icmp ult i32 %32, %33
  br i1 %34, label %.lr.ph, label %._crit_edge, !llvm.loop !18

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %.142.lcssa = phi ptr [ %.04156, %.preheader ], [ %30, %.lr.ph ]
  %.1.lcssa = phi ptr [ %.04057, %.preheader ], [ %31, %.lr.ph ]
  %.036.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %22, %.lr.ph ]
  %.0.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %28, %.lr.ph ]
  %35 = fmul float %.036.lcssa, -5.000000e-01
  %36 = tail call float @llvm.fmuladd.f32(float %.0.lcssa, float -5.000000e-01, float %35)
  %37 = getelementptr inbounds i8, ptr %.04355, i64 4
  %38 = load float, ptr %.04355, align 4, !tbaa !16
  %39 = tail call float @logf(float noundef %38) #5
  %40 = fadd float %36, %39
  store float %40, ptr %.03958, align 4, !tbaa !16
  %41 = getelementptr inbounds i8, ptr %.03958, i64 4
  %42 = add nuw i32 %.03759, 1
  %43 = load i32, ptr %9, align 4, !tbaa !12
  %44 = icmp ult i32 %42, %43
  br i1 %44, label %.preheader, label %._crit_edge60, !llvm.loop !20

._crit_edge60:                                    ; preds = %._crit_edge, %4
  %.lcssa = phi i32 [ 0, %4 ], [ %43, %._crit_edge ]
  call void @arm_max_f32(ptr noundef %2, i32 noundef %.lcssa, ptr noundef nonnull %5, ptr noundef nonnull %6) #5
  %45 = load i32, ptr %6, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i32 %45
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #2

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

declare void @arm_max_f32(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

; 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 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { "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 = !{!6, !10, i64 24}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!6, !11, i64 32}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass