; LLVM IR from AmplitudeAudio/sdk :: src/Utils/pffft (pffft)

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @pffft_min_fft_size(i32 noundef) #0

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

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

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

10:                                               ; preds = %21, %2
  %11 = load i32, ptr %6, align 4, !tbaa !5
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = mul nsw i32 5, %12
  %14 = icmp sge i32 %11, %13
  br i1 %14, label %15, label %19

15:                                               ; preds = %10
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = srem i32 %16, 5
  %18 = icmp eq i32 %17, 0
  br label %19

19:                                               ; preds = %15, %10
  %20 = phi i1 [ false, %10 ], [ %18, %15 ]
  br i1 %20, label %21, label %24

21:                                               ; preds = %19
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = sdiv i32 %22, 5
  store i32 %23, ptr %6, align 4, !tbaa !5
  br label %10, !llvm.loop !11

24:                                               ; preds = %19
  br label %25

25:                                               ; preds = %36, %24
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = load i32, ptr %5, align 4, !tbaa !5
  %28 = mul nsw i32 3, %27
  %29 = icmp sge i32 %26, %28
  br i1 %29, label %30, label %34

30:                                               ; preds = %25
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = srem i32 %31, 3
  %33 = icmp eq i32 %32, 0
  br label %34

34:                                               ; preds = %30, %25
  %35 = phi i1 [ false, %25 ], [ %33, %30 ]
  br i1 %35, label %36, label %39

36:                                               ; preds = %34
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = sdiv i32 %37, 3
  store i32 %38, ptr %6, align 4, !tbaa !5
  br label %25, !llvm.loop !13

39:                                               ; preds = %34
  br label %40

40:                                               ; preds = %51, %39
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = load i32, ptr %5, align 4, !tbaa !5
  %43 = mul nsw i32 2, %42
  %44 = icmp sge i32 %41, %43
  br i1 %44, label %45, label %49

45:                                               ; preds = %40
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = srem i32 %46, 2
  %48 = icmp eq i32 %47, 0
  br label %49

49:                                               ; preds = %45, %40
  %50 = phi i1 [ false, %40 ], [ %48, %45 ]
  br i1 %50, label %51, label %54

51:                                               ; preds = %49
  %52 = load i32, ptr %6, align 4, !tbaa !5
  %53 = sdiv i32 %52, 2
  store i32 %53, ptr %6, align 4, !tbaa !5
  br label %40, !llvm.loop !14

54:                                               ; preds = %49
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %57 = icmp eq i32 %55, %56
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 1, i32 0
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %59
}

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"_ZTS17pffft_transform_t", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


; 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: mustprogress nounwind uwtable
declare dso_local i32 @pffft_min_fft_size(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local range(i32 0, 2) i32 @pffft_is_valid_size(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @pffft_min_fft_size(i32 noundef %1)
  %4 = mul nsw i32 %3, 5
  %.not27 = icmp sle i32 %4, %0
  %5 = srem i32 %0, 5
  %6 = icmp eq i32 %5, 0
  %or.cond28 = and i1 %.not27, %6
  br i1 %or.cond28, label %.lr.ph, label %.critedge.preheader

.critedge.preheader:                              ; preds = %.lr.ph, %2
  %.0.lcssa = phi i32 [ %0, %2 ], [ %10, %.lr.ph ]
  %7 = mul nsw i32 %3, 3
  %.not2030 = icmp sge i32 %.0.lcssa, %7
  %8 = srem i32 %.0.lcssa, 3
  %9 = icmp eq i32 %8, 0
  %or.cond2431 = and i1 %.not2030, %9
  br i1 %or.cond2431, label %.critedge, label %.critedge2.preheader

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.029 = phi i32 [ %10, %.lr.ph ], [ %0, %2 ]
  %10 = sdiv i32 %.029, 5
  %.not = icmp sge i32 %10, %4
  %11 = srem i32 %10, 5
  %12 = icmp eq i32 %11, 0
  %or.cond = and i1 %.not, %12
  br i1 %or.cond, label %.lr.ph, label %.critedge.preheader, !llvm.loop !5

.critedge2.preheader:                             ; preds = %.critedge, %.critedge.preheader
  %.1.lcssa = phi i32 [ %.0.lcssa, %.critedge.preheader ], [ %14, %.critedge ]
  %13 = shl nsw i32 %3, 1
  br label %.critedge2

.critedge:                                        ; preds = %.critedge.preheader, %.critedge
  %.132 = phi i32 [ %14, %.critedge ], [ %.0.lcssa, %.critedge.preheader ]
  %14 = sdiv i32 %.132, 3
  %.not20 = icmp sge i32 %14, %7
  %15 = srem i32 %14, 3
  %16 = icmp eq i32 %15, 0
  %or.cond24 = and i1 %.not20, %16
  br i1 %or.cond24, label %.critedge, label %.critedge2.preheader, !llvm.loop !7

.critedge2:                                       ; preds = %.critedge2, %.critedge2.preheader
  %.2 = phi i32 [ %19, %.critedge2 ], [ %.1.lcssa, %.critedge2.preheader ]
  %.not21 = icmp sge i32 %.2, %13
  %17 = and i32 %.2, 1
  %18 = icmp eq i32 %17, 0
  %or.cond26 = and i1 %.not21, %18
  %19 = ashr exact i32 %.2, 1
  br i1 %or.cond26, label %.critedge2, label %.critedge4, !llvm.loop !8

.critedge4:                                       ; preds = %.critedge2
  %20 = icmp eq i32 %.2, %3
  %21 = zext i1 %20 to i32
  ret i32 %21
}

attributes #0 = { mustprogress 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 = distinct !{!7, !6}
!8 = distinct !{!8, !6}


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