; LLVM IR from jgaeddert/liquid-dsp :: src/channel/src (channel_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.tvmpch_cccf_s = type { ptr, i32, ptr, 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

declare float @randnf(...) #1

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

7:                                                ; preds = %63, %2
  %8 = load i32, ptr %5, align 4, !tbaa !9
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %9, i32 0, i32 1
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = sub i32 %11, 1
  %13 = icmp ult i32 %8, %12
  br i1 %13, label %14, label %66

14:                                               ; preds = %7
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %15, i32 0, i32 4
  %17 = load float, ptr %16, align 4, !tbaa !14
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !15
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds { float, float }, ptr %20, 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 = fmul float %17, %25
  %29 = fmul float %17, %27
  %30 = fpext float %28 to double
  %31 = fpext float %29 to double
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %32, i32 0, i32 5
  %34 = load float, ptr %33, align 8, !tbaa !16
  %35 = call float (...) @randnf()
  %36 = call float (...) @randnf()
  %37 = fmul float 0.000000e+00, %36
  %38 = fmul float 1.000000e+00, %36
  %39 = fadd float %35, %37
  %40 = fmul float %34, %39
  %41 = fmul float %34, %38
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %42, i32 0, i32 3
  %44 = load float, ptr %43, align 8, !tbaa !17
  %45 = fmul float %40, %44
  %46 = fmul float %41, %44
  %47 = fpext float %45 to double
  %48 = fpext float %46 to double
  %49 = fmul double %47, 0x3FE6A09E667F3BCD
  %50 = fmul double %48, 0x3FE6A09E667F3BCD
  %51 = fadd double %30, %49
  %52 = fadd double %31, %50
  %53 = fptrunc double %51 to float
  %54 = fptrunc double %52 to float
  %55 = load ptr, ptr %4, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = load i32, ptr %5, align 4, !tbaa !9
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds { float, float }, ptr %57, i64 %59
  %61 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 1
  store float %53, ptr %61, align 4
  store float %54, ptr %62, align 4
  br label %63

63:                                               ; preds = %14
  %64 = load i32, ptr %5, align 4, !tbaa !9
  %65 = add i32 %64, 1
  store i32 %65, ptr %5, align 4, !tbaa !9
  br label %7, !llvm.loop !18

66:                                               ; preds = %7
  %67 = load ptr, ptr %4, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.tvmpch_cccf_s, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !20
  %70 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 0
  %71 = load float, ptr %70, align 4
  %72 = getelementptr inbounds { float, float }, ptr %3, i32 0, i32 1
  %73 = load float, ptr %72, align 4
  %74 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %75 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %71, ptr %74, align 4
  store float %73, ptr %75, align 4
  %76 = load <2 x float>, ptr %6, align 4
  %77 = call i32 @windowcf_push(ptr noundef %69, <2 x float> noundef %76)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret i32 0
}

declare i32 @windowcf_push(ptr noundef, <2 x float> noundef) #1

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

declare float @randnf(...) local_unnamed_addr #0

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

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 28
  %6 = getelementptr inbounds i8, ptr %0, i64 32
  %7 = getelementptr inbounds i8, ptr %0, i64 24
  br label %8

8:                                                ; preds = %.lr.ph, %8
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %8 ]
  %9 = load float, ptr %5, align 4, !tbaa !12
  %10 = load ptr, ptr %0, align 8, !tbaa !13
  %11 = getelementptr inbounds { float, float }, ptr %10, i64 %indvars.iv
  %12 = load float, ptr %6, align 8, !tbaa !14
  %13 = load <2 x float>, ptr %11, align 4
  %14 = insertelement <2 x float> poison, float %9, i64 0
  %15 = shufflevector <2 x float> %14, <2 x float> poison, <2 x i32> zeroinitializer
  %16 = fmul <2 x float> %15, %13
  %17 = fpext <2 x float> %16 to <2 x double>
  %18 = tail call float (...) @randnf() #2
  %19 = tail call float (...) @randnf() #2
  %20 = fmul float %19, 0.000000e+00
  %21 = fadd float %18, %20
  %22 = insertelement <2 x float> poison, float %12, i64 0
  %23 = shufflevector <2 x float> %22, <2 x float> poison, <2 x i32> zeroinitializer
  %24 = insertelement <2 x float> poison, float %21, i64 0
  %25 = insertelement <2 x float> %24, float %19, i64 1
  %26 = fmul <2 x float> %23, %25
  %27 = load float, ptr %7, align 8, !tbaa !15
  %28 = insertelement <2 x float> poison, float %27, i64 0
  %29 = shufflevector <2 x float> %28, <2 x float> poison, <2 x i32> zeroinitializer
  %30 = fmul <2 x float> %29, %26
  %31 = fpext <2 x float> %30 to <2 x double>
  %32 = fmul <2 x double> %31, <double 0x3FE6A09E667F3BCD, double 0x3FE6A09E667F3BCD>
  %33 = fadd <2 x double> %32, %17
  %34 = fptrunc <2 x double> %33 to <2 x float>
  %35 = load ptr, ptr %0, align 8, !tbaa !13
  %36 = getelementptr inbounds { float, float }, ptr %35, i64 %indvars.iv
  store <2 x float> %34, ptr %36, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %37 = load i32, ptr %3, align 8, !tbaa !5
  %38 = add i32 %37, -1
  %39 = zext i32 %38 to i64
  %40 = icmp ult i64 %indvars.iv.next, %39
  br i1 %40, label %8, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %8, %2
  %41 = getelementptr inbounds i8, ptr %0, i64 16
  %42 = load ptr, ptr %41, align 8, !tbaa !18
  %43 = tail call i32 @windowcf_push(ptr noundef %42, <2 x float> noundef %1) #2
  ret i32 0
}

declare i32 @windowcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #0

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


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