; 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.msresamp_rrrf_s = type { float, float, i32, i32, ptr, float, ptr, float, i32, ptr, i32 }

; 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
define dso_local i32 @msresamp_rrrf_interp_execute(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3, ptr noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !9
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %61, %5
  %16 = load i32, ptr %11, align 4, !tbaa !9
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %64

19:                                               ; preds = %15
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.msresamp_rrrf_s, ptr %20, i32 0, i32 6
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %23, i64 %25
  %27 = load float, ptr %26, align 4, !tbaa !14
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.msresamp_rrrf_s, ptr %28, i32 0, i32 9
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = call i32 @resamp_rrrf_execute(ptr noundef %22, float noundef %27, ptr noundef %30, ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %57, %19
  %33 = load i32, ptr %14, align 4, !tbaa !9
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = icmp ult i32 %33, %34
  br i1 %35, label %36, label %60

36:                                               ; preds = %32
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.msresamp_rrrf_s, ptr %37, i32 0, i32 4
  %39 = load ptr, ptr %38, align 8, !tbaa !16
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.msresamp_rrrf_s, ptr %40, i32 0, i32 9
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  %43 = load i32, ptr %14, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds float, ptr %42, i64 %44
  %46 = load ptr, ptr %9, align 8, !tbaa !5
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds float, ptr %46, i64 %48
  %50 = call i32 @msresamp2_rrrf_execute(ptr noundef %39, ptr noundef %45, ptr noundef %49)
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.msresamp_rrrf_s, ptr %51, i32 0, i32 3
  %53 = load i32, ptr %52, align 4, !tbaa !17
  %54 = shl i32 1, %53
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = add i32 %55, %54
  store i32 %56, ptr %13, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %36
  %58 = load i32, ptr %14, align 4, !tbaa !9
  %59 = add i32 %58, 1
  store i32 %59, ptr %14, align 4, !tbaa !9
  br label %32, !llvm.loop !18

60:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %61

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

64:                                               ; preds = %15
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %65, ptr %66, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret i32 0
}

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @msresamp2_rrrf_execute(ptr noundef, ptr noundef, 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, !6, i64 32}
!12 = !{!"msresamp_rrrf_s", !13, i64 0, !13, i64 4, !10, i64 8, !10, i64 12, !6, i64 16, !13, i64 24, !6, i64 32, !13, i64 40, !10, i64 44, !6, i64 48, !10, i64 56}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !6, i64 16}
!17 = !{!12, !10, i64 12}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}


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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @msresamp_rrrf_interp_execute(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2, ptr noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #1 {
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #2
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge25, label %.lr.ph24

.lr.ph24:                                         ; preds = %5
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = getelementptr inbounds i8, ptr %0, i64 48
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %wide.trip.count = zext i32 %2 to i64
  br label %11

11:                                               ; preds = %.lr.ph24, %._crit_edge
  %indvars.iv29 = phi i64 [ 0, %.lr.ph24 ], [ %indvars.iv.next30, %._crit_edge ]
  %.01722 = phi i32 [ 0, %.lr.ph24 ], [ %.1.lcssa, %._crit_edge ]
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = getelementptr inbounds float, ptr %1, i64 %indvars.iv29
  %14 = load float, ptr %13, align 4, !tbaa !12
  %15 = load ptr, ptr %8, align 8, !tbaa !13
  %16 = call i32 @resamp_rrrf_execute(ptr noundef %12, float noundef %14, ptr noundef %15, ptr noundef nonnull %6)
  %17 = load i32, ptr %6, align 4, !tbaa !14
  %.not27 = icmp eq i32 %17, 0
  br i1 %.not27, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %11 ]
  %.119 = phi i32 [ %26, %.lr.ph ], [ %.01722, %11 ]
  %18 = load ptr, ptr %9, align 8, !tbaa !15
  %19 = load ptr, ptr %8, align 8, !tbaa !13
  %20 = getelementptr inbounds float, ptr %19, i64 %indvars.iv
  %21 = zext i32 %.119 to i64
  %22 = getelementptr inbounds float, ptr %3, i64 %21
  %23 = call i32 @msresamp2_rrrf_execute(ptr noundef %18, ptr noundef %20, ptr noundef %22)
  %24 = load i32, ptr %10, align 4, !tbaa !16
  %25 = shl nuw i32 1, %24
  %26 = add i32 %25, %.119
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %6, align 4, !tbaa !14
  %28 = zext i32 %27 to i64
  %29 = icmp ult i64 %indvars.iv.next, %28
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !17

._crit_edge:                                      ; preds = %.lr.ph, %11
  %.1.lcssa = phi i32 [ %.01722, %11 ], [ %26, %.lr.ph ]
  %indvars.iv.next30 = add nuw nsw i64 %indvars.iv29, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next30, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge25, label %11, !llvm.loop !19

._crit_edge25:                                    ; preds = %._crit_edge, %5
  %.017.lcssa = phi i32 [ 0, %5 ], [ %.1.lcssa, %._crit_edge ]
  store i32 %.017.lcssa, ptr %4, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #2
  ret i32 0
}

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

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

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


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