; 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_REDFT10(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 = %73, %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 %76

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 = %61, %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 %64

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

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

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

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

76:                                               ; 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_REDFT10(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 ], [ %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 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 @cosf(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
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %38 = zext i32 %33 to i64
  %39 = icmp ult i64 %indvars.iv.next29, %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 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