; LLVM IR from software-mansion/react-native-audio-api :: packages/react-native-audio-api/common/cpp/audioapi/dsp (Windows)

; 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.audioapi::dsp::Kaiser" = type { %"class.audioapi::dsp::WindowFunction.base", float, float, [4 x i8] }
%"class.audioapi::dsp::WindowFunction.base" = type <{ ptr, float }>
%"class.audioapi::dsp::WindowFunction" = type <{ ptr, float, [4 x i8] }>

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) #2

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

11:                                               ; preds = %45, %3
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = icmp slt i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %48

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = mul nsw i32 2, %17
  %19 = add nsw i32 %18, 1
  %20 = sitofp i32 %19 to float
  %21 = load i32, ptr %6, align 4, !tbaa !9
  %22 = sitofp i32 %21 to float
  %23 = fdiv float %20, %22
  %24 = fsub float %23, 1.000000e+00
  store float %24, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %25 = load float, ptr %8, align 4, !tbaa !11
  %26 = load float, ptr %8, align 4, !tbaa !11
  %27 = fneg float %25
  %28 = call float @llvm.fmuladd.f32(float %27, float %26, float 1.000000e+00)
  %29 = call noundef float @_ZSt4sqrtf(float noundef %28)
  store float %29, ptr %9, align 4, !tbaa !11
  %30 = getelementptr inbounds %"class.audioapi::dsp::Kaiser", ptr %10, i32 0, i32 1
  %31 = load float, ptr %30, align 4, !tbaa !13
  %32 = load float, ptr %9, align 4, !tbaa !11
  %33 = fmul float %31, %32
  %34 = call noundef float @_ZN8audioapi3dsp6Kaiser7bessel0Ef(float noundef %33)
  %35 = getelementptr inbounds %"class.audioapi::dsp::Kaiser", ptr %10, i32 0, i32 2
  %36 = load float, ptr %35, align 8, !tbaa !16
  %37 = fmul float %34, %36
  %38 = getelementptr inbounds %"class.audioapi::dsp::WindowFunction", ptr %10, i32 0, i32 1
  %39 = load float, ptr %38, align 8, !tbaa !17
  %40 = fmul float %37, %39
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %41, i64 %43
  store float %40, ptr %44, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %45

45:                                               ; preds = %16
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !18

48:                                               ; preds = %15
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8audioapi3dsp6Kaiser7bessel0Ef(float noundef) #2 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { inlinehint 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 #3 = { 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 #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 = !{!14, !12, i64 12}
!14 = !{!"_ZTSN8audioapi3dsp6KaiserE", !15, i64 0, !12, i64 12, !12, i64 16}
!15 = !{!"_ZTSN8audioapi3dsp14WindowFunctionE", !12, i64 8}
!16 = !{!14, !12, i64 16}
!17 = !{!15, !12, i64 8}
!18 = distinct !{!18, !19}
!19 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4sqrtf(float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZNK8audioapi3dsp6Kaiser5applyEPfi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(20) %0, ptr nocapture noundef writeonly %1, i32 noundef %2) unnamed_addr #2 align 2 {
  %4 = icmp sgt i32 %2, 0
  br i1 %4, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %5 = uitofp nneg i32 %2 to float
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %wide.trip.count = zext nneg i32 %2 to i64
  br label %9

._crit_edge:                                      ; preds = %9, %3
  ret void

9:                                                ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %indvars.iv.tr = trunc i64 %indvars.iv to i32
  %10 = shl i32 %indvars.iv.tr, 1
  %11 = or disjoint i32 %10, 1
  %12 = uitofp nneg i32 %11 to float
  %13 = fdiv float %12, %5
  %14 = fadd float %13, -1.000000e+00
  %15 = fneg float %14
  %16 = tail call float @llvm.fmuladd.f32(float %15, float %14, float 1.000000e+00)
  %17 = tail call noundef float @_ZSt4sqrtf(float noundef %16)
  %18 = load float, ptr %6, align 4, !tbaa !5
  %19 = fmul float %17, %18
  %20 = tail call noundef float @_ZN8audioapi3dsp6Kaiser7bessel0Ef(float noundef %19)
  %21 = load float, ptr %7, align 8, !tbaa !11
  %22 = fmul float %20, %21
  %23 = load float, ptr %8, align 8, !tbaa !12
  %24 = fmul float %22, %23
  %25 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  store float %24, ptr %25, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %9, !llvm.loop !14
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZN8audioapi3dsp6Kaiser7bessel0Ef(float noundef) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { inlinehint 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 = { 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 = !{!6, !8, i64 12}
!6 = !{!"_ZTSN8audioapi3dsp6KaiserE", !7, i64 0, !8, i64 12, !8, i64 16}
!7 = !{!"_ZTSN8audioapi3dsp14WindowFunctionE", !8, i64 8}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 16}
!12 = !{!7, !8, i64 8}
!13 = !{!8, !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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