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

; 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_rrrf_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_rrrf_push(ptr noundef, float noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @resamp_rrrf_execute(ptr noundef %0, float noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store float %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %11, i32 0, i32 8
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = load float, ptr %6, align 4, !tbaa !9
  %15 = call i32 @firpfb_rrrf_push(ptr noundef %13, float noundef %14)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !14
  br label %16

16:                                               ; preds = %21, %4
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %17, i32 0, i32 5
  %19 = load i32, ptr %18, align 4, !tbaa !15
  %20 = icmp ule i32 %19, 16777215
  br i1 %20, label %21, label %47

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %22, i32 0, i32 5
  %24 = load i32, ptr %23, align 4, !tbaa !15
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %25, i32 0, i32 6
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = sub i32 24, %27
  %29 = lshr i32 %24, %28
  store i32 %29, ptr %10, align 4, !tbaa !14
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %30, i32 0, i32 8
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = load i32, ptr %10, align 4, !tbaa !14
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i32, ptr %9, align 4, !tbaa !14
  %36 = add i32 %35, 1
  store i32 %36, ptr %9, align 4, !tbaa !14
  %37 = zext i32 %35 to i64
  %38 = getelementptr inbounds float, ptr %34, i64 %37
  %39 = call i32 @firpfb_rrrf_execute(ptr noundef %32, i32 noundef %33, ptr noundef %38)
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %40, i32 0, i32 4
  %42 = load i32, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %43, i32 0, i32 5
  %45 = load i32, ptr %44, align 4, !tbaa !15
  %46 = add i32 %45, %42
  store i32 %46, ptr %44, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  br label %16, !llvm.loop !18

47:                                               ; preds = %16
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.resamp_rrrf_s, ptr %48, i32 0, i32 5
  %50 = load i32, ptr %49, align 4, !tbaa !15
  %51 = sub i32 %50, 16777216
  store i32 %51, ptr %49, align 4, !tbaa !15
  %52 = load i32, ptr %9, align 4, !tbaa !14
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %52, ptr %53, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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, !6, i64 32}
!12 = !{!"resamp_rrrf_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 = !{!13, !13, i64 0}
!15 = !{!12, !13, i64 20}
!16 = !{!12, !13, i64 24}
!17 = !{!12, !13, i64 16}
!18 = distinct !{!18, !19}
!19 = !{!"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_rrrf_push(ptr noundef, float noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @resamp_rrrf_execute(ptr nocapture noundef %0, 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_rrrf_push(ptr noundef %6, 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 ]
  %.015 = 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 %.015, 1
  %20 = zext i32 %.015 to i64
  %21 = getelementptr inbounds float, ptr %2, i64 %20
  %22 = tail call i32 @firpfb_rrrf_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"="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" }

!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_rrrf_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