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

@.str.19 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [40 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 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_estimate_mixed_radix(i32 noundef %0) #2 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca [40 x i32], align 16
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 160, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = getelementptr inbounds [40 x i32], ptr %4, i64 0, i64 0
  %11 = call i32 @liquid_factor(i32 noundef %9, ptr noundef %10, ptr noundef %5)
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = icmp ult i32 %12, 2
  br i1 %13, label %14, label %17

14:                                               ; preds = %1
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.19, i32 noundef 202, ptr noundef @.str.22, i32 noundef %15)
  store i32 0, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %57

17:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %30, %17
  %19 = load i32, ptr %8, align 4, !tbaa !5
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = icmp ult i32 %19, %20
  br i1 %21, label %22, label %33

22:                                               ; preds = %18
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [40 x i32], ptr %4, i64 0, i64 %24
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 2
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  br label %33

29:                                               ; preds = %22
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = add i32 %31, 1
  store i32 %32, ptr %8, align 4, !tbaa !5
  br label %18, !llvm.loop !9

33:                                               ; preds = %28, %18
  %34 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %34, ptr %7, align 4, !tbaa !5
  %35 = load i32, ptr %7, align 4, !tbaa !5
  %36 = icmp ugt i32 %35, 0
  br i1 %36, label %37, label %53

37:                                               ; preds = %33
  %38 = load i32, ptr %3, align 4, !tbaa !5
  %39 = urem i32 %38, 16
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %41, label %42

41:                                               ; preds = %37
  store i32 16, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %56

42:                                               ; preds = %37
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = urem i32 %43, 8
  %45 = icmp eq i32 %44, 0
  br i1 %45, label %46, label %47

46:                                               ; preds = %42
  store i32 8, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %56

47:                                               ; preds = %42
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = urem i32 %48, 4
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %47
  store i32 4, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %56

52:                                               ; preds = %47
  store i32 2, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %56

53:                                               ; preds = %33
  %54 = getelementptr inbounds [40 x i32], ptr %4, i64 0, i64 0
  %55 = load i32, ptr %54, align 16, !tbaa !5
  store i32 %55, ptr %2, align 4
  store i32 1, ptr %6, align 4
  br label %56

56:                                               ; preds = %53, %52, %51, %46, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %57

57:                                               ; preds = %56, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 160, ptr %4) #3
  %58 = load i32, ptr %2, align 4
  ret i32 %58
}

declare i32 @liquid_factor(i32 noundef, ptr noundef, ptr noundef) #1

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; 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.19 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [40 x i8], align 1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fft_estimate_mixed_radix(i32 noundef %0) local_unnamed_addr #2 {
  %2 = alloca [40 x i32], align 16
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #3
  %4 = call i32 @liquid_factor(i32 noundef %0, ptr noundef nonnull %2, ptr noundef nonnull %3) #3
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 2
  br i1 %6, label %7, label %.preheader

7:                                                ; preds = %1
  %8 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.19, i32 noundef 202, ptr noundef nonnull @.str.22, i32 noundef %0) #3
  br label %25

.preheader:                                       ; preds = %1, %12
  %.015 = phi i32 [ %13, %12 ], [ 0, %1 ]
  %9 = zext i32 %.015 to i64
  %10 = getelementptr inbounds [40 x i32], ptr %2, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %.not = icmp eq i32 %11, 2
  br i1 %.not, label %12, label %14

12:                                               ; preds = %.preheader
  %13 = add nuw i32 %.015, 1
  %exitcond.not = icmp eq i32 %13, %5
  br i1 %exitcond.not, label %.thread, label %.preheader, !llvm.loop !9

14:                                               ; preds = %.preheader
  %.not12 = icmp eq i32 %.015, 0
  br i1 %.not12, label %23, label %.thread

.thread:                                          ; preds = %12, %14
  %15 = and i32 %0, 15
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %25, label %17

17:                                               ; preds = %.thread
  %18 = and i32 %0, 7
  %19 = icmp eq i32 %18, 0
  br i1 %19, label %25, label %20

20:                                               ; preds = %17
  %21 = and i32 %0, 3
  %22 = icmp eq i32 %21, 0
  %. = select i1 %22, i32 4, i32 2
  br label %25

23:                                               ; preds = %14
  %24 = load i32, ptr %2, align 16, !tbaa !5
  br label %25

25:                                               ; preds = %23, %.thread, %17, %20, %7
  %.1 = phi i32 [ 0, %7 ], [ %24, %23 ], [ 16, %.thread ], [ 8, %17 ], [ %., %20 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %2) #3
  ret i32 %.1
}

declare i32 @liquid_factor(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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