; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/SVMFunctions (arm_svm_rbf_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_svm_rbf_instance_f32 = type { i32, i32, float, ptr, ptr, ptr, float }

; Function Attrs: nounwind uwtable
define dso_local void @arm_svm_rbf_predict_f32(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %12, i32 0, i32 2
  %14 = load float, ptr %13, align 8, !tbaa !9
  store float %14, ptr %7, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store float 0.000000e+00, ptr %8, align 4, !tbaa !13
  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 8, ptr %11) #4
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %15, i32 0, i32 4
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %11, align 8, !tbaa !5
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %18

18:                                               ; preds = %72, %3
  %19 = load i32, ptr %9, align 4, !tbaa !15
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !16
  %23 = icmp ult i32 %19, %22
  br i1 %23, label %24, label %75

24:                                               ; preds = %18
  store float 0.000000e+00, ptr %8, align 4, !tbaa !13
  store i32 0, ptr %10, align 4, !tbaa !15
  br label %25

25:                                               ; preds = %52, %24
  %26 = load i32, ptr %10, align 4, !tbaa !15
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !17
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %55

31:                                               ; preds = %25
  %32 = load float, ptr %8, align 4, !tbaa !13
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i32, ptr %10, align 4, !tbaa !15
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %33, i64 %35
  %37 = load float, ptr %36, align 4, !tbaa !13
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = load float, ptr %38, align 4, !tbaa !13
  %40 = fsub float %37, %39
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %10, align 4, !tbaa !15
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !13
  %46 = load ptr, ptr %11, align 8, !tbaa !5
  %47 = load float, ptr %46, align 4, !tbaa !13
  %48 = fsub float %45, %47
  %49 = call float @llvm.fmuladd.f32(float %40, float %48, float %32)
  store float %49, ptr %8, align 4, !tbaa !13
  %50 = load ptr, ptr %11, align 8, !tbaa !5
  %51 = getelementptr inbounds float, ptr %50, i32 1
  store ptr %51, ptr %11, align 8, !tbaa !5
  br label %52

52:                                               ; preds = %31
  %53 = load i32, ptr %10, align 4, !tbaa !15
  %54 = add i32 %53, 1
  store i32 %54, ptr %10, align 4, !tbaa !15
  br label %25, !llvm.loop !18

55:                                               ; preds = %25
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  %59 = load i32, ptr %9, align 4, !tbaa !15
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds float, ptr %58, i64 %60
  %62 = load float, ptr %61, align 4, !tbaa !13
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %63, i32 0, i32 6
  %65 = load float, ptr %64, align 8, !tbaa !21
  %66 = fneg float %65
  %67 = load float, ptr %8, align 4, !tbaa !13
  %68 = fmul float %66, %67
  %69 = call float @expf(float noundef %68) #4, !tbaa !15
  %70 = load float, ptr %7, align 4, !tbaa !13
  %71 = call float @llvm.fmuladd.f32(float %62, float %69, float %70)
  store float %71, ptr %7, align 4, !tbaa !13
  br label %72

72:                                               ; preds = %55
  %73 = load i32, ptr %9, align 4, !tbaa !15
  %74 = add i32 %73, 1
  store i32 %74, ptr %9, align 4, !tbaa !15
  br label %18, !llvm.loop !22

75:                                               ; preds = %18
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.arm_svm_rbf_instance_f32, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %77, align 8, !tbaa !23
  %79 = load float, ptr %7, align 4, !tbaa !13
  %80 = fcmp ole float %79, 0.000000e+00
  %81 = zext i1 %80 to i64
  %82 = select i1 %80, i32 0, i32 1
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds i32, ptr %78, i64 %83
  %85 = load i32, ptr %84, align 4, !tbaa !15
  %86 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %85, ptr %86, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, 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 void
}

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind
declare float @expf(float 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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, !12, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 4, !12, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !6, i64 24}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !11, i64 0}
!17 = !{!10, !11, i64 4}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!10, !6, i64 16}
!21 = !{!10, !12, i64 40}
!22 = distinct !{!22, !19}
!23 = !{!10, !6, i64 32}


; 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: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local void @arm_svm_rbf_predict_f32(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load float, ptr %4, align 8, !tbaa !5
  %6 = load i32, ptr %0, align 8, !tbaa !12
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge34, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  %13 = load float, ptr %12, align 8, !tbaa !15
  %14 = fneg float %13
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv40 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next41, %._crit_edge ]
  %.033 = phi ptr [ %8, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %.02631 = phi float [ %5, %.preheader.lr.ph ], [ %51, %._crit_edge ]
  %15 = load i32, ptr %9, align 4, !tbaa !16
  %.not36 = icmp eq i32 %15, 0
  br i1 %.not36, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext i32 %15 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %16 = icmp ult i32 %15, 4
  br i1 %16, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %.129 = phi ptr [ %.033, %.lr.ph.preheader.new ], [ %40, %.lr.ph ]
  %.02527 = phi float [ 0.000000e+00, %.lr.ph.preheader.new ], [ %39, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %17 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %18 = load float, ptr %17, align 4, !tbaa !17
  %19 = load float, ptr %.129, align 4, !tbaa !17
  %20 = fsub float %18, %19
  %21 = tail call float @llvm.fmuladd.f32(float %20, float %20, float %.02527)
  %22 = getelementptr inbounds i8, ptr %.129, i64 4
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %23 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  %24 = load float, ptr %23, align 4, !tbaa !17
  %25 = load float, ptr %22, align 4, !tbaa !17
  %26 = fsub float %24, %25
  %27 = tail call float @llvm.fmuladd.f32(float %26, float %26, float %21)
  %28 = getelementptr inbounds i8, ptr %.129, i64 8
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %29 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next.1
  %30 = load float, ptr %29, align 4, !tbaa !17
  %31 = load float, ptr %28, align 4, !tbaa !17
  %32 = fsub float %30, %31
  %33 = tail call float @llvm.fmuladd.f32(float %32, float %32, float %27)
  %34 = getelementptr inbounds i8, ptr %.129, i64 12
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %35 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next.2
  %36 = load float, ptr %35, align 4, !tbaa !17
  %37 = load float, ptr %34, align 4, !tbaa !17
  %38 = fsub float %36, %37
  %39 = tail call float @llvm.fmuladd.f32(float %38, float %38, float %33)
  %40 = getelementptr inbounds i8, ptr %.129, i64 16
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add nuw i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !18

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa47.ph = phi float [ poison, %.lr.ph.preheader ], [ %39, %.lr.ph ]
  %.lcssa.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %40, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.129.unr = phi ptr [ %.033, %.lr.ph.preheader ], [ %40, %.lr.ph ]
  %.02527.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %39, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.129.epil = phi ptr [ %46, %.lr.ph.epil ], [ %.129.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02527.epil = phi float [ %45, %.lr.ph.epil ], [ %.02527.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %41 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.epil
  %42 = load float, ptr %41, align 4, !tbaa !17
  %43 = load float, ptr %.129.epil, align 4, !tbaa !17
  %44 = fsub float %42, %43
  %45 = tail call float @llvm.fmuladd.f32(float %44, float %44, float %.02527.epil)
  %46 = getelementptr inbounds i8, ptr %.129.epil, i64 4
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !20

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %.025.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %.lcssa47.ph, %._crit_edge.loopexit.unr-lcssa ], [ %45, %.lr.ph.epil ]
  %.1.lcssa = phi ptr [ %.033, %.preheader ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %46, %.lr.ph.epil ]
  %47 = getelementptr inbounds float, ptr %11, i64 %indvars.iv40
  %48 = load float, ptr %47, align 4, !tbaa !17
  %49 = fmul float %.025.lcssa, %14
  %50 = tail call float @expf(float noundef %49) #3, !tbaa !22
  %51 = tail call float @llvm.fmuladd.f32(float %48, float %50, float %.02631)
  %indvars.iv.next41 = add nuw nsw i64 %indvars.iv40, 1
  %52 = load i32, ptr %0, align 8, !tbaa !12
  %53 = zext i32 %52 to i64
  %54 = icmp ult i64 %indvars.iv.next41, %53
  br i1 %54, label %.preheader, label %._crit_edge34, !llvm.loop !23

._crit_edge34:                                    ; preds = %._crit_edge, %3
  %.026.lcssa = phi float [ %5, %3 ], [ %51, %._crit_edge ]
  %55 = getelementptr inbounds i8, ptr %0, i64 32
  %56 = load ptr, ptr %55, align 8, !tbaa !24
  %57 = fcmp ugt float %.026.lcssa, 0.000000e+00
  %58 = zext i1 %57 to i64
  %59 = getelementptr inbounds i32, ptr %56, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !22
  store i32 %60, ptr %2, align 4, !tbaa !22
  ret void
}

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

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

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


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