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

; 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.resamp_cccf_s = type { i32, float, float, float, i32, i32, i32, i32, ptr }

@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.138 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

8:                                                ; preds = %2
  %9 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.129, i32 noundef 195, ptr noundef @.str.138, ptr noundef @.str.3)
  store i32 %9, ptr %3, align 4
  br label %32

10:                                               ; preds = %2
  %11 = load float, ptr %5, align 4, !tbaa !9
  %12 = fcmp olt float %11, 0x3F70624DE0000000
  br i1 %12, label %16, label %13

13:                                               ; preds = %10
  %14 = load float, ptr %5, align 4, !tbaa !9
  %15 = fcmp ogt float %14, 2.500000e+02
  br i1 %15, label %16, label %18

16:                                               ; preds = %13, %10
  %17 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str.129, i32 noundef 197, ptr noundef @.str.139, ptr noundef @.str.3)
  store i32 %17, ptr %3, align 4
  br label %32

18:                                               ; preds = %13
  br label %19

19:                                               ; preds = %18
  %20 = load float, ptr %5, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.resamp_cccf_s, ptr %21, i32 0, i32 3
  store float %20, ptr %22, align 4, !tbaa !11
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.resamp_cccf_s, ptr %23, i32 0, i32 3
  %25 = load float, ptr %24, align 4, !tbaa !11
  %26 = fdiv float 0x4170000000000000, %25
  %27 = fpext float %26 to double
  %28 = call double @llvm.round.f64(double %27)
  %29 = fptoui double %28 to i32
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.resamp_cccf_s, ptr %30, i32 0, i32 4
  store i32 %29, ptr %31, align 8, !tbaa !14
  store i32 0, ptr %3, align 4
  br label %32

32:                                               ; preds = %19, %16, %8
  %33 = load i32, ptr %3, align 4
  ret i32 %33
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.round.f64(double) #2

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 = { 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 #2 = { 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 12}
!12 = !{!"resamp_cccf_s", !13, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !13, i64 16, !13, i64 20, !13, i64 24, !13, i64 28, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !13, i64 16}


; 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.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.129 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.138 = external hidden unnamed_addr constant [64 x i8], align 1
@.str.139 = external hidden unnamed_addr constant [61 x i8], align 1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @resamp_cccf_set_rate(ptr nocapture noundef writeonly %0, float noundef %1) local_unnamed_addr #1 {
  %3 = fcmp ugt float %1, 0.000000e+00
  br i1 %3, label %6, label %4

4:                                                ; preds = %2
  %5 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.129, i32 noundef 195, ptr noundef nonnull @.str.138, ptr noundef nonnull @.str.3) #3
  br label %17

6:                                                ; preds = %2
  %7 = fcmp olt float %1, 0x3F70624DE0000000
  %8 = fcmp ogt float %1, 2.500000e+02
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %9, label %11

9:                                                ; preds = %6
  %10 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str.129, i32 noundef 197, ptr noundef nonnull @.str.139, ptr noundef nonnull @.str.3) #3
  br label %17

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  store float %1, ptr %12, align 4, !tbaa !5
  %13 = fdiv float 0x4170000000000000, %1
  %14 = tail call float @llvm.round.f32(float %13)
  %15 = fptoui float %14 to i32
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  store i32 %15, ptr %16, align 8, !tbaa !12
  br label %17

17:                                               ; preds = %11, %9, %4
  %.0 = phi i32 [ %5, %4 ], [ %10, %9 ], [ 0, %11 ]
  ret i32 %.0
}

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

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 = { 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 #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 12}
!6 = !{!"resamp_cccf_s", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !7, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !11, i64 32}
!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, !7, i64 16}


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