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

%struct.modemcf_s = type { i32, i32, i32, [8 x float], ptr, i32, { float, float }, { float, float }, %union.anon, ptr, ptr, ptr, i32 }
%union.anon = type { %struct.anon.3 }
%struct.anon.3 = type { i32, [8 x i32], [8 x float], [8 x float], [8 x float], ptr }
%struct.anon.6 = type { 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
declare float @cosf(float noundef) #1

; Function Attrs: nounwind
declare float @sinf(float noundef) #1

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_demodulate_pi4dqpsk(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #2 {
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  store <2 x float> %1, ptr %4, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %11 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %12 = load float, ptr %11, align 4
  %13 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %14 = load float, ptr %13, align 4
  %15 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %16 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %12, ptr %15, align 4
  store float %14, ptr %16, align 4
  %17 = load <2 x float>, ptr %8, align 4
  %18 = call float @cargf(<2 x float> noundef %17) #3
  store float %18, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %19 = load float, ptr %7, align 4, !tbaa !9
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.modemcf_s, ptr %20, i32 0, i32 8
  %22 = getelementptr inbounds %struct.anon.6, ptr %21, i32 0, i32 0
  %23 = load float, ptr %22, align 8, !tbaa !11
  %24 = fsub float %19, %23
  store float %24, ptr %9, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %29, %3
  %26 = load float, ptr %9, align 4, !tbaa !9
  %27 = fpext float %26 to double
  %28 = fcmp ogt double %27, 0x400921FB54442D18
  br i1 %28, label %29, label %34

29:                                               ; preds = %25
  %30 = load float, ptr %9, align 4, !tbaa !9
  %31 = fpext float %30 to double
  %32 = fsub double %31, 0x401921FB54442D18
  %33 = fptrunc double %32 to float
  store float %33, ptr %9, align 4, !tbaa !9
  br label %25, !llvm.loop !12

34:                                               ; preds = %25
  br label %35

35:                                               ; preds = %39, %34
  %36 = load float, ptr %9, align 4, !tbaa !9
  %37 = fpext float %36 to double
  %38 = fcmp olt double %37, 0xC00921FB54442D18
  br i1 %38, label %39, label %44

39:                                               ; preds = %35
  %40 = load float, ptr %9, align 4, !tbaa !9
  %41 = fpext float %40 to double
  %42 = fadd double %41, 0x401921FB54442D18
  %43 = fptrunc double %42 to float
  store float %43, ptr %9, align 4, !tbaa !9
  br label %35, !llvm.loop !14

44:                                               ; preds = %35
  %45 = load float, ptr %9, align 4, !tbaa !9
  %46 = fpext float %45 to double
  %47 = fcmp ogt double %46, 0x3FF921FB54442D18
  br i1 %47, label %48, label %50

48:                                               ; preds = %44
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 1, ptr %49, align 4, !tbaa !15
  br label %65

50:                                               ; preds = %44
  %51 = load float, ptr %9, align 4, !tbaa !9
  %52 = fcmp ogt float %51, 0.000000e+00
  br i1 %52, label %53, label %55

53:                                               ; preds = %50
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 0, ptr %54, align 4, !tbaa !15
  br label %64

55:                                               ; preds = %50
  %56 = load float, ptr %9, align 4, !tbaa !9
  %57 = fpext float %56 to double
  %58 = fcmp olt double %57, 0xBFF921FB54442D18
  br i1 %58, label %59, label %61

59:                                               ; preds = %55
  %60 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 3, ptr %60, align 4, !tbaa !15
  br label %63

61:                                               ; preds = %55
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 2, ptr %62, align 4, !tbaa !15
  br label %63

63:                                               ; preds = %61, %59
  br label %64

64:                                               ; preds = %63, %53
  br label %65

65:                                               ; preds = %64, %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store float 0.000000e+00, ptr %10, align 4, !tbaa !9
  %66 = load ptr, ptr %6, align 8, !tbaa !5
  %67 = load i32, ptr %66, align 4, !tbaa !15
  switch i32 %67, label %72 [
    i32 0, label %68
    i32 1, label %69
    i32 2, label %70
    i32 3, label %71
  ]

68:                                               ; preds = %65
  store float 0x3FE921FB60000000, ptr %10, align 4, !tbaa !9
  br label %73

69:                                               ; preds = %65
  store float 0x4002D97C80000000, ptr %10, align 4, !tbaa !9
  br label %73

70:                                               ; preds = %65
  store float 0xBFE921FB60000000, ptr %10, align 4, !tbaa !9
  br label %73

71:                                               ; preds = %65
  store float 0xC002D97C80000000, ptr %10, align 4, !tbaa !9
  br label %73

72:                                               ; preds = %65
  br label %73

73:                                               ; preds = %72, %71, %70, %69, %68
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.modemcf_s, ptr %74, i32 0, i32 8
  %76 = getelementptr inbounds %struct.anon.6, ptr %75, i32 0, i32 0
  %77 = load float, ptr %76, align 8, !tbaa !11
  %78 = load float, ptr %10, align 4, !tbaa !9
  %79 = fadd float %77, %78
  %80 = call float @cosf(float noundef %79) #3
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.modemcf_s, ptr %81, i32 0, i32 8
  %83 = getelementptr inbounds %struct.anon.6, ptr %82, i32 0, i32 0
  %84 = load float, ptr %83, align 8, !tbaa !11
  %85 = load float, ptr %10, align 4, !tbaa !9
  %86 = fadd float %84, %85
  %87 = call float @sinf(float noundef %86) #3
  %88 = fmul float 0.000000e+00, %87
  %89 = fmul float 1.000000e+00, %87
  %90 = fadd float %80, %88
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.modemcf_s, ptr %91, i32 0, i32 7
  %93 = getelementptr inbounds { float, float }, ptr %92, i32 0, i32 0
  %94 = getelementptr inbounds { float, float }, ptr %92, i32 0, i32 1
  store float %90, ptr %93, align 4
  store float %89, ptr %94, align 4
  %95 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %96 = load float, ptr %95, align 4
  %97 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %98 = load float, ptr %97, align 4
  %99 = load ptr, ptr %5, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.modemcf_s, ptr %99, i32 0, i32 6
  %101 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 0
  %102 = getelementptr inbounds { float, float }, ptr %100, i32 0, i32 1
  store float %96, ptr %101, align 4
  store float %98, ptr %102, align 4
  %103 = load float, ptr %7, align 4, !tbaa !9
  %104 = load ptr, ptr %5, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.modemcf_s, ptr %104, i32 0, i32 8
  %106 = getelementptr inbounds %struct.anon.6, ptr %105, i32 0, i32 0
  store float %103, ptr %106, align 8, !tbaa !11
  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 %7) #3
  ret i32 0
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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"="64" "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 = !{!"float", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}


; 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 nofree nounwind willreturn memory(write)
declare float @cosf(float noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sinf(float noundef) local_unnamed_addr #0

; Function Attrs: nounwind
declare float @cargf(<2 x float> noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @modemcf_demodulate_pi4dqpsk(ptr nocapture noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = tail call float @cargf(<2 x float> noundef %1) #3
  %5 = getelementptr inbounds i8, ptr %0, i64 80
  %6 = load float, ptr %5, align 8, !tbaa !5
  %7 = fsub float %4, %6
  %8 = fpext float %7 to double
  %9 = fcmp ogt double %8, 0x400921FB54442D18
  br i1 %9, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %3
  %.pre-phi = phi double [ %8, %3 ], [ %14, %.lr.ph ]
  %.028.lcssa = phi float [ %7, %3 ], [ %13, %.lr.ph ]
  %10 = fcmp olt double %.pre-phi, 0xC00921FB54442D18
  br i1 %10, label %.lr.ph34, label %._crit_edge

.lr.ph:                                           ; preds = %3, %.lr.ph
  %11 = phi double [ %14, %.lr.ph ], [ %8, %3 ]
  %12 = fadd double %11, 0xC01921FB54442D18
  %13 = fptrunc double %12 to float
  %14 = fpext float %13 to double
  %15 = fcmp ogt double %14, 0x400921FB54442D18
  br i1 %15, label %.lr.ph, label %.preheader, !llvm.loop !8

.lr.ph34:                                         ; preds = %.preheader, %.lr.ph34
  %16 = phi double [ %19, %.lr.ph34 ], [ %.pre-phi, %.preheader ]
  %17 = fadd double %16, 0x401921FB54442D18
  %18 = fptrunc double %17 to float
  %19 = fpext float %18 to double
  %20 = fcmp olt double %19, 0xC00921FB54442D18
  br i1 %20, label %.lr.ph34, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph34, %.preheader
  %.1.lcssa = phi float [ %.028.lcssa, %.preheader ], [ %18, %.lr.ph34 ]
  %.lcssa = phi double [ %.pre-phi, %.preheader ], [ %19, %.lr.ph34 ]
  %21 = fcmp ogt double %.lcssa, 0x3FF921FB54442D18
  br i1 %21, label %26, label %22

22:                                               ; preds = %._crit_edge
  %23 = fcmp ogt float %.1.lcssa, 0.000000e+00
  br i1 %23, label %26, label %24

24:                                               ; preds = %22
  %25 = fcmp olt double %.lcssa, 0xBFF921FB54442D18
  %. = select i1 %25, i32 3, i32 2
  %.44 = select i1 %25, float 0xC002D97C80000000, float 0xBFE921FB60000000
  br label %26

26:                                               ; preds = %._crit_edge, %22, %24
  %.sink = phi i32 [ %., %24 ], [ 0, %22 ], [ 1, %._crit_edge ]
  %.0 = phi float [ %.44, %24 ], [ 0x3FE921FB60000000, %22 ], [ 0x4002D97C80000000, %._crit_edge ]
  store i32 %.sink, ptr %2, align 4, !tbaa !11
  %27 = load float, ptr %5, align 8, !tbaa !5
  %28 = fadd float %.0, %27
  %29 = tail call float @cosf(float noundef %28) #3
  %30 = load float, ptr %5, align 8, !tbaa !5
  %31 = fadd float %.0, %30
  %32 = tail call float @sinf(float noundef %31) #3
  %33 = fmul float %32, 0.000000e+00
  %34 = fadd float %29, %33
  %35 = getelementptr inbounds i8, ptr %0, i64 68
  %36 = getelementptr inbounds i8, ptr %0, i64 72
  store float %34, ptr %35, align 4
  store float %32, ptr %36, align 4
  %37 = getelementptr inbounds i8, ptr %0, i64 60
  store <2 x float> %1, ptr %37, align 4
  store float %4, ptr %5, align 8, !tbaa !5
  ret i32 0
}

attributes #0 = { mustprogress nofree nounwind willreturn memory(write) "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 "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"="64" "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = distinct !{!10, !9}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !6, i64 0}


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