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

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

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @SpectrogramColumn(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca float, align 4
  %11 = alloca float, align 4
  %12 = 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 4, ptr %7) #5
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %13, i32 0, i32 4
  %15 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %15, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %16, i32 0, i32 5
  %18 = load i32, ptr %17, align 8, !tbaa !13
  store i32 %18, ptr %8, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %19, i32 0, i32 6
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  store ptr %21, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %7, align 4, !tbaa !12
  call void @arm_mult_f32(ptr noundef %22, ptr noundef %25, ptr noundef %26, i32 noundef %27)
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load i32, ptr %7, align 4, !tbaa !12
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %28, i64 %30
  %32 = load i32, ptr %8, align 4, !tbaa !12
  %33 = load i32, ptr %7, align 4, !tbaa !12
  %34 = sub i32 %32, %33
  %35 = zext i32 %34 to i64
  call void @llvm.memset.p0.i64(ptr align 4 %31, i8 0, i64 %35, i1 false)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  call void @arm_rfft_fast_f32(ptr noundef %38, ptr noundef %39, ptr noundef %40, i8 noundef zeroext 0)
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds float, ptr %41, i64 0
  %43 = load float, ptr %42, align 4, !tbaa !17
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  %45 = getelementptr inbounds float, ptr %44, i64 0
  %46 = load float, ptr %45, align 4, !tbaa !17
  %47 = fmul float %43, %46
  store float %47, ptr %10, align 4, !tbaa !17
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds float, ptr %48, i64 1
  %50 = load float, ptr %49, align 4, !tbaa !17
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds float, ptr %51, i64 1
  %53 = load float, ptr %52, align 4, !tbaa !17
  %54 = fmul float %50, %53
  store float %54, ptr %11, align 4, !tbaa !17
  %55 = load float, ptr %10, align 4, !tbaa !17
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds float, ptr %56, i64 0
  store float %55, ptr %57, align 4, !tbaa !17
  %58 = load ptr, ptr %9, align 8, !tbaa !5
  %59 = getelementptr inbounds float, ptr %58, i64 2
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds float, ptr %60, i64 1
  %62 = load i32, ptr %8, align 4, !tbaa !12
  %63 = udiv i32 %62, 2
  %64 = sub i32 %63, 1
  call void @arm_cmplx_mag_squared_f32(ptr noundef %59, ptr noundef %61, i32 noundef %64)
  %65 = load float, ptr %11, align 4, !tbaa !17
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !12
  %68 = udiv i32 %67, 2
  %69 = zext i32 %68 to i64
  %70 = getelementptr inbounds float, ptr %66, i64 %69
  store float %65, ptr %70, align 4, !tbaa !17
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.SpectrogramTypeDef, ptr %71, i32 0, i32 1
  %73 = load i32, ptr %72, align 8, !tbaa !19
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %98

75:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !12
  br label %76

76:                                               ; preds = %94, %75
  %77 = load i32, ptr %12, align 4, !tbaa !12
  %78 = load i32, ptr %8, align 4, !tbaa !12
  %79 = udiv i32 %78, 2
  %80 = add i32 %79, 1
  %81 = icmp ult i32 %77, %80
  br i1 %81, label %83, label %82

82:                                               ; preds = %76
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %97

83:                                               ; preds = %76
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i32, ptr %12, align 4, !tbaa !12
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds float, ptr %84, i64 %86
  %88 = load float, ptr %87, align 4, !tbaa !17
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = load i32, ptr %12, align 4, !tbaa !12
  %91 = zext i32 %90 to i64
  %92 = getelementptr inbounds float, ptr %89, i64 %91
  %93 = call i32 @arm_sqrt_f32(float noundef %88, ptr noundef %92)
  br label %94

94:                                               ; preds = %83
  %95 = load i32, ptr %12, align 4, !tbaa !12
  %96 = add i32 %95, 1
  store i32 %96, ptr %12, align 4, !tbaa !12
  br label %76, !llvm.loop !20

97:                                               ; preds = %82
  br label %98

98:                                               ; preds = %97, %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

declare void @arm_rfft_fast_f32(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) #2

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #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, !11, i64 28}
!10 = !{!"", !6, i64 0, !11, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 40}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !6, i64 16}
!16 = !{!10, !6, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{!10, !11, i64 8}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}


; 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 void @SpectrogramColumn(ptr nocapture noundef readonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 28
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = load i32, ptr %6, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %0, i64 40
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  tail call void @arm_mult_f32(ptr noundef %1, ptr noundef %11, ptr noundef %1, i32 noundef %5) #4
  %12 = zext i32 %5 to i64
  %13 = getelementptr inbounds float, ptr %1, i64 %12
  %14 = sub i32 %7, %5
  %15 = zext i32 %14 to i64
  tail call void @llvm.memset.p0.i64(ptr align 4 %13, i8 0, i64 %15, i1 false)
  %16 = load ptr, ptr %0, align 8, !tbaa !14
  tail call void @arm_rfft_fast_f32(ptr noundef %16, ptr noundef %1, ptr noundef %9, i8 noundef zeroext 0) #4
  %17 = load float, ptr %9, align 4, !tbaa !15
  %18 = fmul float %17, %17
  %19 = getelementptr inbounds i8, ptr %9, i64 4
  %20 = load float, ptr %19, align 4, !tbaa !15
  %21 = fmul float %20, %20
  store float %18, ptr %2, align 4, !tbaa !15
  %22 = getelementptr inbounds i8, ptr %9, i64 8
  %23 = getelementptr inbounds i8, ptr %2, i64 4
  %24 = lshr i32 %7, 1
  %25 = add nsw i32 %24, -1
  tail call void @arm_cmplx_mag_squared_f32(ptr noundef nonnull %22, ptr noundef nonnull %23, i32 noundef %25) #4
  %26 = zext nneg i32 %24 to i64
  %27 = getelementptr inbounds float, ptr %2, i64 %26
  store float %21, ptr %27, align 4, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %0, i64 8
  %29 = load i32, ptr %28, align 8, !tbaa !17
  %30 = icmp eq i32 %29, 0
  br i1 %30, label %.preheader.preheader, label %.loopexit

.preheader.preheader:                             ; preds = %3
  %31 = add nuw i32 %24, 1
  %wide.trip.count = zext i32 %31 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %.preheader ]
  %32 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %33 = load float, ptr %32, align 4, !tbaa !15
  %34 = tail call i32 @arm_sqrt_f32(float noundef %33, ptr noundef nonnull %32)
  %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 %.loopexit, label %.preheader, !llvm.loop !18

.loopexit:                                        ; preds = %.preheader, %3
  ret void
}

declare void @arm_mult_f32(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare void @arm_rfft_fast_f32(ptr noundef, ptr noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @arm_cmplx_mag_squared_f32(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

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

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


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