; 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.firfilt_cccf_s = type { ptr, i32, ptr, ptr, { 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 ptr @firfilt_cccf_recreate(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %8 = load i32, ptr %6, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = icmp ne i32 %8, %11
  br i1 %12, label %13, label %37

13:                                               ; preds = %3
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %15, i32 0, i32 1
  store i32 %14, ptr %16, align 8, !tbaa !11
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %20, i32 0, i32 1
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = zext i32 %22 to i64
  %24 = mul i64 %23, 8
  %25 = call ptr @realloc(ptr noundef %19, i64 noundef %24) #5
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %26, i32 0, i32 0
  store ptr %25, ptr %27, align 8, !tbaa !13
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = call ptr @windowcf_recreate(ptr noundef %30, i32 noundef %33)
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %35, i32 0, i32 2
  store ptr %34, ptr %36, align 8, !tbaa !14
  br label %37

37:                                               ; preds = %13, %3
  %38 = load i32, ptr %6, align 4, !tbaa !9
  store i32 %38, ptr %7, align 4, !tbaa !9
  br label %39

39:                                               ; preds = %62, %37
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp ugt i32 %40, 0
  br i1 %41, label %42, label %65

42:                                               ; preds = %39
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = load i32, ptr %6, align 4, !tbaa !9
  %45 = load i32, ptr %7, align 4, !tbaa !9
  %46 = sub i32 %44, %45
  %47 = zext i32 %46 to i64
  %48 = getelementptr inbounds { float, float }, ptr %43, i64 %47
  %49 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 0
  %50 = load float, ptr %49, align 4
  %51 = getelementptr inbounds { float, float }, ptr %48, i32 0, i32 1
  %52 = load float, ptr %51, align 4
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %53, i32 0, i32 0
  %55 = load ptr, ptr %54, align 8, !tbaa !13
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = sub i32 %56, 1
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds { float, float }, ptr %55, i64 %58
  %60 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 0
  %61 = getelementptr inbounds { float, float }, ptr %59, i32 0, i32 1
  store float %50, ptr %60, align 4
  store float %52, ptr %61, align 4
  br label %62

62:                                               ; preds = %42
  %63 = load i32, ptr %7, align 4, !tbaa !9
  %64 = add i32 %63, -1
  store i32 %64, ptr %7, align 4, !tbaa !9
  br label %39, !llvm.loop !15

65:                                               ; preds = %39
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %66, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !17
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !13
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %72, i32 0, i32 1
  %74 = load i32, ptr %73, align 8, !tbaa !11
  %75 = call ptr @dotprod_cccf_recreate(ptr noundef %68, ptr noundef %71, i32 noundef %74)
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.firfilt_cccf_s, ptr %76, i32 0, i32 3
  store ptr %75, ptr %77, align 8, !tbaa !17
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret ptr %78
}

; Function Attrs: nounwind allocsize(1)
declare ptr @realloc(ptr noundef, i64 noundef) #2

declare ptr @windowcf_recreate(ptr noundef, i32 noundef) #3

declare ptr @dotprod_cccf_recreate(ptr noundef, ptr noundef, i32 noundef) #3

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 allocsize(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 #3 = { "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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(1) }

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


; 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 ptr @firfilt_cccf_recreate(ptr noundef returned %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %.not = icmp eq i32 %5, %2
  br i1 %.not, label %15, label %6

6:                                                ; preds = %3
  store i32 %2, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %0, align 8, !tbaa !11
  %8 = zext i32 %2 to i64
  %9 = shl nuw nsw i64 %8, 3
  %10 = tail call ptr @realloc(ptr noundef %7, i64 noundef %9) #3
  store ptr %10, ptr %0, align 8, !tbaa !11
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = load i32, ptr %4, align 8, !tbaa !5
  %14 = tail call ptr @windowcf_recreate(ptr noundef %12, i32 noundef %13) #4
  store ptr %14, ptr %11, align 8, !tbaa !12
  br label %15

15:                                               ; preds = %6, %3
  %.not2324 = icmp eq i32 %2, 0
  br i1 %.not2324, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %15
  %16 = zext i32 %2 to i64
  %xtraiter = and i64 %16, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader, %.lr.ph.prol
  %indvars.iv.prol = phi i64 [ %20, %.lr.ph.prol ], [ %16, %.lr.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader ]
  %17 = sub nuw nsw i64 %16, %indvars.iv.prol
  %18 = getelementptr inbounds { float, float }, ptr %1, i64 %17
  %19 = load ptr, ptr %0, align 8, !tbaa !11
  %20 = add nsw i64 %indvars.iv.prol, -1
  %21 = getelementptr inbounds { float, float }, ptr %19, i64 %20
  %22 = load <2 x float>, ptr %18, align 4
  store <2 x float> %22, ptr %21, align 4
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !13

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ %16, %.lr.ph.preheader ], [ %20, %.lr.ph.prol ]
  %23 = icmp ult i32 %2, 4
  br i1 %23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %indvars.iv = phi i64 [ %45, %.lr.ph ], [ %indvars.iv.unr, %.lr.ph.prol.loopexit ]
  %24 = sub nuw nsw i64 %16, %indvars.iv
  %25 = getelementptr inbounds { float, float }, ptr %1, i64 %24
  %26 = load ptr, ptr %0, align 8, !tbaa !11
  %27 = add nsw i64 %indvars.iv, -1
  %28 = getelementptr inbounds { float, float }, ptr %26, i64 %27
  %29 = load <2 x float>, ptr %25, align 4
  store <2 x float> %29, ptr %28, align 4
  %30 = sub nuw nsw i64 %16, %27
  %31 = getelementptr inbounds { float, float }, ptr %1, i64 %30
  %32 = load ptr, ptr %0, align 8, !tbaa !11
  %33 = add nsw i64 %indvars.iv, -2
  %34 = getelementptr inbounds { float, float }, ptr %32, i64 %33
  %35 = load <2 x float>, ptr %31, align 4
  store <2 x float> %35, ptr %34, align 4
  %36 = sub nuw nsw i64 %16, %33
  %37 = getelementptr inbounds { float, float }, ptr %1, i64 %36
  %38 = load ptr, ptr %0, align 8, !tbaa !11
  %39 = add nsw i64 %indvars.iv, -3
  %40 = getelementptr inbounds { float, float }, ptr %38, i64 %39
  %41 = load <2 x float>, ptr %37, align 4
  store <2 x float> %41, ptr %40, align 4
  %42 = sub nuw nsw i64 %16, %39
  %43 = getelementptr inbounds { float, float }, ptr %1, i64 %42
  %44 = load ptr, ptr %0, align 8, !tbaa !11
  %45 = add nsw i64 %indvars.iv, -4
  %46 = getelementptr inbounds { float, float }, ptr %44, i64 %45
  %47 = load <2 x float>, ptr %43, align 4
  store <2 x float> %47, ptr %46, align 4
  %.not23.wide.3 = icmp eq i64 %45, 0
  br i1 %.not23.wide.3, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %15
  %48 = getelementptr inbounds i8, ptr %0, i64 24
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = load ptr, ptr %0, align 8, !tbaa !11
  %51 = load i32, ptr %4, align 8, !tbaa !5
  %52 = tail call ptr @dotprod_cccf_recreate(ptr noundef %49, ptr noundef %50, i32 noundef %51) #4
  store ptr %52, ptr %48, align 8, !tbaa !17
  ret ptr %0
}

; Function Attrs: mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias noundef ptr @realloc(ptr allocptr nocapture noundef, i64 noundef) local_unnamed_addr #1

declare ptr @windowcf_recreate(ptr noundef, i32 noundef) local_unnamed_addr #2

declare ptr @dotprod_cccf_recreate(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

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" }
attributes #1 = { mustprogress nounwind willreturn allockind("realloc") allocsize(1) memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { "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 allocsize(1) }
attributes #4 = { 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 = !{!"firfilt_cccf_s", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 24, !8, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!6, !7, i64 24}


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