; LLVM IR from jgaeddert/liquid-dsp :: src/equalization/src (equalizer_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.eqlms_cccf_s = type { i32, float, ptr, ptr, ptr, i32, i32, ptr, ptr, float }

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1

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

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

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local void @eqlms_cccf_get_weights(ptr noundef, ptr noundef) #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqlms_cccf_train(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca { float, float }, align 4
  %16 = alloca { float, float }, align 4
  %17 = alloca { float, float }, align 4
  %18 = alloca { float, float }, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  store i32 %21, ptr %12, align 4, !tbaa !9
  %22 = load i32, ptr %11, align 4, !tbaa !9
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = icmp ult i32 %22, %25
  br i1 %26, label %27, label %29

27:                                               ; preds = %5
  %28 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 484, ptr noundef @.str.13, ptr noundef @.str.2)
  store i32 %28, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %106

29:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = call i32 @eqlms_cccf_reset(ptr noundef %30)
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %56, %29
  %33 = load i32, ptr %14, align 4, !tbaa !9
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %59

36:                                               ; preds = %32
  %37 = load ptr, ptr %8, align 8, !tbaa !5
  %38 = load i32, ptr %12, align 4, !tbaa !9
  %39 = load i32, ptr %14, align 4, !tbaa !9
  %40 = sub i32 %38, %39
  %41 = sub i32 %40, 1
  %42 = zext i32 %41 to i64
  %43 = getelementptr inbounds { float, float }, ptr %37, i64 %42
  %44 = getelementptr inbounds { float, float }, ptr %43, i32 0, i32 0
  %45 = load float, ptr %44, align 4
  %46 = getelementptr inbounds { float, float }, ptr %43, i32 0, i32 1
  %47 = load float, ptr %46, align 4
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.eqlms_cccf_s, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = load i32, ptr %14, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds { float, float }, ptr %50, i64 %52
  %54 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 0
  %55 = getelementptr inbounds { float, float }, ptr %53, i32 0, i32 1
  store float %45, ptr %54, align 4
  store float %47, ptr %55, align 4
  br label %56

56:                                               ; preds = %36
  %57 = load i32, ptr %14, align 4, !tbaa !9
  %58 = add i32 %57, 1
  store i32 %58, ptr %14, align 4, !tbaa !9
  br label %32, !llvm.loop !15

59:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %60

60:                                               ; preds = %100, %59
  %61 = load i32, ptr %14, align 4, !tbaa !9
  %62 = load i32, ptr %11, align 4, !tbaa !9
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %64, label %103

64:                                               ; preds = %60
  %65 = load ptr, ptr %7, align 8, !tbaa !5
  %66 = load ptr, ptr %9, align 8, !tbaa !5
  %67 = load i32, ptr %14, align 4, !tbaa !9
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds { float, float }, ptr %66, i64 %68
  %70 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 0
  %71 = load float, ptr %70, align 4
  %72 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 1
  %73 = load float, ptr %72, align 4
  %74 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %75 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  store float %71, ptr %74, align 4
  store float %73, ptr %75, align 4
  %76 = load <2 x float>, ptr %16, align 4
  %77 = call i32 @eqlms_cccf_push(ptr noundef %65, <2 x float> noundef %76)
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call i32 @eqlms_cccf_execute(ptr noundef %78, ptr noundef %15)
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i32, ptr %14, align 4, !tbaa !9
  %83 = zext i32 %82 to i64
  %84 = getelementptr inbounds { float, float }, ptr %81, i64 %83
  %85 = getelementptr inbounds { float, float }, ptr %84, i32 0, i32 0
  %86 = load float, ptr %85, align 4
  %87 = getelementptr inbounds { float, float }, ptr %84, i32 0, i32 1
  %88 = load float, ptr %87, align 4
  %89 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %90 = load float, ptr %89, align 4
  %91 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  %92 = load float, ptr %91, align 4
  %93 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 0
  %94 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 1
  store float %86, ptr %93, align 4
  store float %88, ptr %94, align 4
  %95 = load <2 x float>, ptr %17, align 4
  %96 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  store float %90, ptr %96, align 4
  store float %92, ptr %97, align 4
  %98 = load <2 x float>, ptr %18, align 4
  %99 = call i32 @eqlms_cccf_step(ptr noundef %80, <2 x float> noundef %95, <2 x float> noundef %98)
  br label %100

100:                                              ; preds = %64
  %101 = load i32, ptr %14, align 4, !tbaa !9
  %102 = add i32 %101, 1
  store i32 %102, ptr %14, align 4, !tbaa !9
  br label %60, !llvm.loop !17

103:                                              ; preds = %60
  %104 = load ptr, ptr %7, align 8, !tbaa !5
  %105 = load ptr, ptr %8, align 8, !tbaa !5
  call void @eqlms_cccf_get_weights(ptr noundef %104, ptr noundef %105)
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %106

106:                                              ; preds = %103, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %107 = load i32, ptr %6, align 4
  ret i32 %107
}

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 = { "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 }

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

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [58 x i8], align 1

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

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

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @eqlms_cccf_get_weights(ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqlms_cccf_train(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly %3, i32 noundef %4) local_unnamed_addr #3 {
  %6 = alloca { float, float }, align 8
  %7 = load i32, ptr %0, align 8, !tbaa !5
  %8 = icmp ugt i32 %7, %4
  br i1 %8, label %9, label %11

9:                                                ; preds = %5
  %10 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 484, ptr noundef nonnull @.str.13, ptr noundef nonnull @.str.2) #4
  br label %49

11:                                               ; preds = %5
  %12 = tail call i32 @eqlms_cccf_reset(ptr noundef nonnull %0)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %wide.trip.count = zext i32 %7 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %14 = icmp eq i32 %7, 1
  br i1 %14, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  br label %15

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

._crit_edge.loopexit.unr-lcssa:                   ; preds = %15, %.lr.ph
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next.1, %15 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %32 = trunc nuw i64 %indvars.iv.unr to i32
  %33 = xor i32 %32, -1
  %34 = add i32 %7, %33
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds { float, float }, ptr %1, i64 %35
  %37 = load ptr, ptr %13, align 8, !tbaa !12
  %38 = getelementptr inbounds { float, float }, ptr %37, i64 %indvars.iv.unr
  %39 = load <2 x float>, ptr %36, align 4
  store <2 x float> %39, ptr %38, align 4
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %.not37 = icmp eq i32 %4, 0
  br i1 %.not37, label %._crit_edge36, label %.lr.ph35

.lr.ph35:                                         ; preds = %._crit_edge
  %wide.trip.count42 = zext i32 %4 to i64
  br label %40

40:                                               ; preds = %.lr.ph35, %40
  %indvars.iv39 = phi i64 [ 0, %.lr.ph35 ], [ %indvars.iv.next40, %40 ]
  %41 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv39
  %42 = load <2 x float>, ptr %41, align 4
  %43 = call i32 @eqlms_cccf_push(ptr noundef nonnull %0, <2 x float> noundef %42)
  %44 = call i32 @eqlms_cccf_execute(ptr noundef nonnull %0, ptr noundef nonnull %6)
  %45 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv39
  %46 = load <2 x float>, ptr %45, align 4
  %47 = load <2 x float>, ptr %6, align 8
  %48 = call i32 @eqlms_cccf_step(ptr noundef nonnull %0, <2 x float> noundef %46, <2 x float> noundef %47)
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %._crit_edge36, label %40, !llvm.loop !15

._crit_edge36:                                    ; preds = %40, %._crit_edge
  call void @eqlms_cccf_get_weights(ptr noundef nonnull %0, ptr noundef %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %49

49:                                               ; preds = %._crit_edge36, %9
  %.029 = phi i32 [ %10, %9 ], [ 0, %._crit_edge36 ]
  ret i32 %.029
}

attributes #0 = { mustprogress 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 = { "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 }

!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, !7, i64 0}
!6 = !{!"eqlms_cccf_s", !7, i64 0, !10, i64 4, !11, i64 8, !11, i64 16, !11, i64 24, !7, i64 32, !7, i64 36, !11, i64 40, !11, i64 48, !10, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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