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

; 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_crcf_s = type { ptr, ptr, ptr, i32, i32, i32, i32, ptr, ptr, ptr, i32, 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

declare i32 @dotprod_crcf_execute(ptr noundef, ptr noundef, ptr noundef) #1

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

13:                                               ; preds = %36, %3
  %14 = load i32, ptr %7, align 4, !tbaa !13
  %15 = icmp ugt i32 %14, 0
  br i1 %15, label %16, label %39

16:                                               ; preds = %13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  %20 = load i32, ptr %7, align 4, !tbaa !13
  %21 = sub i32 %20, 1
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds { float, float }, ptr %19, i64 %22
  %24 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 4
  %26 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  %27 = load float, ptr %26, align 4
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %28, i32 0, i32 2
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = load i32, ptr %7, align 4, !tbaa !13
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds { float, float }, ptr %30, i64 %32
  %34 = getelementptr inbounds { float, float }, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds { float, float }, ptr %33, i32 0, i32 1
  store float %25, ptr %34, align 4
  store float %27, ptr %35, align 4
  br label %36

36:                                               ; preds = %16
  %37 = load i32, ptr %7, align 4, !tbaa !13
  %38 = add i32 %37, -1
  store i32 %38, ptr %7, align 4, !tbaa !13
  br label %13, !llvm.loop !15

39:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %43, i32 0, i32 2
  %45 = load ptr, ptr %44, align 8, !tbaa !14
  %46 = getelementptr inbounds { float, float }, ptr %45, i64 1
  %47 = call i32 @dotprod_crcf_execute(ptr noundef %42, ptr noundef %46, ptr noundef %8)
  %48 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %49 = load float, ptr %48, align 4
  %50 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %51 = load float, ptr %50, align 4
  %52 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %53 = load float, ptr %52, align 4
  %54 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %55 = load float, ptr %54, align 4
  %56 = fsub float %49, %53
  %57 = fsub float %51, %55
  %58 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %59 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %56, ptr %58, align 4
  store float %57, ptr %59, align 4
  %60 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !14
  %67 = getelementptr inbounds { float, float }, ptr %66, i64 0
  %68 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 0
  %69 = getelementptr inbounds { float, float }, ptr %67, i32 0, i32 1
  store float %61, ptr %68, align 4
  store float %63, ptr %69, align 4
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %70, i32 0, i32 7
  %72 = load ptr, ptr %71, align 8, !tbaa !18
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %73, i32 0, i32 2
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = call i32 @dotprod_crcf_execute(ptr noundef %72, ptr noundef %75, ptr noundef %76)
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.iirfilt_crcf_s, ptr %78, i32 0, i32 11
  %80 = load float, ptr %79, align 4, !tbaa !19
  %81 = load ptr, ptr %6, align 8, !tbaa !5
  %82 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 0
  %83 = load float, ptr %82, align 4
  %84 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 1
  %85 = load float, ptr %84, align 4
  %86 = fmul float %83, %80
  %87 = fmul float %85, %80
  %88 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 0
  %89 = getelementptr inbounds { float, float }, ptr %81, i32 0, i32 1
  store float %86, ptr %88, align 4
  store float %87, ptr %89, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { 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 24}
!10 = !{!"iirfilt_crcf_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, !12, i64 68}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!10, !6, i64 48}
!18 = !{!10, !6, i64 40}
!19 = !{!10, !12, i64 68}


; 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @dotprod_crcf_execute(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @iirfilt_crcf_execute_norm(ptr nocapture noundef readonly %0, <2 x float> noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca { float, float }, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %.014 = add i32 %6, -1
  %.not15 = icmp eq i32 %.014, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = zext i32 %.014 to i64
  %xtraiter = and i32 %.014, 1
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.loopexit.unr-lcssa

.prol.loopexit.unr-lcssa:                         ; preds = %.lr.ph
  %9 = load ptr, ptr %7, align 8, !tbaa !12
  %10 = add i32 %6, -2
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds { float, float }, ptr %9, i64 %11
  %13 = getelementptr inbounds { float, float }, ptr %9, i64 %8
  %14 = load <2 x float>, ptr %12, align 4
  store <2 x float> %14, ptr %13, align 4
  %indvars.iv.next.prol = add nsw i64 %8, -1
  br label %.prol.loopexit

.prol.loopexit:                                   ; preds = %.prol.loopexit.unr-lcssa, %.lr.ph
  %indvars.iv.unr = phi i64 [ %8, %.lr.ph ], [ %indvars.iv.next.prol, %.prol.loopexit.unr-lcssa ]
  %.0.in16.unr = phi i32 [ %6, %.lr.ph ], [ %.014, %.prol.loopexit.unr-lcssa ]
  %15 = icmp eq i32 %6, 2
  br i1 %15, label %._crit_edge, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.prol.loopexit, %.lr.ph.new
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %.lr.ph.new ], [ %indvars.iv.unr, %.prol.loopexit ]
  %.0.in16 = phi i32 [ %29, %.lr.ph.new ], [ %.0.in16.unr, %.prol.loopexit ]
  %16 = load ptr, ptr %7, align 8, !tbaa !12
  %17 = add i32 %.0.in16, -2
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds { float, float }, ptr %16, i64 %18
  %20 = getelementptr inbounds { float, float }, ptr %16, i64 %indvars.iv
  %21 = load <2 x float>, ptr %19, align 4
  store <2 x float> %21, ptr %20, align 4
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %22 = load ptr, ptr %7, align 8, !tbaa !12
  %23 = add i64 %indvars.iv, 4294967294
  %24 = and i64 %23, 4294967295
  %25 = getelementptr inbounds { float, float }, ptr %22, i64 %24
  %26 = getelementptr inbounds { float, float }, ptr %22, i64 %indvars.iv.next
  %27 = load <2 x float>, ptr %25, align 4
  store <2 x float> %27, ptr %26, align 4
  %indvars.iv.next.1 = add nsw i64 %indvars.iv, -2
  %28 = and i64 %indvars.iv.next.1, 4294967295
  %.not.1 = icmp eq i64 %28, 0
  %29 = trunc nuw i64 %indvars.iv.next to i32
  br i1 %.not.1, label %._crit_edge, label %.lr.ph.new, !llvm.loop !13

._crit_edge:                                      ; preds = %.prol.loopexit, %.lr.ph.new, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %30 = getelementptr inbounds i8, ptr %0, i64 48
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %32 = getelementptr inbounds i8, ptr %0, i64 16
  %33 = load ptr, ptr %32, align 8, !tbaa !12
  %34 = getelementptr inbounds i8, ptr %33, i64 8
  %35 = call i32 @dotprod_crcf_execute(ptr noundef %31, ptr noundef nonnull %34, ptr noundef nonnull %4) #3
  %36 = load <2 x float>, ptr %4, align 8
  %37 = fsub <2 x float> %1, %36
  store <2 x float> %37, ptr %4, align 8
  %38 = load ptr, ptr %32, align 8, !tbaa !12
  store <2 x float> %37, ptr %38, align 4
  %39 = getelementptr inbounds i8, ptr %0, i64 40
  %40 = load ptr, ptr %39, align 8, !tbaa !16
  %41 = load ptr, ptr %32, align 8, !tbaa !12
  %42 = call i32 @dotprod_crcf_execute(ptr noundef %40, ptr noundef %41, ptr noundef %2) #3
  %43 = getelementptr inbounds i8, ptr %0, i64 68
  %44 = load float, ptr %43, align 4, !tbaa !17
  %45 = load <2 x float>, ptr %2, align 4
  %46 = insertelement <2 x float> poison, float %44, i64 0
  %47 = shufflevector <2 x float> %46, <2 x float> poison, <2 x i32> zeroinitializer
  %48 = fmul <2 x float> %47, %45
  store <2 x float> %48, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #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 #2 = { 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 #3 = { 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 24}
!6 = !{!"iirfilt_crcf_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, !11, 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 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!6, !7, i64 48}
!16 = !{!6, !7, i64 40}
!17 = !{!6, !11, i64 68}


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