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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.87 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [75 x i8], align 1
@__const.iirfilt_crcf_create_dc_blocker.bf = external hidden unnamed_addr constant [2 x float], align 4

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @iirfilt_crcf_create(ptr noundef, i32 noundef, ptr noundef, i32 noundef) #2

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

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

11:                                               ; preds = %1
  %12 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.87, i32 noundef 386, ptr noundef @.str.92, ptr noundef @.str.2)
  store ptr %12, ptr %2, align 8
  br label %38

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %4, ptr align 4 @__const.iirfilt_crcf_create_dc_blocker.bf, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  store float 1.000000e+00, ptr %5, align 4, !tbaa !5
  %14 = getelementptr inbounds float, ptr %5, i64 1
  %15 = load float, ptr %3, align 4, !tbaa !5
  %16 = fadd float -1.000000e+00, %15
  store float %16, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %17 = getelementptr inbounds [2 x float], ptr %4, i64 0, i64 0
  %18 = load float, ptr %17, align 4, !tbaa !5
  store float %18, ptr %6, align 4, !tbaa !5
  %19 = getelementptr inbounds float, ptr %6, i64 1
  %20 = getelementptr inbounds [2 x float], ptr %4, i64 0, i64 1
  %21 = load float, ptr %20, align 4, !tbaa !5
  store float %21, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %22 = getelementptr inbounds [2 x float], ptr %5, i64 0, i64 0
  %23 = load float, ptr %22, align 4, !tbaa !5
  store float %23, ptr %7, align 4, !tbaa !5
  %24 = getelementptr inbounds float, ptr %7, i64 1
  %25 = getelementptr inbounds [2 x float], ptr %5, i64 0, i64 1
  %26 = load float, ptr %25, align 4, !tbaa !5
  store float %26, ptr %24, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %27 = getelementptr inbounds [2 x float], ptr %6, i64 0, i64 0
  %28 = getelementptr inbounds [2 x float], ptr %7, i64 0, i64 0
  %29 = call ptr @iirfilt_crcf_create(ptr noundef %27, i32 noundef 2, ptr noundef %28, i32 noundef 2)
  store ptr %29, ptr %8, align 8, !tbaa !9
  %30 = load ptr, ptr %8, align 8, !tbaa !9
  %31 = load float, ptr %3, align 4, !tbaa !5
  %32 = fsub float 1.000000e+00, %31
  %33 = fpext float %32 to double
  %34 = call double @sqrt(double noundef %33) #5
  %35 = fptrunc double %34 to float
  %36 = call i32 @iirfilt_crcf_set_scale(ptr noundef %30, float noundef %35)
  %37 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %37, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %38

38:                                               ; preds = %13, %11
  %39 = load ptr, ptr %2, align 8
  ret ptr %39
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: nounwind
declare double @sqrt(double noundef) #4

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nounwind "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 #5 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}


; 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.87 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.92 = external hidden unnamed_addr constant [75 x i8], align 1
@__const.iirfilt_crcf_create_dc_blocker.bf = external hidden unnamed_addr constant [2 x float], align 4

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @iirfilt_crcf_create(ptr noundef, i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @iirfilt_crcf_set_scale(ptr noundef, float noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @iirfilt_crcf_create_dc_blocker(float noundef %0) local_unnamed_addr #2 {
  %2 = alloca [2 x float], align 8
  %3 = alloca [2 x float], align 4
  %4 = fcmp ugt float %0, 0.000000e+00
  br i1 %4, label %7, label %5

5:                                                ; preds = %1
  %6 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.87, i32 noundef 386, ptr noundef nonnull @.str.92, ptr noundef nonnull @.str.2) #3
  br label %14

7:                                                ; preds = %1
  %8 = fadd float %0, -1.000000e+00
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %9 = load <2 x float>, ptr @__const.iirfilt_crcf_create_dc_blocker.bf, align 4
  store <2 x float> %9, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store float 1.000000e+00, ptr %3, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  store float %8, ptr %10, align 4, !tbaa !5
  %11 = call ptr @iirfilt_crcf_create(ptr noundef nonnull %2, i32 noundef 2, ptr noundef nonnull %3, i32 noundef 2)
  %12 = fsub float 1.000000e+00, %0
  %sqrtf = call float @sqrtf(float noundef %12) #4
  %13 = call i32 @iirfilt_crcf_set_scale(ptr noundef %11, float noundef %sqrtf)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  br label %14

14:                                               ; preds = %7, %5
  %.0 = phi ptr [ %6, %5 ], [ %11, %7 ]
  ret ptr %.0
}

declare float @sqrtf(float) local_unnamed_addr

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 willreturn memory(argmem: readwrite) }
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 }
attributes #4 = { mustprogress nofree nounwind willreturn memory(write) "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" }

!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"}


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