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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.171 = external hidden unnamed_addr constant [51 x i8], align 1

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

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @symsync_crcf_set_lf_bw(ptr noundef %0, float noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %10 = load float, ptr %5, align 4, !tbaa !9
  %11 = fcmp olt float %10, 0.000000e+00
  br i1 %11, label %15, label %12

12:                                               ; preds = %2
  %13 = load float, ptr %5, align 4, !tbaa !9
  %14 = fcmp ogt float %13, 1.000000e+00
  br i1 %14, label %15, label %17

15:                                               ; preds = %12, %2
  %16 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.155, i32 noundef 362, ptr noundef @.str.171, ptr noundef @.str.2)
  store i32 %16, ptr %3, align 4
  br label %65

17:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = fsub float 1.000000e+00, %18
  store float %19, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = fmul float 0x3FCC28F5C0000000, %20
  store float %21, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store float 5.000000e-01, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store float 0x3FDFAE1480000000, ptr %9, align 4, !tbaa !9
  %22 = load float, ptr %7, align 4, !tbaa !9
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.symsync_crcf_s, ptr %23, i32 0, i32 13
  %25 = getelementptr inbounds [3 x float], ptr %24, i64 0, i64 0
  store float %22, ptr %25, align 4, !tbaa !9
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.symsync_crcf_s, ptr %26, i32 0, i32 13
  %28 = getelementptr inbounds [3 x float], ptr %27, i64 0, i64 1
  store float 0.000000e+00, ptr %28, align 4, !tbaa !9
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.symsync_crcf_s, ptr %29, i32 0, i32 13
  %31 = getelementptr inbounds [3 x float], ptr %30, i64 0, i64 2
  store float 0.000000e+00, ptr %31, align 4, !tbaa !9
  %32 = load float, ptr %8, align 4, !tbaa !9
  %33 = load float, ptr %6, align 4, !tbaa !9
  %34 = fneg float %32
  %35 = call float @llvm.fmuladd.f32(float %34, float %33, float 1.000000e+00)
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.symsync_crcf_s, ptr %36, i32 0, i32 14
  %38 = getelementptr inbounds [3 x float], ptr %37, i64 0, i64 0
  store float %35, ptr %38, align 8, !tbaa !9
  %39 = load float, ptr %9, align 4, !tbaa !9
  %40 = fneg float %39
  %41 = load float, ptr %6, align 4, !tbaa !9
  %42 = fmul float %40, %41
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.symsync_crcf_s, ptr %43, i32 0, i32 14
  %45 = getelementptr inbounds [3 x float], ptr %44, i64 0, i64 1
  store float %42, ptr %45, align 4, !tbaa !9
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.symsync_crcf_s, ptr %46, i32 0, i32 14
  %48 = getelementptr inbounds [3 x float], ptr %47, i64 0, i64 2
  store float 0.000000e+00, ptr %48, align 8, !tbaa !9
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.symsync_crcf_s, ptr %49, i32 0, i32 15
  %51 = load ptr, ptr %50, align 8, !tbaa !11
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.symsync_crcf_s, ptr %52, i32 0, i32 13
  %54 = getelementptr inbounds [3 x float], ptr %53, i64 0, i64 0
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.symsync_crcf_s, ptr %55, i32 0, i32 14
  %57 = getelementptr inbounds [3 x float], ptr %56, i64 0, i64 0
  %58 = call i32 @iirfiltsos_rrrf_set_coefficients(ptr noundef %51, ptr noundef %54, ptr noundef %57)
  %59 = load float, ptr %5, align 4, !tbaa !9
  %60 = fpext float %59 to double
  %61 = fmul double 5.000000e-01, %60
  %62 = fptrunc double %61 to float
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.symsync_crcf_s, ptr %63, i32 0, i32 16
  store float %62, ptr %64, align 8, !tbaa !14
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %65

65:                                               ; preds = %17, %15
  %66 = load i32, ptr %3, align 4
  ret i32 %66
}

declare i32 @iirfiltsos_rrrf_set_coefficients(ptr noundef, ptr noundef, ptr noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 speculatable willreturn memory(none) }
attributes #3 = { 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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !6, i64 80}
!12 = !{!"symsync_crcf_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, !10, i64 88}


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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.171 = external hidden unnamed_addr constant [51 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 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 i32 @symsync_crcf_set_lf_bw(ptr noundef %0, float noundef %1) local_unnamed_addr #2 {
  %3 = fcmp olt float %1, 0.000000e+00
  %4 = fcmp ogt float %1, 1.000000e+00
  %or.cond = or i1 %3, %4
  br i1 %or.cond, label %5, label %7

5:                                                ; preds = %2
  %6 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.155, i32 noundef 362, ptr noundef nonnull @.str.171, ptr noundef nonnull @.str.2) #3
  br label %22

7:                                                ; preds = %2
  %8 = fsub float 1.000000e+00, %1
  %9 = fmul float %1, 0x3FCC28F5C0000000
  %10 = getelementptr inbounds i8, ptr %0, i64 52
  store float %9, ptr %10, align 4, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 56
  store <2 x float> zeroinitializer, ptr %11, align 4, !tbaa !5
  %12 = tail call float @llvm.fmuladd.f32(float %8, float -5.000000e-01, float 1.000000e+00)
  %13 = getelementptr inbounds i8, ptr %0, i64 64
  store float %12, ptr %13, align 8, !tbaa !5
  %14 = fmul float %8, 0xBFDFAE1480000000
  %15 = getelementptr inbounds i8, ptr %0, i64 68
  store float %14, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 72
  store float 0.000000e+00, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %0, i64 80
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  %19 = tail call i32 @iirfiltsos_rrrf_set_coefficients(ptr noundef %18, ptr noundef nonnull %10, ptr noundef nonnull %13) #3
  %20 = fmul float %1, 5.000000e-01
  %21 = getelementptr inbounds i8, ptr %0, i64 88
  store float %20, ptr %21, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %7, %5
  %.0 = phi i32 [ %6, %5 ], [ 0, %7 ]
  ret i32 %.0
}

declare i32 @iirfiltsos_rrrf_set_coefficients(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #0

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass