; LLVM IR from jgaeddert/liquid-dsp :: sandbox (firfilt_dcblocker_test)

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

; 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 speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #1

; Function Attrs: nounwind uwtable
define dso_local float @firfilt_dcblocker_init(i32 noundef %0, float noundef %1, float noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store float %2, ptr %7, align 4, !tbaa !9
  store ptr %3, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = mul i32 2, %12
  %14 = add i32 %13, 1
  store i32 %14, ptr %9, align 4, !tbaa !5
  %15 = load i32, ptr %9, align 4, !tbaa !5
  %16 = load float, ptr %6, align 4, !tbaa !9
  %17 = load float, ptr %7, align 4, !tbaa !9
  %18 = load ptr, ptr %8, align 8, !tbaa !11
  %19 = call i32 @liquid_firdes_kaiser(i32 noundef %15, float noundef %16, float noundef %17, float noundef 0.000000e+00, ptr noundef %18)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %45, %4
  %21 = load i32, ptr %11, align 4, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !5
  %23 = icmp ult i32 %21, %22
  br i1 %23, label %24, label %48

24:                                               ; preds = %20
  %25 = load i32, ptr %11, align 4, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = add i32 %25, %26
  %28 = urem i32 %27, 2
  %29 = icmp eq i32 %28, 0
  %30 = zext i1 %29 to i64
  %31 = select i1 %29, float 1.000000e+00, float -1.000000e+00
  %32 = load ptr, ptr %8, align 8, !tbaa !11
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %32, i64 %34
  %36 = load float, ptr %35, align 4, !tbaa !9
  %37 = fmul float %36, %31
  store float %37, ptr %35, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !11
  %39 = load i32, ptr %11, align 4, !tbaa !5
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %38, i64 %40
  %42 = load float, ptr %41, align 4, !tbaa !9
  %43 = load float, ptr %10, align 4, !tbaa !9
  %44 = fadd float %43, %42
  store float %44, ptr %10, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %24
  %46 = load i32, ptr %11, align 4, !tbaa !5
  %47 = add i32 %46, 1
  store i32 %47, ptr %11, align 4, !tbaa !5
  br label %20, !llvm.loop !13

48:                                               ; preds = %20
  %49 = load float, ptr %10, align 4, !tbaa !9
  %50 = call float @llvm.fabs.f32(float %49)
  %51 = fpext float %50 to double
  %52 = call double @log10(double noundef %51) #5
  %53 = fmul double 2.000000e+01, %52
  %54 = fptrunc double %53 to float
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  ret float %54
}

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

declare i32 @liquid_firdes_kaiser(i32 noundef, float noundef, float noundef, float noundef, ptr noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { "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 "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 = !{!"int", !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, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.f32(float) #0

; Function Attrs: nounwind uwtable
define dso_local float @firfilt_dcblocker_init(i32 noundef %0, float noundef %1, float noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = shl i32 %0, 1
  %6 = or disjoint i32 %5, 1
  %7 = tail call i32 @liquid_firdes_kaiser(i32 noundef %6, float noundef %1, float noundef %2, float noundef 0.000000e+00, ptr noundef %3) #4
  %8 = icmp eq i32 %5, 0
  br i1 %8, label %.epilog-lcssa, label %.new

.new:                                             ; preds = %4
  %unroll_iter = zext i32 %5 to i64
  %9 = and i32 %0, 1
  %10 = and i32 %0, 1
  %11 = icmp eq i32 %10, 0
  %.not = icmp eq i32 %9, 0
  br label %12

12:                                               ; preds = %12, %.new
  %indvars.iv = phi i64 [ 0, %.new ], [ %indvars.iv.next.1, %12 ]
  %.01516 = phi float [ 0.000000e+00, %.new ], [ %22, %12 ]
  %niter = phi i64 [ 0, %.new ], [ %niter.next.1, %12 ]
  %13 = getelementptr inbounds float, ptr %3, i64 %indvars.iv
  %14 = load float, ptr %13, align 4, !tbaa !5
  %15 = fneg float %14
  %16 = select i1 %11, float %14, float %15
  store float %16, ptr %13, align 4, !tbaa !5
  %17 = fadd float %.01516, %16
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %18 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.next
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = fneg float %19
  %21 = select i1 %.not, float %20, float %19
  store float %21, ptr %18, align 4, !tbaa !5
  %22 = fadd float %17, %21
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.epilog-lcssa, label %12, !llvm.loop !9

.epilog-lcssa:                                    ; preds = %12, %4
  %indvars.iv.unr = phi i64 [ 0, %4 ], [ %indvars.iv.next.1, %12 ]
  %.01516.unr = phi float [ 0.000000e+00, %4 ], [ %22, %12 ]
  %23 = trunc nuw i64 %indvars.iv.unr to i32
  %24 = add i32 %23, %0
  %25 = and i32 %24, 1
  %26 = icmp eq i32 %25, 0
  %27 = getelementptr inbounds float, ptr %3, i64 %indvars.iv.unr
  %28 = load float, ptr %27, align 4, !tbaa !5
  %29 = fneg float %28
  %30 = select i1 %26, float %28, float %29
  store float %30, ptr %27, align 4, !tbaa !5
  %31 = fadd float %.01516.unr, %30
  %32 = tail call float @llvm.fabs.f32(float %31)
  %33 = fpext float %32 to double
  %34 = tail call double @log10(double noundef %33) #4
  %35 = fmul double %34, 2.000000e+01
  %36 = fptrunc double %35 to float
  ret float %36
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @log10(double noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = { "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 = { 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" }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass