; 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_REDFT00(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
  %7 = alloca float, align 4
  %8 = 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
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.fftplan_s, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = sub i32 %11, 1
  %13 = uitofp i32 %12 to float
  %14 = fdiv float 1.000000e+00, %13
  store float %14, 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 %15

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

21:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.fftplan_s, ptr %22, i32 0, i32 8
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  %25 = getelementptr inbounds float, ptr %24, i64 0
  %26 = load float, ptr %25, align 4, !tbaa !12
  store float %26, ptr %7, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.fftplan_s, ptr %27, i32 0, i32 8
  %29 = load ptr, ptr %28, align 8, !tbaa !15
  %30 = load ptr, ptr %2, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.fftplan_s, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !9
  %33 = sub i32 %32, 1
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %29, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !12
  store float %36, ptr %8, align 4, !tbaa !12
  %37 = load float, ptr %7, align 4, !tbaa !12
  %38 = load i32, ptr %3, align 4, !tbaa !14
  %39 = urem i32 %38, 2
  %40 = icmp ne i32 %39, 0
  br i1 %40, label %41, label %44

41:                                               ; preds = %21
  %42 = load float, ptr %8, align 4, !tbaa !12
  %43 = fneg float %42
  br label %46

44:                                               ; preds = %21
  %45 = load float, ptr %8, align 4, !tbaa !12
  br label %46

46:                                               ; preds = %44, %41
  %47 = phi float [ %43, %41 ], [ %45, %44 ]
  %48 = fadd float %37, %47
  %49 = fmul float 5.000000e-01, %48
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.fftplan_s, ptr %50, i32 0, i32 9
  %52 = load ptr, ptr %51, align 8, !tbaa !16
  %53 = load i32, ptr %3, align 4, !tbaa !14
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds float, ptr %52, i64 %54
  store float %49, ptr %55, align 4, !tbaa !12
  store i32 1, ptr %4, align 4, !tbaa !14
  br label %56

56:                                               ; preds = %93, %46
  %57 = load i32, ptr %4, align 4, !tbaa !14
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.fftplan_s, ptr %58, i32 0, i32 0
  %60 = load i32, ptr %59, align 8, !tbaa !9
  %61 = sub i32 %60, 1
  %62 = icmp ult i32 %57, %61
  br i1 %62, label %63, label %96

63:                                               ; preds = %56
  %64 = load float, ptr %5, align 4, !tbaa !12
  %65 = fpext float %64 to double
  %66 = fmul double 0x400921FB54442D18, %65
  %67 = load i32, ptr %4, align 4, !tbaa !14
  %68 = uitofp i32 %67 to float
  %69 = fpext float %68 to double
  %70 = fmul double %66, %69
  %71 = load i32, ptr %3, align 4, !tbaa !14
  %72 = uitofp i32 %71 to float
  %73 = fpext float %72 to double
  %74 = fmul double %70, %73
  %75 = fptrunc double %74 to float
  store float %75, ptr %6, align 4, !tbaa !12
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.fftplan_s, ptr %76, i32 0, i32 8
  %78 = load ptr, ptr %77, align 8, !tbaa !15
  %79 = load i32, ptr %4, align 4, !tbaa !14
  %80 = zext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %78, i64 %80
  %82 = load float, ptr %81, align 4, !tbaa !12
  %83 = load float, ptr %6, align 4, !tbaa !12
  %84 = call float @cosf(float noundef %83) #4
  %85 = load ptr, ptr %2, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.fftplan_s, ptr %85, i32 0, i32 9
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = load i32, ptr %3, align 4, !tbaa !14
  %89 = zext i32 %88 to i64
  %90 = getelementptr inbounds float, ptr %87, i64 %89
  %91 = load float, ptr %90, align 4, !tbaa !12
  %92 = call float @llvm.fmuladd.f32(float %82, float %84, float %91)
  store float %92, ptr %90, align 4, !tbaa !12
  br label %93

93:                                               ; preds = %63
  %94 = load i32, ptr %4, align 4, !tbaa !14
  %95 = add i32 %94, 1
  store i32 %95, ptr %4, align 4, !tbaa !14
  br label %56, !llvm.loop !17

96:                                               ; preds = %56
  %97 = load ptr, ptr %2, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.fftplan_s, ptr %97, i32 0, i32 9
  %99 = load ptr, ptr %98, align 8, !tbaa !16
  %100 = load i32, ptr %3, align 4, !tbaa !14
  %101 = zext i32 %100 to i64
  %102 = getelementptr inbounds float, ptr %99, i64 %101
  %103 = load float, ptr %102, align 4, !tbaa !12
  %104 = fmul float %103, 2.000000e+00
  store float %104, ptr %102, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %105

105:                                              ; preds = %96
  %106 = load i32, ptr %3, align 4, !tbaa !14
  %107 = add i32 %106, 1
  store i32 %107, ptr %3, align 4, !tbaa !14
  br label %15, !llvm.loop !19

108:                                              ; preds = %15
  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 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_REDFT00(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %.not32 = icmp eq i32 %2, 0
  br i1 %.not32, label %._crit_edge31, label %.lr.ph30

.lr.ph30:                                         ; 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 48
  %7 = getelementptr inbounds i8, ptr %0, i64 56
  %8 = fpext float %5 to double
  %9 = fmul double %8, 0x400921FB54442D18
  %.pre = load ptr, ptr %7, align 8, !tbaa !11
  br label %10

10:                                               ; preds = %.lr.ph30, %._crit_edge
  %11 = phi i32 [ %2, %.lr.ph30 ], [ %49, %._crit_edge ]
  %12 = phi ptr [ %.pre, %.lr.ph30 ], [ %51, %._crit_edge ]
  %indvars.iv34 = phi i64 [ 0, %.lr.ph30 ], [ %indvars.iv.next35, %._crit_edge ]
  %13 = load ptr, ptr %6, align 8, !tbaa !12
  %14 = load float, ptr %13, align 4, !tbaa !13
  %15 = add i32 %11, -1
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds float, ptr %13, i64 %16
  %18 = load float, ptr %17, align 4, !tbaa !13
  %19 = trunc nuw i64 %indvars.iv34 to i32
  %20 = and i32 %19, 1
  %.not = icmp eq i32 %20, 0
  %21 = fneg float %18
  %22 = select i1 %.not, float %18, float %21
  %23 = fadd float %14, %22
  %24 = fmul float %23, 5.000000e-01
  %25 = getelementptr inbounds float, ptr %12, i64 %indvars.iv34
  store float %24, ptr %25, align 4, !tbaa !13
  %26 = add i32 %11, -3
  %27 = icmp ult i32 %26, -2
  br i1 %27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10
  %28 = uitofp i32 %19 to float
  %29 = fpext float %28 to double
  br label %30

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

._crit_edge:                                      ; preds = %30, %10
  %49 = phi i32 [ %11, %10 ], [ %45, %30 ]
  %50 = phi float [ %24, %10 ], [ %44, %30 ]
  %51 = phi ptr [ %12, %10 ], [ %41, %30 ]
  %52 = getelementptr inbounds float, ptr %51, i64 %indvars.iv34
  %53 = fmul float %50, 2.000000e+00
  store float %53, ptr %52, align 4, !tbaa !13
  %indvars.iv.next35 = add nuw nsw i64 %indvars.iv34, 1
  %54 = zext i32 %49 to i64
  %55 = icmp ult i64 %indvars.iv.next35, %54
  br i1 %55, label %10, label %._crit_edge31, !llvm.loop !17

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