; LLVM IR from kdrag0n/fxdsp :: effects/geq_common.ll (ZN5fxdsp13GraphicEqBase10init_bandsEiff)

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

%"class.fxdsp::GraphicEqBase" = type { %"class.fxdsp::Effect.base", %"class.std::vector.0" }
%"class.fxdsp::Effect.base" = type <{ %"class.fxdsp::AudioSink", ptr, i8 }>
%"class.fxdsp::AudioSink" = type { ptr, %"class.std::vector", i32, i32 }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<float>, std::allocator<std::vector<float>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<float>, std::allocator<std::vector<float>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<float>, std::allocator<std::vector<float>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<float>, std::allocator<std::vector<float>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<fxdsp::GraphicEqBand, std::allocator<fxdsp::GraphicEqBand>>::_Vector_impl" }
%"struct.std::_Vector_base<fxdsp::GraphicEqBand, std::allocator<fxdsp::GraphicEqBand>>::_Vector_impl" = type { %"struct.std::_Vector_base<fxdsp::GraphicEqBand, std::allocator<fxdsp::GraphicEqBand>>::_Vector_impl_data" }
%"struct.std::_Vector_base<fxdsp::GraphicEqBand, std::allocator<fxdsp::GraphicEqBand>>::_Vector_impl_data" = type { ptr, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5fxdsp13GraphicEqBase10init_bandsEiff(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1, float noundef %2, float noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !11
  store float %3, ptr %8, align 4, !tbaa !11
  %17 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %18 = load float, ptr %8, align 4, !tbaa !11
  %19 = load float, ptr %7, align 4, !tbaa !11
  %20 = fdiv float %18, %19
  %21 = fpext float %20 to double
  %22 = call double @log2(double noundef %21) #4
  %23 = fptrunc double %22 to float
  store float %23, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %24 = load float, ptr %9, align 4, !tbaa !11
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = sitofp i32 %25 to float
  %27 = fdiv float %24, %26
  %28 = call noundef float @_ZN5fxdsp14octave_bw_to_qEf(float noundef %27)
  store float %28, ptr %10, align 4, !tbaa !11
  %29 = getelementptr inbounds %"class.fxdsp::GraphicEqBase", ptr %17, i32 0, i32 1
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  call void @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %74, %4
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = load i32, ptr %6, align 4, !tbaa !9
  %35 = icmp slt i32 %33, %34
  br i1 %35, label %37, label %36

36:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %77

37:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %38 = load float, ptr %8, align 4, !tbaa !11
  %39 = fpext float %38 to double
  %40 = call double @log2(double noundef %39) #4
  %41 = load float, ptr %7, align 4, !tbaa !11
  %42 = fpext float %41 to double
  %43 = call double @log2(double noundef %42) #4
  %44 = fsub double %40, %43
  %45 = load i32, ptr %6, align 4, !tbaa !9
  %46 = sitofp i32 %45 to float
  %47 = fpext float %46 to double
  %48 = fdiv double %44, %47
  %49 = fptrunc double %48 to float
  store float %49, ptr %12, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = sitofp i32 %50 to float
  %52 = load float, ptr %12, align 4, !tbaa !11
  %53 = fmul float %51, %52
  store float %53, ptr %13, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %54 = load i32, ptr %11, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  %56 = sitofp i32 %55 to float
  %57 = load float, ptr %12, align 4, !tbaa !11
  %58 = fmul float %56, %57
  store float %58, ptr %14, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %59 = load float, ptr %7, align 4, !tbaa !11
  %60 = fpext float %59 to double
  %61 = load float, ptr %13, align 4, !tbaa !11
  %62 = load float, ptr %14, align 4, !tbaa !11
  %63 = fadd float %61, %62
  %64 = fdiv float %63, 2.000000e+00
  %65 = fpext float %64 to double
  %66 = call double @pow(double noundef 2.000000e+00, double noundef %65) #4
  %67 = fmul double %60, %66
  %68 = fptrunc double %67 to float
  store float %68, ptr %15, align 4, !tbaa !11
  br label %69

69:                                               ; preds = %37
  br label %70

70:                                               ; preds = %69
  br label %71

71:                                               ; preds = %70
  %72 = getelementptr inbounds %"class.fxdsp::GraphicEqBase", ptr %17, i32 0, i32 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store float 0.000000e+00, ptr %16, align 4, !tbaa !11
  %73 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE12emplace_backIJRfS5_fEEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %72, ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %16)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %74

74:                                               ; preds = %71
  %75 = load i32, ptr %11, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %11, align 4, !tbaa !9
  br label %32, !llvm.loop !13

77:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

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

; Function Attrs: nounwind
declare double @log2(double noundef) #2

declare noundef float @_ZN5fxdsp14octave_bw_to_qEf(float noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #0 align 2

; Function Attrs: nounwind
declare double @pow(double noundef, double noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE12emplace_backIJRfS5_fEEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0 align 2

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5fxdsp13GraphicEqBase10init_bandsEiff(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 align 2 {
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = fdiv float %3, %2
  %9 = fpext float %8 to double
  %10 = tail call double @log2(double noundef %9) #4
  %11 = fptrunc double %10 to float
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %12 = sitofp i32 %1 to float
  %13 = fdiv float %11, %12
  %14 = tail call noundef float @_ZN5fxdsp14octave_bw_to_qEf(float noundef %13)
  store float %14, ptr %5, align 4, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 56
  %16 = sext i32 %1 to i64
  tail call void @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %16)
  %17 = icmp sgt i32 %1, 0
  br i1 %17, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %18 = fpext float %3 to double
  %19 = fpext float %2 to double
  %20 = fpext float %12 to double
  br label %21

._crit_edge:                                      ; preds = %21, %4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  ret void

21:                                               ; preds = %.lr.ph, %21
  %.018 = phi i32 [ 0, %.lr.ph ], [ %29, %21 ]
  %22 = call double @log2(double noundef %18) #4
  %23 = call double @log2(double noundef %19) #4
  %24 = fsub double %22, %23
  %25 = fdiv double %24, %20
  %26 = fptrunc double %25 to float
  %27 = uitofp nneg i32 %.018 to float
  %28 = fmul float %27, %26
  %29 = add nuw nsw i32 %.018, 1
  %30 = uitofp nneg i32 %29 to float
  %31 = fmul float %30, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  %32 = fadd float %28, %31
  %33 = fmul float %32, 5.000000e-01
  %34 = fpext float %33 to double
  %exp2 = call double @exp2(double %34)
  %35 = fmul double %exp2, %19
  %36 = fptrunc double %35 to float
  store float %36, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store float 0.000000e+00, ptr %7, align 4, !tbaa !5
  %37 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE12emplace_backIJRfS5_fEEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24) %15, ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %7)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  %exitcond.not = icmp eq i32 %29, %1
  br i1 %exitcond.not, label %._crit_edge, label %21, !llvm.loop !9
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log2(double noundef) local_unnamed_addr #2

declare noundef float @_ZN5fxdsp14octave_bw_to_qEf(float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE7reserveEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNSt6vectorIN5fxdsp13GraphicEqBandESaIS1_EE12emplace_backIJRfS5_fEEERS1_DpOT_(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0 align 2

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

declare double @exp2(double) local_unnamed_addr

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass