; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_rrrf)

; 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"

%struct.symsync_rrrf_s = type { i32, i32, i32, i32, i32, float, float, float, float, float, i32, float, float, [3 x float], [3 x float], ptr, float, i32, ptr, ptr }

; Function Attrs: nounwind uwtable
declare dso_local i32 @iirfiltsos_rrrf_execute(ptr noundef, float noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local i32 @symsync_rrrf_advance_internal_loop(ptr noundef %0, float noundef %1, float noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store float %2, ptr %6, align 4, !tbaa !9
  %7 = load float, ptr %5, align 4, !tbaa !9
  %8 = load float, ptr %6, align 4, !tbaa !9
  %9 = fmul float %7, %8
  %10 = fmul float -0.000000e+00, %8
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %11, i32 0, i32 11
  store float %9, ptr %12, align 4, !tbaa !11
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %13, i32 0, i32 11
  %15 = load float, ptr %14, align 4, !tbaa !11
  %16 = fcmp ogt float %15, 1.000000e+00
  br i1 %16, label %17, label %20

17:                                               ; preds = %3
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %18, i32 0, i32 11
  store float 1.000000e+00, ptr %19, align 4, !tbaa !11
  br label %29

20:                                               ; preds = %3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %21, i32 0, i32 11
  %23 = load float, ptr %22, align 4, !tbaa !11
  %24 = fcmp olt float %23, -1.000000e+00
  br i1 %24, label %25, label %28

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %26, i32 0, i32 11
  store float -1.000000e+00, ptr %27, align 4, !tbaa !11
  br label %28

28:                                               ; preds = %25, %20
  br label %29

29:                                               ; preds = %28, %17
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %30, i32 0, i32 15
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %33, i32 0, i32 11
  %35 = load float, ptr %34, align 4, !tbaa !11
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %36, i32 0, i32 12
  %38 = call i32 @iirfiltsos_rrrf_execute(ptr noundef %32, float noundef %35, ptr noundef %37)
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %39, i32 0, i32 16
  %41 = load float, ptr %40, align 8, !tbaa !15
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %42, i32 0, i32 12
  %44 = load float, ptr %43, align 8, !tbaa !16
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %45, i32 0, i32 5
  %47 = load float, ptr %46, align 4, !tbaa !17
  %48 = call float @llvm.fmuladd.f32(float %41, float %44, float %47)
  store float %48, ptr %46, align 4, !tbaa !17
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %49, i32 0, i32 5
  %51 = load float, ptr %50, align 4, !tbaa !17
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %52, i32 0, i32 12
  %54 = load float, ptr %53, align 8, !tbaa !16
  %55 = fadd float %51, %54
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.symsync_rrrf_s, ptr %56, i32 0, i32 6
  store float %55, ptr %57, align 8, !tbaa !18
  ret i32 0
}

attributes #0 = { 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 #1 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 44}
!12 = !{!"symsync_rrrf_s", !13, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !13, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !13, i64 40, !10, i64 44, !10, i64 48, !7, i64 52, !7, i64 64, !6, i64 80, !10, i64 88, !13, i64 92, !6, i64 96, !6, i64 104}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 80}
!15 = !{!12, !10, i64 88}
!16 = !{!12, !10, i64 48}
!17 = !{!12, !10, i64 20}
!18 = !{!12, !10, i64 24}


; 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: nounwind uwtable
declare dso_local i32 @iirfiltsos_rrrf_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @symsync_rrrf_advance_internal_loop(ptr noundef %0, float noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = fmul float %1, %2
  %5 = getelementptr inbounds i8, ptr %0, i64 44
  store float %4, ptr %5, align 4, !tbaa !5
  %6 = fcmp ogt float %4, 1.000000e+00
  br i1 %6, label %.sink.split, label %7

7:                                                ; preds = %3
  %8 = fcmp olt float %4, -1.000000e+00
  br i1 %8, label %.sink.split, label %9

.sink.split:                                      ; preds = %7, %3
  %.sink = phi float [ 1.000000e+00, %3 ], [ -1.000000e+00, %7 ]
  store float %.sink, ptr %5, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %.sink.split, %7
  %10 = phi float [ %4, %7 ], [ %.sink, %.sink.split ]
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = tail call i32 @iirfiltsos_rrrf_execute(ptr noundef %12, float noundef %10, ptr noundef nonnull %13)
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  %16 = load float, ptr %15, align 8, !tbaa !13
  %17 = load float, ptr %13, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 20
  %19 = load float, ptr %18, align 4, !tbaa !15
  %20 = tail call float @llvm.fmuladd.f32(float %16, float %17, float %19)
  store float %20, ptr %18, align 4, !tbaa !15
  %21 = fadd float %17, %20
  %22 = getelementptr inbounds i8, ptr %0, i64 24
  store float %21, ptr %22, align 8, !tbaa !16
  ret i32 0
}

attributes #0 = { 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 #1 = { 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 44}
!6 = !{!"symsync_rrrf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !10, i64 44, !10, i64 48, !8, i64 52, !8, i64 64, !11, i64 80, !10, i64 88, !7, i64 92, !11, i64 96, !11, i64 104}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 80}
!13 = !{!6, !10, i64 88}
!14 = !{!6, !10, i64 48}
!15 = !{!6, !10, i64 20}
!16 = !{!6, !10, i64 24}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass