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

@realCoefA = external constant [8192 x float], align 16
@realCoefB = external constant [8192 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_rfft_init_f32(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  store i32 -1, ptr %11, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  %12 = load i32, ptr %8, align 4, !tbaa !9
  %13 = trunc i32 %12 to i16
  %14 = zext i16 %13 to i32
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %15, i32 0, i32 0
  store i32 %14, ptr %16, align 8, !tbaa !11
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = trunc i32 %17 to i16
  %19 = zext i16 %18 to i32
  %20 = udiv i32 %19, 2
  %21 = trunc i32 %20 to i16
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %22, i32 0, i32 1
  store i16 %21, ptr %23, align 4, !tbaa !14
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %24, i32 0, i32 5
  store ptr @realCoefA, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %26, i32 0, i32 6
  store ptr @realCoefB, ptr %27, align 8, !tbaa !16
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = trunc i32 %28 to i8
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %30, i32 0, i32 2
  store i8 %29, ptr %31, align 2, !tbaa !17
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = trunc i32 %32 to i8
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %34, i32 0, i32 3
  store i8 %33, ptr %35, align 1, !tbaa !18
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !11
  switch i32 %38, label %51 [
    i32 8192, label %39
    i32 2048, label %42
    i32 512, label %45
    i32 128, label %48
  ]

39:                                               ; preds = %5
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %40, i32 0, i32 4
  store i32 1, ptr %41, align 8, !tbaa !19
  br label %52

42:                                               ; preds = %5
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %43, i32 0, i32 4
  store i32 4, ptr %44, align 8, !tbaa !19
  br label %52

45:                                               ; preds = %5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %46, i32 0, i32 4
  store i32 16, ptr %47, align 8, !tbaa !19
  br label %52

48:                                               ; preds = %5
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %49, i32 0, i32 4
  store i32 64, ptr %50, align 8, !tbaa !19
  br label %52

51:                                               ; preds = %5
  store i32 -1, ptr %11, align 4, !tbaa !9
  br label %52

52:                                               ; preds = %51, %48, %45, %42, %39
  %53 = load ptr, ptr %7, align 8, !tbaa !5
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %54, i32 0, i32 7
  store ptr %53, ptr %55, align 8, !tbaa !20
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %56, i32 0, i32 2
  %58 = load i8, ptr %57, align 2, !tbaa !17
  %59 = icmp ne i8 %58, 0
  br i1 %59, label %60, label %68

60:                                               ; preds = %52
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %61, i32 0, i32 7
  %63 = load ptr, ptr %62, align 8, !tbaa !20
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %64, i32 0, i32 1
  %66 = load i16, ptr %65, align 4, !tbaa !14
  %67 = call i32 @arm_cfft_radix4_init_f32(ptr noundef %63, i16 noundef zeroext %66, i8 noundef zeroext 1, i8 noundef zeroext 0)
  br label %76

68:                                               ; preds = %52
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %69, i32 0, i32 7
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = load ptr, ptr %6, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.arm_rfft_instance_f32, ptr %72, i32 0, i32 1
  %74 = load i16, ptr %73, align 4, !tbaa !14
  %75 = call i32 @arm_cfft_radix4_init_f32(ptr noundef %71, i16 noundef zeroext %74, i8 noundef zeroext 0, i8 noundef zeroext 0)
  br label %76

76:                                               ; preds = %68, %60
  %77 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  ret i32 %77
}

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

declare i32 @arm_cfft_radix4_init_f32(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) #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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !13, i64 4, !7, i64 6, !7, i64 7, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!13 = !{!"short", !7, i64 0}
!14 = !{!12, !13, i64 4}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 24}
!17 = !{!12, !7, i64 6}
!18 = !{!12, !7, i64 7}
!19 = !{!12, !10, i64 8}
!20 = !{!12, !6, i64 32}


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

@realCoefA = external constant [8192 x float], align 16
@realCoefB = external constant [8192 x float], align 16

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @arm_rfft_init_f32(ptr nocapture noundef writeonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = and i32 %2, 65535
  store i32 %6, ptr %0, align 8, !tbaa !5
  %7 = lshr i32 %6, 1
  %8 = trunc nuw nsw i32 %7 to i16
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  store i16 %8, ptr %9, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr @realCoefA, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr @realCoefB, ptr %11, align 8, !tbaa !14
  %12 = trunc i32 %3 to i8
  %13 = getelementptr inbounds i8, ptr %0, i64 6
  store i8 %12, ptr %13, align 2, !tbaa !15
  %14 = trunc i32 %4 to i8
  %15 = getelementptr inbounds i8, ptr %0, i64 7
  store i8 %14, ptr %15, align 1, !tbaa !16
  %trunc = trunc i32 %2 to i16
  switch i16 %trunc, label %20 [
    i16 8192, label %.sink.split
    i16 2048, label %16
    i16 512, label %17
    i16 128, label %18
  ]

16:                                               ; preds = %5
  br label %.sink.split

17:                                               ; preds = %5
  br label %.sink.split

18:                                               ; preds = %5
  br label %.sink.split

.sink.split:                                      ; preds = %5, %16, %17, %18
  %.sink = phi i32 [ 64, %18 ], [ 16, %17 ], [ 4, %16 ], [ 1, %5 ]
  %19 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %.sink, ptr %19, align 8, !tbaa !17
  br label %20

20:                                               ; preds = %.sink.split, %5
  %.0 = phi i32 [ -1, %5 ], [ 0, %.sink.split ]
  %21 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %1, ptr %21, align 8, !tbaa !18
  %.not = icmp ne i8 %12, 0
  %. = zext i1 %.not to i8
  %22 = tail call i32 @arm_cfft_radix4_init_f32(ptr noundef %1, i16 noundef zeroext %8, i8 noundef zeroext %., i8 noundef zeroext 0) #2
  ret i32 %.0
}

declare i32 @arm_cfft_radix4_init_f32(ptr noundef, i16 noundef zeroext, i8 noundef zeroext, i8 noundef zeroext) 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, !10, i64 4, !8, i64 6, !8, i64 7, !7, i64 8, !11, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !10, i64 4}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !11, i64 24}
!15 = !{!6, !8, i64 6}
!16 = !{!6, !8, i64 7}
!17 = !{!6, !7, i64 8}
!18 = !{!6, !11, i64 32}


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