; 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_REDFT11(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 = %75, %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 %78

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 = %63, %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 %66

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

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

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

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

78:                                               ; 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 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_REDFT11(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 ], [ %35, %._crit_edge ]
  %10 = phi ptr [ %.pre, %.lr.ph22.split.preheader ], [ %37, %._crit_edge ]
  %indvars.iv28 = phi i64 [ 0, %.lr.ph22.split.preheader ], [ %indvars.iv.next29, %._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
  br i1 %.not25, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph22.split
  %12 = trunc nuw i64 %indvars.iv28 to i32
  %13 = uitofp i32 %12 to float
  %14 = fadd float %13, 5.000000e-01
  %15 = fpext float %14 to double
  br label %16

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

._crit_edge:                                      ; preds = %16, %.lr.ph22.split
  %35 = phi i32 [ 0, %.lr.ph22.split ], [ %32, %16 ]
  %36 = phi float [ 0.000000e+00, %.lr.ph22.split ], [ %31, %16 ]
  %37 = phi ptr [ %10, %.lr.ph22.split ], [ %28, %16 ]
  %38 = getelementptr inbounds float, ptr %37, i64 %indvars.iv28
  %39 = fmul float %36, 2.000000e+00
  store float %39, ptr %38, align 4, !tbaa !12
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %40 = zext i32 %35 to i64
  %41 = icmp ult i64 %indvars.iv.next29, %40
  br i1 %41, label %.lr.ph22.split, label %._crit_edge23, !llvm.loop !17

._crit_edge23:                                    ; preds = %._crit_edge, %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 = !{!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