; 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_RODFT10(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 = %74, %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 %77

18:                                               ; preds = %12
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.fftplan_s, ptr %19, i32 0, i32 9
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %3, align 4, !tbaa !14
  %23 = zext i32 %22 to i64
  %24 = getelementptr inbounds float, ptr %21, i64 %23
  store float 0.000000e+00, ptr %24, align 4, !tbaa !12
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %25

25:                                               ; preds = %62, %18
  %26 = load i32, ptr %4, align 4, !tbaa !14
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.fftplan_s, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !9
  %30 = icmp ult i32 %26, %29
  br i1 %30, label %31, label %65

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

62:                                               ; preds = %31
  %63 = load i32, ptr %4, align 4, !tbaa !14
  %64 = add i32 %63, 1
  store i32 %64, ptr %4, align 4, !tbaa !14
  br label %25, !llvm.loop !17

65:                                               ; preds = %25
  %66 = load ptr, ptr %2, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.fftplan_s, ptr %66, i32 0, i32 9
  %68 = load ptr, ptr %67, align 8, !tbaa !15
  %69 = load i32, ptr %3, align 4, !tbaa !14
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds float, ptr %68, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !12
  %73 = fmul float %72, 2.000000e+00
  store float %73, ptr %71, align 4, !tbaa !12
  br label %74

74:                                               ; preds = %65
  %75 = load i32, ptr %3, align 4, !tbaa !14
  %76 = add i32 %75, 1
  store i32 %76, ptr %3, align 4, !tbaa !14
  br label %12, !llvm.loop !19

77:                                               ; 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nounwind
declare float @sinf(float noundef) #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 56}
!16 = !{!10, !6, i64 48}
!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_RODFT10(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_edge23, label %.lr.ph22.split.preheader

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

.lr.ph22.split:                                   ; preds = %.lr.ph22.split.preheader, %._crit_edge
  %9 = phi i32 [ 1, %.lr.ph22.split.preheader ], [ %33, %._crit_edge ]
  %10 = phi ptr [ %.pre, %.lr.ph22.split.preheader ], [ %35, %._crit_edge ]
  %indvars.iv28 = phi i64 [ 0, %.lr.ph22.split.preheader ], [ %.pre35, %._crit_edge ]
  %11 = getelementptr inbounds float, ptr %10, i64 %indvars.iv28
  store float 0.000000e+00, ptr %11, align 4, !tbaa !12
  %.not25 = icmp eq i32 %9, 0
  %.pre35 = add nuw nsw i64 %indvars.iv28, 1
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph22.split
  %12 = trunc nuw i64 %.pre35 to i32
  %13 = uitofp i32 %12 to double
  br label %14

14:                                               ; preds = %.lr.ph, %14
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %14 ]
  %15 = trunc nuw i64 %indvars.iv to i32
  %16 = uitofp i32 %15 to float
  %17 = fadd float %16, 5.000000e-01
  %18 = fpext float %17 to double
  %19 = fmul double %7, %18
  %20 = fmul double %19, %13
  %21 = fptrunc double %20 to float
  %22 = load ptr, ptr %8, align 8, !tbaa !14
  %23 = getelementptr inbounds float, ptr %22, i64 %indvars.iv
  %24 = load float, ptr %23, align 4, !tbaa !12
  %25 = tail call float @sinf(float noundef %21) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !11
  %27 = getelementptr inbounds float, ptr %26, i64 %indvars.iv28
  %28 = load float, ptr %27, align 4, !tbaa !12
  %29 = tail call float @llvm.fmuladd.f32(float %24, float %25, float %28)
  store float %29, ptr %27, align 4, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = load i32, ptr %0, align 8, !tbaa !5
  %31 = zext i32 %30 to i64
  %32 = icmp ult i64 %indvars.iv.next, %31
  br i1 %32, label %14, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %14, %.lr.ph22.split
  %33 = phi i32 [ 0, %.lr.ph22.split ], [ %30, %14 ]
  %34 = phi float [ 0.000000e+00, %.lr.ph22.split ], [ %29, %14 ]
  %35 = phi ptr [ %10, %.lr.ph22.split ], [ %26, %14 ]
  %36 = getelementptr inbounds float, ptr %35, i64 %indvars.iv28
  %37 = fmul float %34, 2.000000e+00
  store float %37, ptr %36, align 4, !tbaa !12
  %38 = zext i32 %33 to i64
  %39 = icmp ult i64 %.pre35, %38
  br i1 %39, label %.lr.ph22.split, label %._crit_edge23, !llvm.loop !17

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

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!6, !10, i64 48}
!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,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass