; LLVM IR from jgaeddert/liquid-dsp :: src/fft/src (fftf)

; 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.fftplan_s = type { i32, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, %union.anon }
%union.anon = type { %struct.anon.1 }
%struct.anon.1 = type { i32, i32, ptr, ptr, ptr, ptr, ptr, ptr }

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_execute_REDFT01(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.fftplan_s, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = uitofp i32 %9 to float
  %11 = fdiv float 1.000000e+00, %10
  store float %11, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %3, align 4, !tbaa !14
  br label %12

12:                                               ; preds = %79, %1
  %13 = load i32, ptr %3, align 4, !tbaa !14
  %14 = load ptr, ptr %2, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.fftplan_s, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %82

18:                                               ; preds = %12
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.fftplan_s, ptr %19, i32 0, i32 8
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = getelementptr inbounds float, ptr %21, i64 0
  %23 = load float, ptr %22, align 4, !tbaa !12
  %24 = fmul float %23, 5.000000e-01
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.fftplan_s, ptr %25, i32 0, i32 9
  %27 = load ptr, ptr %26, align 8, !tbaa !16
  %28 = load i32, ptr %3, align 4, !tbaa !14
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds float, ptr %27, i64 %29
  store float %24, ptr %30, align 4, !tbaa !12
  store i32 1, ptr %4, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %67, %18
  %32 = load i32, ptr %4, align 4, !tbaa !14
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.fftplan_s, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !9
  %36 = icmp ult i32 %32, %35
  br i1 %36, label %37, label %70

37:                                               ; preds = %31
  %38 = load float, ptr %5, align 4, !tbaa !12
  %39 = fpext float %38 to double
  %40 = fmul double 0x400921FB54442D18, %39
  %41 = load i32, ptr %3, align 4, !tbaa !14
  %42 = uitofp i32 %41 to float
  %43 = fadd float %42, 5.000000e-01
  %44 = fpext float %43 to double
  %45 = fmul double %40, %44
  %46 = load i32, ptr %4, align 4, !tbaa !14
  %47 = uitofp i32 %46 to double
  %48 = fmul double %45, %47
  %49 = fptrunc double %48 to float
  store float %49, ptr %6, align 4, !tbaa !12
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.fftplan_s, ptr %50, i32 0, i32 8
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = load i32, ptr %4, align 4, !tbaa !14
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %52, i64 %54
  %56 = load float, ptr %55, align 4, !tbaa !12
  %57 = load float, ptr %6, align 4, !tbaa !12
  %58 = call float @cosf(float noundef %57) #4
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.fftplan_s, ptr %59, i32 0, i32 9
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = load i32, ptr %3, align 4, !tbaa !14
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %61, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !12
  %66 = call float @llvm.fmuladd.f32(float %56, float %58, float %65)
  store float %66, ptr %64, align 4, !tbaa !12
  br label %67

67:                                               ; preds = %37
  %68 = load i32, ptr %4, align 4, !tbaa !14
  %69 = add i32 %68, 1
  store i32 %69, ptr %4, align 4, !tbaa !14
  br label %31, !llvm.loop !17

70:                                               ; preds = %31
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.fftplan_s, ptr %71, i32 0, i32 9
  %73 = load ptr, ptr %72, align 8, !tbaa !16
  %74 = load i32, ptr %3, align 4, !tbaa !14
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds float, ptr %73, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !12
  %78 = fmul float %77, 2.000000e+00
  store float %78, ptr %76, align 4, !tbaa !12
  br label %79

79:                                               ; preds = %70
  %80 = load i32, ptr %3, align 4, !tbaa !14
  %81 = add i32 %80, 1
  store i32 %81, ptr %3, align 4, !tbaa !14
  br label %12, !llvm.loop !19

82:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 0
}

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { nounwind "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !11, i64 0}
!10 = !{!"fftplan_s", !11, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !11, i64 0}
!15 = !{!10, !6, i64 48}
!16 = !{!10, !6, i64 56}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


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

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local noundef i32 @fft_execute_REDFT01(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge24, label %.lr.ph23

.lr.ph23:                                         ; preds = %1
  %3 = uitofp i32 %2 to float
  %4 = fdiv float 1.000000e+00, %3
  %5 = getelementptr inbounds i8, ptr %0, i64 48
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = fpext float %4 to double
  %8 = fmul double %7, 0x400921FB54442D18
  %.not35 = icmp eq i32 %2, 1
  %9 = load ptr, ptr %6, align 8, !tbaa !11
  br i1 %.not35, label %._crit_edge24.loopexit25, label %.lr.ph23.split

.lr.ph23.split:                                   ; preds = %.lr.ph23, %._crit_edge
  %10 = phi i32 [ %38, %._crit_edge ], [ %2, %.lr.ph23 ]
  %11 = phi ptr [ %40, %._crit_edge ], [ %9, %.lr.ph23 ]
  %indvars.iv30 = phi i64 [ %indvars.iv.next31, %._crit_edge ], [ 0, %.lr.ph23 ]
  %12 = load ptr, ptr %5, align 8, !tbaa !12
  %13 = load float, ptr %12, align 4, !tbaa !13
  %14 = fmul float %13, 5.000000e-01
  %15 = getelementptr inbounds float, ptr %11, i64 %indvars.iv30
  store float %14, ptr %15, align 4, !tbaa !13
  %16 = icmp ugt i32 %10, 1
  br i1 %16, label %.lr.ph, label %.lr.ph23.split.._crit_edge_crit_edge

.lr.ph23.split.._crit_edge_crit_edge:             ; preds = %.lr.ph23.split
  %.pre34 = zext nneg i32 %10 to i64
  br label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph23.split
  %17 = trunc nuw i64 %indvars.iv30 to i32
  %18 = uitofp i32 %17 to float
  %19 = fadd float %18, 5.000000e-01
  %20 = fpext float %19 to double
  %21 = fmul double %8, %20
  br label %22

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv27 = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next28, %22 ]
  %23 = trunc nuw i64 %indvars.iv27 to i32
  %24 = uitofp i32 %23 to double
  %25 = fmul double %21, %24
  %26 = fptrunc double %25 to float
  %27 = load ptr, ptr %5, align 8, !tbaa !12
  %28 = getelementptr inbounds float, ptr %27, i64 %indvars.iv27
  %29 = load float, ptr %28, align 4, !tbaa !13
  %30 = tail call float @cosf(float noundef %26) #3
  %31 = load ptr, ptr %6, align 8, !tbaa !11
  %32 = getelementptr inbounds float, ptr %31, i64 %indvars.iv30
  %33 = load float, ptr %32, align 4, !tbaa !13
  %34 = tail call float @llvm.fmuladd.f32(float %29, float %30, float %33)
  store float %34, ptr %32, align 4, !tbaa !13
  %indvars.iv.next28 = add nuw nsw i64 %indvars.iv27, 1
  %35 = load i32, ptr %0, align 8, !tbaa !5
  %36 = zext i32 %35 to i64
  %37 = icmp ult i64 %indvars.iv.next28, %36
  br i1 %37, label %22, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %22, %.lr.ph23.split.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre34, %.lr.ph23.split.._crit_edge_crit_edge ], [ %36, %22 ]
  %38 = phi i32 [ %10, %.lr.ph23.split.._crit_edge_crit_edge ], [ %35, %22 ]
  %39 = phi float [ %14, %.lr.ph23.split.._crit_edge_crit_edge ], [ %34, %22 ]
  %40 = phi ptr [ %11, %.lr.ph23.split.._crit_edge_crit_edge ], [ %31, %22 ]
  %41 = getelementptr inbounds float, ptr %40, i64 %indvars.iv30
  %42 = fmul float %39, 2.000000e+00
  store float %42, ptr %41, align 4, !tbaa !13
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %43 = icmp ult i64 %indvars.iv.next31, %.pre-phi
  br i1 %43, label %.lr.ph23.split, label %._crit_edge24, !llvm.loop !17

._crit_edge24.loopexit25:                         ; preds = %.lr.ph23
  %44 = load ptr, ptr %5, align 8, !tbaa !12
  %45 = load float, ptr %44, align 4, !tbaa !13
  %46 = fmul float %45, 5.000000e-01
  %47 = fmul float %46, 2.000000e+00
  store float %47, ptr %9, align 4, !tbaa !13
  br label %._crit_edge24

._crit_edge24:                                    ; preds = %._crit_edge, %._crit_edge24.loopexit25, %1
  ret i32 0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

attributes #0 = { nofree nounwind memory(readwrite, inaccessiblemem: 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" }
attributes #1 = { mustprogress nofree nounwind willreturn memory(write) "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !7, i64 0}
!6 = !{!"fftplan_s", !7, i64 0, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !7, i64 32, !7, i64 36, !10, i64 40, !10, i64 48, !10, i64 56, !8, i64 64}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 56}
!12 = !{!6, !10, i64 48}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass