; LLVM IR from jgaeddert/liquid-dsp :: src/nco/src (nco_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.synth_crcf_s = type { float, float, ptr, i32, i32, float, { float, float }, { float, float }, { float, float }, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
declare dso_local void @synth_crcf_step(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local void @synth_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) #3

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

16:                                               ; preds = %72, %3
  %17 = load i32, ptr %9, align 4, !tbaa !11
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.synth_crcf_s, ptr %18, i32 0, i32 4
  %20 = load i32, ptr %19, align 4, !tbaa !13
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %22, label %75

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = load i32, ptr %9, align 4, !tbaa !11
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds { float, float }, ptr %24, i64 %26
  %28 = getelementptr inbounds { float, float }, ptr %27, i32 0, i32 0
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %27, i32 0, i32 1
  %31 = load float, ptr %30, align 4
  %32 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %33 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  store float %29, ptr %32, align 4
  store float %31, ptr %33, align 4
  %34 = load <2 x float>, ptr %11, align 4
  call void @synth_crcf_mix_down(ptr noundef %23, <2 x float> noundef %34, ptr noundef %10)
  %35 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %36 = load float, ptr %35, align 4
  %37 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %38 = load float, ptr %37, align 4
  %39 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %40 = load float, ptr %39, align 4
  %41 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %42 = load float, ptr %41, align 4
  %43 = fadd float %40, %36
  %44 = fadd float %42, %38
  %45 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %46 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  store float %43, ptr %45, align 4
  store float %44, ptr %46, align 4
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !11
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds { float, float }, ptr %47, i64 %49
  %51 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 0
  %52 = load float, ptr %51, align 4
  %53 = getelementptr inbounds { float, float }, ptr %50, i32 0, i32 1
  %54 = load float, ptr %53, align 4
  %55 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %56 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  store float %52, ptr %55, align 4
  store float %54, ptr %56, align 4
  %57 = load <2 x float>, ptr %12, align 4
  %58 = call float @cabsf(<2 x float> noundef %57) #5
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.synth_crcf_s, ptr %59, i32 0, i32 7
  %61 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 0
  %62 = load float, ptr %61, align 4
  %63 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 1
  %64 = load float, ptr %63, align 4
  %65 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %66 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  store float %62, ptr %65, align 4
  store float %64, ptr %66, align 4
  %67 = load <2 x float>, ptr %13, align 4
  %68 = call float @cabsf(<2 x float> noundef %67) #5
  %69 = load float, ptr %8, align 4, !tbaa !9
  %70 = call float @llvm.fmuladd.f32(float %58, float %68, float %69)
  store float %70, ptr %8, align 4, !tbaa !9
  %71 = load ptr, ptr %4, align 8, !tbaa !5
  call void @synth_crcf_step(ptr noundef %71)
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %72

72:                                               ; preds = %22
  %73 = load i32, ptr %9, align 4, !tbaa !11
  %74 = add i32 %73, 1
  store i32 %74, ptr %9, align 4, !tbaa !11
  br label %16, !llvm.loop !15

75:                                               ; preds = %16
  %76 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %77 = load float, ptr %76, align 4
  %78 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %79 = load float, ptr %78, align 4
  %80 = load float, ptr %8, align 4, !tbaa !9
  %81 = fdiv float %77, %80
  %82 = fdiv float %79, %80
  %83 = load ptr, ptr %6, align 8, !tbaa !5
  %84 = getelementptr inbounds { float, float }, ptr %83, i32 0, i32 0
  %85 = getelementptr inbounds { float, float }, ptr %83, i32 0, i32 1
  store float %81, ptr %84, align 4
  store float %82, ptr %85, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { nounwind "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 #5 = { 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, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 20}
!14 = !{!"synth_crcf_s", !10, i64 0, !10, i64 4, !6, i64 8, !12, i64 16, !12, i64 20, !10, i64 24, !7, i64 28, !7, i64 36, !7, i64 44, !10, i64 52, !10, i64 56}
!15 = distinct !{!15, !16}
!16 = !{!"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: 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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: nounwind uwtable
declare dso_local void @synth_crcf_step(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @synth_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @synth_crcf_despread(ptr noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #3 {
  %4 = alloca { float, float }, align 8
  %5 = getelementptr inbounds i8, ptr %0, i64 20
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 36
  br label %8

8:                                                ; preds = %.lr.ph, %8
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %8 ]
  %.02023 = phi float [ 0.000000e+00, %.lr.ph ], [ %18, %8 ]
  %9 = phi <2 x float> [ zeroinitializer, %.lr.ph ], [ %13, %8 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %10 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %11 = load <2 x float>, ptr %10, align 4
  call void @synth_crcf_mix_down(ptr noundef nonnull %0, <2 x float> noundef %11, ptr noundef nonnull %4)
  %12 = load <2 x float>, ptr %4, align 8
  %13 = fadd <2 x float> %9, %12
  %14 = load <2 x float>, ptr %10, align 4
  %15 = call float @cabsf(<2 x float> noundef %14) #5
  %16 = load <2 x float>, ptr %7, align 4
  %17 = call float @cabsf(<2 x float> noundef %16) #5
  %18 = call float @llvm.fmuladd.f32(float %15, float %17, float %.02023)
  call void @synth_crcf_step(ptr noundef nonnull %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = zext i32 %19 to i64
  %21 = icmp ult i64 %indvars.iv.next, %20
  br i1 %21, label %8, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %8, %3
  %.020.lcssa = phi float [ 0.000000e+00, %3 ], [ %18, %8 ]
  %22 = phi <2 x float> [ zeroinitializer, %3 ], [ %13, %8 ]
  %23 = insertelement <2 x float> poison, float %.020.lcssa, i64 0
  %24 = shufflevector <2 x float> %23, <2 x float> poison, <2 x i32> zeroinitializer
  %25 = fdiv <2 x float> %22, %24
  store <2 x float> %25, ptr %2, align 4
  ret void
}

; Function Attrs: nounwind
declare float @cabsf(<2 x float> noundef) local_unnamed_addr #4

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #3 = { 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 #4 = { nounwind "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 #5 = { 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, !11, i64 20}
!6 = !{!"synth_crcf_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 16, !11, i64 20, !7, i64 24, !8, i64 28, !8, i64 36, !8, i64 44, !7, i64 52, !7, i64 56}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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