; 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: nounwind uwtable
declare dso_local ptr @eqrls_cccf_create(ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @eqrls_cccf_recreate(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  %9 = load ptr, ptr %5, 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 !11
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %43

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

15:                                               ; preds = %38, %14
  %16 = load i32, ptr %8, align 4, !tbaa !9
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 8, !tbaa !11
  %20 = icmp ult i32 %16, %19
  br i1 %20, label %21, label %41

21:                                               ; preds = %15
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds { float, float }, ptr %22, i64 %24
  %26 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 4
  %28 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 1
  %29 = load float, ptr %28, align 4
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.eqrls_cccf_s, ptr %30, i32 0, i32 3
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  %33 = load i32, ptr %8, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds { float, float }, ptr %32, i64 %34
  %36 = getelementptr inbounds { float, float }, ptr %35, i32 0, i32 0
  %37 = getelementptr inbounds { float, float }, ptr %35, i32 0, i32 1
  store float %27, ptr %36, align 4
  store float %29, ptr %37, align 4
  br label %38

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

41:                                               ; preds = %15
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %42, ptr %4, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  br label %49

43:                                               ; preds = %3
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = call i32 @eqrls_cccf_destroy(ptr noundef %44)
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %7, align 4, !tbaa !9
  %48 = call ptr @eqrls_cccf_create(ptr noundef %46, i32 noundef %47)
  store ptr %48, ptr %4, align 8
  br label %49

49:                                               ; preds = %43, %41
  %50 = load ptr, ptr %4, align 8
  ret ptr %50
}

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @eqrls_cccf_recreate(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr %0, align 8, !tbaa !5
  %5 = icmp eq i32 %4, %2
  br i1 %5, label %.preheader, label %15

.preheader:                                       ; preds = %3
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  br label %7

7:                                                ; preds = %.lr.ph, %7
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %7 ]
  %8 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %9 = load ptr, ptr %6, align 8, !tbaa !12
  %10 = getelementptr inbounds { float, float }, ptr %9, i64 %indvars.iv
  %11 = load <2 x float>, ptr %8, align 4
  store <2 x float> %11, ptr %10, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %12 = load i32, ptr %0, align 8, !tbaa !5
  %13 = zext i32 %12 to i64
  %14 = icmp ult i64 %indvars.iv.next, %13
  br i1 %14, label %7, label %.loopexit, !llvm.loop !13

15:                                               ; preds = %3
  %16 = tail call i32 @eqrls_cccf_destroy(ptr noundef nonnull %0)
  %17 = tail call ptr @eqrls_cccf_create(ptr noundef %1, i32 noundef %2)
  br label %.loopexit

.loopexit:                                        ; preds = %7, %.preheader, %15
  %.013 = phi ptr [ %17, %15 ], [ %0, %.preheader ], [ %0, %7 ]
  ret ptr %.013
}

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

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

!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 16}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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