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

; 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_crcf_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 }

declare <2 x float> @__mulsc3(float, float, float, float)

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

; Function Attrs: nounwind uwtable
define dso_local i32 @symsync_crcf_advance_internal_loop(ptr noundef %0, <2 x float> noundef %1, <2 x float> noundef %2) #1 {
  %4 = alloca { float, float }, align 4
  %5 = alloca { float, float }, align 4
  %6 = alloca ptr, align 8
  %7 = alloca { float, float }, align 4
  store <2 x float> %1, ptr %4, align 4
  store <2 x float> %2, ptr %5, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %9 = load float, ptr %8, align 4
  %10 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %11 = load float, ptr %10, align 4
  %12 = fneg float %11
  %13 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %14 = load float, ptr %13, align 4
  %15 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %16 = load float, ptr %15, align 4
  %17 = fmul float %9, %14
  %18 = fmul float %12, %16
  %19 = fmul float %9, %16
  %20 = fmul float %12, %14
  %21 = fsub float %17, %18
  %22 = fadd float %19, %20
  %23 = fcmp uno float %21, %21
  br i1 %23, label %24, label %32, !prof !9

24:                                               ; preds = %3
  %25 = fcmp uno float %22, %22
  br i1 %25, label %26, label %32, !prof !9

26:                                               ; preds = %24
  %27 = call <2 x float> @__mulsc3(float noundef %9, float noundef %12, float noundef %14, float noundef %16) #3
  store <2 x float> %27, ptr %7, align 4
  %28 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  br label %32

32:                                               ; preds = %26, %24, %3
  %33 = phi float [ %21, %3 ], [ %21, %24 ], [ %29, %26 ]
  %34 = phi float [ %22, %3 ], [ %22, %24 ], [ %31, %26 ]
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.symsync_crcf_s, ptr %35, i32 0, i32 11
  store float %33, ptr %36, align 4, !tbaa !10
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.symsync_crcf_s, ptr %37, i32 0, i32 11
  %39 = load float, ptr %38, align 4, !tbaa !10
  %40 = fcmp ogt float %39, 1.000000e+00
  br i1 %40, label %41, label %44

41:                                               ; preds = %32
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.symsync_crcf_s, ptr %42, i32 0, i32 11
  store float 1.000000e+00, ptr %43, align 4, !tbaa !10
  br label %53

44:                                               ; preds = %32
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.symsync_crcf_s, ptr %45, i32 0, i32 11
  %47 = load float, ptr %46, align 4, !tbaa !10
  %48 = fcmp olt float %47, -1.000000e+00
  br i1 %48, label %49, label %52

49:                                               ; preds = %44
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.symsync_crcf_s, ptr %50, i32 0, i32 11
  store float -1.000000e+00, ptr %51, align 4, !tbaa !10
  br label %52

52:                                               ; preds = %49, %44
  br label %53

53:                                               ; preds = %52, %41
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.symsync_crcf_s, ptr %54, i32 0, i32 15
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.symsync_crcf_s, ptr %57, i32 0, i32 11
  %59 = load float, ptr %58, align 4, !tbaa !10
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.symsync_crcf_s, ptr %60, i32 0, i32 12
  %62 = call i32 @iirfiltsos_rrrf_execute(ptr noundef %56, float noundef %59, ptr noundef %61)
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.symsync_crcf_s, ptr %63, i32 0, i32 16
  %65 = load float, ptr %64, align 8, !tbaa !15
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.symsync_crcf_s, ptr %66, i32 0, i32 12
  %68 = load float, ptr %67, align 8, !tbaa !16
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.symsync_crcf_s, ptr %69, i32 0, i32 5
  %71 = load float, ptr %70, align 4, !tbaa !17
  %72 = call float @llvm.fmuladd.f32(float %65, float %68, float %71)
  store float %72, ptr %70, align 4, !tbaa !17
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.symsync_crcf_s, ptr %73, i32 0, i32 5
  %75 = load float, ptr %74, align 4, !tbaa !17
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.symsync_crcf_s, ptr %76, i32 0, i32 12
  %78 = load float, ptr %77, align 8, !tbaa !16
  %79 = fadd float %75, %78
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.symsync_crcf_s, ptr %80, i32 0, i32 6
  store float %79, ptr %81, align 8, !tbaa !18
  ret i32 0
}

declare i32 @iirfiltsos_rrrf_execute(ptr noundef, float noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 = { 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/C++ TBAA"}
!9 = !{!"branch_weights", i32 1, i32 1048575}
!10 = !{!11, !13, i64 44}
!11 = !{!"symsync_crcf_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !13, i64 32, !13, i64 36, !12, i64 40, !13, i64 44, !13, i64 48, !7, i64 52, !7, i64 64, !6, i64 80, !13, i64 88, !12, i64 92, !6, i64 96, !6, i64 104}
!12 = !{!"int", !7, i64 0}
!13 = !{!"float", !7, i64 0}
!14 = !{!11, !6, i64 80}
!15 = !{!11, !13, i64 88}
!16 = !{!11, !13, i64 48}
!17 = !{!11, !13, i64 20}
!18 = !{!11, !13, 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"

declare <2 x float> @__mulsc3(float, float, float, float) local_unnamed_addr

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @symsync_crcf_advance_internal_loop(ptr noundef %0, <2 x float> noundef %1, <2 x float> noundef %2) local_unnamed_addr #1 {
  %4 = extractelement <2 x float> %2, i64 1
  %5 = extractelement <2 x float> %2, i64 0
  %6 = extractelement <2 x float> %1, i64 1
  %7 = extractelement <2 x float> %1, i64 0
  %8 = fneg float %6
  %9 = fmul <2 x float> %1, %2
  %shift = shufflevector <2 x float> %9, <2 x float> poison, <2 x i32> <i32 1, i32 poison>
  %10 = fadd <2 x float> %9, %shift
  %11 = extractelement <2 x float> %10, i64 0
  %12 = fcmp uno float %11, 0.000000e+00
  br i1 %12, label %13, label %20, !prof !5

13:                                               ; preds = %3
  %14 = fmul float %7, %4
  %15 = fmul float %6, %5
  %16 = fsub float %14, %15
  %17 = fcmp uno float %16, 0.000000e+00
  br i1 %17, label %18, label %20, !prof !5

18:                                               ; preds = %13
  %19 = tail call <2 x float> @__mulsc3(float noundef %7, float noundef %8, float noundef %5, float noundef %4) #3
  %.sroa.0.0.vec.extract = extractelement <2 x float> %19, i64 0
  br label %20

20:                                               ; preds = %18, %13, %3
  %21 = phi float [ %11, %3 ], [ %11, %13 ], [ %.sroa.0.0.vec.extract, %18 ]
  %22 = getelementptr inbounds i8, ptr %0, i64 44
  store float %21, ptr %22, align 4, !tbaa !6
  %23 = fcmp ogt float %21, 1.000000e+00
  br i1 %23, label %.sink.split, label %24

24:                                               ; preds = %20
  %25 = fcmp olt float %21, -1.000000e+00
  br i1 %25, label %.sink.split, label %26

.sink.split:                                      ; preds = %24, %20
  %.sink = phi float [ 1.000000e+00, %20 ], [ -1.000000e+00, %24 ]
  store float %.sink, ptr %22, align 4, !tbaa !6
  br label %26

26:                                               ; preds = %.sink.split, %24
  %27 = phi float [ %21, %24 ], [ %.sink, %.sink.split ]
  %28 = getelementptr inbounds i8, ptr %0, i64 80
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = tail call i32 @iirfiltsos_rrrf_execute(ptr noundef %29, float noundef %27, ptr noundef nonnull %30) #3
  %32 = getelementptr inbounds i8, ptr %0, i64 88
  %33 = load float, ptr %32, align 8, !tbaa !14
  %34 = load float, ptr %30, align 8, !tbaa !15
  %35 = getelementptr inbounds i8, ptr %0, i64 20
  %36 = load float, ptr %35, align 4, !tbaa !16
  %37 = tail call float @llvm.fmuladd.f32(float %33, float %34, float %36)
  store float %37, ptr %35, align 4, !tbaa !16
  %38 = fadd float %34, %37
  %39 = getelementptr inbounds i8, ptr %0, i64 24
  store float %38, ptr %39, align 8, !tbaa !17
  ret i32 0
}

declare i32 @iirfiltsos_rrrf_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { "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 = { 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 = !{!"branch_weights", i32 1, i32 1048575}
!6 = !{!7, !11, i64 44}
!7 = !{!"symsync_crcf_s", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !11, i64 44, !11, i64 48, !9, i64 52, !9, i64 64, !12, i64 80, !11, i64 88, !8, i64 92, !12, i64 96, !12, i64 104}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!7, !12, i64 80}
!14 = !{!7, !11, i64 88}
!15 = !{!7, !11, i64 48}
!16 = !{!7, !11, i64 20}
!17 = !{!7, !11, i64 24}


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