; 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
define dso_local i32 @resamp_cccf_get_num_output(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.resamp_cccf_s, ptr %8, i32 0, i32 5
  %10 = load i32, ptr %9, align 4, !tbaa !11
  store i32 %10, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %30, %2
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = icmp ult i32 %12, %13
  br i1 %14, label %15, label %33

15:                                               ; preds = %11
  br label %16

16:                                               ; preds = %19, %15
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = icmp ule i32 %17, 16777215
  br i1 %18, label %19, label %27

19:                                               ; preds = %16
  %20 = load i32, ptr %7, align 4, !tbaa !9
  %21 = add i32 %20, 1
  store i32 %21, ptr %7, align 4, !tbaa !9
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.resamp_cccf_s, ptr %22, i32 0, i32 4
  %24 = load i32, ptr %23, align 8, !tbaa !14
  %25 = load i32, ptr %5, align 4, !tbaa !9
  %26 = add i32 %25, %24
  store i32 %26, ptr %5, align 4, !tbaa !9
  br label %16, !llvm.loop !15

27:                                               ; preds = %16
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = sub i32 %28, 16777216
  store i32 %29, ptr %5, align 4, !tbaa !9
  br label %30

30:                                               ; preds = %27
  %31 = load i32, ptr %6, align 4, !tbaa !9
  %32 = add i32 %31, 1
  store i32 %32, ptr %6, align 4, !tbaa !9
  br label %11, !llvm.loop !17

33:                                               ; preds = %11
  %34 = load i32, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret i32 %34
}

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 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 20}
!12 = !{!"resamp_cccf_s", !10, i64 0, !13, i64 4, !13, i64 8, !13, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


; 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: nofree norecurse nosync nounwind memory(argmem: read) uwtable
define dso_local i32 @resamp_cccf_get_num_output(ptr nocapture noundef readonly %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge18, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %2
  %3 = getelementptr inbounds i8, ptr %0, i64 20
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %xtraiter = and i32 %1, 1
  %6 = icmp eq i32 %1, 1
  br i1 %6, label %._crit_edge18.loopexit.unr-lcssa, label %.preheader.lr.ph.new

.preheader.lr.ph.new:                             ; preds = %.preheader.lr.ph
  %unroll_iter = and i32 %1, -2
  br label %.preheader

.preheader:                                       ; preds = %._crit_edge.1, %.preheader.lr.ph.new
  %.017 = phi i32 [ 0, %.preheader.lr.ph.new ], [ %.1.lcssa.1, %._crit_edge.1 ]
  %.01015 = phi i32 [ %4, %.preheader.lr.ph.new ], [ %20, %._crit_edge.1 ]
  %niter = phi i32 [ 0, %.preheader.lr.ph.new ], [ %niter.next.1, %._crit_edge.1 ]
  %7 = icmp ult i32 %.01015, 16777216
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %8 = load i32, ptr %5, align 8, !tbaa !12
  br label %9

9:                                                ; preds = %.lr.ph, %9
  %.113 = phi i32 [ %.017, %.lr.ph ], [ %10, %9 ]
  %.11112 = phi i32 [ %.01015, %.lr.ph ], [ %11, %9 ]
  %10 = add i32 %.113, 1
  %11 = add i32 %8, %.11112
  %12 = icmp ult i32 %11, 16777216
  br i1 %12, label %9, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %9, %.preheader
  %.111.lcssa = phi i32 [ %.01015, %.preheader ], [ %11, %9 ]
  %.1.lcssa = phi i32 [ %.017, %.preheader ], [ %10, %9 ]
  %13 = add i32 %.111.lcssa, -16777216
  %14 = icmp ult i32 %13, 16777216
  br i1 %14, label %.lr.ph.1, label %._crit_edge.1

.lr.ph.1:                                         ; preds = %._crit_edge
  %15 = load i32, ptr %5, align 8, !tbaa !12
  br label %16

16:                                               ; preds = %16, %.lr.ph.1
  %.113.1 = phi i32 [ %.1.lcssa, %.lr.ph.1 ], [ %17, %16 ]
  %.11112.1 = phi i32 [ %13, %.lr.ph.1 ], [ %18, %16 ]
  %17 = add i32 %.113.1, 1
  %18 = add i32 %15, %.11112.1
  %19 = icmp ult i32 %18, 16777216
  br i1 %19, label %16, label %._crit_edge.1, !llvm.loop !13

._crit_edge.1:                                    ; preds = %16, %._crit_edge
  %.111.lcssa.1 = phi i32 [ %13, %._crit_edge ], [ %18, %16 ]
  %.1.lcssa.1 = phi i32 [ %.1.lcssa, %._crit_edge ], [ %17, %16 ]
  %20 = add i32 %.111.lcssa.1, -16777216
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge18.loopexit.unr-lcssa, label %.preheader, !llvm.loop !15

._crit_edge18.loopexit.unr-lcssa:                 ; preds = %._crit_edge.1, %.preheader.lr.ph
  %.1.lcssa.lcssa.ph = phi i32 [ poison, %.preheader.lr.ph ], [ %.1.lcssa.1, %._crit_edge.1 ]
  %.017.unr = phi i32 [ 0, %.preheader.lr.ph ], [ %.1.lcssa.1, %._crit_edge.1 ]
  %.01015.unr = phi i32 [ %4, %.preheader.lr.ph ], [ %20, %._crit_edge.1 ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge18, label %.preheader.epil

.preheader.epil:                                  ; preds = %._crit_edge18.loopexit.unr-lcssa
  %21 = icmp ult i32 %.01015.unr, 16777216
  br i1 %21, label %.lr.ph.epil, label %._crit_edge18

.lr.ph.epil:                                      ; preds = %.preheader.epil
  %22 = load i32, ptr %5, align 8, !tbaa !12
  br label %23

23:                                               ; preds = %23, %.lr.ph.epil
  %.113.epil = phi i32 [ %.017.unr, %.lr.ph.epil ], [ %24, %23 ]
  %.11112.epil = phi i32 [ %.01015.unr, %.lr.ph.epil ], [ %25, %23 ]
  %24 = add i32 %.113.epil, 1
  %25 = add i32 %22, %.11112.epil
  %26 = icmp ult i32 %25, 16777216
  br i1 %26, label %23, label %._crit_edge18, !llvm.loop !13

._crit_edge18:                                    ; preds = %._crit_edge18.loopexit.unr-lcssa, %23, %.preheader.epil, %2
  %.0.lcssa = phi i32 [ 0, %2 ], [ %.1.lcssa.lcssa.ph, %._crit_edge18.loopexit.unr-lcssa ], [ %.017.unr, %.preheader.epil ], [ %24, %23 ]
  ret i32 %.0.lcssa
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: read) 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, !7, i64 20}
!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 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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