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

; 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 @_ZN6SoLoud22RobotizeFilterInstance13filterChannelEPfjfdjj(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 i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  %19 = 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
  %20 = load ptr, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %21 = load float, ptr %11, align 4, !tbaa !11
  %22 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %20, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = getelementptr inbounds float, ptr %23, i64 1
  %25 = load float, ptr %24, align 4, !tbaa !11
  %26 = fdiv float %21, %25
  %27 = fptosi float %26 to i32
  store i32 %27, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %28 = load double, ptr %12, align 8, !tbaa !13
  %29 = load float, ptr %11, align 4, !tbaa !11
  %30 = fpext float %29 to double
  %31 = fmul double %28, %30
  %32 = fptosi double %31 to i32
  %33 = load i32, ptr %16, align 4, !tbaa !9
  %34 = srem i32 %32, %33
  store i32 %34, ptr %17, align 4, !tbaa !9
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %81, %7
  %36 = load i32, ptr %15, align 4, !tbaa !9
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = icmp ult i32 %36, %37
  br i1 %38, label %39, label %84

39:                                               ; preds = %35
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = load i32, ptr %15, align 4, !tbaa !9
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds float, ptr %40, i64 %42
  %44 = load float, ptr %43, align 4, !tbaa !11
  store float %44, ptr %18, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  %45 = load i32, ptr %17, align 4, !tbaa !9
  %46 = load i32, ptr %15, align 4, !tbaa !9
  %47 = add i32 %45, %46
  %48 = load i32, ptr %16, align 4, !tbaa !9
  %49 = urem i32 %47, %48
  %50 = uitofp i32 %49 to float
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = sitofp i32 %51 to float
  %53 = fdiv float %50, %52
  store float %53, ptr %19, align 4, !tbaa !11
  %54 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %20, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !15
  %56 = getelementptr inbounds float, ptr %55, i64 2
  %57 = load float, ptr %56, align 4, !tbaa !11
  %58 = fptosi float %57 to i32
  %59 = load float, ptr %19, align 4, !tbaa !11
  %60 = call noundef float @_ZN6SoLoud4Misc16generateWaveformEif(i32 noundef %58, float noundef %59)
  %61 = fadd float %60, 5.000000e-01
  %62 = load float, ptr %18, align 4, !tbaa !11
  %63 = fmul float %62, %61
  store float %63, ptr %18, align 4, !tbaa !11
  %64 = load float, ptr %18, align 4, !tbaa !11
  %65 = load ptr, ptr %9, align 8, !tbaa !5
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !11
  %70 = fsub float %64, %69
  %71 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %20, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !15
  %73 = getelementptr inbounds float, ptr %72, i64 0
  %74 = load float, ptr %73, align 4, !tbaa !11
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = load i32, ptr %15, align 4, !tbaa !9
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds float, ptr %75, i64 %77
  %79 = load float, ptr %78, align 4, !tbaa !11
  %80 = call float @llvm.fmuladd.f32(float %70, float %74, float %79)
  store float %80, ptr %78, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %81

81:                                               ; preds = %39
  %82 = load i32, ptr %15, align 4, !tbaa !9
  %83 = add i32 %82, 1
  store i32 %83, ptr %15, align 4, !tbaa !9
  br label %35, !llvm.loop !17

84:                                               ; preds = %35
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  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

declare noundef float @_ZN6SoLoud4Misc16generateWaveformEif(i32 noundef, 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 = { "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, !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 @_ZN6SoLoud22RobotizeFilterInstance13filterChannelEPfjfdjj(ptr nocapture noundef nonnull readonly 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 = getelementptr inbounds i8, ptr %0, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 4
  %11 = load float, ptr %10, align 4, !tbaa !11
  %12 = fdiv float %3, %11
  %13 = fptosi float %12 to i32
  %14 = fpext float %3 to double
  %15 = fmul double %14, %4
  %16 = fptosi double %15 to i32
  %17 = srem i32 %16, %13
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %7
  %18 = sitofp i32 %13 to float
  %wide.trip.count = zext i32 %2 to i64
  br label %19

19:                                               ; preds = %.lr.ph, %19
  %20 = phi ptr [ %9, %.lr.ph ], [ %36, %19 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %21 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %22 = load float, ptr %21, align 4, !tbaa !11
  %23 = trunc nuw i64 %indvars.iv to i32
  %24 = add i32 %17, %23
  %25 = urem i32 %24, %13
  %26 = uitofp i32 %25 to float
  %27 = fdiv float %26, %18
  %28 = getelementptr inbounds i8, ptr %20, i64 8
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = fptosi float %29 to i32
  %31 = tail call noundef float @_ZN6SoLoud4Misc16generateWaveformEif(i32 noundef %30, float noundef %27)
  %32 = fadd float %31, 5.000000e-01
  %33 = fmul float %22, %32
  %34 = load float, ptr %21, align 4, !tbaa !11
  %35 = fsub float %33, %34
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = load float, ptr %36, align 4, !tbaa !11
  %38 = tail call float @llvm.fmuladd.f32(float %35, float %37, float %34)
  store float %38, ptr %21, 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 %19, !llvm.loop !13

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

declare noundef float @_ZN6SoLoud4Misc16generateWaveformEif(i32 noundef, 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 = { "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, !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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass