; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/filter (soloud_waveshaperfilter)

; 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.SoLoud::FilterInstance" = type { ptr, i32, i32, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud24WaveShaperFilterInstance13filterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr noundef %1, i32 noundef %2, float noundef %3, double noundef %4, i32 noundef %5, i32 noundef %6) unnamed_addr #0 align 2 {
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca float, align 4
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca float, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store i32 %2, ptr %10, align 4, !tbaa !9
  store float %3, ptr %11, align 4, !tbaa !11
  store double %4, ptr %12, align 8, !tbaa !13
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  %19 = load ptr, ptr %8, align 8
  %20 = load double, ptr %12, align 8, !tbaa !13
  %21 = load ptr, ptr %19, align 8, !tbaa !15
  %22 = getelementptr inbounds ptr, ptr %21, i64 1
  %23 = load ptr, ptr %22, align 8
  call void %23(ptr noundef nonnull align 8 dereferenceable(32) %19, double noundef %20)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store float 0.000000e+00, ptr %16, align 4, !tbaa !11
  %24 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %19, i32 0, i32 3
  %25 = load ptr, ptr %24, align 8, !tbaa !17
  %26 = getelementptr inbounds float, ptr %25, i64 1
  %27 = load float, ptr %26, align 4, !tbaa !11
  %28 = fcmp oeq float %27, 1.000000e+00
  br i1 %28, label %29, label %36

29:                                               ; preds = %7
  %30 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %19, i32 0, i32 3
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  %32 = getelementptr inbounds float, ptr %31, i64 1
  %33 = load float, ptr %32, align 4, !tbaa !11
  %34 = fmul float 2.000000e+00, %33
  %35 = fdiv float %34, 0x3F847AE140000000
  store float %35, ptr %16, align 4, !tbaa !11
  br label %48

36:                                               ; preds = %7
  %37 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %19, i32 0, i32 3
  %38 = load ptr, ptr %37, align 8, !tbaa !17
  %39 = getelementptr inbounds float, ptr %38, i64 1
  %40 = load float, ptr %39, align 4, !tbaa !11
  %41 = fmul float 2.000000e+00, %40
  %42 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %19, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = getelementptr inbounds float, ptr %43, i64 1
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = fsub float 1.000000e+00, %45
  %47 = fdiv float %41, %46
  store float %47, ptr %16, align 4, !tbaa !11
  br label %48

48:                                               ; preds = %36, %29
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %89, %48
  %50 = load i32, ptr %15, align 4, !tbaa !9
  %51 = load i32, ptr %10, align 4, !tbaa !9
  %52 = icmp ult i32 %50, %51
  br i1 %52, label %53, label %92

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %54 = load ptr, ptr %9, align 8, !tbaa !5
  %55 = load i32, ptr %15, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %54, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !11
  store float %58, ptr %17, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %59 = load float, ptr %16, align 4, !tbaa !11
  %60 = fadd float 1.000000e+00, %59
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %15, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds float, ptr %61, i64 %63
  %65 = load float, ptr %64, align 4, !tbaa !11
  %66 = fmul float %60, %65
  %67 = load float, ptr %16, align 4, !tbaa !11
  %68 = load ptr, ptr %9, align 8, !tbaa !5
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds float, ptr %68, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !11
  %73 = call noundef float @_ZSt4fabsf(float noundef %72)
  %74 = call float @llvm.fmuladd.f32(float %67, float %73, float 1.000000e+00)
  %75 = fdiv float %66, %74
  store float %75, ptr %18, align 4, !tbaa !11
  %76 = load float, ptr %18, align 4, !tbaa !11
  %77 = load float, ptr %17, align 4, !tbaa !11
  %78 = fsub float %76, %77
  %79 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %19, i32 0, i32 3
  %80 = load ptr, ptr %79, align 8, !tbaa !17
  %81 = getelementptr inbounds float, ptr %80, i64 0
  %82 = load float, ptr %81, align 4, !tbaa !11
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load i32, ptr %15, align 4, !tbaa !9
  %85 = zext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %83, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !11
  %88 = call float @llvm.fmuladd.f32(float %78, float %82, float %87)
  store float %88, ptr %86, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %89

89:                                               ; preds = %53
  %90 = load i32, ptr %15, align 4, !tbaa !9
  %91 = add i32 %90, 1
  store i32 %91, ptr %15, align 4, !tbaa !9
  br label %49, !llvm.loop !19

92:                                               ; preds = %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt4fabsf(float noundef) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !14, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"vtable pointer", !8, i64 0}
!17 = !{!18, !6, i64 16}
!18 = !{!"_ZTSN6SoLoud14FilterInstanceE", !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"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 @_ZN6SoLoud24WaveShaperFilterInstance13filterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(40) %0, ptr nocapture noundef %1, i32 noundef %2, float noundef %3, double noundef %4, i32 noundef %5, i32 noundef %6) unnamed_addr #0 align 2 {
  %8 = load ptr, ptr %0, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %8, i64 8
  %10 = load ptr, ptr %9, align 8
  tail call void %10(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %4)
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !8
  %13 = getelementptr inbounds i8, ptr %12, i64 4
  %14 = load float, ptr %13, align 4, !tbaa !13
  %15 = fcmp oeq float %14, 1.000000e+00
  %16 = fmul float %14, 2.000000e+00
  %17 = fsub float 1.000000e+00, %14
  %18 = fdiv float %16, %17
  %.016 = select i1 %15, float 2.000000e+02, float %18
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %19 = fadd float %.016, 1.000000e+00
  %wide.trip.count = zext i32 %2 to i64
  br label %20

20:                                               ; preds = %.lr.ph, %20
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %20 ]
  %21 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !13
  %23 = fmul float %19, %22
  %24 = tail call noundef float @_ZSt4fabsf(float noundef %22)
  %25 = tail call float @llvm.fmuladd.f32(float %.016, float %24, float 1.000000e+00)
  %26 = fdiv float %23, %25
  %27 = fsub float %26, %22
  %28 = load ptr, ptr %11, align 8, !tbaa !8
  %29 = load float, ptr %28, align 4, !tbaa !13
  %30 = load float, ptr %21, align 4, !tbaa !13
  %31 = tail call float @llvm.fmuladd.f32(float %27, float %29, float %30)
  store float %31, ptr %21, 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 %20, !llvm.loop !15

._crit_edge:                                      ; preds = %20, %7
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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 = { 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !12, i64 16}
!9 = !{!"_ZTSN6SoLoud14FilterInstanceE", !10, i64 8, !10, i64 12, !12, i64 16, !12, i64 24}
!10 = !{!"int", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!"any pointer", !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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