; LLVM IR from ubaldot/defrecs :: stm32f4x/ADC_Readings/Drivers/CMSIS/DSP/Examples/ARM (main)

; 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_cas_df1_32x64_ins_q31 = type { i8, ptr, ptr, i8 }
%struct.arm_biquad_casd_df1_inst_q31 = type { i32, ptr, ptr, i8 }

@coeffTable = external dso_local constant [950 x i32], align 16
@gainDB = external dso_local global [5 x i32], align 16
@testInput_f32 = external global [320 x float], align 16
@testOutput = external hidden global [320 x float], align 16
@biquadStateBand1Q31 = external hidden global [8 x i64], align 16
@biquadStateBand2Q31 = external hidden global [8 x i64], align 16
@biquadStateBand3Q31 = external hidden global [8 x i32], align 16
@biquadStateBand4Q31 = external hidden global [8 x i32], align 16
@biquadStateBand5Q31 = external hidden global [8 x i32], align 16
@inputQ31 = external dso_local global [32 x i32], align 16
@outputQ31 = external dso_local global [32 x i32], align 16
@testRefOutput_f32 = external global [320 x float], align 16
@snr = external dso_local global float, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.arm_biquad_cas_df1_32x64_ins_q31, align 8
  %5 = alloca %struct.arm_biquad_cas_df1_32x64_ins_q31, align 8
  %6 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  %7 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  %8 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store ptr @testInput_f32, ptr %2, align 8, !tbaa !5
  store ptr @testOutput, ptr %3, align 8, !tbaa !5
  %11 = load i32, ptr @gainDB, align 16, !tbaa !9
  %12 = add nsw i32 %11, 9
  %13 = mul nsw i32 10, %12
  %14 = add nsw i32 0, %13
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %15
  call void @arm_biquad_cas_df1_32x64_init_q31(ptr noundef %4, i8 noundef zeroext 2, ptr noundef %16, ptr noundef @biquadStateBand1Q31, i8 noundef zeroext 2)
  %17 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @gainDB, i64 0, i64 1), align 4, !tbaa !9
  %18 = add nsw i32 %17, 9
  %19 = mul nsw i32 10, %18
  %20 = add nsw i32 190, %19
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %21
  call void @arm_biquad_cas_df1_32x64_init_q31(ptr noundef %5, i8 noundef zeroext 2, ptr noundef %22, ptr noundef @biquadStateBand2Q31, i8 noundef zeroext 2)
  %23 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @gainDB, i64 0, i64 2), align 8, !tbaa !9
  %24 = add nsw i32 %23, 9
  %25 = mul nsw i32 10, %24
  %26 = add nsw i32 380, %25
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %27
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef %6, i8 noundef zeroext 2, ptr noundef %28, ptr noundef @biquadStateBand3Q31, i8 noundef signext 2)
  %29 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @gainDB, i64 0, i64 3), align 4, !tbaa !9
  %30 = add nsw i32 %29, 9
  %31 = mul nsw i32 10, %30
  %32 = add nsw i32 570, %31
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %33
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef %7, i8 noundef zeroext 2, ptr noundef %34, ptr noundef @biquadStateBand4Q31, i8 noundef signext 2)
  %35 = load i32, ptr getelementptr inbounds ([5 x i32], ptr @gainDB, i64 0, i64 4), align 16, !tbaa !9
  %36 = add nsw i32 %35, 9
  %37 = mul nsw i32 10, %36
  %38 = add nsw i32 760, %37
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %39
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef %8, i8 noundef zeroext 2, ptr noundef %40, ptr noundef @biquadStateBand5Q31, i8 noundef signext 2)
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %41

41:                                               ; preds = %65, %0
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = icmp slt i32 %42, 10
  br i1 %43, label %44, label %68

44:                                               ; preds = %41
  %45 = load ptr, ptr %2, align 8, !tbaa !5
  %46 = load i32, ptr %9, align 4, !tbaa !9
  %47 = mul nsw i32 %46, 32
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %45, i64 %48
  call void @arm_float_to_q31(ptr noundef %49, ptr noundef @inputQ31, i32 noundef 32)
  call void @arm_scale_q31(ptr noundef @inputQ31, i32 noundef 2147483647, i8 noundef signext -3, ptr noundef @inputQ31, i32 noundef 32)
  call void @arm_biquad_cas_df1_32x64_q31(ptr noundef %4, ptr noundef @inputQ31, ptr noundef @outputQ31, i32 noundef 32)
  call void @arm_biquad_cas_df1_32x64_q31(ptr noundef %5, ptr noundef @outputQ31, ptr noundef @outputQ31, i32 noundef 32)
  call void @arm_biquad_cascade_df1_q31(ptr noundef %6, ptr noundef @outputQ31, ptr noundef @outputQ31, i32 noundef 32)
  call void @arm_biquad_cascade_df1_q31(ptr noundef %7, ptr noundef @outputQ31, ptr noundef @outputQ31, i32 noundef 32)
  call void @arm_biquad_cascade_df1_q31(ptr noundef %8, ptr noundef @outputQ31, ptr noundef @outputQ31, i32 noundef 32)
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = mul nsw i32 %51, 32
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %50, i64 %53
  call void @arm_q31_to_float(ptr noundef @outputQ31, ptr noundef %54, i32 noundef 32)
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = mul nsw i32 %56, 32
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %55, i64 %58
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load i32, ptr %9, align 4, !tbaa !9
  %62 = mul nsw i32 %61, 32
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %60, i64 %63
  call void @arm_scale_f32(ptr noundef %59, float noundef 8.000000e+00, ptr noundef %64, i32 noundef 32)
  br label %65

65:                                               ; preds = %44
  %66 = load i32, ptr %9, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %9, align 4, !tbaa !9
  br label %41, !llvm.loop !11

68:                                               ; preds = %41
  %69 = call float @arm_snr_f32(ptr noundef @testRefOutput_f32, ptr noundef @testOutput, i32 noundef 320)
  store float %69, ptr @snr, align 4, !tbaa !13
  %70 = load float, ptr @snr, align 4, !tbaa !13
  %71 = fcmp olt float %70, 9.800000e+01
  %72 = zext i1 %71 to i64
  %73 = select i1 %71, i32 -6, i32 0
  store i32 %73, ptr %10, align 4, !tbaa !9
  %74 = load i32, ptr %10, align 4, !tbaa !9
  %75 = icmp ne i32 %74, 0
  br i1 %75, label %76, label %79

76:                                               ; preds = %68
  br label %77

77:                                               ; preds = %78, %76
  br label %78

78:                                               ; preds = %77
  br label %77

79:                                               ; preds = %68
  br label %80

80:                                               ; preds = %81, %79
  br label %81

81:                                               ; preds = %80
  br label %80
}

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

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

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

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

declare void @arm_scale_q31(ptr noundef, i32 noundef, i8 noundef signext, ptr noundef, i32 noundef) #2

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

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

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

declare void @arm_scale_f32(ptr noundef, float noundef, ptr noundef, i32 noundef) #2

declare float @arm_snr_f32(ptr noundef, ptr noundef, i32 noundef) #2

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 = { "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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}


; 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"

%struct.arm_biquad_cas_df1_32x64_ins_q31 = type { i8, ptr, ptr, i8 }
%struct.arm_biquad_casd_df1_inst_q31 = type { i32, ptr, ptr, i8 }

@coeffTable = external dso_local constant [950 x i32], align 16
@gainDB = external dso_local local_unnamed_addr global [5 x i32], align 16
@testInput_f32 = external global [320 x float], align 16
@testOutput = external hidden global [320 x float], align 16
@biquadStateBand1Q31 = external hidden global [8 x i64], align 16
@biquadStateBand2Q31 = external hidden global [8 x i64], align 16
@biquadStateBand3Q31 = external hidden global [8 x i32], align 16
@biquadStateBand4Q31 = external hidden global [8 x i32], align 16
@biquadStateBand5Q31 = external hidden global [8 x i32], align 16
@inputQ31 = external dso_local global [32 x i32], align 16
@outputQ31 = external dso_local global [32 x i32], align 16
@testRefOutput_f32 = external global [320 x float], align 16
@snr = external dso_local local_unnamed_addr global float, align 4

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.arm_biquad_cas_df1_32x64_ins_q31, align 8
  %2 = alloca %struct.arm_biquad_cas_df1_32x64_ins_q31, align 8
  %3 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  %4 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  %5 = alloca %struct.arm_biquad_casd_df1_inst_q31, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %5) #3
  %6 = load i32, ptr @gainDB, align 16, !tbaa !5
  %7 = mul i32 %6, 10
  %8 = add i32 %7, 90
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %9
  call void @arm_biquad_cas_df1_32x64_init_q31(ptr noundef nonnull %1, i8 noundef zeroext 2, ptr noundef nonnull %10, ptr noundef nonnull @biquadStateBand1Q31, i8 noundef zeroext 2) #3
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @gainDB, i64 4), align 4, !tbaa !5
  %12 = mul i32 %11, 10
  %13 = add i32 %12, 280
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %14
  call void @arm_biquad_cas_df1_32x64_init_q31(ptr noundef nonnull %2, i8 noundef zeroext 2, ptr noundef nonnull %15, ptr noundef nonnull @biquadStateBand2Q31, i8 noundef zeroext 2) #3
  %16 = load i32, ptr getelementptr inbounds (i8, ptr @gainDB, i64 8), align 8, !tbaa !5
  %17 = mul i32 %16, 10
  %18 = add i32 %17, 470
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %19
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef nonnull %3, i8 noundef zeroext 2, ptr noundef nonnull %20, ptr noundef nonnull @biquadStateBand3Q31, i8 noundef signext 2) #3
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @gainDB, i64 12), align 4, !tbaa !5
  %22 = mul i32 %21, 10
  %23 = add i32 %22, 660
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %24
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef nonnull %4, i8 noundef zeroext 2, ptr noundef nonnull %25, ptr noundef nonnull @biquadStateBand4Q31, i8 noundef signext 2) #3
  %26 = load i32, ptr getelementptr inbounds (i8, ptr @gainDB, i64 16), align 16, !tbaa !5
  %27 = mul i32 %26, 10
  %28 = add i32 %27, 850
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [950 x i32], ptr @coeffTable, i64 0, i64 %29
  call void @arm_biquad_cascade_df1_init_q31(ptr noundef nonnull %5, i8 noundef zeroext 2, ptr noundef nonnull %30, ptr noundef nonnull @biquadStateBand5Q31, i8 noundef signext 2) #3
  br label %31

