; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (modemcf)

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

13:                                               ; preds = %49, %5
  %14 = load i32, ptr %11, align 4, !tbaa !9
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp ult i32 %14, %15
  br i1 %16, label %17, label %52

17:                                               ; preds = %13
  %18 = load i32, ptr %12, align 4, !tbaa !9
  %19 = shl i32 %18, 1
  store i32 %19, ptr %12, align 4, !tbaa !9
  %20 = load float, ptr %6, align 4, !tbaa !5
  %21 = fcmp ogt float %20, 0.000000e+00
  br i1 %21, label %22, label %35

22:                                               ; preds = %17
  %23 = load i32, ptr %12, align 4, !tbaa !9
  %24 = or i32 %23, 1
  store i32 %24, ptr %12, align 4, !tbaa !9
  %25 = load ptr, ptr %8, align 8, !tbaa !11
  %26 = load i32, ptr %7, align 4, !tbaa !9
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = sub i32 %26, %27
  %29 = sub i32 %28, 1
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds float, ptr %25, i64 %30
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = load float, ptr %6, align 4, !tbaa !5
  %34 = fsub float %33, %32
  store float %34, ptr %6, align 4, !tbaa !5
  br label %48

35:                                               ; preds = %17
  %36 = load i32, ptr %12, align 4, !tbaa !9
  %37 = or i32 %36, 0
  store i32 %37, ptr %12, align 4, !tbaa !9
  %38 = load ptr, ptr %8, align 8, !tbaa !11
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = load i32, ptr %11, align 4, !tbaa !9
  %41 = sub i32 %39, %40
  %42 = sub i32 %41, 1
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %38, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !5
  %46 = load float, ptr %6, align 4, !tbaa !5
  %47 = fadd float %46, %45
  store float %47, ptr %6, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %35, %22
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %11, align 4, !tbaa !9
  %51 = add i32 %50, 1
  store i32 %51, ptr %11, align 4, !tbaa !9
  br label %13, !llvm.loop !13

52:                                               ; preds = %13
  %53 = load i32, ptr %12, align 4, !tbaa !9
  %54 = load ptr, ptr %9, align 8, !tbaa !11
  store i32 %53, ptr %54, align 4, !tbaa !9
  %55 = load float, ptr %6, align 4, !tbaa !5
  %56 = load ptr, ptr %10, align 8, !tbaa !11
  store float %55, ptr %56, align 4, !tbaa !5
  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
}

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


; 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 noundef i32 @modemcf_demodulate_linear_array_ref(float noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4) local_unnamed_addr #0 {
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %25
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %25 ]
  %.024 = phi i32 [ 0, %.lr.ph.preheader ], [ %.1, %25 ]
  %.01922 = phi float [ %0, %.lr.ph.preheader ], [ %.120, %25 ]
  %6 = shl i32 %.024, 1
  %7 = fcmp ogt float %.01922, 0.000000e+00
  br i1 %7, label %8, label %17

8:                                                ; preds = %.lr.ph
  %9 = or disjoint i32 %6, 1
  %10 = trunc nuw i64 %indvars.iv to i32
  %11 = xor i32 %10, -1
  %12 = add i32 %11, %1
  %13 = zext i32 %12 to i64
  %14 = getelementptr inbounds float, ptr %2, i64 %13
  %15 = load float, ptr %14, align 4, !tbaa !5
  %16 = fsub float %.01922, %15
  br label %25

17:                                               ; preds = %.lr.ph
  %18 = trunc nuw i64 %indvars.iv to i32
  %19 = xor i32 %18, -1
  %20 = add i32 %19, %1
  %21 = zext i32 %20 to i64
  %22 = getelementptr inbounds float, ptr %2, i64 %21
  %23 = load float, ptr %22, align 4, !tbaa !5
  %24 = fadd float %.01922, %23
  br label %25

25:                                               ; preds = %8, %17
  %.120 = phi float [ %16, %8 ], [ %24, %17 ]
  %.1 = phi i32 [ %9, %8 ], [ %6, %17 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %25, %5
  %.019.lcssa = phi float [ %0, %5 ], [ %.120, %25 ]
  %.0.lcssa = phi i32 [ 0, %5 ], [ %.1, %25 ]
  store i32 %.0.lcssa, ptr %3, align 4, !tbaa !11
  store float %.019.lcssa, ptr %4, align 4, !tbaa !5
  ret i32 0
}

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

!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 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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