; LLVM IR from jgaeddert/liquid-dsp :: src/equalization/src (equalizer_rrrf)

; 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_rrrf_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.12 = external hidden unnamed_addr constant [72 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 @eqlms_rrrf_push(ptr noundef, float noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqlms_rrrf_execute_block(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !5
  %14 = load i32, ptr %8, align 4, !tbaa !9
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %5
  %17 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 382, ptr noundef @.str.12, ptr noundef @.str.2)
  store i32 %17, ptr %6, align 4
  br label %56

18:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %12, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %52, %18
  %20 = load i32, ptr %12, align 4, !tbaa !9
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %55

23:                                               ; preds = %19
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = load i32, ptr %12, align 4, !tbaa !9
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %25, i64 %27
  %29 = load float, ptr %28, align 4, !tbaa !11
  %30 = call i32 @eqlms_rrrf_push(ptr noundef %24, float noundef %29)
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = call i32 @eqlms_rrrf_execute(ptr noundef %31, ptr noundef %13)
  %33 = load float, ptr %13, align 4, !tbaa !11
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  %35 = load i32, ptr %12, align 4, !tbaa !9
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  store float %33, ptr %37, align 4, !tbaa !11
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.eqlms_rrrf_s, ptr %38, i32 0, i32 5
  %40 = load i32, ptr %39, align 8, !tbaa !13
  %41 = load i32, ptr %8, align 4, !tbaa !9
  %42 = add i32 %40, %41
  %43 = sub i32 %42, 1
  %44 = load i32, ptr %8, align 4, !tbaa !9
  %45 = urem i32 %43, %44
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %51

47:                                               ; preds = %23
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load float, ptr %13, align 4, !tbaa !11
  %50 = call i32 @eqlms_rrrf_step_blind(ptr noundef %48, float noundef %49)
  br label %51

51:                                               ; preds = %47, %23
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = add i32 %53, 1
  store i32 %54, ptr %12, align 4, !tbaa !9
  br label %19, !llvm.loop !15

55:                                               ; preds = %19
  store i32 0, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  br label %56

56:                                               ; preds = %55, %16
  %57 = load i32, ptr %6, align 4
  ret i32 %57
}

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

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 }

!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, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 32}
!14 = !{!"eqlms_rrrf_s", !10, i64 0, !12, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48, !12, 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"

@.str = external hidden unnamed_addr constant [89 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [72 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 @eqlms_rrrf_push(ptr noundef, float noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @eqlms_rrrf_execute_block(ptr noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #2 {
  %6 = alloca float, align 4
  %7 = icmp eq i32 %1, 0
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 382, ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.2) #3
  br label %27

10:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %10
  %11 = getelementptr inbounds i8, ptr %0, i64 32
  %12 = add i32 %1, -1
  %wide.trip.count = zext i32 %3 to i64
  br label %13

13:                                               ; preds = %.lr.ph, %26
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %14 = getelementptr inbounds float, ptr %2, i64 %indvars.iv
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = call i32 @eqlms_rrrf_push(ptr noundef %0, float noundef %15)
  %17 = call i32 @eqlms_rrrf_execute(ptr noundef %0, ptr noundef nonnull %6)
  %18 = load float, ptr %6, align 4, !tbaa !5
  %19 = getelementptr inbounds float, ptr %4, i64 %indvars.iv
  store float %18, ptr %19, align 4, !tbaa !5
  %20 = load i32, ptr %11, align 8, !tbaa !9
  %21 = add i32 %12, %20
  %22 = urem i32 %21, %1
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %13
  %25 = call i32 @eqlms_rrrf_step_blind(ptr noundef nonnull %0, float noundef %18)
  br label %26

26:                                               ; preds = %13, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %13, !llvm.loop !13

._crit_edge:                                      ; preds = %26, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  br label %27

27:                                               ; preds = %._crit_edge, %8
  %.014 = phi i32 [ %9, %8 ], [ 0, %._crit_edge ]
  ret i32 %.014
}

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

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 }

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


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