; LLVM IR from jgaeddert/liquid-dsp :: src/fft/src (spgramcf)

; 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.spwaterfallcf_s = type { i32, i32, ptr, ptr, i32, i32, float, float, i32, i32, ptr }

; 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: nounwind
declare float @log10f(float noundef) #1

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

7:                                                ; preds = %77, %1
  %8 = load i32, ptr %3, align 4, !tbaa !9
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 4, !tbaa !11
  %12 = icmp ult i32 %8, %11
  br i1 %12, label %13, label %80

13:                                               ; preds = %7
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %73, %13
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = icmp ult i32 %15, %18
  br i1 %19, label %20, label %76

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = load i32, ptr %3, align 4, !tbaa !9
  %25 = mul i32 2, %24
  %26 = add i32 %25, 0
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 8, !tbaa !14
  %30 = mul i32 %26, %29
  %31 = load i32, ptr %4, align 4, !tbaa !9
  %32 = add i32 %30, %31
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds float, ptr %23, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !16
  %36 = fmul float %35, 0x3FB99999A0000000
  %37 = call float @powf(float noundef 1.000000e+01, float noundef %36) #3
  store float %37, ptr %5, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %38 = load ptr, ptr %2, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !15
  %41 = load i32, ptr %3, align 4, !tbaa !9
  %42 = mul i32 2, %41
  %43 = add i32 %42, 1
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 8, !tbaa !14
  %47 = mul i32 %43, %46
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = add i32 %47, %48
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %40, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !16
  %53 = fmul float %52, 0x3FB99999A0000000
  %54 = call float @powf(float noundef 1.000000e+01, float noundef %53) #3
  store float %54, ptr %6, align 4, !tbaa !16
  %55 = load float, ptr %5, align 4, !tbaa !16
  %56 = load float, ptr %6, align 4, !tbaa !16
  %57 = fadd float %55, %56
  %58 = fmul float 5.000000e-01, %57
  %59 = call float @log10f(float noundef %58) #3
  %60 = fmul float 1.000000e+01, %59
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %61, i32 0, i32 3
  %63 = load ptr, ptr %62, align 8, !tbaa !15
  %64 = load i32, ptr %3, align 4, !tbaa !9
  %65 = load ptr, ptr %2, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 8, !tbaa !14
  %68 = mul i32 %64, %67
  %69 = load i32, ptr %4, align 4, !tbaa !9
  %70 = add i32 %68, %69
  %71 = zext i32 %70 to i64
  %72 = getelementptr inbounds float, ptr %63, i64 %71
  store float %60, ptr %72, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %73

73:                                               ; preds = %20
  %74 = load i32, ptr %4, align 4, !tbaa !9
  %75 = add i32 %74, 1
  store i32 %75, ptr %4, align 4, !tbaa !9
  br label %14, !llvm.loop !17

76:                                               ; preds = %14
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %3, align 4, !tbaa !9
  %79 = add i32 %78, 1
  store i32 %79, ptr %3, align 4, !tbaa !9
  br label %7, !llvm.loop !19

80:                                               ; preds = %7
  %81 = load ptr, ptr %2, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %81, i32 0, i32 1
  %83 = load i32, ptr %82, align 4, !tbaa !11
  %84 = load ptr, ptr %2, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %84, i32 0, i32 4
  store i32 %83, ptr %85, align 8, !tbaa !20
  %86 = load ptr, ptr %2, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.spwaterfallcf_s, ptr %86, i32 0, i32 5
  %88 = load i32, ptr %87, align 4, !tbaa !21
  %89 = mul i32 %88, 2
  store i32 %89, ptr %87, align 4, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret i32 0
}

; Function Attrs: nounwind
declare float @powf(float noundef, float noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 4}
!12 = !{!"spwaterfallcf_s", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !13, i64 32, !13, i64 36, !10, i64 40, !10, i64 44, !6, i64 48}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !6, i64 16}
!16 = !{!13, !13, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!12, !10, i64 24}
!21 = !{!12, !10, i64 28}


; 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 nounwind willreturn memory(write)
declare float @log10f(float noundef) local_unnamed_addr #0

