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

@.str = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.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.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [48 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_print_plan(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds %struct.fftplan_s, ptr %4, i32 0, i32 5
  %6 = load i32, ptr %5, align 8, !tbaa !9
  switch i32 %6, label %46 [
    i32 1, label %7
    i32 -1, label %7
    i32 10, label %40
    i32 11, label %40
    i32 12, label %40
    i32 13, label %40
    i32 20, label %40
    i32 21, label %40
    i32 22, label %40
    i32 23, label %40
    i32 30, label %43
    i32 31, label %44
    i32 0, label %45
  ]

7:                                                ; preds = %1, %1
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.fftplan_s, ptr %8, i32 0, i32 3
  %10 = load i32, ptr %9, align 8, !tbaa !12
  %11 = icmp eq i32 %10, 1
  %12 = zext i1 %11 to i64
  %13 = select i1 %11, ptr @.str.5, ptr @.str.6
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.fftplan_s, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, ptr noundef %13, i32 noundef %16)
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.fftplan_s, ptr %18, i32 0, i32 6
  %20 = load i32, ptr %19, align 4, !tbaa !14
  switch i32 %20, label %32 [
    i32 5, label %21
    i32 1, label %23
    i32 2, label %25
    i32 3, label %27
    i32 4, label %29
    i32 0, label %31
  ]

21:                                               ; preds = %7
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  br label %37

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

25:                                               ; preds = %7
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  br label %37

27:                                               ; preds = %7
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  br label %37

29:                                               ; preds = %7
  %30 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  br label %37

31:                                               ; preds = %7
  br label %32

32:                                               ; preds = %31, %7
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.fftplan_s, ptr %33, i32 0, i32 6
  %35 = load i32, ptr %34, align 4, !tbaa !14
  %36 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str, i32 noundef 220, ptr noundef @.str.12, i32 noundef %35)
  store i32 %36, ptr %2, align 4
  br label %52

37:                                               ; preds = %29, %27, %25, %23, %21
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = call i32 @fft_print_plan_recursive(ptr noundef %38, i32 noundef 0)
  store i32 %39, ptr %2, align 4
  br label %52

40:                                               ; preds = %1, %1, %1, %1, %1, %1, %1, %1
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = call i32 @fft_print_plan(ptr noundef %41)
  store i32 %42, ptr %2, align 4
  br label %52

43:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %52

44:                                               ; preds = %1
  store i32 0, ptr %2, align 4
  br label %52

45:                                               ; preds = %1
  br label %46

46:                                               ; preds = %45, %1
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.fftplan_s, ptr %48, i32 0, i32 5
  %50 = load i32, ptr %49, align 8, !tbaa !9
  %51 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef @.str, i32 noundef 243, ptr noundef @.str.13, i32 noundef %50)
  store i32 %51, ptr %2, align 4
  br label %52

52:                                               ; preds = %47, %44, %43, %40, %37, %32
  %53 = load i32, ptr %2, align 4
  ret i32 %53
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @fft_print_plan_recursive(ptr noundef, i32 noundef) #1

attributes #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 = { 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 = !{!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 32}
!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 = !{!10, !11, i64 24}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 36}


; 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 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [8 x i8], align 1
@.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.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [48 x i8], align 1
@switch.table.fft_print_plan = private unnamed_addr constant [5 x ptr] [ptr @.str.8, ptr @.str.9, ptr @.str.10, ptr @.str.11, ptr @.str.7], align 8

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_print_plan(ptr noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load i32, ptr %2, align 8, !tbaa !5
  switch i32 %3, label %19 [
    i32 1, label %4
    i32 -1, label %4
    i32 30, label %.loopexit
    i32 31, label %.loopexit
    i32 22, label %tailrecurse.preheader
    i32 23, label %tailrecurse.preheader
    i32 10, label %tailrecurse.preheader
    i32 11, label %tailrecurse.preheader
    i32 12, label %tailrecurse.preheader
    i32 13, label %tailrecurse.preheader
    i32 20, label %tailrecurse.preheader
    i32 21, label %tailrecurse.preheader
  ]

tailrecurse.preheader:                            ; preds = %1, %1, %1, %1, %1, %1, %1, %1
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.preheader, %tailrecurse
  br label %tailrecurse

4:                                                ; preds = %1, %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %7 = icmp eq i32 %6, 1
  %8 = select i1 %7, ptr @.str.5, ptr @.str.6
  %9 = load i32, ptr %0, align 8, !tbaa !12
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, ptr noundef nonnull %8, i32 noundef %9)
  %11 = getelementptr inbounds i8, ptr %0, i64 36
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %switch.tableidx = add i32 %12, -1
  %13 = icmp ult i32 %switch.tableidx, 5
  br i1 %13, label %switch.lookup, label %14

14:                                               ; preds = %4
  %15 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str, i32 noundef 220, ptr noundef nonnull @.str.12, i32 noundef %12) #3
  br label %.loopexit

switch.lookup:                                    ; preds = %4
  %16 = zext nneg i32 %switch.tableidx to i64
  %switch.gep = getelementptr inbounds [5 x ptr], ptr @switch.table.fft_print_plan, i64 0, i64 %16
  %switch.load = load ptr, ptr %switch.gep, align 8
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %switch.load)
  %18 = tail call i32 @fft_print_plan_recursive(ptr noundef nonnull %0, i32 noundef 0)
  br label %.loopexit

19:                                               ; preds = %1
  %20 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 6, ptr noundef nonnull @.str, i32 noundef 243, ptr noundef nonnull @.str.13, i32 noundef %3) #3
  br label %.loopexit

.loopexit:                                        ; preds = %1, %1, %19, %switch.lookup, %14
  %.0 = phi i32 [ %20, %19 ], [ %15, %14 ], [ %18, %switch.lookup ], [ 0, %1 ], [ 0, %1 ]
  ret i32 %.0
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @fft_print_plan_recursive(ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #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 = { 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 = { 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 #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 32}
!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, !7, i64 24}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !7, i64 36}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass