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

@twiddleCoef_4096_q15 = external constant [6144 x i16], align 16
@armBitRevTable = external constant [1024 x i16], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_cfft_radix2_init_q15(ptr noundef %0, i16 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i16, align 2
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i16 %1, ptr %6, align 2, !tbaa !9
  store i8 %2, ptr %7, align 1, !tbaa !11
  store i8 %3, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 -1, ptr %9, align 4, !tbaa !12
  store i32 0, ptr %9, align 4, !tbaa !12
  %10 = load i16, ptr %6, align 2, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %11, i32 0, i32 0
  store i16 %10, ptr %12, align 8, !tbaa !14
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %13, i32 0, i32 3
  store ptr @twiddleCoef_4096_q15, ptr %14, align 8, !tbaa !16
  %15 = load i8, ptr %7, align 1, !tbaa !11
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %16, i32 0, i32 1
  store i8 %15, ptr %17, align 2, !tbaa !17
  %18 = load i8, ptr %8, align 1, !tbaa !11
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %19, i32 0, i32 2
  store i8 %18, ptr %20, align 1, !tbaa !18
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %21, i32 0, i32 0
  %23 = load i16, ptr %22, align 8, !tbaa !14
  %24 = zext i16 %23 to i32
  switch i32 %24, label %88 [
    i32 4096, label %25
    i32 2048, label %32
    i32 1024, label %39
    i32 512, label %46
    i32 256, label %53
    i32 128, label %60
    i32 64, label %67
    i32 32, label %74
    i32 16, label %81
  ]

25:                                               ; preds = %4
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %26, i32 0, i32 5
  store i16 1, ptr %27, align 8, !tbaa !19
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %28, i32 0, i32 6
  store i16 1, ptr %29, align 2, !tbaa !20
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %30, i32 0, i32 4
  store ptr @armBitRevTable, ptr %31, align 8, !tbaa !21
  br label %89

32:                                               ; preds = %4
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %33, i32 0, i32 5
  store i16 2, ptr %34, align 8, !tbaa !19
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %35, i32 0, i32 6
  store i16 2, ptr %36, align 2, !tbaa !20
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %37, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 1), ptr %38, align 8, !tbaa !21
  br label %89

39:                                               ; preds = %4
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %40, i32 0, i32 5
  store i16 4, ptr %41, align 8, !tbaa !19
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %42, i32 0, i32 6
  store i16 4, ptr %43, align 2, !tbaa !20
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %44, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 3), ptr %45, align 8, !tbaa !21
  br label %89

46:                                               ; preds = %4
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %47, i32 0, i32 5
  store i16 8, ptr %48, align 8, !tbaa !19
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %49, i32 0, i32 6
  store i16 8, ptr %50, align 2, !tbaa !20
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %51, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 7), ptr %52, align 8, !tbaa !21
  br label %89

53:                                               ; preds = %4
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %54, i32 0, i32 5
  store i16 16, ptr %55, align 8, !tbaa !19
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %56, i32 0, i32 6
  store i16 16, ptr %57, align 2, !tbaa !20
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %58, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 15), ptr %59, align 8, !tbaa !21
  br label %89

60:                                               ; preds = %4
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %61, i32 0, i32 5
  store i16 32, ptr %62, align 8, !tbaa !19
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %63, i32 0, i32 6
  store i16 32, ptr %64, align 2, !tbaa !20
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %65, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 31), ptr %66, align 8, !tbaa !21
  br label %89

67:                                               ; preds = %4
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %68, i32 0, i32 5
  store i16 64, ptr %69, align 8, !tbaa !19
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %70, i32 0, i32 6
  store i16 64, ptr %71, align 2, !tbaa !20
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %72, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 63), ptr %73, align 8, !tbaa !21
  br label %89

74:                                               ; preds = %4
  %75 = load ptr, ptr %5, align 8, !tbaa !5
  %76 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %75, i32 0, i32 5
  store i16 128, ptr %76, align 8, !tbaa !19
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %77, i32 0, i32 6
  store i16 128, ptr %78, align 2, !tbaa !20
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %79, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 127), ptr %80, align 8, !tbaa !21
  br label %89

81:                                               ; preds = %4
  %82 = load ptr, ptr %5, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %82, i32 0, i32 5
  store i16 256, ptr %83, align 8, !tbaa !19
  %84 = load ptr, ptr %5, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %84, i32 0, i32 6
  store i16 256, ptr %85, align 2, !tbaa !20
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.arm_cfft_radix2_instance_q15, ptr %86, i32 0, i32 4
  store ptr getelementptr inbounds ([1024 x i16], ptr @armBitRevTable, i64 0, i64 255), ptr %87, align 8, !tbaa !21
  br label %89

88:                                               ; preds = %4
  store i32 -1, ptr %9, align 4, !tbaa !12
  br label %89

89:                                               ; preds = %88, %81, %74, %67, %60, %53, %46, %39, %32, %25
  %90 = load i32, ptr %9, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 %90
}

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

; 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 = { 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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !10, i64 0}
!15 = !{!"", !10, i64 0, !7, i64 2, !7, i64 3, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 26}
!16 = !{!15, !6, i64 8}
!17 = !{!15, !7, i64 2}
!18 = !{!15, !7, i64 3}
!19 = !{!15, !10, i64 24}
!20 = !{!15, !10, i64 26}
!21 = !{!15, !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"

@twiddleCoef_4096_q15 = external constant [6144 x i16], align 16
@armBitRevTable = external constant [1024 x i16], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) uwtable
define dso_local range(i32 -1, 1) i32 @arm_cfft_radix2_init_q15(ptr nocapture noundef writeonly %0, i16 noundef zeroext %1, i8 noundef zeroext %2, i8 noundef zeroext %3) local_unnamed_addr #0 {
  store i16 %1, ptr %0, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr @twiddleCoef_4096_q15, ptr %5, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  store i8 %2, ptr %6, align 2, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 3
  store i8 %3, ptr %7, align 1, !tbaa !13
  switch i16 %1, label %19 [
    i16 4096, label %.sink.split
    i16 2048, label %8
    i16 1024, label %9
    i16 512, label %10
    i16 256, label %11
    i16 128, label %12
    i16 64, label %13
    i16 32, label %14
    i16 16, label %15
  ]

8:                                                ; preds = %4
  br label %.sink.split

9:                                                ; preds = %4
  br label %.sink.split

10:                                               ; preds = %4
  br label %.sink.split

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

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

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

14:                                               ; preds = %4
  br label %.sink.split

15:                                               ; preds = %4
  br label %.sink.split

.sink.split:                                      ; preds = %4, %8, %9, %10, %11, %12, %13, %14, %15
  %.sink38 = phi i16 [ 256, %15 ], [ 128, %14 ], [ 64, %13 ], [ 32, %12 ], [ 16, %11 ], [ 8, %10 ], [ 4, %9 ], [ 2, %8 ], [ 1, %4 ]
  %.sink = phi ptr [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 510), %15 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 254), %14 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 126), %13 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 62), %12 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 30), %11 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 14), %10 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 6), %9 ], [ getelementptr inbounds (i8, ptr @armBitRevTable, i64 2), %8 ], [ @armBitRevTable, %4 ]
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store i16 %.sink38, ptr %16, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %0, i64 26
  store i16 %.sink38, ptr %17, align 2, !tbaa !15
  %18 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %.sink, ptr %18, align 8, !tbaa !16
  br label %19

19:                                               ; preds = %.sink.split, %4
  %.0 = phi i32 [ -1, %4 ], [ 0, %.sink.split ]
  ret i32 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) 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" }

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


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