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

; 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

; Function Attrs: nounwind uwtable
declare dso_local i32 @firpfb_cccf_push(ptr noundef, <2 x float> noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @resamp_cccf_execute(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca { float, float }, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca { float, float }, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store <2 x float> %1, ptr %5, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %12 = load ptr, ptr %6, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.resamp_cccf_s, ptr %12, i32 0, i32 8
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 0
  %16 = load float, ptr %15, align 4
  %17 = getelementptr inbounds { float, float }, ptr %5, i32 0, i32 1
  %18 = load float, ptr %17, align 4
  %19 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %20 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %16, ptr %19, align 4
  store float %18, ptr %20, align 4
  %21 = load <2 x float>, ptr %9, align 4
  %22 = call i32 @firpfb_cccf_push(ptr noundef %14, <2 x float> noundef %21)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %10, align 4, !tbaa !13
  br label %23

23:                                               ; preds = %28, %4
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.resamp_cccf_s, ptr %24, i32 0, i32 5
  %26 = load i32, ptr %25, align 4, !tbaa !14
  %27 = icmp ule i32 %26, 16777215
  br i1 %27, label %28, label %54

28:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.resamp_cccf_s, ptr %29, i32 0, i32 5
  %31 = load i32, ptr %30, align 4, !tbaa !14
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.resamp_cccf_s, ptr %32, i32 0, i32 6
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = sub i32 24, %34
  %36 = lshr i32 %31, %35
  store i32 %36, ptr %11, align 4, !tbaa !13
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.resamp_cccf_s, ptr %37, i32 0, i32 8
  %39 = load ptr, ptr %38, align 8, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !13
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load i32, ptr %10, align 4, !tbaa !13
  %43 = add i32 %42, 1
  store i32 %43, ptr %10, align 4, !tbaa !13
  %44 = zext i32 %42 to i64
  %45 = getelementptr inbounds { float, float }, ptr %41, i64 %44
  %46 = call i32 @firpfb_cccf_execute(ptr noundef %39, i32 noundef %40, ptr noundef %45)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.resamp_cccf_s, ptr %47, i32 0, i32 4
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.resamp_cccf_s, ptr %50, i32 0, i32 5
  %52 = load i32, ptr %51, align 4, !tbaa !14
  %53 = add i32 %52, %49
  store i32 %53, ptr %51, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %23, !llvm.loop !17

54:                                               ; preds = %23
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.resamp_cccf_s, ptr %55, i32 0, i32 5
  %57 = load i32, ptr %56, align 4, !tbaa !14
  %58 = sub i32 %57, 16777216
  store i32 %58, ptr %56, align 4, !tbaa !14
  %59 = load i32, ptr %10, align 4, !tbaa !13
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %59, ptr %60, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 }

!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, !6, i64 32}
!10 = !{!"resamp_cccf_s", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28, !6, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 20}
!15 = !{!10, !11, i64 24}
!16 = !{!10, !11, i64 16}
!17 = distinct !{!17, !18}
!18 = !{!"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: nounwind uwtable
declare dso_local i32 @firpfb_cccf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @resamp_cccf_execute(ptr nocapture noundef %0, <2 x float> noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %0, i64 32
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call i32 @firpfb_cccf_push(ptr noundef %6, <2 x float> noundef %1)
  %8 = getelementptr inbounds i8, ptr %0, i64 20
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = icmp ult i32 %9, 16777216
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %4
  %11 = getelementptr inbounds i8, ptr %0, i64 24
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  br label %13

13:                                               ; preds = %.lr.ph, %13
  %14 = phi i32 [ %9, %.lr.ph ], [ %25, %13 ]
  %.016 = phi i32 [ 0, %.lr.ph ], [ %19, %13 ]
  %15 = load i32, ptr %11, align 8, !tbaa !13
  %16 = sub i32 24, %15
  %17 = lshr i32 %14, %16
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = add i32 %.016, 1
  %20 = zext i32 %.016 to i64
  %21 = getelementptr inbounds { float, float }, ptr %2, i64 %20
  %22 = tail call i32 @firpfb_cccf_execute(ptr noundef %18, i32 noundef %17, ptr noundef %21)
  %23 = load i32, ptr %12, align 8, !tbaa !14
  %24 = load i32, ptr %8, align 4, !tbaa !12
  %25 = add i32 %24, %23
  store i32 %25, ptr %8, align 4, !tbaa !12
  %26 = icmp ult i32 %25, 16777216
  br i1 %26, label %13, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %13, %4
  %.0.lcssa = phi i32 [ 0, %4 ], [ %19, %13 ]
  %.lcssa = phi i32 [ %9, %4 ], [ %25, %13 ]
  %27 = add i32 %.lcssa, -16777216
  store i32 %27, ptr %8, align 4, !tbaa !12
  store i32 %.0.lcssa, ptr %3, align 4, !tbaa !17
  ret i32 0
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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, !11, i64 32}
!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 20}
!13 = !{!6, !7, i64 24}
!14 = !{!6, !7, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass