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

; 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 @msresamp2_rrrf_interp_execute(ptr noundef %0, float noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %12, i32 0, i32 11
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  store ptr %14, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %15, i32 0, i32 12
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  store ptr %17, ptr %8, align 8, !tbaa !5
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = load ptr, ptr %7, align 8, !tbaa !5
  %20 = getelementptr inbounds float, ptr %19, i64 0
  store float %18, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  store i32 0, ptr %9, align 4, !tbaa !15
  br label %21

21:                                               ; preds = %92, %3
  %22 = load i32, ptr %9, align 4, !tbaa !15
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %23, i32 0, i32 1
  %25 = load i32, ptr %24, align 4, !tbaa !16
  %26 = icmp ult i32 %22, %25
  br i1 %26, label %27, label %95

27:                                               ; preds = %21
  %28 = load i32, ptr %9, align 4, !tbaa !15
  %29 = shl i32 1, %28
  store i32 %29, ptr %10, align 4, !tbaa !15
  %30 = load i32, ptr %9, align 4, !tbaa !15
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %31, i32 0, i32 1
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = sub i32 %33, 1
  %35 = icmp eq i32 %30, %34
  br i1 %35, label %36, label %38

36:                                               ; preds = %27
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %37, ptr %8, align 8, !tbaa !5
  br label %38

38:                                               ; preds = %36, %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  store i32 0, ptr %11, align 4, !tbaa !15
  br label %39

39:                                               ; preds = %62, %38
  %40 = load i32, ptr %11, align 4, !tbaa !15
  %41 = load i32, ptr %10, align 4, !tbaa !15
  %42 = icmp ult i32 %40, %41
  br i1 %42, label %43, label %65

43:                                               ; preds = %39
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %44, i32 0, i32 10
  %46 = load ptr, ptr %45, align 8, !tbaa !17
  %47 = load i32, ptr %9, align 4, !tbaa !15
  %48 = zext i32 %47 to i64
  %49 = getelementptr inbounds ptr, ptr %46, i64 %48
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !15
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds float, ptr %51, i64 %53
  %55 = load float, ptr %54, align 4, !tbaa !9
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = load i32, ptr %11, align 4, !tbaa !15
  %58 = mul i32 2, %57
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds float, ptr %56, i64 %59
  %61 = call i32 @resamp2_rrrf_interp_execute(ptr noundef %50, float noundef %55, ptr noundef %60)
  br label %62

62:                                               ; preds = %43
  %63 = load i32, ptr %11, align 4, !tbaa !15
  %64 = add i32 %63, 1
  store i32 %64, ptr %11, align 4, !tbaa !15
  br label %39, !llvm.loop !18

65:                                               ; preds = %39
  %66 = load i32, ptr %9, align 4, !tbaa !15
  %67 = urem i32 %66, 2
  %68 = icmp eq i32 %67, 0
  br i1 %68, label %69, label %73

69:                                               ; preds = %65
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %70, i32 0, i32 12
  %72 = load ptr, ptr %71, align 8, !tbaa !14
  br label %77

73:                                               ; preds = %65
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %74, i32 0, i32 11
  %76 = load ptr, ptr %75, align 8, !tbaa !11
  br label %77

77:                                               ; preds = %73, %69
  %78 = phi ptr [ %72, %69 ], [ %76, %73 ]
  store ptr %78, ptr %7, align 8, !tbaa !5
  %79 = load i32, ptr %9, align 4, !tbaa !15
  %80 = urem i32 %79, 2
  %81 = icmp eq i32 %80, 0
  br i1 %81, label %82, label %86

82:                                               ; preds = %77
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %83, i32 0, i32 11
  %85 = load ptr, ptr %84, align 8, !tbaa !11
  br label %90

86:                                               ; preds = %77
  %87 = load ptr, ptr %4, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.msresamp2_rrrf_s, ptr %87, i32 0, i32 12
  %89 = load ptr, ptr %88, align 8, !tbaa !14
  br label %90

90:                                               ; preds = %86, %82
  %91 = phi ptr [ %85, %82 ], [ %89, %86 ]
  store ptr %91, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  br label %92

92:                                               ; preds = %90
  %93 = load i32, ptr %9, align 4, !tbaa !15
  %94 = add i32 %93, 1
  store i32 %94, ptr %9, align 4, !tbaa !15
  br label %21, !llvm.loop !20

95:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i32 0
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @resamp2_rrrf_interp_execute(ptr noundef, float 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 = !{!"float", !7, i64 0}
!11 = !{!12, !6, i64 64}
!12 = !{!"msresamp2_rrrf_s", !13, i64 0, !13, i64 4, !10, i64 8, !10, i64 12, !10, i64 16, !13, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !13, i64 80, !10, i64 84}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 72}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !13, i64 4}
!17 = !{!12, !6, i64 56}
!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: nounwind uwtable
define dso_local noundef i32 @msresamp2_rrrf_interp_execute(ptr nocapture noundef readonly %0, float noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %0, i64 64
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 72
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  store float %1, ptr %5, align 4, !tbaa !13
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i32, ptr %8, align 4, !tbaa !14
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  br label %11

11:                                               ; preds = %.lr.ph, %30
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %30 ]
  %12 = phi i32 [ %9, %.lr.ph ], [ %35, %30 ]
  %.02533 = phi ptr [ %5, %.lr.ph ], [ %33, %30 ]
  %.02731 = phi ptr [ %7, %.lr.ph ], [ %34, %30 ]
  %13 = add i32 %12, -1
  %14 = zext i32 %13 to i64
  %15 = icmp eq i64 %indvars.iv, %14
  %spec.select = select i1 %15, ptr %2, ptr %.02731
  %16 = trunc nuw i64 %indvars.iv to i32
  br label %17

17:                                               ; preds = %11, %17
  %.030 = phi i32 [ 0, %11 ], [ %28, %17 ]
  %18 = load ptr, ptr %10, align 8, !tbaa !15
  %19 = getelementptr inbounds ptr, ptr %18, i64 %indvars.iv
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = zext i32 %.030 to i64
  %22 = getelementptr inbounds float, ptr %.02533, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !13
  %24 = shl i32 %.030, 1
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds float, ptr %spec.select, i64 %25
  %27 = tail call i32 @resamp2_rrrf_interp_execute(ptr noundef %20, float noundef %23, ptr noundef %26)
  %28 = add i32 %.030, 1
  %.0.highbits = lshr i32 %28, %16
  %29 = icmp eq i32 %.0.highbits, 0
  br i1 %29, label %17, label %30, !llvm.loop !17

30:                                               ; preds = %17
  %31 = and i32 %16, 1
  %32 = icmp eq i32 %31, 0
  %. = select i1 %32, ptr %6, ptr %4
  %33 = load ptr, ptr %., align 8, !tbaa !16
  %.in29 = select i1 %32, ptr %4, ptr %6
  %34 = load ptr, ptr %.in29, align 8, !tbaa !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %35 = load i32, ptr %8, align 4, !tbaa !14
  %36 = zext i32 %35 to i64
  %37 = icmp ult i64 %indvars.iv.next, %36
  br i1 %37, label %11, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %30, %3
  ret i32 0
}

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


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