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

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

8:                                                ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %9

9:                                                ; preds = %24, %8
  %10 = load i32, ptr %3, align 4, !tbaa !12
  %11 = load ptr, ptr %2, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.iirfilt_cccf_s, ptr %11, i32 0, i32 10
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = icmp ult i32 %10, %13
  br i1 %14, label %15, label %27

15:                                               ; preds = %9
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.iirfilt_cccf_s, ptr %16, i32 0, i32 9
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  %19 = load i32, ptr %3, align 4, !tbaa !12
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds ptr, ptr %18, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !5
  %23 = call i32 @iirfiltsos_cccf_reset(ptr noundef %22)
  br label %24

24:                                               ; preds = %15
  %25 = load i32, ptr %3, align 4, !tbaa !12
  %26 = add i32 %25, 1
  store i32 %26, ptr %3, align 4, !tbaa !12
  br label %9, !llvm.loop !15

27:                                               ; preds = %9
  br label %48

28:                                               ; preds = %1
  store i32 0, ptr %3, align 4, !tbaa !12
  br label %29

29:                                               ; preds = %44, %28
  %30 = load i32, ptr %3, align 4, !tbaa !12
  %31 = load ptr, ptr %2, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.iirfilt_cccf_s, ptr %31, i32 0, i32 3
  %33 = load i32, ptr %32, align 8, !tbaa !17
  %34 = icmp ult i32 %30, %33
  br i1 %34, label %35, label %47

35:                                               ; preds = %29
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.iirfilt_cccf_s, ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !18
  %39 = load i32, ptr %3, align 4, !tbaa !12
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds { float, float }, ptr %38, i64 %40
  %42 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 1
  store float 0.000000e+00, ptr %42, align 4
  store float 0.000000e+00, ptr %43, align 4
  br label %44

44:                                               ; preds = %35
  %45 = load i32, ptr %3, align 4, !tbaa !12
  %46 = add i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !12
  br label %29, !llvm.loop !19

47:                                               ; preds = %29
  br label %48

48:                                               ; preds = %47, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 0
}

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

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, !11, i64 36}
!10 = !{!"iirfilt_cccf_s", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !6, i64 40, !6, i64 48, !6, i64 56, !11, i64 64, !7, i64 68}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!10, !11, i64 64}
!14 = !{!10, !6, i64 56}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !11, i64 24}
!18 = !{!10, !6, i64 16}
!19 = distinct !{!19, !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: nounwind uwtable
define dso_local noundef i32 @iirfilt_cccf_reset(ptr nocapture noundef readonly %0) local_unnamed_addr #0 {
  %2 = getelementptr inbounds i8, ptr %0, i64 36
  %3 = load i32, ptr %2, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %.preheader, label %.preheader10

.preheader10:                                     ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader10
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  br label %19

.preheader:                                       ; preds = %1
  %8 = getelementptr inbounds i8, ptr %0, i64 64
  %9 = load i32, ptr %8, align 8, !tbaa !12
  %.not15 = icmp eq i32 %9, 0
  br i1 %.not15, label %.loopexit, label %.lr.ph14

.lr.ph14:                                         ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  br label %11

11:                                               ; preds = %.lr.ph14, %11
  %indvars.iv18 = phi i64 [ 0, %.lr.ph14 ], [ %indvars.iv.next19, %11 ]
  %12 = load ptr, ptr %10, align 8, !tbaa !13
  %13 = getelementptr inbounds ptr, ptr %12, i64 %indvars.iv18
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = tail call i32 @iirfiltsos_cccf_reset(ptr noundef %14)
  %indvars.iv.next19 = add nuw nsw i64 %indvars.iv18, 1
  %16 = load i32, ptr %8, align 8, !tbaa !12
  %17 = zext i32 %16 to i64
  %18 = icmp ult i64 %indvars.iv.next19, %17
  br i1 %18, label %11, label %.loopexit, !llvm.loop !15

19:                                               ; preds = %.lr.ph, %19
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %19 ]
  %20 = load ptr, ptr %7, align 8, !tbaa !17
  %21 = getelementptr inbounds { float, float }, ptr %20, i64 %indvars.iv
  store <2 x float> zeroinitializer, ptr %21, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %22 = load i32, ptr %5, align 8, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = icmp ult i64 %indvars.iv.next, %23
  br i1 %24, label %19, label %.loopexit, !llvm.loop !18

.loopexit:                                        ; preds = %19, %11, %.preheader10, %.preheader
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @iirfiltsos_cccf_reset(ptr noundef) local_unnamed_addr #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, !10, i64 36}
!6 = !{!"iirfilt_cccf_s", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !7, i64 40, !7, i64 48, !7, i64 56, !10, i64 64, !8, i64 68}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !10, i64 64}
!13 = !{!6, !7, i64 56}
!14 = !{!7, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !7, i64 16}
!18 = distinct !{!18, !16}


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