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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [48 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: nounwind uwtable
define dso_local i32 @firfarrow_crcf_set_delay(ptr noundef %0, float noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  %8 = load float, ptr %5, align 4, !tbaa !9
  %9 = fcmp olt float %8, -1.000000e+00
  br i1 %9, label %13, label %10

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

13:                                               ; preds = %10, %2
  %14 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef @.str.31, i32 noundef 201, ptr noundef @.str.37, ptr noundef @.str.2)
  store i32 %14, ptr %3, align 4
  br label %62

15:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !11
  store i32 0, ptr %6, align 4, !tbaa !11
  br label %16

16:                                               ; preds = %58, %15
  %17 = load i32, ptr %6, align 4, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %18, i32 0, i32 1
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %22, label %61

22:                                               ; preds = %16
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %23, i32 0, i32 6
  %25 = load ptr, ptr %24, align 8, !tbaa !15
  %26 = load i32, ptr %7, align 4, !tbaa !11
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %25, i64 %27
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %29, i32 0, i32 4
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = load float, ptr %5, align 4, !tbaa !9
  %33 = fneg float %32
  %34 = call float @polyf_val(ptr noundef %28, i32 noundef %31, float noundef %33)
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !17
  %38 = load i32, ptr %6, align 4, !tbaa !11
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %37, i64 %39
  store float %34, ptr %40, align 4, !tbaa !9
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %41, i32 0, i32 7
  %43 = load float, ptr %42, align 8, !tbaa !18
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load i32, ptr %6, align 4, !tbaa !11
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %46, i64 %48
  %50 = load float, ptr %49, align 4, !tbaa !9
  %51 = fmul float %50, %43
  store float %51, ptr %49, align 4, !tbaa !9
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.firfarrow_crcf_s, ptr %52, i32 0, i32 4
  %54 = load i32, ptr %53, align 4, !tbaa !16
  %55 = add i32 %54, 1
  %56 = load i32, ptr %7, align 4, !tbaa !11
  %57 = add i32 %56, %55
  store i32 %57, ptr %7, align 4, !tbaa !11
  br label %58

58:                                               ; preds = %22
  %59 = load i32, ptr %6, align 4, !tbaa !11
  %60 = add i32 %59, 1
  store i32 %60, ptr %6, align 4, !tbaa !11
  br label %16, !llvm.loop !19

61:                                               ; preds = %16
  store i32 0, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %62

62:                                               ; preds = %61, %13
  %63 = load i32, ptr %3, align 4
  ret i32 %63
}

declare float @polyf_val(ptr noundef, i32 noundef, float 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 = { 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 = !{!"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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"firfarrow_crcf_s", !6, i64 0, !12, i64 8, !10, i64 12, !10, i64 16, !12, i64 20, !10, i64 24, !6, i64 32, !10, i64 40, !6, i64 48}
!15 = !{!14, !6, i64 32}
!16 = !{!14, !12, i64 20}
!17 = !{!14, !6, i64 0}
!18 = !{!14, !10, i64 40}
!19 = distinct !{!19, !20}
!20 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.31 = external hidden unnamed_addr constant [87 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [48 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 @firfarrow_crcf_set_delay(ptr nocapture noundef readonly %0, float noundef %1) local_unnamed_addr #1 {
  %3 = tail call float @llvm.fabs.f32(float %1)
  %or.cond = fcmp ogt float %3, 1.000000e+00
  br i1 %or.cond, label %10, label %.preheader

.preheader:                                       ; preds = %2
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 20
  %8 = fneg float %1
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %.pre = load i32, ptr %7, align 4, !tbaa !12
  br label %12

10:                                               ; preds = %2
  %11 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef nonnull @.str.31, i32 noundef 201, ptr noundef nonnull @.str.37, ptr noundef nonnull @.str.2) #3
  br label %.loopexit

12:                                               ; preds = %.lr.ph, %12
  %13 = phi i32 [ %.pre, %.lr.ph ], [ %22, %12 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %12 ]
  %.021 = phi i32 [ 0, %.lr.ph ], [ %24, %12 ]
  %14 = load ptr, ptr %6, align 8, !tbaa !13
  %15 = zext i32 %.021 to i64
  %16 = getelementptr inbounds float, ptr %14, i64 %15
  %17 = tail call float @polyf_val(ptr noundef %16, i32 noundef %13, float noundef %8) #3
  %18 = load ptr, ptr %0, align 8, !tbaa !14
  %19 = getelementptr inbounds float, ptr %18, i64 %indvars.iv
  store float %17, ptr %19, align 4, !tbaa !15
  %20 = load float, ptr %9, align 8, !tbaa !16
  %21 = fmul float %17, %20
  store float %21, ptr %19, align 4, !tbaa !15
  %22 = load i32, ptr %7, align 4, !tbaa !12
  %23 = add i32 %.021, 1
  %24 = add i32 %23, %22
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr %4, align 8, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = icmp ult i64 %indvars.iv.next, %26
  br i1 %27, label %12, label %.loopexit, !llvm.loop !17

.loopexit:                                        ; preds = %12, %.preheader, %10
  %.018 = phi i32 [ %11, %10 ], [ 0, %.preheader ], [ 0, %12 ]
  ret i32 %.018
}

declare float @polyf_val(ptr noundef, i32 noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fabs.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 8}
!6 = !{!"firfarrow_crcf_s", !7, i64 0, !10, i64 8, !11, i64 12, !11, i64 16, !10, i64 20, !11, i64 24, !7, i64 32, !11, i64 40, !7, i64 48}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 20}
!13 = !{!6, !7, i64 32}
!14 = !{!6, !7, i64 0}
!15 = !{!11, !11, i64 0}
!16 = !{!6, !11, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass