; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_fft.ll (ZN7fftimpl7cfttreeEiiiPf)

; 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 uwtable
declare dso_local void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN7fftimpl7cfttreeEiiiPf(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) #1 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %12 = load i32, ptr %7, align 4, !tbaa !5
  %13 = and i32 %12, 3
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %37

15:                                               ; preds = %4
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = and i32 %16, 1
  store i32 %17, ptr %10, align 4, !tbaa !5
  %18 = load i32, ptr %10, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %28

20:                                               ; preds = %15
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = load ptr, ptr %8, align 8, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = sub nsw i32 %23, %24
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds float, ptr %22, i64 %26
  call void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef %21, ptr noundef %27)
  br label %36

28:                                               ; preds = %15
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = sub nsw i32 %31, %32
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %30, i64 %34
  call void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef %29, ptr noundef %35)
  br label %36

36:                                               ; preds = %28, %20
  br label %86

37:                                               ; preds = %4
  %38 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %38, ptr %11, align 4, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %39, ptr %9, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %47, %37
  %41 = load i32, ptr %9, align 4, !tbaa !5
  %42 = and i32 %41, 3
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %50

44:                                               ; preds = %40
  %45 = load i32, ptr %11, align 4, !tbaa !5
  %46 = shl i32 %45, 2
  store i32 %46, ptr %11, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %44
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = ashr i32 %48, 2
  store i32 %49, ptr %9, align 4, !tbaa !5
  br label %40, !llvm.loop !11

50:                                               ; preds = %40
  %51 = load i32, ptr %9, align 4, !tbaa !5
  %52 = and i32 %51, 1
  store i32 %52, ptr %10, align 4, !tbaa !5
  %53 = load i32, ptr %10, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %70

55:                                               ; preds = %50
  br label %56

56:                                               ; preds = %59, %55
  %57 = load i32, ptr %11, align 4, !tbaa !5
  %58 = icmp sgt i32 %57, 128
  br i1 %58, label %59, label %69

59:                                               ; preds = %56
  %60 = load i32, ptr %11, align 4, !tbaa !5
  %61 = load ptr, ptr %8, align 8, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !5
  %63 = load i32, ptr %11, align 4, !tbaa !5
  %64 = sub nsw i32 %62, %63
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds float, ptr %61, i64 %65
  call void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef %60, ptr noundef %66)
  %67 = load i32, ptr %11, align 4, !tbaa !5
  %68 = ashr i32 %67, 2
  store i32 %68, ptr %11, align 4, !tbaa !5
  br label %56, !llvm.loop !13

69:                                               ; preds = %56
  br label %85

70:                                               ; preds = %50
  br label %71

71:                                               ; preds = %74, %70
  %72 = load i32, ptr %11, align 4, !tbaa !5
  %73 = icmp sgt i32 %72, 128
  br i1 %73, label %74, label %84

74:                                               ; preds = %71
  %75 = load i32, ptr %11, align 4, !tbaa !5
  %76 = load ptr, ptr %8, align 8, !tbaa !9
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = sub nsw i32 %77, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds float, ptr %76, i64 %80
  call void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef %75, ptr noundef %81)
  %82 = load i32, ptr %11, align 4, !tbaa !5
  %83 = ashr i32 %82, 2
  store i32 %83, ptr %11, align 4, !tbaa !5
  br label %71, !llvm.loop !14

84:                                               ; preds = %71
  br label %85

85:                                               ; preds = %84, %69
  br label %86

86:                                               ; preds = %85, %36
  %87 = load i32, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 %87
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !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 uwtable
declare dso_local void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef range(i32 0, 2) i32 @_ZN7fftimpl7cfttreeEiiiPf(i32 noundef %0, i32 noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #0 {
  %5 = and i32 %2, 3
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.lr.ph, label %6

6:                                                ; preds = %4
  %7 = and i32 %2, 1
  %.not35 = icmp eq i32 %7, 0
  %8 = sub nsw i32 %1, %0
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds float, ptr %3, i64 %9
  br i1 %.not35, label %12, label %11

11:                                               ; preds = %6
  tail call void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef %0, ptr noundef %10)
  br label %.loopexit

12:                                               ; preds = %6
  tail call void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef %0, ptr noundef %10)
  br label %.loopexit

.lr.ph:                                           ; preds = %4, %.lr.ph
  %.040 = phi i32 [ %13, %.lr.ph ], [ %0, %4 ]
  %.03139 = phi i32 [ %14, %.lr.ph ], [ %2, %4 ]
  %13 = shl i32 %.040, 2
  %14 = ashr exact i32 %.03139, 2
  %15 = and i32 %.03139, 12
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %.lr.ph, label %._crit_edge, !llvm.loop !5

._crit_edge:                                      ; preds = %.lr.ph
  %17 = and i32 %14, 1
  %.not34 = icmp eq i32 %17, 0
  %18 = icmp sgt i32 %13, 128
  br i1 %.not34, label %.preheader, label %.preheader36

.preheader36:                                     ; preds = %._crit_edge
  br i1 %18, label %.lr.ph43, label %.loopexit

.preheader:                                       ; preds = %._crit_edge
  br i1 %18, label %.lr.ph45, label %.loopexit

.lr.ph43:                                         ; preds = %.preheader36, %.lr.ph43
  %.142 = phi i32 [ %22, %.lr.ph43 ], [ %13, %.preheader36 ]
  %19 = sub nsw i32 %1, %.142
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds float, ptr %3, i64 %20
  tail call void @_ZN7fftimpl7cftmdl1EiPf(i32 noundef %.142, ptr noundef %21)
  %22 = lshr i32 %.142, 2
  %23 = icmp ugt i32 %.142, 515
  br i1 %23, label %.lr.ph43, label %.loopexit, !llvm.loop !7

.lr.ph45:                                         ; preds = %.preheader, %.lr.ph45
  %.244 = phi i32 [ %27, %.lr.ph45 ], [ %13, %.preheader ]
  %24 = sub nsw i32 %1, %.244
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %3, i64 %25
  tail call void @_ZN7fftimpl7cftmdl2EiPf(i32 noundef %.244, ptr noundef %26)
  %27 = lshr i32 %.244, 2
  %28 = icmp ugt i32 %.244, 515
  br i1 %28, label %.lr.ph45, label %.loopexit, !llvm.loop !8

.loopexit:                                        ; preds = %.lr.ph43, %.lr.ph45, %.preheader36, %.preheader, %11, %12
  %.030 = phi i32 [ 1, %11 ], [ 0, %12 ], [ 0, %.preheader ], [ 1, %.preheader36 ], [ 0, %.lr.ph45 ], [ %17, %.lr.ph43 ]
  ret i32 %.030
}

attributes #0 = { mustprogress 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,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass