; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (lpc)

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

@.str = external hidden unnamed_addr constant [75 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

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

19:                                               ; preds = %5
  %20 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef @.str, i32 noundef 51, ptr noundef @.str.1)
  br label %79

21:                                               ; preds = %5
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = add i32 %22, 1
  %24 = zext i32 %23 to i64
  %25 = call ptr @llvm.stacksave.p0()
  store ptr %25, ptr %11, align 8
  %26 = alloca float, i64 %24, align 16
  store i64 %24, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %71, %21
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = add i32 %29, 1
  %31 = icmp ult i32 %28, %30
  br i1 %31, label %32, label %74

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %33 = load i32, ptr %13, align 4, !tbaa !9
  store i32 %33, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %34 = load i32, ptr %13, align 4, !tbaa !9
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %26, i64 %35
  store float 0.000000e+00, ptr %36, align 4, !tbaa !11
  %37 = load i32, ptr %14, align 4, !tbaa !9
  store i32 %37, ptr %15, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %60, %32
  %39 = load i32, ptr %15, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = icmp ult i32 %39, %40
  br i1 %41, label %42, label %63

42:                                               ; preds = %38
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %15, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %43, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !11
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = load i32, ptr %14, align 4, !tbaa !9
  %51 = sub i32 %49, %50
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %48, i64 %52
  %54 = load float, ptr %53, align 4, !tbaa !11
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = zext i32 %55 to i64
  %57 = getelementptr inbounds float, ptr %26, i64 %56
  %58 = load float, ptr %57, align 4, !tbaa !11
  %59 = call float @llvm.fmuladd.f32(float %47, float %54, float %58)
  store float %59, ptr %57, align 4, !tbaa !11
  br label %60

60:                                               ; preds = %42
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %15, align 4, !tbaa !9
  br label %38, !llvm.loop !13

63:                                               ; preds = %38
  %64 = load i32, ptr %13, align 4, !tbaa !9
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = zext i32 %65 to i64
  %67 = getelementptr inbounds float, ptr %26, i64 %66
  %68 = load float, ptr %67, align 4, !tbaa !11
  %69 = fpext float %68 to double
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %64, double noundef %69)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %71

71:                                               ; preds = %63
  %72 = load i32, ptr %13, align 4, !tbaa !9
  %73 = add i32 %72, 1
  store i32 %73, ptr %13, align 4, !tbaa !9
  br label %27, !llvm.loop !15

74:                                               ; preds = %27
  %75 = load i32, ptr %8, align 4, !tbaa !9
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load ptr, ptr %10, align 8, !tbaa !5
  call void @liquid_levinson(ptr noundef %26, i32 noundef %75, ptr noundef %76, ptr noundef %77)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %78 = load ptr, ptr %11, align 8
  call void @llvm.stackrestore.p0(ptr %78)
  br label %79

79:                                               ; preds = %74, %19
  ret void
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #4

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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" }
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 = { nocallback nofree nosync nounwind willreturn }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 [75 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @liquid_lpc(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = icmp ugt i32 %2, %1
  br i1 %6, label %7, label %9

7:                                                ; preds = %5
  %8 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 3, ptr noundef nonnull @.str, i32 noundef 51, ptr noundef nonnull @.str.1) #5
  br label %29

9:                                                ; preds = %5
  %10 = add i32 %2, 1
  %11 = zext i32 %10 to i64
  %12 = tail call ptr @llvm.stacksave.p0()
  %13 = alloca float, i64 %11, align 16
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %._crit_edge30, label %.lr.ph29.preheader

.lr.ph29.preheader:                               ; preds = %9
  %14 = zext i32 %1 to i64
  br label %.lr.ph29

.lr.ph29:                                         ; preds = %.lr.ph29.preheader, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph29.preheader ], [ %indvars.iv.next, %24 ]
  %15 = getelementptr inbounds float, ptr %13, i64 %indvars.iv
  store float 0.000000e+00, ptr %15, align 4, !tbaa !5
  %16 = icmp ult i64 %indvars.iv, %14
  br i1 %16, label %.lr.ph, label %24

.lr.ph:                                           ; preds = %.lr.ph29, %.lr.ph
  %indvars.iv31 = phi i64 [ %indvars.iv.next32, %.lr.ph ], [ %indvars.iv, %.lr.ph29 ]
  %17 = phi float [ %23, %.lr.ph ], [ 0.000000e+00, %.lr.ph29 ]
  %18 = getelementptr inbounds float, ptr %0, i64 %indvars.iv31
  %19 = load float, ptr %18, align 4, !tbaa !5
  %20 = sub nuw nsw i64 %indvars.iv31, %indvars.iv
  %21 = getelementptr inbounds float, ptr %0, i64 %20
  %22 = load float, ptr %21, align 4, !tbaa !5
  %23 = tail call float @llvm.fmuladd.f32(float %19, float %22, float %17)
  %indvars.iv.next32 = add nuw nsw i64 %indvars.iv31, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next32, %14
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph
  store float %23, ptr %15, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %._crit_edge, %.lr.ph29
  %25 = phi float [ %23, %._crit_edge ], [ 0.000000e+00, %.lr.ph29 ]
  %26 = fpext float %25 to double
  %27 = trunc nuw i64 %indvars.iv to i32
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %27, double noundef %26)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next, %11
  br i1 %exitcond36.not, label %._crit_edge30, label %.lr.ph29, !llvm.loop !11

._crit_edge30:                                    ; preds = %24, %9
  call void @liquid_levinson(ptr noundef nonnull %13, i32 noundef %2, ptr noundef %3, ptr noundef %4)
  call void @llvm.stackrestore.p0(ptr %12)
  br label %29

29:                                               ; preds = %._crit_edge30, %7
  ret void
}

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #2

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" }
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 = { mustprogress nocallback nofree nosync nounwind willreturn }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nofree nounwind "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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}


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