; 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 }

; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #1

declare i32 @windowcf_reset(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @eqrls_cccf_reset(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %5, i32 0, i32 13
  store i32 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %7

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

13:                                               ; preds = %7
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %14

14:                                               ; preds = %59, %13
  %15 = load i32, ptr %4, align 4, !tbaa !13
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !14
  %19 = icmp ult i32 %15, %18
  br i1 %19, label %20, label %62

20:                                               ; preds = %14
  %21 = load i32, ptr %3, align 4, !tbaa !13
  %22 = load i32, ptr %4, align 4, !tbaa !13
  %23 = icmp eq i32 %21, %22
  br i1 %23, label %24, label %43

24:                                               ; preds = %20
  %25 = load ptr, ptr %2, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %25, i32 0, i32 2
  %27 = load float, ptr %26, align 8, !tbaa !15
  %28 = fdiv float 1.000000e+00, %27
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %29, i32 0, i32 6
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !14
  %35 = load i32, ptr %3, align 4, !tbaa !13
  %36 = mul i32 %34, %35
  %37 = load i32, ptr %4, align 4, !tbaa !13
  %38 = add i32 %36, %37
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds { float, float }, ptr %31, i64 %39
  %41 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 0
  %42 = getelementptr inbounds { float, float }, ptr %40, i32 0, i32 1
  store float %28, ptr %41, align 4
  store float 0.000000e+00, ptr %42, align 4
  br label %58

43:                                               ; preds = %20
  %44 = load ptr, ptr %2, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %44, i32 0, i32 6
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 8, !tbaa !14
  %50 = load i32, ptr %3, align 4, !tbaa !13
  %51 = mul i32 %49, %50
  %52 = load i32, ptr %4, align 4, !tbaa !13
  %53 = add i32 %51, %52
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds { float, float }, ptr %46, i64 %54
  %56 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 0
  %57 = getelementptr inbounds { float, float }, ptr %55, i32 0, i32 1
  store float 0.000000e+00, ptr %56, align 4
  store float 0.000000e+00, ptr %57, align 4
  br label %58

58:                                               ; preds = %43, %24
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %4, align 4, !tbaa !13
  %61 = add i32 %60, 1
  store i32 %61, ptr %4, align 4, !tbaa !13
  br label %14, !llvm.loop !17

62:                                               ; preds = %14
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %3, align 4, !tbaa !13
  %65 = add i32 %64, 1
  store i32 %65, ptr %3, align 4, !tbaa !13
  br label %7, !llvm.loop !19

66:                                               ; preds = %7
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %67, i32 0, i32 4
  %69 = load ptr, ptr %68, align 8, !tbaa !20
  %70 = load ptr, ptr %2, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %70, i32 0, i32 3
  %72 = load ptr, ptr %71, align 8, !tbaa !21
  %73 = load ptr, ptr %2, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !14
  %76 = zext i32 %75 to i64
  %77 = mul i64 %76, 8
  call void @llvm.memmove.p0.p0.i64(ptr align 4 %69, ptr align 4 %72, i64 %77, i1 false)
  %78 = load ptr, ptr %2, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %78, i32 0, i32 14
  %80 = load ptr, ptr %79, align 8, !tbaa !22
  %81 = call i32 @windowcf_reset(ptr noundef %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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"="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 #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, !11, i64 96}
!10 = !{!"eqrls_cccf_s", !11, i64 0, !12, i64 4, !12, 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, !11, i64 96, !6, i64 104}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !12, i64 8}
!16 = !{!10, !6, i64 40}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!10, !6, i64 24}
!21 = !{!10, !6, i64 16}
!22 = !{!10, !6, i64 104}


; 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memmove.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1 immarg) #0

declare i32 @windowcf_reset(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @eqrls_cccf_reset(ptr nocapture noundef %0) local_unnamed_addr #2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 96
  store i32 0, ptr %2, align 8, !tbaa !5
  %3 = load i32, ptr %0, align 8, !tbaa !12
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %._crit_edge26, label %.preheader.preheader

.preheader.preheader:                             ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  br label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %._crit_edge, %.preheader.preheader
  %6 = phi i32 [ %22, %._crit_edge ], [ %3, %.preheader.preheader ]
  %.02125 = phi i32 [ %24, %._crit_edge ], [ 0, %.preheader.preheader ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %17
  %7 = phi i32 [ %22, %17 ], [ %6, %.lr.ph.preheader ]
  %.024 = phi i32 [ %21, %17 ], [ 0, %.lr.ph.preheader ]
  %8 = icmp eq i32 %.02125, %.024
  br i1 %8, label %9, label %14

9:                                                ; preds = %.lr.ph
  %10 = load float, ptr %5, align 8, !tbaa !13
  %11 = fdiv float 1.000000e+00, %10
  %12 = add i32 %7, 1
  %13 = mul i32 %12, %.02125
  br label %17

14:                                               ; preds = %.lr.ph
  %15 = mul i32 %7, %.02125
  %16 = add i32 %15, %.024
  br label %17

17:                                               ; preds = %9, %14
  %.sink36 = phi i32 [ %13, %9 ], [ %16, %14 ]
  %.sink32 = phi float [ %11, %9 ], [ 0.000000e+00, %14 ]
  %.sink = load ptr, ptr %4, align 8, !tbaa !14
  %18 = zext i32 %.sink36 to i64
  %19 = getelementptr inbounds { float, float }, ptr %.sink, i64 %18
  %20 = getelementptr inbounds i8, ptr %19, i64 4
  store float %.sink32, ptr %19, align 4
  store float 0.000000e+00, ptr %20, align 4
  %21 = add nuw i32 %.024, 1
  %22 = load i32, ptr %0, align 8, !tbaa !12
  %23 = icmp ult i32 %21, %22
  br i1 %23, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %17
  %24 = add nuw i32 %.02125, 1
  %25 = icmp ult i32 %24, %22
  br i1 %25, label %.lr.ph.preheader, label %._crit_edge26.loopexit29, !llvm.loop !17

._crit_edge26.loopexit29:                         ; preds = %._crit_edge
  %26 = zext i32 %22 to i64
  %27 = shl nuw nsw i64 %26, 3
  br label %._crit_edge26

._crit_edge26:                                    ; preds = %._crit_edge26.loopexit29, %1
  %.lcssa = phi i64 [ 0, %1 ], [ %27, %._crit_edge26.loopexit29 ]
  %28 = getelementptr inbounds i8, ptr %0, i64 24
  %29 = load ptr, ptr %28, align 8, !tbaa !19
  %30 = getelementptr inbounds i8, ptr %0, i64 16
  %31 = load ptr, ptr %30, align 8, !tbaa !20
  tail call void @llvm.memmove.p0.p0.i64(ptr align 4 %29, ptr align 4 %31, i64 %.lcssa, i1 false)
  %32 = getelementptr inbounds i8, ptr %0, i64 104
  %33 = load ptr, ptr %32, align 8, !tbaa !21
  %34 = tail call i32 @windowcf_reset(ptr noundef %33) #3
  ret i32 0
}

attributes #0 = { mustprogress nocallback nofree 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, !7, i64 96}
!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, !7, i64 0}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !11, i64 40}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16, !18}
!18 = !{!"llvm.loop.unswitch.partial.disable"}
!19 = !{!6, !11, i64 24}
!20 = !{!6, !11, i64 16}
!21 = !{!6, !11, i64 104}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass,TailCallElimPass