; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/FilteringFunctions (arm_biquad_cascade_df1_fast_q15)

; 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_biquad_casd_df1_inst_q15 = type { i8, ptr, ptr, i8 }

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

41:                                               ; preds = %98, %4
  %42 = call i32 @read_q15x2_ia(ptr noundef %12)
  store i32 %42, ptr %16, align 4, !tbaa !9
  %43 = call i32 @read_q15x2_ia(ptr noundef %12)
  store i32 %43, ptr %17, align 4, !tbaa !9
  %44 = call i32 @read_q15x2_ia(ptr noundef %12)
  store i32 %44, ptr %18, align 4, !tbaa !9
  %45 = call i32 @read_q15x2_ia(ptr noundef %11)
  store i32 %45, ptr %19, align 4, !tbaa !9
  %46 = call i32 @read_q15x2_da(ptr noundef %11)
  store i32 %46, ptr %20, align 4, !tbaa !9
  %47 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %47, ptr %22, align 4, !tbaa !9
  br label %48

48:                                               ; preds = %51, %41
  %49 = load i32, ptr %22, align 4, !tbaa !9
  %50 = icmp ugt i32 %49, 0
  br i1 %50, label %51, label %91

51:                                               ; preds = %48
  %52 = load ptr, ptr %9, align 8, !tbaa !5
  %53 = getelementptr inbounds i16, ptr %52, i32 1
  store ptr %53, ptr %9, align 8, !tbaa !5
  %54 = load i16, ptr %52, align 2, !tbaa !16
  %55 = sext i16 %54 to i32
  store i32 %55, ptr %14, align 4, !tbaa !9
  %56 = load i32, ptr %16, align 4, !tbaa !9
  %57 = load i32, ptr %14, align 4, !tbaa !9
  %58 = call i32 @__SMUAD(i32 noundef %56, i32 noundef %57)
  store i32 %58, ptr %15, align 4, !tbaa !9
  %59 = load i32, ptr %17, align 4, !tbaa !9
  %60 = load i32, ptr %19, align 4, !tbaa !9
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = call i32 @__SMLAD(i32 noundef %59, i32 noundef %60, i32 noundef %61)
  store i32 %62, ptr %13, align 4, !tbaa !9
  %63 = load i32, ptr %18, align 4, !tbaa !9
  %64 = load i32, ptr %20, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = call i32 @__SMLAD(i32 noundef %63, i32 noundef %64, i32 noundef %65)
  store i32 %66, ptr %13, align 4, !tbaa !9
  %67 = load i32, ptr %13, align 4, !tbaa !9
  %68 = load i32, ptr %21, align 4, !tbaa !9
  %69 = ashr i32 %67, %68
  %70 = call i32 @__SSAT(i32 noundef %69, i32 noundef 16)
  store i32 %70, ptr %15, align 4, !tbaa !9
  %71 = load i32, ptr %15, align 4, !tbaa !9
  %72 = trunc i32 %71 to i16
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds i16, ptr %73, i32 1
  store ptr %74, ptr %10, align 8, !tbaa !5
  store i16 %72, ptr %73, align 2, !tbaa !16
  %75 = load i32, ptr %14, align 4, !tbaa !9
  %76 = shl i32 %75, 0
  %77 = and i32 %76, 65535
  %78 = load i32, ptr %19, align 4, !tbaa !9
  %79 = shl i32 %78, 16
  %80 = and i32 %79, -65536
  %81 = or i32 %77, %80
  store i32 %81, ptr %19, align 4, !tbaa !9
  %82 = load i32, ptr %15, align 4, !tbaa !9
  %83 = shl i32 %82, 0
  %84 = and i32 %83, 65535
  %85 = load i32, ptr %20, align 4, !tbaa !9
  %86 = shl i32 %85, 16
  %87 = and i32 %86, -65536
  %88 = or i32 %84, %87
  store i32 %88, ptr %20, align 4, !tbaa !9
  %89 = load i32, ptr %22, align 4, !tbaa !9
  %90 = add i32 %89, -1
  store i32 %90, ptr %22, align 4, !tbaa !9
  br label %48, !llvm.loop !18

91:                                               ; preds = %48
  %92 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %92, ptr %9, align 8, !tbaa !5
  %93 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %93, ptr %10, align 8, !tbaa !5
  %94 = load i32, ptr %19, align 4, !tbaa !9
  call void @write_q15x2_ia(ptr noundef %11, i32 noundef %94)
  %95 = load i32, ptr %20, align 4, !tbaa !9
  call void @write_q15x2_ia(ptr noundef %11, i32 noundef %95)
  %96 = load i32, ptr %23, align 4, !tbaa !9
  %97 = add i32 %96, -1
  store i32 %97, ptr %23, align 4, !tbaa !9
  br label %98

98:                                               ; preds = %91
  %99 = load i32, ptr %23, align 4, !tbaa !9
  %100 = icmp ugt i32 %99, 0
  br i1 %100, label %41, label %101, !llvm.loop !20

101:                                              ; preds = %98
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, 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
  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: alwaysinline nounwind uwtable