; Function Attrs: nofree nounwind memory(readwrite, inaccessiblemem: write) uwtable
define dso_local noundef i32 @spwaterfallcf_consolidate_buffer(ptr nocapture noundef %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 4
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge27, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = load i32, ptr %0, align 8, !tbaa !12
  %.not28 = icmp eq i32 %5, 0
  br i1 %.not28, label %._crit_edge27, label %.preheader

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge
  %6 = phi i32 [ %41, %._crit_edge ], [ %3, %.preheader.lr.ph ]
  %7 = phi i32 [ %42, %._crit_edge ], [ %5, %.preheader.lr.ph ]
  %.026 = phi i32 [ %43, %._crit_edge ], [ 0, %.preheader.lr.ph ]
  %.not29 = icmp eq i32 %7, 0
  br i1 %.not29, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %8 = shl i32 %.026, 1
  %9 = or disjoint i32 %8, 1
  %.pre = load ptr, ptr %4, align 8, !tbaa !13
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %11 = phi ptr [ %.pre, %.lr.ph ], [ %33, %10 ]
  %12 = phi i32 [ %7, %.lr.ph ], [ %34, %10 ]
  %.02225 = phi i32 [ 0, %.lr.ph ], [ %39, %10 ]
  %13 = mul i32 %12, %8
  %14 = add i32 %13, %.02225
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds float, ptr %11, i64 %15
  %17 = load float, ptr %16, align 4, !tbaa !14
  %18 = fmul float %17, 0x3FB99999A0000000
  %19 = tail call float @powf(float noundef 1.000000e+01, float noundef %18) #2
  %20 = load ptr, ptr %4, align 8, !tbaa !13
  %21 = load i32, ptr %0, align 8, !tbaa !12
  %22 = mul i32 %21, %9
  %23 = add i32 %22, %.02225
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds float, ptr %20, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !14
  %27 = fmul float %26, 0x3FB99999A0000000
  %28 = tail call float @powf(float noundef 1.000000e+01, float noundef %27) #2
  %29 = fadd float %19, %28
  %30 = fmul float %29, 5.000000e-01
  %31 = tail call float @log10f(float noundef %30) #2
  %32 = fmul float %31, 1.000000e+01
  %33 = load ptr, ptr %4, align 8, !tbaa !13
  %34 = load i32, ptr %0, align 8, !tbaa !12
  %35 = mul i32 %34, %.026
  %36 = add i32 %35, %.02225
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %33, i64 %37
  store float %32, ptr %38, align 4, !tbaa !14
  %39 = add nuw i32 %.02225, 1
  %40 = icmp ult i32 %39, %34
  br i1 %40, label %10, label %._crit_edge.loopexit, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %10
  %.pre32 = load i32, ptr %2, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %41 = phi i32 [ %.pre32, %._crit_edge.loopexit ], [ %6, %.preheader ]
  %42 = phi i32 [ %34, %._crit_edge.loopexit ], [ 0, %.preheader ]
  %43 = add nuw i32 %.026, 1
  %44 = icmp ult i32 %43, %41
  br i1 %44, label %.preheader, label %._crit_edge27, !llvm.loop !17

._crit_edge27:                                    ; preds = %._crit_edge, %.preheader.lr.ph, %1
  %.lcssa = phi i32 [ 0, %1 ], [ %3, %.preheader.lr.ph ], [ %41, %._crit_edge ]
  %45 = getelementptr inbounds i8, ptr %0, i64 24
  store i32 %.lcssa, ptr %45, align 8, !tbaa !19
  %46 = getelementptr inbounds i8, ptr %0, i64 28
  %47 = load i32, ptr %46, align 4, !tbaa !20
  %48 = shl i32 %47, 1
  store i32 %48, ptr %46, align 4, !tbaa !20
  ret i32 0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @powf(float noundef, float noundef) local_unnamed_addr #0

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 = { nofree nounwind memory(readwrite, inaccessiblemem: write) 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, !7, i64 4}
!6 = !{!"spwaterfallcf_s", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !7, i64 24, !7, i64 28, !11, i64 32, !11, i64 36, !7, i64 40, !7, i64 44, !10, i64 48}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!6, !7, i64 24}
!20 = !{!6, !7, i64 28}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass