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

@WeightsQ15_8192 = external constant [16384 x i16], align 16
@cos_factorsQ15_8192 = external constant [8192 x i16], align 16
@WeightsQ15_2048 = external constant [4096 x i16], align 16
@cos_factorsQ15_2048 = external constant [2048 x i16], align 16
@WeightsQ15_512 = external constant [1024 x i16], align 16
@cos_factorsQ15_512 = external constant [512 x i16], align 16
@WeightsQ15_128 = external constant [256 x i16], align 16
@cos_factorsQ15_128 = external constant [128 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_dct4_init_q15(ptr noundef %0, ptr noundef %1, ptr noundef %2, i16 noundef zeroext %3, i16 noundef zeroext %4, i16 noundef signext %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 i16, align 2
  %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 i16 %5, ptr %12, align 2, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !11
  %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_q15, ptr %15, i32 0, i32 0
  store i16 %14, ptr %16, align 8, !tbaa !13
  %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_q15, ptr %18, i32 0, i32 1
  store i16 %17, ptr %19, align 2, !tbaa !15
  %20 = load i16, ptr %12, align 2, !tbaa !9
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %21, i32 0, i32 2
  store i16 %20, ptr %22, align 4, !tbaa !16
  %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_q15, ptr %24, i32 0, i32 5
  store ptr %23, ptr %25, align 8, !tbaa !17
  %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_q15, ptr %27, i32 0, i32 6
  store ptr %26, ptr %28, align 8, !tbaa !18
  %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_q15, ptr %32, i32 0, i32 3
  store ptr @WeightsQ15_8192, ptr %33, align 8, !tbaa !19
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %34, i32 0, i32 4
  store ptr @cos_factorsQ15_8192, ptr %35, align 8, !tbaa !20
  br label %52

36:                                               ; preds = %6
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %37, i32 0, i32 3
  store ptr @WeightsQ15_2048, ptr %38, align 8, !tbaa !19
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %39, i32 0, i32 4
  store ptr @cos_factorsQ15_2048, ptr %40, align 8, !tbaa !20
  br label %52

41:                                               ; preds = %6
  %42 = load ptr, ptr %7, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %42, i32 0, i32 3
  store ptr @WeightsQ15_512, ptr %43, align 8, !tbaa !19
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %44, i32 0, i32 4
  store ptr @cos_factorsQ15_512, ptr %45, align 8, !tbaa !20
  br label %52

46:                                               ; preds = %6
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %47, i32 0, i32 3
  store ptr @WeightsQ15_128, ptr %48, align 8, !tbaa !19
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %49, i32 0, i32 4
  store ptr @cos_factorsQ15_128, ptr %50, align 8, !tbaa !20
  br label %52

51:                                               ; preds = %6
  store i32 -1, ptr %13, align 4, !tbaa !11
  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_q15, ptr %53, i32 0, i32 5
  %55 = load ptr, ptr %54, align 8, !tbaa !17
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_dct4_instance_q15, ptr %56, i32 0, i32 0
  %58 = load i16, ptr %57, align 8, !tbaa !13
  %59 = zext i16 %58 to i32
  %60 = call i32 @arm_rfft_init_q15(ptr noundef %55, i32 noundef %59, i32 noundef 0, i32 noundef 1)
  %61 = load i32, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  ret i32 %61
}

; 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_q15(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 = !{!"int", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 2, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!15 = !{!14, !10, i64 2}
!16 = !{!14, !10, i64 4}
!17 = !{!14, !6, i64 24}
!18 = !{!14, !6, i64 32}
!19 = !{!14, !6, i64 8}
!20 = !{!14, !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"

@WeightsQ15_8192 = external constant [16384 x i16], align 16
@cos_factorsQ15_8192 = external constant [8192 x i16], align 16
@WeightsQ15_2048 = external constant [4096 x i16], align 16
@cos_factorsQ15_2048 = external constant [2048 x i16], align 16
@WeightsQ15_512 = external constant [1024 x i16], align 16
@cos_factorsQ15_512 = external constant [512 x i16], align 16
@WeightsQ15_128 = external constant [256 x i16], align 16
@cos_factorsQ15_128 = external constant [128 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @arm_dct4_init_q15(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2, i16 noundef zeroext %3, i16 noundef zeroext %4, i16 noundef signext %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 !11
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  store i16 %5, ptr %8, align 4, !tbaa !12
  %9 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %1, ptr %9, align 8, !tbaa !13
  %10 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %2, ptr %10, align 8, !tbaa !14
  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
  %WeightsQ15_128.sink = phi ptr [ @WeightsQ15_128, %13 ], [ @WeightsQ15_512, %12 ], [ @WeightsQ15_2048, %11 ], [ @WeightsQ15_8192, %6 ]
  %cos_factorsQ15_128.sink = phi ptr [ @cos_factorsQ15_128, %13 ], [ @cos_factorsQ15_512, %12 ], [ @cos_factorsQ15_2048, %11 ], [ @cos_factorsQ15_8192, %6 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %WeightsQ15_128.sink, ptr %14, align 8, !tbaa !15
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %cos_factorsQ15_128.sink, ptr %15, align 8, !tbaa !16
  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_q15(ptr noundef %1, i32 noundef %17, i32 noundef 0, i32 noundef 1) #2
  ret i32 %.0
}

declare i32 @arm_rfft_init_q15(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, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !7, i64 4}
!13 = !{!6, !10, i64 24}
!14 = !{!6, !10, i64 32}
!15 = !{!6, !10, i64 8}
!16 = !{!6, !10, i64 16}


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