; 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_RODFT01(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 = %92, %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 %95

18:                                               ; preds = %12
  %19 = load i32, ptr %3, align 4, !tbaa !14
  %20 = urem i32 %19, 2
  %21 = icmp eq i32 %20, 0
  %22 = zext i1 %21 to i64
  %23 = select i1 %21, float 5.000000e-01, float -5.000000e-01
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.fftplan_s, ptr %24, i32 0, i32 8
  %26 = load ptr, ptr %25, align 8, !tbaa !15
  %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 = sub i32 %29, 1
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds float, ptr %26, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = fmul float %23, %33
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.fftplan_s, ptr %35, i32 0, i32 9
  %37 = load ptr, ptr %36, align 8, !tbaa !16
  %38 = load i32, ptr %3, align 4, !tbaa !14
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %37, i64 %39
  store float %34, ptr %40, align 4, !tbaa !12
  store i32 0, ptr %4, align 4, !tbaa !14
  br label %41

41:                                               ; preds = %80, %18
  %42 = load i32, ptr %4, align 4, !tbaa !14
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.fftplan_s, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = sub i32 %45, 1
  %47 = icmp ult i32 %42, %46
  br i1 %47, label %48, label %83

48:                                               ; preds = %41
  %49 = load float, ptr %5, align 4, !tbaa !12
  %50 = fpext float %49 to double
  %51 = fmul double 0x400921FB54442D18, %50
  %52 = load i32, ptr %4, align 4, !tbaa !14
  %53 = uitofp i32 %52 to float
  %54 = fadd float %53, 1.000000e+00
  %55 = fpext float %54 to double
  %56 = fmul double %51, %55
  %57 = load i32, ptr %3, align 4, !tbaa !14
  %58 = uitofp i32 %57 to float
  %59 = fadd float %58, 5.000000e-01
  %60 = fpext float %59 to double
  %61 = fmul double %56, %60
  %62 = fptrunc double %61 to float
  store float %62, ptr %6, align 4, !tbaa !12
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.fftplan_s, ptr %63, i32 0, i32 8
  %65 = load ptr, ptr %64, align 8, !tbaa !15
  %66 = load i32, ptr %4, align 4, !tbaa !14
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !12
  %70 = load float, ptr %6, align 4, !tbaa !12
  %71 = call float @sinf(float noundef %70) #4
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.fftplan_s, ptr %72, i32 0, i32 9
  %74 = load ptr, ptr %73, align 8, !tbaa !16
  %75 = load i32, ptr %3, align 4, !tbaa !14
  %76 = zext i32 %75 to i64
  %77 = getelementptr inbounds float, ptr %74, i64 %76
  %78 = load float, ptr %77, align 4, !tbaa !12
  %79 = call float @llvm.fmuladd.f32(float %69, float %71, float %78)
  store float %79, ptr %77, align 4, !tbaa !12
  br label %80

80:                                               ; preds = %48
  %81 = load i32, ptr %4, align 4, !tbaa !14
  %82 = add i32 %81, 1
  store i32 %82, ptr %4, align 4, !tbaa !14
  br label %41, !llvm.loop !17

83:                                               ; preds = %41
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.fftplan_s, ptr %84, i32 0, i32 9
  %86 = load ptr, ptr %85, align 8, !tbaa !16
  %87 = load i32, ptr %3, align 4, !tbaa !14
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %86, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !12
  %91 = fmul float %90, 2.000000e+00
  store float %91, ptr %89, align 4, !tbaa !12
  br label %92

92:                                               ; preds = %83
  %93 = load i32, ptr %3, align 4, !tbaa !14
  %94 = add i32 %93, 1
  store i32 %94, ptr %3, align 4, !tbaa !14
  br label %12, !llvm.loop !19

95:                                               ; 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 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_RODFT01(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_edge27, label %.lr.ph26

.lr.ph26:                                         ; 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
  %.pre = load ptr, ptr %6, align 8, !tbaa !11
  br label %9

9:                                                ; preds = %.lr.ph26, %._crit_edge
  %10 = phi i32 [ %2, %.lr.ph26 ], [ %46, %._crit_edge ]
  %11 = phi ptr [ %.pre, %.lr.ph26 ], [ %48, %._crit_edge ]
  %indvars.iv30 = phi i64 [ 0, %.lr.ph26 ], [ %indvars.iv.next31, %._crit_edge ]
  %12 = trunc nuw i64 %indvars.iv30 to i32
  %13 = and i32 %12, 1
  %14 = icmp eq i32 %13, 0
  %15 = select i1 %14, float 5.000000e-01, float -5.000000e-01
  %16 = load ptr, ptr %5, align 8, !tbaa !12
  %17 = add i32 %10, -1
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds float, ptr %16, i64 %18
  %20 = load float, ptr %19, align 4, !tbaa !13
  %21 = fmul float %15, %20
  %22 = getelementptr inbounds float, ptr %11, i64 %indvars.iv30
  store float %21, ptr %22, align 4, !tbaa !13
  %.not28 = icmp eq i32 %10, 1
  br i1 %.not28, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9
  %23 = uitofp i32 %12 to float
  %24 = fadd float %23, 5.000000e-01
  %25 = fpext float %24 to double
  br label %26

26:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %27 = trunc nuw i64 %indvars.iv to i32
  %28 = uitofp i32 %27 to float
  %29 = fadd float %28, 1.000000e+00
  %30 = fpext float %29 to double
  %31 = fmul double %8, %30
  %32 = fmul double %31, %25
  %33 = fptrunc double %32 to float
  %34 = load ptr, ptr %5, align 8, !tbaa !12
  %35 = getelementptr inbounds float, ptr %34, i64 %indvars.iv
  %36 = load float, ptr %35, align 4, !tbaa !13
  %37 = tail call float @sinf(float noundef %33) #3
  %38 = load ptr, ptr %6, align 8, !tbaa !11
  %39 = getelementptr inbounds float, ptr %38, i64 %indvars.iv30
  %40 = load float, ptr %39, align 4, !tbaa !13
  %41 = tail call float @llvm.fmuladd.f32(float %36, float %37, float %40)
  store float %41, ptr %39, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load i32, ptr %0, align 8, !tbaa !5
  %43 = add i32 %42, -1
  %44 = zext i32 %43 to i64
  %45 = icmp ult i64 %indvars.iv.next, %44
  br i1 %45, label %26, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %26, %9
  %46 = phi i32 [ 1, %9 ], [ %42, %26 ]
  %47 = phi float [ %21, %9 ], [ %41, %26 ]
  %48 = phi ptr [ %11, %9 ], [ %38, %26 ]
  %49 = getelementptr inbounds float, ptr %48, i64 %indvars.iv30
  %50 = fmul float %47, 2.000000e+00
  store float %50, ptr %49, align 4, !tbaa !13
  %indvars.iv.next31 = add nuw nsw i64 %indvars.iv30, 1
  %51 = zext i32 %46 to i64
  %52 = icmp ult i64 %indvars.iv.next31, %51
  br i1 %52, label %9, label %._crit_edge27, !llvm.loop !17

._crit_edge27:                                    ; 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 = !{!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}


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