; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_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.rresamp_rrrf_s = type { i32, i32, i32, i32, ptr }

@.str.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.144 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.151 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.152 = external hidden unnamed_addr constant [53 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 @firpfb_rrrf_push(ptr noundef, float noundef) #2

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rresamp_rrrf_execute_primitive(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %56, %3
  %13 = load i32, ptr %9, align 4, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %14, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !11
  %17 = icmp ult i32 %13, %16
  br i1 %17, label %18, label %59

18:                                               ; preds = %12
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds float, ptr %22, i64 %24
  %26 = load float, ptr %25, align 4, !tbaa !14
  %27 = call i32 @firpfb_rrrf_push(ptr noundef %21, float noundef %26)
  br label %28

28:                                               ; preds = %34, %18
  %29 = load i32, ptr %8, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %30, i32 0, i32 0
  %32 = load i32, ptr %31, align 8, !tbaa !16
  %33 = icmp ult i32 %29, %32
  br i1 %33, label %34, label %50

34:                                               ; preds = %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %35, i32 0, i32 4
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = add i32 %40, 1
  store i32 %41, ptr %10, align 4, !tbaa !9
  %42 = zext i32 %40 to i64
  %43 = getelementptr inbounds float, ptr %39, i64 %42
  %44 = call i32 @firpfb_rrrf_execute(ptr noundef %37, i32 noundef %38, ptr noundef %43)
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %45, i32 0, i32 1
  %47 = load i32, ptr %46, align 4, !tbaa !11
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = add i32 %48, %47
  store i32 %49, ptr %8, align 4, !tbaa !9
  br label %28, !llvm.loop !17

50:                                               ; preds = %28
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !16
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = sub i32 %54, %53
  store i32 %55, ptr %8, align 4, !tbaa !9
  br label %56

56:                                               ; preds = %50
  %57 = load i32, ptr %9, align 4, !tbaa !9
  %58 = add i32 %57, 1
  store i32 %58, ptr %9, align 4, !tbaa !9
  br label %12, !llvm.loop !19

59:                                               ; preds = %12
  %60 = load i32, ptr %8, align 4, !tbaa !9
  %61 = icmp ne i32 %60, 0
  br i1 %61, label %62, label %65

62:                                               ; preds = %59
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str.144, i32 noundef 359, ptr noundef @.str.151, ptr noundef @.str.3, i32 noundef %63)
  store i32 %64, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %79

65:                                               ; preds = %59
  %66 = load i32, ptr %10, align 4, !tbaa !9
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %67, i32 0, i32 0
  %69 = load i32, ptr %68, align 8, !tbaa !16
  %70 = icmp ne i32 %66, %69
  br i1 %70, label %71, label %77

71:                                               ; preds = %65
  %72 = load i32, ptr %10, align 4, !tbaa !9
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.rresamp_rrrf_s, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !16
  %76 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str.144, i32 noundef 362, ptr noundef @.str.152, ptr noundef @.str.3, i32 noundef %72, i32 noundef %75)
  store i32 %76, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %79

77:                                               ; preds = %65
  br label %78

78:                                               ; preds = %77
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %79

79:                                               ; preds = %78, %71, %62
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %80 = load i32, ptr %4, align 4
  ret i32 %80
}

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, !10, i64 4}
!12 = !{!"rresamp_rrrf_s", !10, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}
!16 = !{!12, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}


; 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.3 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.144 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.151 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.152 = external hidden unnamed_addr constant [53 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @rresamp_rrrf_execute_primitive(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %0, i64 4
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not41 = icmp eq i32 %5, 0
  br i1 %.not41, label %._crit_edge38.thread, label %.lr.ph37

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

7:                                                ; preds = %.lr.ph37, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.lr.ph37 ], [ %indvars.iv.next, %._crit_edge ]
  %.035 = phi i32 [ 0, %.lr.ph37 ], [ %.1.lcssa, %._crit_edge ]
  %.02333 = phi i32 [ 0, %.lr.ph37 ], [ %24, %._crit_edge ]
  %8 = load ptr, ptr %6, align 8, !tbaa !11
  %9 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %10 = load float, ptr %9, align 4, !tbaa !12
  %11 = tail call i32 @firpfb_rrrf_push(ptr noundef %8, float noundef %10)
  %12 = load i32, ptr %0, align 8, !tbaa !14
  %13 = icmp ult i32 %.02333, %12
  br i1 %13, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %7
  %.pre = load i32, ptr %4, align 4, !tbaa !5
  br label %._crit_edge

.lr.ph:                                           ; preds = %7, %.lr.ph
  %.130 = phi i32 [ %15, %.lr.ph ], [ %.035, %7 ]
  %.12429 = phi i32 [ %20, %.lr.ph ], [ %.02333, %7 ]
  %14 = load ptr, ptr %6, align 8, !tbaa !11
  %15 = add i32 %.130, 1
  %16 = zext i32 %.130 to i64
  %17 = getelementptr inbounds float, ptr %2, i64 %16
  %18 = tail call i32 @firpfb_rrrf_execute(ptr noundef %14, i32 noundef %.12429, ptr noundef %17)
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = add i32 %19, %.12429
  %21 = load i32, ptr %0, align 8, !tbaa !14
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %23 = phi i32 [ %.pre, %.._crit_edge_crit_edge ], [ %19, %.lr.ph ]
  %.124.lcssa = phi i32 [ %.02333, %.._crit_edge_crit_edge ], [ %20, %.lr.ph ]
  %.1.lcssa = phi i32 [ %.035, %.._crit_edge_crit_edge ], [ %15, %.lr.ph ]
  %.lcssa = phi i32 [ %12, %.._crit_edge_crit_edge ], [ %21, %.lr.ph ]
  %24 = sub i32 %.124.lcssa, %.lcssa
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = zext i32 %23 to i64
  %26 = icmp ult i64 %indvars.iv.next, %25
  br i1 %26, label %7, label %._crit_edge38, !llvm.loop !17

._crit_edge38:                                    ; preds = %._crit_edge
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %._crit_edge38.thread, label %27

27:                                               ; preds = %._crit_edge38
  %28 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str.144, i32 noundef 359, ptr noundef nonnull @.str.151, ptr noundef nonnull @.str.3, i32 noundef %24) #2
  br label %32

._crit_edge38.thread:                             ; preds = %3, %._crit_edge38
  %.0.lcssa50 = phi i32 [ %.1.lcssa, %._crit_edge38 ], [ 0, %3 ]
  %29 = load i32, ptr %0, align 8, !tbaa !14
  %.not28 = icmp eq i32 %.0.lcssa50, %29
  br i1 %.not28, label %32, label %30

30:                                               ; preds = %._crit_edge38.thread
  %31 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str.144, i32 noundef 362, ptr noundef nonnull @.str.152, ptr noundef nonnull @.str.3, i32 noundef %.0.lcssa50, i32 noundef %29) #2
  br label %32

32:                                               ; preds = %._crit_edge38.thread, %30, %27
  %.025 = phi i32 [ %28, %27 ], [ %31, %30 ], [ 0, %._crit_edge38.thread ]
  ret i32 %.025
}

attributes #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 = { 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, !7, i64 4}
!6 = !{!"rresamp_rrrf_s", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 16}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = !{!6, !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}


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