; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/STM32_AI_AudioPreprocessing_Library/Src (mel_filterbank)

; 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.MelFilterTypeDef = type { ptr, ptr, ptr, i32, i32, i32, i32, float, float, i32, i32, i32 }

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

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

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

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

29:                                               ; preds = %75, %3
  %30 = load i32, ptr %14, align 4, !tbaa !16
  %31 = load i32, ptr %12, align 4, !tbaa !16
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  store i32 2, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %78

34:                                               ; preds = %29
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  %36 = load i32, ptr %14, align 4, !tbaa !16
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds i32, ptr %35, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !16
  %40 = trunc i32 %39 to i16
  store i16 %40, ptr %7, align 2, !tbaa !17
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load i32, ptr %14, align 4, !tbaa !16
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i32, ptr %41, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !16
  %46 = trunc i32 %45 to i16
  store i16 %46, ptr %8, align 2, !tbaa !17
  store float 0.000000e+00, ptr %13, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %47 = load i16, ptr %7, align 2, !tbaa !17
  %48 = zext i16 %47 to i32
  store i32 %48, ptr %16, align 4, !tbaa !16
  br label %49

49:                                               ; preds = %66, %34
  %50 = load i32, ptr %16, align 4, !tbaa !16
  %51 = load i16, ptr %8, align 2, !tbaa !17
  %52 = zext i16 %51 to i32
  %53 = icmp ule i32 %50, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %49
  store i32 5, ptr %15, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %69

55:                                               ; preds = %49
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i32, ptr %16, align 4, !tbaa !16
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %56, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !19
  %61 = load ptr, ptr %11, align 8, !tbaa !5
  %62 = getelementptr inbounds float, ptr %61, i32 1
  store ptr %62, ptr %11, align 8, !tbaa !5
  %63 = load float, ptr %61, align 4, !tbaa !19
  %64 = load float, ptr %13, align 4, !tbaa !19
  %65 = call float @llvm.fmuladd.f32(float %60, float %63, float %64)
  store float %65, ptr %13, align 4, !tbaa !19
  br label %66

66:                                               ; preds = %55
  %67 = load i32, ptr %16, align 4, !tbaa !16
  %68 = add i32 %67, 1
  store i32 %68, ptr %16, align 4, !tbaa !16
  br label %49, !llvm.loop !20

69:                                               ; preds = %54
  %70 = load float, ptr %13, align 4, !tbaa !19
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = load i32, ptr %14, align 4, !tbaa !16
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %71, i64 %73
  store float %70, ptr %74, align 4, !tbaa !19
  br label %75

75:                                               ; preds = %69
  %76 = load i32, ptr %14, align 4, !tbaa !16
  %77 = add i32 %76, 1
  store i32 %77, ptr %14, align 4, !tbaa !16
  br label %29, !llvm.loop !22

78:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 2, ptr %7) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { 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 0}
!10 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !12, i64 40, !12, i64 44, !11, i64 48, !11, i64 52, !11, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !6, i64 8}
!14 = !{!10, !6, i64 16}
!15 = !{!10, !11, i64 28}
!16 = !{!11, !11, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"short", !7, i64 0}
!19 = !{!12, !12, i64 0}
!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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @MelFilterbank(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load ptr, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 28
  %8 = load i32, ptr %7, align 4, !tbaa !13
  %.not34 = icmp eq i32 %8, 0
  br i1 %.not34, label %._crit_edge33, label %.lr.ph32.preheader

.lr.ph32.preheader:                               ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %wide.trip.count40 = zext i32 %8 to i64
  br label %.lr.ph32

._crit_edge33:                                    ; preds = %._crit_edge, %3
  ret void

.lr.ph32:                                         ; preds = %.lr.ph32.preheader, %._crit_edge
  %indvars.iv37 = phi i64 [ 0, %.lr.ph32.preheader ], [ %indvars.iv.next38, %._crit_edge ]
  %.02329 = phi ptr [ %10, %.lr.ph32.preheader ], [ %.1.lcssa, %._crit_edge ]
  %11 = getelementptr inbounds i32, ptr %4, i64 %indvars.iv37
  %12 = load i32, ptr %11, align 4, !tbaa !15
  %13 = getelementptr inbounds i32, ptr %6, i64 %indvars.iv37
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = and i32 %12, 65535
  %16 = and i32 %14, 65535
  %.not24 = icmp ugt i32 %15, %16
  br i1 %.not24, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph32
  %17 = and i32 %12, 65535
  %18 = zext nneg i32 %17 to i64
  %19 = add nuw nsw i32 %16, 1
  %wide.trip.count = zext nneg i32 %19 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph32
  %.1.lcssa = phi ptr [ %.02329, %.lr.ph32 ], [ %23, %.lr.ph ]
  %.022.lcssa = phi float [ 0.000000e+00, %.lr.ph32 ], [ %25, %.lr.ph ]
  %20 = getelementptr inbounds float, ptr %2, i64 %indvars.iv37
  store float %.022.lcssa, ptr %20, align 4, !tbaa !16
  %indvars.iv.next38 = add nuw nsw i64 %indvars.iv37, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next38, %wide.trip.count40
  br i1 %exitcond41.not, label %._crit_edge33, label %.lr.ph32, !llvm.loop !17

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %18, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.02226 = phi float [ 0.000000e+00, %.lr.ph.preheader ], [ %25, %.lr.ph ]
  %.125 = phi ptr [ %.02329, %.lr.ph.preheader ], [ %23, %.lr.ph ]
  %21 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !16
  %23 = getelementptr inbounds i8, ptr %.125, i64 4
  %24 = load float, ptr %.125, align 4, !tbaa !16
  %25 = tail call float @llvm.fmuladd.f32(float %22, float %24, float %.02226)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !19
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !11, i64 40, !11, i64 44, !10, i64 48, !10, i64 52, !10, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !10, i64 28}
!14 = !{!6, !7, i64 16}
!15 = !{!10, !10, i64 0}
!16 = !{!11, !11, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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