; LLVM IR from suxiaojack/sapDecoder :: src/equalizer.ll (ZN9Equalizer9EqzPresetEi)

; 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.eqz_preset_t = type { [16 x i8], i32, float, [10 x float] }
%class.Equalizer = type { ptr }
%struct.eq_param_t = type { i32, ptr, ptr, ptr, ptr, float, [32 x [2 x float]], [32 x [128 x [2 x float]]], [32 x [2 x float]], [32 x [128 x [2 x float]]], i32 }

@_ZL14eqz_preset_10b = external hidden constant [3 x %struct.eqz_preset_t], align 16

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN9Equalizer9EqzPresetEi(ptr noundef nonnull align 8 dereferenceable(8) %0, i32 noundef %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %7 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store ptr null, ptr %6, align 8, !tbaa !5
  %8 = load i32, ptr %4, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds %struct.eqz_preset_t, ptr @_ZL14eqz_preset_10b, i64 %9
  store ptr %10, ptr %6, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.eqz_preset_t, ptr %11, i32 0, i32 2
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = getelementptr inbounds %class.Equalizer, ptr %7, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds %struct.eq_param_t, ptr %15, i32 0, i32 5
  store float %13, ptr %16, align 8, !tbaa !16
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %38, %2
  %18 = load i32, ptr %5, align 4, !tbaa !9
  %19 = getelementptr inbounds %class.Equalizer, ptr %7, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !14
  %21 = getelementptr inbounds %struct.eq_param_t, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !18
  %23 = icmp slt i32 %18, %22
  br i1 %23, label %24, label %41

24:                                               ; preds = %17
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.eqz_preset_t, ptr %25, i32 0, i32 3
  %27 = load i32, ptr %5, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [10 x float], ptr %26, i64 0, i64 %28
  %30 = load float, ptr %29, align 4, !tbaa !19
  %31 = getelementptr inbounds %class.Equalizer, ptr %7, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = getelementptr inbounds %struct.eq_param_t, ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %34, i64 %36
  store float %30, ptr %37, align 4, !tbaa !19
  br label %38

38:                                               ; preds = %24
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %5, align 4, !tbaa !9
  br label %17, !llvm.loop !21

41:                                               ; preds = %17
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 20}
!12 = !{!"_ZTS12eqz_preset_t", !7, i64 0, !10, i64 16, !13, i64 20, !7, i64 24}
!13 = !{!"float", !7, i64 0}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS9Equalizer", !6, i64 0}
!16 = !{!17, !13, i64 40}
!17 = !{!"_ZTS10eq_param_t", !10, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !7, i64 44, !7, i64 300, !7, i64 33068, !7, i64 33324, !10, i64 66092}
!18 = !{!17, !10, i64 0}
!19 = !{!13, !13, i64 0}
!20 = !{!17, !6, i64 32}
!21 = distinct !{!21, !22}
!22 = !{!"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"

%struct.eqz_preset_t = type { [16 x i8], i32, float, [10 x float] }

@_ZL14eqz_preset_10b = external hidden local_unnamed_addr constant [3 x %struct.eqz_preset_t], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN9Equalizer9EqzPresetEi(ptr nocapture noundef nonnull readonly align 8 dereferenceable(8) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %3 = sext i32 %1 to i64
  %4 = getelementptr inbounds %struct.eqz_preset_t, ptr @_ZL14eqz_preset_10b, i64 %3
  %5 = getelementptr inbounds i8, ptr %4, i64 20
  %6 = load float, ptr %5, align 4, !tbaa !5
  %7 = load ptr, ptr %0, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %7, i64 40
  store float %6, ptr %8, align 8, !tbaa !14
  %9 = load i32, ptr %7, align 8, !tbaa !16
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %2
  %11 = getelementptr inbounds i8, ptr %4, i64 24
  %12 = getelementptr inbounds i8, ptr %7, i64 32
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %wide.trip.count = zext nneg i32 %9 to i64
  %min.iters.check = icmp ult i32 %9, 16
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph
  %14 = ptrtoint ptr %13 to i64
  %15 = add i64 %14, -24
  %16 = shl nsw i64 %3, 6
  %17 = add i64 %16, ptrtoint (ptr @_ZL14eqz_preset_10b to i64)
  %18 = sub i64 %15, %17
  %diff.check = icmp ult i64 %18, 32
  br i1 %diff.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %wide.trip.count, 2147483640
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %19 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %index
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %wide.load = load <4 x float>, ptr %19, align 8, !tbaa !18
  %wide.load9 = load <4 x float>, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds float, ptr %13, i64 %index
  %22 = getelementptr inbounds i8, ptr %21, i64 16
  store <4 x float> %wide.load, ptr %21, align 4, !tbaa !18
  store <4 x float> %wide.load9, ptr %22, align 4, !tbaa !18
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !19

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.memcheck, %.lr.ph
  %indvars.iv.ph = phi i64 [ 0, %vector.memcheck ], [ 0, %.lr.ph ], [ %n.vec, %middle.block ]
  %xtraiter = and i64 %wide.trip.count, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol

scalar.ph.prol:                                   ; preds = %scalar.ph.preheader, %scalar.ph.prol
  %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %scalar.ph.prol ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %scalar.ph.prol ], [ 0, %scalar.ph.preheader ]
  %24 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %indvars.iv.prol
  %25 = load float, ptr %24, align 4, !tbaa !18
  %26 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.prol
  store float %25, ptr %26, align 4, !tbaa !18
  %indvars.iv.next.prol = add nuw nsw i64 %indvars.iv.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %scalar.ph.prol.loopexit, label %scalar.ph.prol, !llvm.loop !23

scalar.ph.prol.loopexit:                          ; preds = %scalar.ph.prol, %scalar.ph.preheader
  %indvars.iv.unr = phi i64 [ %indvars.iv.ph, %scalar.ph.preheader ], [ %indvars.iv.next.prol, %scalar.ph.prol ]
  %27 = sub nsw i64 %indvars.iv.ph, %wide.trip.count
  %28 = icmp ugt i64 %27, -4
  br i1 %28, label %._crit_edge, label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.prol.loopexit, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next.3, %scalar.ph ], [ %indvars.iv.unr, %scalar.ph.prol.loopexit ]
  %29 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %indvars.iv
  %30 = load float, ptr %29, align 4, !tbaa !18
  %31 = getelementptr inbounds float, ptr %13, i64 %indvars.iv
  store float %30, ptr %31, align 4, !tbaa !18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %32 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %indvars.iv.next
  %33 = load float, ptr %32, align 4, !tbaa !18
  %34 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next
  store float %33, ptr %34, align 4, !tbaa !18
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %35 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %indvars.iv.next.1
  %36 = load float, ptr %35, align 4, !tbaa !18
  %37 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next.1
  store float %36, ptr %37, align 4, !tbaa !18
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %38 = getelementptr inbounds [10 x float], ptr %11, i64 0, i64 %indvars.iv.next.2
  %39 = load float, ptr %38, align 4, !tbaa !18
  %40 = getelementptr inbounds float, ptr %13, i64 %indvars.iv.next.2
  store float %39, ptr %40, align 4, !tbaa !18
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge, label %scalar.ph, !llvm.loop !25

._crit_edge:                                      ; preds = %scalar.ph.prol.loopexit, %scalar.ph, %middle.block, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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 20}
!6 = !{!"_ZTS12eqz_preset_t", !7, i64 0, !9, i64 16, !10, i64 20, !7, i64 24}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS9Equalizer", !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !10, i64 40}
!15 = !{!"_ZTS10eq_param_t", !9, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !10, i64 40, !7, i64 44, !7, i64 300, !7, i64 33068, !7, i64 33324, !9, i64 66092}
!16 = !{!15, !9, i64 0}
!17 = !{!15, !13, i64 32}
!18 = !{!10, !10, i64 0}
!19 = distinct !{!19, !20, !21, !22}
!20 = !{!"llvm.loop.mustprogress"}
!21 = !{!"llvm.loop.isvectorized", i32 1}
!22 = !{!"llvm.loop.unroll.runtime.disable"}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.unroll.disable"}
!25 = distinct !{!25, !20, !21}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass