; 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 }
%struct.anon.2 = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.3 = type { i32, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [11 x i8], align 1

; 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

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_print_plan_recursive(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %6

6:                                                ; preds = %12, %2
  %7 = load i32, ptr %5, align 4, !tbaa !9
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = icmp ult i32 %7, %8
  br i1 %9, label %10, label %15

10:                                               ; preds = %6
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %12

12:                                               ; preds = %10
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = add i32 %13, 1
  store i32 %14, ptr %5, align 4, !tbaa !9
  br label %6, !llvm.loop !11

15:                                               ; preds = %6
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.fftplan_s, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.15, i32 noundef %18)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.fftplan_s, ptr %20, i32 0, i32 6
  %22 = load i32, ptr %21, align 4, !tbaa !15
  switch i32 %22, label %79 [
    i32 5, label %23
    i32 1, label %25
    i32 2, label %27
    i32 3, label %51
    i32 4, label %64
    i32 0, label %77
  ]

23:                                               ; preds = %15
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %81

25:                                               ; preds = %15
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  br label %81

27:                                               ; preds = %15
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.fftplan_s, ptr %28, i32 0, i32 10
  %30 = getelementptr inbounds %struct.anon.1, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.fftplan_s, ptr %32, i32 0, i32 10
  %34 = getelementptr inbounds %struct.anon.1, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 8, !tbaa !16
  %36 = call i32 (ptr, ...) @printf(ptr noundef @.str.16, i32 noundef %31, i32 noundef %35)
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.fftplan_s, ptr %37, i32 0, i32 10
  %39 = getelementptr inbounds %struct.anon.1, ptr %38, i32 0, i32 7
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load i32, ptr %4, align 4, !tbaa !9
  %42 = add i32 %41, 1
  %43 = call i32 @fft_print_plan_recursive(ptr noundef %40, i32 noundef %42)
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.fftplan_s, ptr %44, i32 0, i32 10
  %46 = getelementptr inbounds %struct.anon.1, ptr %45, i32 0, i32 6
  %47 = load ptr, ptr %46, align 8, !tbaa !16
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = add i32 %48, 1
  %50 = call i32 @fft_print_plan_recursive(ptr noundef %47, i32 noundef %49)
  br label %81

51:                                               ; preds = %15
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.fftplan_s, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !13
  %55 = sub i32 %54, 1
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, i32 noundef %55)
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.fftplan_s, ptr %57, i32 0, i32 10
  %59 = getelementptr inbounds %struct.anon.2, ptr %58, i32 0, i32 4
  %60 = load ptr, ptr %59, align 8, !tbaa !16
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = add i32 %61, 1
  %63 = call i32 @fft_print_plan_recursive(ptr noundef %60, i32 noundef %62)
  br label %81

64:                                               ; preds = %15
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.fftplan_s, ptr %65, i32 0, i32 10
  %67 = getelementptr inbounds %struct.anon.3, ptr %66, i32 0, i32 0
  %68 = load i32, ptr %67, align 8, !tbaa !16
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.17, i32 noundef %68)
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.fftplan_s, ptr %70, i32 0, i32 10
  %72 = getelementptr inbounds %struct.anon.3, ptr %71, i32 0, i32 5
  %73 = load ptr, ptr %72, align 8, !tbaa !16
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = add i32 %74, 1
  %76 = call i32 @fft_print_plan_recursive(ptr noundef %73, i32 noundef %75)
  br label %81

77:                                               ; preds = %15
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  br label %81

79:                                               ; preds = %15
  %80 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  br label %81

81:                                               ; preds = %79, %77, %64, %51, %27, %25, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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 #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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !10, i64 0}
!14 = !{!"fftplan_s", !10, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !7, i64 64}
!15 = !{!14, !10, i64 36}
!16 = !{!7, !7, i64 0}


; 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"

@.str.7 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [11 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nofree nounwind uwtable
define dso_local noundef i32 @fft_print_plan_recursive(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #1 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %2
  %.tr = phi ptr [ %0, %2 ], [ %.tr.be, %tailrecurse.backedge ]
  %.tr17 = phi i32 [ %1, %2 ], [ %.tr17.be, %tailrecurse.backedge ]
  %.not = icmp eq i32 %.tr17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %tailrecurse, %.lr.ph
  %.029 = phi i32 [ %4, %.lr.ph ], [ 0, %tailrecurse ]
  %3 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  %4 = add nuw i32 %.029, 1
  %exitcond.not = icmp eq i32 %4, %.tr17
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph, %tailrecurse
  %5 = load i32, ptr %.tr, align 8, !tbaa !7
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15, i32 noundef %5)
  %7 = getelementptr inbounds i8, ptr %.tr, i64 36
  %8 = load i32, ptr %7, align 4, !tbaa !13
  switch i32 %8, label %32 [
    i32 5, label %.loopexit
    i32 1, label %.loopexit30
    i32 2, label %9
    i32 3, label %20
    i32 4, label %26
  ]

9:                                                ; preds = %._crit_edge
  %10 = getelementptr inbounds i8, ptr %.tr, i64 64
  %11 = getelementptr inbounds i8, ptr %.tr, i64 68
  %12 = load i32, ptr %11, align 4, !tbaa !14
  %13 = load i32, ptr %10, align 8, !tbaa !14
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16, i32 noundef %12, i32 noundef %13)
  %15 = getelementptr inbounds i8, ptr %.tr, i64 112
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = add i32 %.tr17, 1
  %18 = tail call i32 @fft_print_plan_recursive(ptr noundef %16, i32 noundef %17)
  %19 = getelementptr inbounds i8, ptr %.tr, i64 104
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %9, %20, %26
  %.tr.be.in = phi ptr [ %19, %9 ], [ %24, %20 ], [ %30, %26 ]
  %.tr17.be = phi i32 [ %17, %9 ], [ %25, %20 ], [ %31, %26 ]
  %.tr.be = load ptr, ptr %.tr.be.in, align 8, !tbaa !14
  br label %tailrecurse

20:                                               ; preds = %._crit_edge
  %21 = load i32, ptr %.tr, align 8, !tbaa !7
  %22 = add i32 %21, -1
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %22)
  %24 = getelementptr inbounds i8, ptr %.tr, i64 96
  %25 = add i32 %.tr17, 1
  br label %tailrecurse.backedge

26:                                               ; preds = %._crit_edge
  %27 = getelementptr inbounds i8, ptr %.tr, i64 64
  %28 = load i32, ptr %27, align 8, !tbaa !14
  %29 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17, i32 noundef %28)
  %30 = getelementptr inbounds i8, ptr %.tr, i64 104
  %31 = add i32 %.tr17, 1
  br label %tailrecurse.backedge

.loopexit:                                        ; preds = %._crit_edge
  br label %32

.loopexit30:                                      ; preds = %._crit_edge
  br label %32

32:                                               ; preds = %._crit_edge, %.loopexit30, %.loopexit
  %.str.18.sink = phi ptr [ @.str.7, %.loopexit ], [ @.str.8, %.loopexit30 ], [ @.str.18, %._crit_edge ]
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.18.sink)
  ret i32 0
}

attributes #0 = { nofree 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 #1 = { nofree 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" }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !9, i64 0}
!8 = !{!"fftplan_s", !9, i64 0, !12, i64 8, !12, i64 16, !9, i64 24, !9, i64 28, !9, i64 32, !9, i64 36, !12, i64 40, !12, i64 48, !12, i64 56, !10, i64 64}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!"any pointer", !10, i64 0}
!13 = !{!8, !9, i64 36}
!14 = !{!10, !10, i64 0}


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