declare hidden i32 @read_q15x2_ia(ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @read_q15x2_da(ptr noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SMUAD(i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SMLAD(i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SSAT(i32 noundef, i32 noundef) #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @write_q15x2_ia(ptr noundef, i32 noundef) #2

; 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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"", !7, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !7, i64 24}
!15 = !{!12, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


; 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 @arm_biquad_cascade_df1_fast_q15(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %8, ptr %5, align 8, !tbaa !10
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  store ptr %10, ptr %6, align 8, !tbaa !10
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = load i8, ptr %11, align 8, !tbaa !12
  %13 = sext i8 %12 to i32
  %14 = sub nsw i32 15, %13
  %15 = load i8, ptr %0, align 8, !tbaa !13
  %16 = sext i8 %15 to i32
  %.not39 = icmp eq i32 %3, 0
  br i1 %.not39, label %.split.us, label %.lr.ph

.split.us:                                        ; preds = %4, %.split.us
  %.0.us = phi i32 [ %22, %.split.us ], [ %16, %4 ]
  %17 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %18 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %19 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %20 = call i32 @read_q15x2_ia(ptr noundef nonnull %5)
  %21 = call i32 @read_q15x2_da(ptr noundef nonnull %5)
  call void @write_q15x2_ia(ptr noundef nonnull %5, i32 noundef %20)
  call void @write_q15x2_ia(ptr noundef nonnull %5, i32 noundef %21)
  %22 = add i32 %.0.us, -1
  %.not38.us = icmp eq i32 %22, 0
  br i1 %.not38.us, label %.split47.us, label %.split.us, !llvm.loop !14

.lr.ph:                                           ; preds = %4, %._crit_edge
  %.032 = phi ptr [ %2, %._crit_edge ], [ %1, %4 ]
  %.0 = phi i32 [ %46, %._crit_edge ], [ %16, %4 ]
  %23 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %24 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %25 = call i32 @read_q15x2_ia(ptr noundef nonnull %6)
  %26 = call i32 @read_q15x2_ia(ptr noundef nonnull %5)
  %27 = call i32 @read_q15x2_da(ptr noundef nonnull %5)
  br label %28

28:                                               ; preds = %.lr.ph, %28
  %.03144 = phi i32 [ %3, %.lr.ph ], [ %45, %28 ]
  %.143 = phi ptr [ %.032, %.lr.ph ], [ %29, %28 ]
  %.03342 = phi i32 [ %27, %.lr.ph ], [ %44, %28 ]
  %.03441 = phi i32 [ %26, %.lr.ph ], [ %41, %28 ]
  %.13640 = phi ptr [ %2, %.lr.ph ], [ %38, %28 ]
  %29 = getelementptr inbounds i8, ptr %.143, i64 2
  %30 = load i16, ptr %.143, align 2, !tbaa !16
  %31 = sext i16 %30 to i32
  %32 = call i32 @__SMUAD(i32 noundef %23, i32 noundef %31)
  %33 = call i32 @__SMLAD(i32 noundef %24, i32 noundef %.03441, i32 noundef %32)
  %34 = call i32 @__SMLAD(i32 noundef %25, i32 noundef %.03342, i32 noundef %33)
  %35 = ashr i32 %34, %14
  %36 = call i32 @__SSAT(i32 noundef %35, i32 noundef 16)
  %37 = trunc i32 %36 to i16
  %38 = getelementptr inbounds i8, ptr %.13640, i64 2
  store i16 %37, ptr %.13640, align 2, !tbaa !16
  %39 = and i32 %31, 65535
  %40 = shl i32 %.03441, 16
  %41 = or disjoint i32 %39, %40
  %42 = and i32 %36, 65535
  %43 = shl i32 %.03342, 16
  %44 = or disjoint i32 %42, %43
  %45 = add i32 %.03144, -1
  %.not = icmp eq i32 %45, 0
  br i1 %.not, label %._crit_edge, label %28, !llvm.loop !18

._crit_edge:                                      ; preds = %28
  call void @write_q15x2_ia(ptr noundef nonnull %5, i32 noundef %41)
  call void @write_q15x2_ia(ptr noundef nonnull %5, i32 noundef %44)
  %46 = add i32 %.0, -1
  %.not38 = icmp eq i32 %46, 0
  br i1 %.not38, label %.split47.us, label %.lr.ph, !llvm.loop !14

.split47.us:                                      ; preds = %._crit_edge, %.split.us
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  ret void
}

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

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @read_q15x2_ia(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @read_q15x2_da(ptr noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SMUAD(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SMLAD(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden i32 @__SSAT(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @write_q15x2_ia(ptr noundef, i32 noundef) local_unnamed_addr #2

; 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 = { 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 #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, !9, i64 8}
!6 = !{!"", !7, i64 0, !9, i64 8, !9, i64 16, !7, i64 24}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"any pointer", !7, i64 0}
!10 = !{!9, !9, i64 0}
!11 = !{!6, !9, i64 16}
!12 = !{!6, !7, i64 24}
!13 = !{!6, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !17, i64 0}
!17 = !{!"short", !7, i64 0}
!18 = distinct !{!18, !15}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass