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

@Weights_8192 = external constant [16384 x float], align 16
@cos_factors_8192 = external constant [8192 x float], align 16
@Weights_2048 = external constant [4096 x float], align 16
@cos_factors_2048 = external constant [2048 x float], align 16
@Weights_512 = external constant [1024 x float], align 16
@cos_factors_512 = external constant [512 x float], align 16
@Weights_128 = external constant [256 x float], align 16
@cos_factors_128 = external constant [128 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_dct4_init_f32(ptr noundef %0, ptr noundef %1, ptr noundef %2, i16 noundef zeroext %3, i16 noundef zeroext %4, float noundef %5) #0 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i16, align 2
  %11 = alloca i16, align 2
  %12 = alloca float, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i16 %3, ptr %10, align 2, !tbaa !9
  store i16 %4, ptr %11, align 2, !tbaa !9
  store float %5, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !13
  %14 = load i16, ptr %10, align 2, !tbaa !9
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %15, i32 0, i32 0
  store i16 %14, ptr %16, align 8, !tbaa !15
  %17 = load i16, ptr %11, align 2, !tbaa !9
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %18, i32 0, i32 1
  store i16 %17, ptr %19, align 2, !tbaa !17
  %20 = load float, ptr %12, align 4, !tbaa !11
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %21, i32 0, i32 2
  store float %20, ptr %22, align 4, !tbaa !18
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %24, i32 0, i32 5
  store ptr %23, ptr %25, align 8, !tbaa !19
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %27, i32 0, i32 6
  store ptr %26, ptr %28, align 8, !tbaa !20
  %29 = load i16, ptr %10, align 2, !tbaa !9
  %30 = zext i16 %29 to i32
  switch i32 %30, label %51 [
    i32 8192, label %31
    i32 2048, label %36
    i32 512, label %41
    i32 128, label %46
  ]

31:                                               ; preds = %6
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %32, i32 0, i32 3
  store ptr @Weights_8192, ptr %33, align 8, !tbaa !21
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %34, i32 0, i32 4
  store ptr @cos_factors_8192, ptr %35, align 8, !tbaa !22
  br label %52

36:                                               ; preds = %6
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %37, i32 0, i32 3
  store ptr @Weights_2048, ptr %38, align 8, !tbaa !21
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %39, i32 0, i32 4
  store ptr @cos_factors_2048, ptr %40, align 8, !tbaa !22
  br label %52

41:                                               ; preds = %6
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %42, i32 0, i32 3
  store ptr @Weights_512, ptr %43, align 8, !tbaa !21
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %44, i32 0, i32 4
  store ptr @cos_factors_512, ptr %45, align 8, !tbaa !22
  br label %52

46:                                               ; preds = %6
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %47, i32 0, i32 3
  store ptr @Weights_128, ptr %48, align 8, !tbaa !21
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %49, i32 0, i32 4
  store ptr @cos_factors_128, ptr %50, align 8, !tbaa !22
  br label %52

51:                                               ; preds = %6
  store i32 -1, ptr %13, align 4, !tbaa !13
  br label %52

52:                                               ; preds = %51, %46, %41, %36, %31
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %53, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %56, i32 0, i32 6
  %58 = load ptr, ptr %57, align 8, !tbaa !20
  %59 = load ptr, ptr %7, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.arm_dct4_instance_f32, ptr %59, i32 0, i32 0
  %61 = load i16, ptr %60, align 8, !tbaa !15
  %62 = zext i16 %61 to i32
  %63 = call i32 @arm_rfft_init_f32(ptr noundef %55, ptr noundef %58, i32 noundef %62, i32 noundef 0, i32 noundef 1)
  %64 = load i32, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret i32 %64
}

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

declare i32 @arm_rfft_init_f32(ptr noundef, ptr noundef, i32 noundef, i32 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 = { "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 = !{!"short", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !10, i64 0}
!16 = !{!"", !10, i64 0, !10, i64 2, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!17 = !{!16, !10, i64 2}
!18 = !{!16, !12, i64 4}
!19 = !{!16, !6, i64 24}
!20 = !{!16, !6, i64 32}
!21 = !{!16, !6, i64 8}
!22 = !{!16, !6, i64 16}


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

@Weights_8192 = external constant [16384 x float], align 16
@cos_factors_8192 = external constant [8192 x float], align 16
@Weights_2048 = external constant [4096 x float], align 16
@cos_factors_2048 = external constant [2048 x float], align 16
@Weights_512 = external constant [1024 x float], align 16
@cos_factors_512 = external constant [512 x float], align 16
@Weights_128 = external constant [256 x float], align 16
@cos_factors_128 = external constant [128 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @arm_dct4_init_f32(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2, i16 noundef zeroext %3, i16 noundef zeroext %4, float noundef %5) local_unnamed_addr #0 {
  store i16 %3, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 2
  store i16 %4, ptr %7, align 2, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  store float %5, ptr %8, align 4, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %2, ptr %10, align 8, !tbaa !15
  switch i16 %3, label %16 [
    i16 8192, label %.sink.split
    i16 2048, label %11
    i16 512, label %12
    i16 128, label %13
  ]

11:                                               ; preds = %6
  br label %.sink.split

12:                                               ; preds = %6
  br label %.sink.split

13:                                               ; preds = %6
  br label %.sink.split

.sink.split:                                      ; preds = %6, %11, %12, %13
  %Weights_128.sink = phi ptr [ @Weights_128, %13 ], [ @Weights_512, %12 ], [ @Weights_2048, %11 ], [ @Weights_8192, %6 ]
  %cos_factors_128.sink = phi ptr [ @cos_factors_128, %13 ], [ @cos_factors_512, %12 ], [ @cos_factors_2048, %11 ], [ @cos_factors_8192, %6 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %Weights_128.sink, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %cos_factors_128.sink, ptr %15, align 8, !tbaa !17
  br label %16

16:                                               ; preds = %.sink.split, %6
  %.0 = phi i32 [ -1, %6 ], [ 0, %.sink.split ]
  %17 = zext i16 %3 to i32
  %18 = tail call i32 @arm_rfft_init_f32(ptr noundef %1, ptr noundef %2, i32 noundef %17, i32 noundef 0, i32 noundef 1) #2
  ret i32 %.0
}

declare i32 @arm_rfft_init_f32(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #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 = { "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 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 2, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"short", !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 2}
!13 = !{!6, !10, i64 4}
!14 = !{!6, !11, i64 24}
!15 = !{!6, !11, i64 32}
!16 = !{!6, !11, i64 8}
!17 = !{!6, !11, i64 16}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass