; LLVM IR from jgaeddert/liquid-dsp :: sandbox (modem_demodulate_arb_gentab)

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

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

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

15:                                               ; preds = %70, %5
  %16 = load i32, ptr %12, align 4, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %73

19:                                               ; preds = %15
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = load i32, ptr %12, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds i8, ptr %20, i64 %22
  store i8 0, ptr %23, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #2
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %56, %19
  %25 = load i32, ptr %13, align 4, !tbaa !9
  %26 = load i32, ptr %8, align 4, !tbaa !9
  %27 = icmp ult i32 %25, %26
  br i1 %27, label %28, label %59

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

29:                                               ; preds = %52, %28
  %30 = load i32, ptr %14, align 4, !tbaa !9
  %31 = load i32, ptr %9, align 4, !tbaa !9
  %32 = icmp ult i32 %30, %31
  br i1 %32, label %33, label %55

33:                                               ; preds = %29
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = mul i32 %35, %36
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = add i32 %37, %38
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds i8, ptr %34, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = zext i8 %42 to i32
  %44 = load i32, ptr %12, align 4, !tbaa !9
  %45 = icmp eq i32 %43, %44
  br i1 %45, label %46, label %51

46:                                               ; preds = %33
  %47 = load ptr, ptr %10, align 8, !tbaa !5
  %48 = load i32, ptr %12, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %47, i64 %49
  store i8 1, ptr %50, align 1, !tbaa !11
  br label %51

51:                                               ; preds = %46, %33
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %14, align 4, !tbaa !9
  %54 = add i32 %53, 1
  store i32 %54, ptr %14, align 4, !tbaa !9
  br label %29, !llvm.loop !12

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

56:                                               ; preds = %55
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = add i32 %57, 1
  store i32 %58, ptr %13, align 4, !tbaa !9
  br label %24, !llvm.loop !14

59:                                               ; preds = %24
  %60 = load ptr, ptr %10, align 8, !tbaa !5
  %61 = load i32, ptr %12, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds i8, ptr %60, i64 %62
  %64 = load i8, ptr %63, align 1, !tbaa !11
  %65 = icmp ne i8 %64, 0
  br i1 %65, label %69, label %66

66:                                               ; preds = %59
  %67 = load i32, ptr %11, align 4, !tbaa !9
  %68 = add i32 %67, 1
  store i32 %68, ptr %11, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %66, %59
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #2
  br label %70

70:                                               ; preds = %69
  %71 = load i32, ptr %12, align 4, !tbaa !9
  %72 = add i32 %71, 1
  store i32 %72, ptr %12, align 4, !tbaa !9
  br label %15, !llvm.loop !15

73:                                               ; preds = %15
  %74 = load i32, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  ret i32 %74
}

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

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


; 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: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local i32 @modemcf_arbref_search_unassigned(ptr nocapture noundef readonly %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %.not36 = icmp eq i32 %1, 0
  br i1 %.not36, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %.not37 = icmp eq i32 %2, 0
  br i1 %.not37, label %.lr.ph.split.preheader, label %.lr.ph.split.us

.lr.ph.split.preheader:                           ; preds = %.lr.ph
  %6 = zext i32 %1 to i64
  tail call void @llvm.memset.p0.i64(ptr align 1 %4, i8 0, i64 %6, i1 false), !tbaa !5
  br label %._crit_edge

.lr.ph.split.us:                                  ; preds = %.lr.ph
  %.not38 = icmp eq i32 %3, 0
  %wide.trip.count51 = zext i32 %1 to i64
  br i1 %.not38, label %.preheader.lr.ph.us.preheader, label %.preheader.lr.ph.us.us.preheader

.preheader.lr.ph.us.preheader:                    ; preds = %.lr.ph.split.us
  %min.iters.check = icmp ult i32 %1, 8
  br i1 %min.iters.check, label %.preheader.lr.ph.us.preheader61, label %vector.ph

.preheader.lr.ph.us.preheader61:                  ; preds = %middle.block, %.preheader.lr.ph.us.preheader
  %indvars.iv48.ph = phi i64 [ 0, %.preheader.lr.ph.us.preheader ], [ %n.vec, %middle.block ]
  %.02328.us.ph = phi i32 [ 0, %.preheader.lr.ph.us.preheader ], [ %12, %middle.block ]
  br label %.preheader.lr.ph.us

vector.ph:                                        ; preds = %.preheader.lr.ph.us.preheader
  %n.vec = and i64 %wide.trip.count51, 4294967288
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %9, %vector.body ]
  %vec.phi60 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %10, %vector.body ]
  %7 = getelementptr inbounds i8, ptr %4, i64 %index
  %8 = getelementptr inbounds i8, ptr %7, i64 4
  store <4 x i8> zeroinitializer, ptr %7, align 1, !tbaa !5
  store <4 x i8> zeroinitializer, ptr %8, align 1, !tbaa !5
  %9 = add <4 x i32> %vec.phi, <i32 1, i32 1, i32 1, i32 1>
  %10 = add <4 x i32> %vec.phi60, <i32 1, i32 1, i32 1, i32 1>
  %index.next = add nuw i64 %index, 8
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, label %middle.block, label %vector.body, !llvm.loop !8

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %10, %9
  %12 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count51
  br i1 %cmp.n, label %._crit_edge, label %.preheader.lr.ph.us.preheader61

.preheader.lr.ph.us.us.preheader:                 ; preds = %.lr.ph.split.us
  %wide.trip.count = zext i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %13 = icmp eq i32 %3, 1
  %unroll_iter = and i64 %wide.trip.count, 4294967294
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br label %.preheader.lr.ph.us.us

.preheader.lr.ph.us.us:                           ; preds = %.preheader.lr.ph.us.us.preheader, %._crit_edge27.split.us.us.us
  %indvars.iv43 = phi i64 [ 0, %.preheader.lr.ph.us.us.preheader ], [ %indvars.iv.next44, %._crit_edge27.split.us.us.us ]
  %.02328.us.us = phi i32 [ 0, %.preheader.lr.ph.us.us.preheader ], [ %spec.select.us.us, %._crit_edge27.split.us.us.us ]
  %14 = getelementptr inbounds i8, ptr %4, i64 %indvars.iv43
  store i8 0, ptr %14, align 1, !tbaa !5
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader.lr.ph.us.us
  %15 = phi i8 [ 0, %.preheader.lr.ph.us.us ], [ %.lcssa64, %._crit_edge.us.us.us ]
  %.02126.us.us.us = phi i32 [ 0, %.preheader.lr.ph.us.us ], [ %47, %._crit_edge.us.us.us ]
  %16 = mul i32 %.02126.us.us.us, %3
  br i1 %13, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new

.preheader.us.us.us.new:                          ; preds = %.preheader.us.us.us, %37
  %17 = phi i8 [ %38, %37 ], [ %15, %.preheader.us.us.us ]
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %37 ], [ 0, %.preheader.us.us.us ]
  %niter = phi i64 [ %niter.next.1, %37 ], [ 0, %.preheader.us.us.us ]
  %18 = trunc nuw i64 %indvars.iv to i32
  %19 = add i32 %16, %18
  %20 = zext i32 %19 to i64
  %21 = getelementptr inbounds i8, ptr %0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = zext i8 %22 to i64
  %24 = icmp eq i64 %indvars.iv43, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %.preheader.us.us.us.new
  store i8 1, ptr %14, align 1, !tbaa !5
  br label %26

26:                                               ; preds = %25, %.preheader.us.us.us.new
  %27 = phi i8 [ 1, %25 ], [ %17, %.preheader.us.us.us.new ]
  %28 = trunc i64 %indvars.iv to i32
  %29 = or disjoint i32 %28, 1
  %30 = add i32 %16, %29
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds i8, ptr %0, i64 %31
  %33 = load i8, ptr %32, align 1, !tbaa !5
  %34 = zext i8 %33 to i64
  %35 = icmp eq i64 %indvars.iv43, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %26
  store i8 1, ptr %14, align 1, !tbaa !5
  br label %37

37:                                               ; preds = %36, %26
  %38 = phi i8 [ 1, %36 ], [ %27, %26 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.us.us.us.unr-lcssa, label %.preheader.us.us.us.new, !llvm.loop !12

._crit_edge.us.us.us.unr-lcssa:                   ; preds = %37, %.preheader.us.us.us
  %.lcssa64.ph = phi i8 [ poison, %.preheader.us.us.us ], [ %38, %37 ]
  %.unr = phi i8 [ %15, %.preheader.us.us.us ], [ %38, %37 ]
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us.us.us ], [ %indvars.iv.next.1, %37 ]
  br i1 %lcmp.mod.not, label %._crit_edge.us.us.us, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge.us.us.us.unr-lcssa
  %39 = trunc nuw i64 %indvars.iv.unr to i32
  %40 = add i32 %16, %39
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds i8, ptr %0, i64 %41
  %43 = load i8, ptr %42, align 1, !tbaa !5
  %44 = zext i8 %43 to i64
  %45 = icmp eq i64 %indvars.iv43, %44
  br i1 %45, label %46, label %._crit_edge.us.us.us

46:                                               ; preds = %.epil.preheader
  store i8 1, ptr %14, align 1, !tbaa !5
  br label %._crit_edge.us.us.us

._crit_edge.us.us.us:                             ; preds = %.epil.preheader, %46, %._crit_edge.us.us.us.unr-lcssa
  %.lcssa64 = phi i8 [ %.lcssa64.ph, %._crit_edge.us.us.us.unr-lcssa ], [ 1, %46 ], [ %.unr, %.epil.preheader ]
  %47 = add nuw i32 %.02126.us.us.us, 1
  %exitcond42.not = icmp eq i32 %47, %2
  br i1 %exitcond42.not, label %._crit_edge27.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !13

._crit_edge27.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %.not.us.us = icmp eq i8 %.lcssa64, 0
  %48 = zext i1 %.not.us.us to i32
  %spec.select.us.us = add i32 %.02328.us.us, %48
  %indvars.iv.next44 = add nuw nsw i64 %indvars.iv43, 1
  %exitcond47.not = icmp eq i64 %indvars.iv.next44, %wide.trip.count51
  br i1 %exitcond47.not, label %._crit_edge, label %.preheader.lr.ph.us.us, !llvm.loop !14

.preheader.lr.ph.us:                              ; preds = %.preheader.lr.ph.us.preheader61, %.preheader.lr.ph.us
  %indvars.iv48 = phi i64 [ %indvars.iv.next49, %.preheader.lr.ph.us ], [ %indvars.iv48.ph, %.preheader.lr.ph.us.preheader61 ]
  %.02328.us = phi i32 [ %spec.select.us, %.preheader.lr.ph.us ], [ %.02328.us.ph, %.preheader.lr.ph.us.preheader61 ]
  %49 = getelementptr inbounds i8, ptr %4, i64 %indvars.iv48
  store i8 0, ptr %49, align 1, !tbaa !5
  %spec.select.us = add i32 %.02328.us, 1
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %exitcond52.not = icmp eq i64 %indvars.iv.next49, %wide.trip.count51
  br i1 %exitcond52.not, label %._crit_edge, label %.preheader.lr.ph.us, !llvm.loop !15

._crit_edge:                                      ; preds = %._crit_edge27.split.us.us.us, %.preheader.lr.ph.us, %middle.block, %.lr.ph.split.preheader, %5
  %.023.lcssa = phi i32 [ 0, %5 ], [ %1, %.lr.ph.split.preheader ], [ %12, %middle.block ], [ %spec.select.us, %.preheader.lr.ph.us ], [ %spec.select.us.us, %._crit_edge27.split.us.us.us ]
  ret i32 %.023.lcssa
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #2

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9, !10, !11}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!"llvm.loop.isvectorized", i32 1}
!11 = !{!"llvm.loop.unroll.runtime.disable"}
!12 = distinct !{!12, !9}
!13 = distinct !{!13, !9}
!14 = distinct !{!14, !9}
!15 = distinct !{!15, !9, !11, !10}


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