; 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_RODFT00(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 = add i32 %9, 1
  %11 = uitofp i32 %10 to float
  %12 = fdiv float 1.000000e+00, %11
  store float %12, 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 %13

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

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

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

32:                                               ; preds = %26
  %33 = load float, ptr %5, align 4, !tbaa !12
  %34 = fpext float %33 to double
  %35 = fmul double 0x400921FB54442D18, %34
  %36 = load i32, ptr %4, align 4, !tbaa !14
  %37 = add i32 %36, 1
  %38 = load i32, ptr %3, align 4, !tbaa !14
  %39 = add i32 %38, 1
  %40 = mul i32 %37, %39
  %41 = uitofp i32 %40 to float
  %42 = fpext float %41 to double
  %43 = fmul double %35, %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 = %32
  %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 %26, !llvm.loop !17

65:                                               ; preds = %26
  %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 %13, !llvm.loop !19

77:                                               ; preds = %13
  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_RODFT00(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 = add i32 %2, 1
  %4 = uitofp i32 %3 to float
  %5 = fdiv float 1.000000e+00, %4
  %6 = getelementptr inbounds i8, ptr %0, i64 56
  %7 = fpext float %5 to double
  %8 = fmul double %7, 0x400921FB54442D18
  %9 = getelementptr inbounds i8, ptr %0, i64 48
  %.pre = load ptr, ptr %6, align 8, !tbaa !11
  br label %.lr.ph22.split

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

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

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

._crit_edge:                                      ; preds = %14, %.lr.ph22.split
  %32 = phi i32 [ 0, %.lr.ph22.split ], [ %29, %14 ]
  %33 = phi float [ 0.000000e+00, %.lr.ph22.split ], [ %28, %14 ]
  %34 = phi ptr [ %11, %.lr.ph22.split ], [ %25, %14 ]
  %35 = getelementptr inbounds float, ptr %34, i64 %indvars.iv28
  %36 = fmul float %33, 2.000000e+00
  store float %36, ptr %35, align 4, !tbaa !12
  %37 = zext i32 %32 to i64
  %38 = icmp ult i64 %.pre35, %37
  br i1 %38, 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,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass