; 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.eqrls_cccf_s = type { i32, float, float, ptr, ptr, ptr, ptr, ptr, ptr, ptr, { float, float }, ptr, ptr, i32, ptr }

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = 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: 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, ...) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @eqrls_cccf_reset(ptr noundef) #2

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqrls_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 { float, float }, align 4
  %15 = alloca { float, float }, align 4
  %16 = alloca { float, float }, align 4
  %17 = 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
  %18 = load i32, ptr %11, align 4, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = icmp ult i32 %18, %21
  br i1 %22, label %23, label %25

23:                                               ; preds = %5
  %24 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 4, ptr noundef @.str.14, i32 noundef 390, ptr noundef @.str.18, ptr noundef @.str.2)
  store i32 %24, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %107

25:                                               ; preds = %5
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = call i32 @eqrls_cccf_reset(ptr noundef %26)
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %56, %25
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !11
  %33 = icmp ult i32 %29, %32
  br i1 %33, label %34, label %59

34:                                               ; preds = %28
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 8, !tbaa !11
  %39 = load i32, ptr %12, 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 %35, 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.eqrls_cccf_s, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !14
  %51 = load i32, ptr %12, 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 = %34
  %57 = load i32, ptr %12, align 4, !tbaa !9
  %58 = add i32 %57, 1
  store i32 %58, ptr %12, align 4, !tbaa !9
  br label %28, !llvm.loop !15

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

60:                                               ; preds = %100, %59
  %61 = load i32, ptr %12, 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 %12, 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 %15, i32 0, i32 0
  %75 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  store float %71, ptr %74, align 4
  store float %73, ptr %75, align 4
  %76 = load <2 x float>, ptr %15, align 4
  %77 = call i32 @eqrls_cccf_push(ptr noundef %65, <2 x float> noundef %76)
  %78 = load ptr, ptr %7, align 8, !tbaa !5
  %79 = call i32 @eqrls_cccf_execute(ptr noundef %78, ptr noundef %14)
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = load ptr, ptr %10, align 8, !tbaa !5
  %82 = load i32, ptr %12, 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 %14, i32 0, i32 0
  %90 = load float, ptr %89, align 4
  %91 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  %92 = load float, ptr %91, align 4
  %93 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %94 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  store float %86, ptr %93, align 4
  store float %88, ptr %94, align 4
  %95 = load <2 x float>, ptr %16, align 4
  %96 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 0
  %97 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 1
  store float %90, ptr %96, align 4
  store float %92, ptr %97, align 4
  %98 = load <2 x float>, ptr %17, align 4
  %99 = call i32 @eqrls_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 %12, align 4, !tbaa !9
  %102 = add i32 %101, 1
  store i32 %102, ptr %12, 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
  %106 = call i32 @eqrls_cccf_get_weights(ptr noundef %104, ptr noundef %105)
  store i32 %106, ptr %6, align 4
  store i32 1, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %107

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

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

!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 = !{!"eqrls_cccf_s", !10, i64 0, !13, i64 4, !13, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !7, i64 72, !6, i64 80, !6, i64 88, !10, i64 96, !6, i64 104}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 24}
!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.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [89 x i8], align 1
@.str.18 = 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: 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 #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqrls_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 4, ptr noundef nonnull @.str.14, i32 noundef 390, ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.2) #4
  br label %38

11:                                               ; preds = %5
  %12 = tail call i32 @eqrls_cccf_reset(ptr noundef nonnull %0)
  %13 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  br label %15

15:                                               ; preds = %.lr.ph, %15
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %15 ]
  %16 = phi i32 [ %13, %.lr.ph ], [ %25, %15 ]
  %17 = trunc nuw i64 %indvars.iv to i32
  %18 = xor i32 %17, -1
  %19 = add i32 %16, %18
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds { float, float }, ptr %1, i64 %20
  %22 = load ptr, ptr %14, align 8, !tbaa !12
  %23 = getelementptr inbounds { float, float }, ptr %22, i64 %indvars.iv
  %24 = load <2 x float>, ptr %21, align 4
  store <2 x float> %24, ptr %23, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr %0, align 8, !tbaa !5
  %26 = zext i32 %25 to i64
  %27 = icmp ult i64 %indvars.iv.next, %26
  br i1 %27, label %15, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %15, %11
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #4
  %.not36 = icmp eq i32 %4, 0
  br i1 %.not36, label %._crit_edge35, label %.lr.ph34

.lr.ph34:                                         ; preds = %._crit_edge
  %wide.trip.count = zext i32 %4 to i64
  br label %28

28:                                               ; preds = %.lr.ph34, %28
  %indvars.iv38 = phi i64 [ 0, %.lr.ph34 ], [ %indvars.iv.next39, %28 ]
  %29 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv38
  %30 = load <2 x float>, ptr %29, align 4
  %31 = call i32 @eqrls_cccf_push(ptr noundef nonnull %0, <2 x float> noundef %30)
  %32 = call i32 @eqrls_cccf_execute(ptr noundef nonnull %0, ptr noundef nonnull %6)
  %33 = getelementptr inbounds { float, float }, ptr %3, i64 %indvars.iv38
  %34 = load <2 x float>, ptr %33, align 4
  %35 = load <2 x float>, ptr %6, align 8
  %36 = call i32 @eqrls_cccf_step(ptr noundef nonnull %0, <2 x float> noundef %34, <2 x float> noundef %35)
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next39, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge35, label %28, !llvm.loop !15

._crit_edge35:                                    ; preds = %28, %._crit_edge
  %37 = call i32 @eqrls_cccf_get_weights(ptr noundef nonnull %0, ptr noundef %1)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #4
  br label %38

38:                                               ; preds = %._crit_edge35, %9
  %.028 = phi i32 [ %10, %9 ], [ %37, %._crit_edge35 ]
  ret i32 %.028
}

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

!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 = !{!"eqrls_cccf_s", !7, i64 0, !10, i64 4, !10, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56, !11, i64 64, !8, i64 72, !11, i64 80, !11, i64 88, !7, i64 96, !11, i64 104}
!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 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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