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

; Function Attrs: nounwind uwtable
define dso_local void @arm_svm_sigmoid_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_sigmoid_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_sigmoid_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 = %64, %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_sigmoid_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 %67

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 = %42, %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_sigmoid_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 %45

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 = getelementptr inbounds float, ptr %38, i32 1
  store ptr %39, ptr %11, align 8, !tbaa !5
  %40 = load float, ptr %38, align 4, !tbaa !13
  %41 = call float @llvm.fmuladd.f32(float %37, float %40, float %32)
  store float %41, ptr %8, align 4, !tbaa !13
  br label %42

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

45:                                               ; preds = %25
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.arm_svm_sigmoid_instance_f32, ptr %46, i32 0, i32 3
  %48 = load ptr, ptr %47, align 8, !tbaa !20
  %49 = load i32, ptr %9, align 4, !tbaa !15
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %48, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !13
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_svm_sigmoid_instance_f32, ptr %53, i32 0, i32 7
  %55 = load float, ptr %54, align 4, !tbaa !21
  %56 = load float, ptr %8, align 4, !tbaa !13
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arm_svm_sigmoid_instance_f32, ptr %57, i32 0, i32 6
  %59 = load float, ptr %58, align 8, !tbaa !22
  %60 = call float @llvm.fmuladd.f32(float %55, float %56, float %59)
  %61 = call float @tanhf(float noundef %60) #4
  %62 = load float, ptr %7, align 4, !tbaa !13
  %63 = call float @llvm.fmuladd.f32(float %52, float %61, float %62)
  store float %63, ptr %7, align 4, !tbaa !13
  br label %64

64:                                               ; preds = %45
  %65 = load i32, ptr %9, align 4, !tbaa !15
  %66 = add i32 %65, 1
  store i32 %66, ptr %9, align 4, !tbaa !15
  br label %18, !llvm.loop !23

67:                                               ; preds = %18
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.arm_svm_sigmoid_instance_f32, ptr %68, i32 0, i32 5
  %70 = load ptr, ptr %69, align 8, !tbaa !24
  %71 = load float, ptr %7, align 4, !tbaa !13
  %72 = fcmp ole float %71, 0.000000e+00
  %73 = zext i1 %72 to i64
  %74 = select i1 %72, i32 0, i32 1
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds i32, ptr %70, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !15
  %78 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %77, ptr %78, 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 @tanhf(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, !12, i64 44}
!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 44}
!22 = !{!10, !12, i64 40}
!23 = distinct !{!23, !19}
!24 = !{!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_sigmoid_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_edge31, 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 = getelementptr inbounds i8, ptr %0, i64 44
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  br label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %indvars.iv37 = phi i64 [ 0, %.preheader.lr.ph ], [ %indvars.iv.next38, %._crit_edge ]
  %.030 = phi ptr [ %8, %.preheader.lr.ph ], [ %.1.lcssa, %._crit_edge ]
  %.02328 = phi float [ %5, %.preheader.lr.ph ], [ %47, %._crit_edge ]
  %13 = load i32, ptr %9, align 4, !tbaa !14
  %.not33 = icmp eq i32 %13, 0
  br i1 %.not33, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext i32 %13 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %14 = icmp ult i32 %13, 4
  br i1 %14, 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 ]
  %.126 = phi ptr [ %.030, %.lr.ph.preheader.new ], [ %32, %.lr.ph ]
  %.02224 = phi float [ 0.000000e+00, %.lr.ph.preheader.new ], [ %34, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %15 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %16 = load float, ptr %15, align 4, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %.126, i64 4
  %18 = load float, ptr %.126, align 4, !tbaa !15
  %19 = tail call float @llvm.fmuladd.f32(float %16, float %18, float %.02224)
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %20 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next
  %21 = load float, ptr %20, align 4, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %.126, i64 8
  %23 = load float, ptr %17, align 4, !tbaa !15
  %24 = tail call float @llvm.fmuladd.f32(float %21, float %23, float %19)
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %25 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next.1
  %26 = load float, ptr %25, align 4, !tbaa !15
  %27 = getelementptr inbounds i8, ptr %.126, i64 12
  %28 = load float, ptr %22, align 4, !tbaa !15
  %29 = tail call float @llvm.fmuladd.f32(float %26, float %28, float %24)
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %30 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next.2
  %31 = load float, ptr %30, align 4, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %.126, i64 16
  %33 = load float, ptr %27, align 4, !tbaa !15
  %34 = tail call float @llvm.fmuladd.f32(float %31, float %33, float %29)
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add 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 !16

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa44.ph = phi ptr [ poison, %.lr.ph.preheader ], [ %32, %.lr.ph ]
  %.lcssa.ph = phi float [ poison, %.lr.ph.preheader ], [ %34, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.126.unr = phi ptr [ %.030, %.lr.ph.preheader ], [ %32, %.lr.ph ]
  %.02224.unr = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %34, %.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 ]
  %.126.epil = phi ptr [ %37, %.lr.ph.epil ], [ %.126.unr, %._crit_edge.loopexit.unr-lcssa ]
  %.02224.epil = phi float [ %39, %.lr.ph.epil ], [ %.02224.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %35 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.epil
  %36 = load float, ptr %35, align 4, !tbaa !15
  %37 = getelementptr inbounds i8, ptr %.126.epil, i64 4
  %38 = load float, ptr %.126.epil, align 4, !tbaa !15
  %39 = tail call float @llvm.fmuladd.f32(float %36, float %38, float %.02224.epil)
  %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 !18

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %.022.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %39, %.lr.ph.epil ]
  %.1.lcssa = phi ptr [ %.030, %.preheader ], [ %.lcssa44.ph, %._crit_edge.loopexit.unr-lcssa ], [ %37, %.lr.ph.epil ]
  %40 = load ptr, ptr %10, align 8, !tbaa !20
  %41 = getelementptr inbounds float, ptr %40, i64 %indvars.iv37
  %42 = load float, ptr %41, align 4, !tbaa !15
  %43 = load float, ptr %11, align 4, !tbaa !21
  %44 = load float, ptr %12, align 8, !tbaa !22
  %45 = tail call float @llvm.fmuladd.f32(float %43, float %.022.lcssa, float %44)
  %46 = tail call float @tanhf(float noundef %45) #3
  %47 = tail call float @llvm.fmuladd.f32(float %42, float %46, float %.02328)
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %48 = load i32, ptr %0, align 8, !tbaa !12
  %49 = zext i32 %48 to i64
  %50 = icmp ult i64 %indvars.iv.next38, %49
  br i1 %50, label %.preheader, label %._crit_edge31, !llvm.loop !23

._crit_edge31:                                    ; preds = %._crit_edge, %3
  %.023.lcssa = phi float [ %5, %3 ], [ %47, %._crit_edge ]
  %51 = getelementptr inbounds i8, ptr %0, i64 32
  %52 = load ptr, ptr %51, align 8, !tbaa !24
  %53 = fcmp ugt float %.023.lcssa, 0.000000e+00
  %54 = zext i1 %53 to i64
  %55 = getelementptr inbounds i32, ptr %52, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !25
  store i32 %56, ptr %2, align 4, !tbaa !25
  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 @tanhf(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, !10, i64 44}
!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, !7, i64 4}
!15 = !{!10, !10, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.unroll.disable"}
!20 = !{!6, !11, i64 16}
!21 = !{!6, !10, i64 44}
!22 = !{!6, !10, i64 40}
!23 = distinct !{!23, !17}
!24 = !{!6, !11, i64 32}
!25 = !{!7, !7, i64 0}


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