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

; 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::LofiFilterInstance" = type { %"class.SoLoud::FilterInstance", [2 x %"struct.SoLoud::LofiChannelData"], ptr }
%"class.SoLoud::FilterInstance" = type { ptr, i32, i32, ptr, ptr }
%"struct.SoLoud::LofiChannelData" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud18LofiFilterInstance13filterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(56) %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
  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
  %17 = load ptr, ptr %8, align 8
  %18 = load double, ptr %12, align 8, !tbaa !13
  %19 = load ptr, ptr %17, align 8, !tbaa !15
  %20 = getelementptr inbounds ptr, ptr %19, i64 1
  %21 = load ptr, ptr %20, align 8
  call void %21(ptr noundef nonnull align 8 dereferenceable(32) %17, double noundef %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %22

22:                                               ; preds = %101, %7
  %23 = load i32, ptr %15, align 4, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = icmp ult i32 %23, %24
  br i1 %25, label %26, label %104

26:                                               ; preds = %22
  %27 = getelementptr inbounds %"class.SoLoud::LofiFilterInstance", ptr %17, i32 0, i32 1
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %27, i64 0, i64 %29
  %31 = getelementptr inbounds %"struct.SoLoud::LofiChannelData", ptr %30, i32 0, i32 1
  %32 = load float, ptr %31, align 4, !tbaa !17
  %33 = fcmp ole float %32, 0.000000e+00
  br i1 %33, label %34, label %70

34:                                               ; preds = %26
  %35 = load float, ptr %11, align 4, !tbaa !11
  %36 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %17, i32 0, i32 3
  %37 = load ptr, ptr %36, align 8, !tbaa !19
  %38 = getelementptr inbounds float, ptr %37, i64 1
  %39 = load float, ptr %38, align 4, !tbaa !11
  %40 = fdiv float %35, %39
  %41 = fsub float %40, 1.000000e+00
  %42 = getelementptr inbounds %"class.SoLoud::LofiFilterInstance", ptr %17, i32 0, i32 1
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %42, i64 0, i64 %44
  %46 = getelementptr inbounds %"struct.SoLoud::LofiChannelData", ptr %45, i32 0, i32 1
  %47 = load float, ptr %46, align 4, !tbaa !17
  %48 = fadd float %47, %41
  store float %48, ptr %46, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %49 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %17, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !19
  %51 = getelementptr inbounds float, ptr %50, i64 2
  %52 = load float, ptr %51, align 4, !tbaa !11
  %53 = call noundef double @_ZSt3powIifEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 2, float noundef %52)
  %54 = fptrunc double %53 to float
  store float %54, ptr %16, align 4, !tbaa !11
  %55 = load float, ptr %16, align 4, !tbaa !11
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %56, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !11
  %61 = fmul float %55, %60
  %62 = call noundef float @_ZSt5floorf(float noundef %61)
  %63 = load float, ptr %16, align 4, !tbaa !11
  %64 = fdiv float %62, %63
  %65 = getelementptr inbounds %"class.SoLoud::LofiFilterInstance", ptr %17, i32 0, i32 1
  %66 = load i32, ptr %13, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %65, i64 0, i64 %67
  %69 = getelementptr inbounds %"struct.SoLoud::LofiChannelData", ptr %68, i32 0, i32 0
  store float %64, ptr %69, align 8, !tbaa !21
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %78

70:                                               ; preds = %26
  %71 = getelementptr inbounds %"class.SoLoud::LofiFilterInstance", ptr %17, i32 0, i32 1
  %72 = load i32, ptr %13, align 4, !tbaa !9
  %73 = zext i32 %72 to i64
  %74 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %71, i64 0, i64 %73
  %75 = getelementptr inbounds %"struct.SoLoud::LofiChannelData", ptr %74, i32 0, i32 1
  %76 = load float, ptr %75, align 4, !tbaa !17
  %77 = fadd float %76, -1.000000e+00
  store float %77, ptr %75, align 4, !tbaa !17
  br label %78

78:                                               ; preds = %70, %34
  %79 = getelementptr inbounds %"class.SoLoud::LofiFilterInstance", ptr %17, i32 0, i32 1
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %79, i64 0, i64 %81
  %83 = getelementptr inbounds %"struct.SoLoud::LofiChannelData", ptr %82, i32 0, i32 0
  %84 = load float, ptr %83, align 8, !tbaa !21
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = load i32, ptr %15, align 4, !tbaa !9
  %87 = zext i32 %86 to i64
  %88 = getelementptr inbounds float, ptr %85, i64 %87
  %89 = load float, ptr %88, align 4, !tbaa !11
  %90 = fsub float %84, %89
  %91 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %17, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !19
  %93 = getelementptr inbounds float, ptr %92, i64 0
  %94 = load float, ptr %93, align 4, !tbaa !11
  %95 = load ptr, ptr %9, align 8, !tbaa !5
  %96 = load i32, ptr %15, align 4, !tbaa !9
  %97 = zext i32 %96 to i64
  %98 = getelementptr inbounds float, ptr %95, i64 %97
  %99 = load float, ptr %98, align 4, !tbaa !11
  %100 = call float @llvm.fmuladd.f32(float %90, float %94, float %99)
  store float %100, ptr %98, align 4, !tbaa !11
  br label %101

101:                                              ; preds = %78
  %102 = load i32, ptr %15, align 4, !tbaa !9
  %103 = add i32 %102, 1
  store i32 %103, ptr %15, align 4, !tbaa !9
  br label %22, !llvm.loop !22

104:                                              ; preds = %22
  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 double @_ZSt3powIifEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, float noundef) #2

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

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

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

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, !12, i64 4}
!18 = !{!"_ZTSN6SoLoud15LofiChannelDataE", !12, i64 0, !12, i64 4}
!19 = !{!20, !6, i64 16}
!20 = !{!"_ZTSN6SoLoud14FilterInstanceE", !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!21 = !{!18, !12, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%"struct.SoLoud::LofiChannelData" = type { float, float }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud18LofiFilterInstance13filterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(56) %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)
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = zext i32 %5 to i64
  %13 = getelementptr inbounds [2 x %"struct.SoLoud::LofiChannelData"], ptr %11, i64 0, i64 %12
  %14 = getelementptr inbounds i8, ptr %13, i64 4
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %wide.trip.count = zext i32 %2 to i64
  br label %16

16:                                               ; preds = %.lr.ph, %37
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %37 ]
  %17 = load float, ptr %14, align 4, !tbaa !8
  %18 = fcmp ugt float %17, 0.000000e+00
  br i1 %18, label %35, label %19

19:                                               ; preds = %16
  %20 = load ptr, ptr %15, align 8, !tbaa !12
  %21 = getelementptr inbounds i8, ptr %20, i64 4
  %22 = load float, ptr %21, align 4, !tbaa !16
  %23 = fdiv float %3, %22
  %24 = fadd float %23, -1.000000e+00
  %25 = fadd float %17, %24
  store float %25, ptr %14, align 4, !tbaa !8
  %26 = getelementptr inbounds i8, ptr %20, i64 8
  %27 = load float, ptr %26, align 4, !tbaa !16
  %28 = tail call noundef double @_ZSt3powIifEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 2, float noundef %27)
  %29 = fptrunc double %28 to float
  %30 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %31 = load float, ptr %30, align 4, !tbaa !16
  %32 = fmul float %31, %29
  %33 = tail call noundef float @_ZSt5floorf(float noundef %32)
  %34 = fdiv float %33, %29
  store float %34, ptr %13, align 8, !tbaa !17
  br label %37

35:                                               ; preds = %16
  %36 = fadd float %17, -1.000000e+00
  store float %36, ptr %14, align 4, !tbaa !8
  %.pre = load float, ptr %13, align 8, !tbaa !17
  br label %37

37:                                               ; preds = %35, %19
  %38 = phi float [ %.pre, %35 ], [ %34, %19 ]
  %39 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %40 = load float, ptr %39, align 4, !tbaa !16
  %41 = fsub float %38, %40
  %42 = load ptr, ptr %15, align 8, !tbaa !12
  %43 = load float, ptr %42, align 4, !tbaa !16
  %44 = tail call float @llvm.fmuladd.f32(float %41, float %43, float %40)
  store float %44, ptr %39, align 4, !tbaa !16
  %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 %16, !llvm.loop !18

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIifEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, float noundef) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef float @_ZSt5floorf(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, !10, i64 4}
!9 = !{!"_ZTSN6SoLoud15LofiChannelDataE", !10, i64 0, !10, i64 4}
!10 = !{!"float", !11, i64 0}
!11 = !{!"omnipotent char", !7, i64 0}
!12 = !{!13, !15, i64 16}
!13 = !{!"_ZTSN6SoLoud14FilterInstanceE", !14, i64 8, !14, i64 12, !15, i64 16, !15, i64 24}
!14 = !{!"int", !11, i64 0}
!15 = !{!"any pointer", !11, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{!9, !10, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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