; LLVM IR from suxiaojack/sapDecoder :: src (kiss_fft)

; 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: 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: mustprogress nounwind uwtable
define dso_local i32 @kiss_fft_next_fast_size(i32 noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %39, %1
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %6 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %6, ptr %3, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %11, %5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = srem i32 %8, 2
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %14

11:                                               ; preds = %7
  %12 = load i32, ptr %3, align 4, !tbaa !5
  %13 = sdiv i32 %12, 2
  store i32 %13, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !9

14:                                               ; preds = %7
  br label %15

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

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = sdiv i32 %20, 3
  store i32 %21, ptr %3, align 4, !tbaa !5
  br label %15, !llvm.loop !11

22:                                               ; preds = %15
  br label %23

23:                                               ; preds = %27, %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = srem i32 %24, 5
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %23
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sdiv i32 %28, 5
  store i32 %29, ptr %3, align 4, !tbaa !5
  br label %23, !llvm.loop !12

30:                                               ; preds = %23
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = icmp sle i32 %31, 1
  br i1 %32, label %33, label %34

33:                                               ; preds = %30
  store i32 3, ptr %4, align 4
  br label %37

34:                                               ; preds = %30
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %2, align 4, !tbaa !5
  store i32 0, ptr %4, align 4
  br label %37

37:                                               ; preds = %34, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  %38 = load i32, ptr %4, align 4
  switch i32 %38, label %42 [
    i32 0, label %39
    i32 3, label %40
  ]

39:                                               ; preds = %37
  br label %5, !llvm.loop !13

40:                                               ; preds = %37
  %41 = load i32, ptr %2, align 4, !tbaa !5
  ret i32 %41

42:                                               ; preds = %37
  unreachable
}

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


; 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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local i32 @kiss_fft_next_fast_size(i32 noundef %0) local_unnamed_addr #0 {
  br label %2

2:                                                ; preds = %._crit_edge, %1
  %.012 = phi i32 [ %0, %1 ], [ %18, %._crit_edge ]
  br label %3

3:                                                ; preds = %3, %2
  %.011 = phi i32 [ %.012, %2 ], [ %6, %3 ]
  %4 = and i32 %.011, 1
  %5 = icmp eq i32 %4, 0
  %6 = ashr exact i32 %.011, 1
  br i1 %5, label %3, label %.preheader14, !llvm.loop !5

.preheader14:                                     ; preds = %3
  %7 = srem i32 %.011, 3
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %.preheader14
  %.1.lcssa = phi i32 [ %.011, %.preheader14 ], [ %11, %.lr.ph ]
  %9 = srem i32 %.1.lcssa, 5
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %.lr.ph17, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader14, %.lr.ph
  %.115 = phi i32 [ %11, %.lr.ph ], [ %.011, %.preheader14 ]
  %11 = sdiv i32 %.115, 3
  %12 = srem i32 %11, 3
  %13 = icmp eq i32 %12, 0
  br i1 %13, label %.lr.ph, label %.preheader, !llvm.loop !7

.lr.ph17:                                         ; preds = %.preheader, %.lr.ph17
  %.216 = phi i32 [ %14, %.lr.ph17 ], [ %.1.lcssa, %.preheader ]
  %14 = sdiv i32 %.216, 5
  %15 = srem i32 %14, 5
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %.lr.ph17, label %._crit_edge, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph17, %.preheader
  %.2.lcssa = phi i32 [ %.1.lcssa, %.preheader ], [ %14, %.lr.ph17 ]
  %17 = icmp slt i32 %.2.lcssa, 2
  %18 = add nsw i32 %.012, 1
  br i1 %17, label %19, label %2

19:                                               ; preds = %._crit_edge
  ret i32 %.012
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass