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

; 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 @_ZN6SoLoud16EqFilterInstance16fftFilterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(184) %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 i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = 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
  %22 = load ptr, ptr %8, align 8
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = udiv i32 %24, 2
  call void @_ZN6SoLoud17FFTFilterInstance13comp2MagPhaseEPfj(ptr noundef nonnull align 8 dereferenceable(176) %22, ptr noundef %23, i32 noundef %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #6
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %26

26:                                               ; preds = %113, %7
  %27 = load i32, ptr %15, align 4, !tbaa !9
  %28 = load i32, ptr %10, align 4, !tbaa !9
  %29 = udiv i32 %28, 2
  %30 = icmp ult i32 %27, %29
  br i1 %30, label %31, label %116

31:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  %32 = load i32, ptr %15, align 4, !tbaa !9
  %33 = uitofp i32 %32 to float
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = udiv i32 %34, 2
  %36 = uitofp i32 %35 to float
  %37 = fdiv float %33, %36
  %38 = call noundef float @_ZSt4sqrtf(float noundef %37)
  %39 = load i32, ptr %10, align 4, !tbaa !9
  %40 = udiv i32 %39, 2
  %41 = uitofp i32 %40 to float
  %42 = fmul float %38, %41
  %43 = call noundef float @_ZSt5floorf(float noundef %42)
  %44 = fptosi float %43 to i32
  store i32 %44, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = load i32, ptr %10, align 4, !tbaa !9
  %47 = udiv i32 %46, 16
  %48 = udiv i32 %45, %47
  store i32 %48, ptr %17, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  %49 = load i32, ptr %17, align 4, !tbaa !9
  %50 = sub nsw i32 %49, 1
  store i32 %50, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %51 = load i32, ptr %18, align 4, !tbaa !9
  %52 = sub nsw i32 %51, 1
  store i32 %52, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %53 = load i32, ptr %17, align 4, !tbaa !9
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %20, align 4, !tbaa !9
  %55 = load i32, ptr %18, align 4, !tbaa !9
  %56 = icmp slt i32 %55, 0
  br i1 %56, label %57, label %58

57:                                               ; preds = %31
  store i32 0, ptr %18, align 4, !tbaa !9
  br label %58

58:                                               ; preds = %57, %31
  %59 = load i32, ptr %19, align 4, !tbaa !9
  %60 = icmp slt i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %58
  store i32 0, ptr %19, align 4, !tbaa !9
  br label %62

62:                                               ; preds = %61, %58
  %63 = load i32, ptr %20, align 4, !tbaa !9
  %64 = icmp sgt i32 %63, 7
  br i1 %64, label %65, label %66

65:                                               ; preds = %62
  store i32 7, ptr %20, align 4, !tbaa !9
  br label %66

66:                                               ; preds = %65, %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #6
  %67 = load i32, ptr %16, align 4, !tbaa !9
  %68 = load i32, ptr %10, align 4, !tbaa !9
  %69 = udiv i32 %68, 16
  %70 = urem i32 %67, %69
  %71 = uitofp i32 %70 to float
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = udiv i32 %72, 16
  %74 = uitofp i32 %73 to float
  %75 = fdiv float %71, %74
  store float %75, ptr %21, align 4, !tbaa !11
  %76 = load float, ptr %21, align 4, !tbaa !11
  %77 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %22, i32 0, i32 3
  %78 = load ptr, ptr %77, align 8, !tbaa !15
  %79 = load i32, ptr %19, align 4, !tbaa !9
  %80 = add nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds float, ptr %78, i64 %81
  %83 = load float, ptr %82, align 4, !tbaa !11
  %84 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %22, i32 0, i32 3
  %85 = load ptr, ptr %84, align 8, !tbaa !15
  %86 = load i32, ptr %18, align 4, !tbaa !9
  %87 = add nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %85, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !11
  %91 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %22, i32 0, i32 3
  %92 = load ptr, ptr %91, align 8, !tbaa !15
  %93 = load i32, ptr %17, align 4, !tbaa !9
  %94 = add nsw i32 %93, 1
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds float, ptr %92, i64 %95
  %97 = load float, ptr %96, align 4, !tbaa !11
  %98 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %22, i32 0, i32 3
  %99 = load ptr, ptr %98, align 8, !tbaa !15
  %100 = load i32, ptr %20, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds float, ptr %99, i64 %102
  %104 = load float, ptr %103, align 4, !tbaa !11
  %105 = call noundef float @_ZN6SoLoudL10catmullromEfffff(float noundef %76, float noundef %83, float noundef %90, float noundef %97, float noundef %104)
  %106 = load ptr, ptr %9, align 8, !tbaa !5
  %107 = load i32, ptr %15, align 4, !tbaa !9
  %108 = mul i32 %107, 2
  %109 = zext i32 %108 to i64
  %110 = getelementptr inbounds float, ptr %106, i64 %109
  %111 = load float, ptr %110, align 4, !tbaa !11
  %112 = fmul float %111, %105
  store float %112, ptr %110, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %113

113:                                              ; preds = %66
  %114 = load i32, ptr %15, align 4, !tbaa !9
  %115 = add i32 %114, 1
  store i32 %115, ptr %15, align 4, !tbaa !9
  br label %26, !llvm.loop !17

116:                                              ; preds = %26
  %117 = load ptr, ptr %9, align 8, !tbaa !5
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = zext i32 %118 to i64
  %120 = getelementptr inbounds float, ptr %117, i64 %119
  %121 = load i32, ptr %10, align 4, !tbaa !9
  %122 = zext i32 %121 to i64
  %123 = mul i64 4, %122
  call void @llvm.memset.p0.i64(ptr align 4 %120, i8 0, i64 %123, i1 false)
  %124 = load ptr, ptr %9, align 8, !tbaa !5
  %125 = load i32, ptr %10, align 4, !tbaa !9
  %126 = udiv i32 %125, 2
  call void @_ZN6SoLoud17FFTFilterInstance13magPhase2CompEPfj(ptr noundef nonnull align 8 dereferenceable(176) %22, ptr noundef %124, i32 noundef %126)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #6
  ret void
}

declare void @_ZN6SoLoud17FFTFilterInstance13comp2MagPhaseEPfj(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef, i32 noundef) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZN6SoLoudL10catmullromEfffff(float noundef, float noundef, float noundef, float noundef, float noundef) #4

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare void @_ZN6SoLoud17FFTFilterInstance13magPhase2CompEPfj(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef, i32 noundef) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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, !6, i64 16}
!16 = !{!"_ZTSN6SoLoud14FilterInstanceE", !10, i64 8, !10, i64 12, !6, i64 16, !6, i64 24}
!17 = distinct !{!17, !18}
!18 = !{!"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 @_ZN6SoLoud16EqFilterInstance16fftFilterChannelEPfjfdjj(ptr noundef nonnull align 8 dereferenceable(184) %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 = lshr i32 %2, 1
  tail call void @_ZN6SoLoud17FFTFilterInstance13comp2MagPhaseEPfj(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1, i32 noundef %8)
  %.not = icmp ult i32 %2, 2
  br i1 %.not, label %._crit_edge, label %.lr.ph

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

13:                                               ; preds = %.lr.ph, %13
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %13 ]
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = uitofp nneg i32 %14 to float
  %16 = fdiv float %15, %9
  %17 = tail call noundef float @_ZSt4sqrtf(float noundef %16)
  %18 = fmul float %17, %9
  %19 = tail call noundef float @_ZSt5floorf(float noundef %18)
  %20 = fptosi float %19 to i32
  %21 = udiv i32 %20, %10
  %22 = add nsw i32 %21, 1
  %23 = tail call i32 @llvm.smax.i32(i32 %21, i32 1)
  %24 = tail call i32 @llvm.smax.i32(i32 %21, i32 2)
  %spec.store.select1 = tail call i32 @llvm.smin.i32(i32 %22, i32 7)
  %25 = urem i32 %20, %10
  %26 = uitofp nneg i32 %25 to float
  %27 = fdiv float %26, %11
  %28 = load ptr, ptr %12, align 8, !tbaa !5
  %29 = zext nneg i32 %24 to i64
  %30 = getelementptr float, ptr %28, i64 %29
  %31 = getelementptr i8, ptr %30, i64 -4
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = zext nneg i32 %23 to i64
  %34 = getelementptr inbounds float, ptr %28, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = sext i32 %22 to i64
  %37 = getelementptr inbounds float, ptr %28, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !11
  %39 = sext i32 %spec.store.select1 to i64
  %40 = getelementptr float, ptr %28, i64 %39
  %41 = getelementptr i8, ptr %40, i64 4
  %42 = load float, ptr %41, align 4, !tbaa !11
  %43 = tail call noundef float @_ZN6SoLoudL10catmullromEfffff(float noundef %27, float noundef %32, float noundef %35, float noundef %38, float noundef %42)
  %.idx = shl i64 %indvars.iv, 3
  %44 = getelementptr inbounds i8, ptr %1, i64 %.idx
  %45 = load float, ptr %44, align 4, !tbaa !11
  %46 = fmul float %43, %45
  store float %46, ptr %44, align 4, !tbaa !11
  %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 %13, !llvm.loop !13

._crit_edge:                                      ; preds = %13, %7
  %47 = zext i32 %2 to i64
  %48 = getelementptr inbounds float, ptr %1, i64 %47
  %49 = shl nuw nsw i64 %47, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %48, i8 0, i64 %49, i1 false)
  tail call void @_ZN6SoLoud17FFTFilterInstance13magPhase2CompEPfj(ptr noundef nonnull align 8 dereferenceable(176) %0, ptr noundef %1, i32 noundef %8)
  ret void
}

declare void @_ZN6SoLoud17FFTFilterInstance13comp2MagPhaseEPfj(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef, i32 noundef) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZN6SoLoudL10catmullromEfffff(float noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare void @_ZN6SoLoud17FFTFilterInstance13magPhase2CompEPfj(ptr noundef nonnull align 8 dereferenceable(176), ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

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 = { "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 = { 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 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 #4 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !10, i64 16}
!6 = !{!"_ZTSN6SoLoud14FilterInstanceE", !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !8, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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