31:                                               ; preds = %0, %31
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %31 ]
  %32 = shl nuw nsw i64 %indvars.iv, 5
  %33 = getelementptr inbounds float, ptr @testInput_f32, i64 %32
  call void @arm_float_to_q31(ptr noundef nonnull %33, ptr noundef nonnull @inputQ31, i32 noundef 32) #3
  call void @arm_scale_q31(ptr noundef nonnull @inputQ31, i32 noundef 2147483647, i8 noundef signext -3, ptr noundef nonnull @inputQ31, i32 noundef 32) #3
  call void @arm_biquad_cas_df1_32x64_q31(ptr noundef nonnull %1, ptr noundef nonnull @inputQ31, ptr noundef nonnull @outputQ31, i32 noundef 32) #3
  call void @arm_biquad_cas_df1_32x64_q31(ptr noundef nonnull %2, ptr noundef nonnull @outputQ31, ptr noundef nonnull @outputQ31, i32 noundef 32) #3
  call void @arm_biquad_cascade_df1_q31(ptr noundef nonnull %3, ptr noundef nonnull @outputQ31, ptr noundef nonnull @outputQ31, i32 noundef 32) #3
  call void @arm_biquad_cascade_df1_q31(ptr noundef nonnull %4, ptr noundef nonnull @outputQ31, ptr noundef nonnull @outputQ31, i32 noundef 32) #3
  call void @arm_biquad_cascade_df1_q31(ptr noundef nonnull %5, ptr noundef nonnull @outputQ31, ptr noundef nonnull @outputQ31, i32 noundef 32) #3
  %34 = getelementptr inbounds float, ptr @testOutput, i64 %32
  call void @arm_q31_to_float(ptr noundef nonnull @outputQ31, ptr noundef nonnull %34, i32 noundef 32) #3
  call void @arm_scale_f32(ptr noundef nonnull %34, float noundef 8.000000e+00, ptr noundef nonnull %34, i32 noundef 32) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
  br i1 %exitcond.not, label %35, label %31, !llvm.loop !9

35:                                               ; preds = %31
  %36 = call float @arm_snr_f32(ptr noundef nonnull @testRefOutput_f32, ptr noundef nonnull @testOutput, i32 noundef 320) #3
  store float %36, ptr @snr, align 4, !tbaa !11
  %37 = fcmp olt float %36, 9.800000e+01
  br i1 %37, label %.preheader, label %.preheader10

.preheader:                                       ; preds = %35, %.preheader
  br label %.preheader

.preheader10:                                     ; preds = %35, %.preheader10
  br label %.preheader10
}

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

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

declare void @arm_biquad_cascade_df1_init_q31(ptr noundef, i8 noundef zeroext, ptr noundef, ptr noundef, i8 noundef signext) local_unnamed_addr #2

declare void @arm_float_to_q31(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_scale_q31(ptr noundef, i32 noundef, i8 noundef signext, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_biquad_cas_df1_32x64_q31(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_biquad_cascade_df1_q31(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_q31_to_float(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare void @arm_scale_f32(ptr noundef, float noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

declare float @arm_snr_f32(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

attributes #0 = { noreturn 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 = { "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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}


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