; 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 uwtable
define dso_local i32 @modemcf_modulate_pi4dqpsk(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store float 0.000000e+00, ptr %7, align 4, !tbaa !11
  %8 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %8, label %13 [
    i32 0, label %9
    i32 1, label %10
    i32 2, label %11
    i32 3, label %12
  ]

9:                                                ; preds = %3
  store float 0x3FE921FB60000000, ptr %7, align 4, !tbaa !11
  br label %14

10:                                               ; preds = %3
  store float 0x4002D97C80000000, ptr %7, align 4, !tbaa !11
  br label %14

11:                                               ; preds = %3
  store float 0xBFE921FB60000000, ptr %7, align 4, !tbaa !11
  br label %14

12:                                               ; preds = %3
  store float 0xC002D97C80000000, ptr %7, align 4, !tbaa !11
  br label %14

13:                                               ; preds = %3
  br label %14

14:                                               ; preds = %13, %12, %11, %10, %9
  %15 = load float, ptr %7, align 4, !tbaa !11
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.modemcf_s, ptr %16, i32 0, i32 8
  %18 = getelementptr inbounds %struct.anon.6, ptr %17, i32 0, i32 0
  %19 = load float, ptr %18, align 8, !tbaa !13
  %20 = fadd float %19, %15
  store float %20, ptr %18, align 8, !tbaa !13
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.modemcf_s, ptr %21, i32 0, i32 8
  %23 = getelementptr inbounds %struct.anon.6, ptr %22, i32 0, i32 0
  %24 = load float, ptr %23, align 8, !tbaa !13
  %25 = fpext float %24 to double
  %26 = fcmp ogt double %25, 0x400921FB54442D18
  br i1 %26, label %27, label %35

27:                                               ; preds = %14
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.modemcf_s, ptr %28, i32 0, i32 8
  %30 = getelementptr inbounds %struct.anon.6, ptr %29, i32 0, i32 0
  %31 = load float, ptr %30, align 8, !tbaa !13
  %32 = fpext float %31 to double
  %33 = fsub double %32, 0x401921FB54442D18
  %34 = fptrunc double %33 to float
  store float %34, ptr %30, align 8, !tbaa !13
  br label %35

35:                                               ; preds = %27, %14
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.modemcf_s, ptr %36, i32 0, i32 8
  %38 = getelementptr inbounds %struct.anon.6, ptr %37, i32 0, i32 0
  %39 = load float, ptr %38, align 8, !tbaa !13
  %40 = fpext float %39 to double
  %41 = fcmp olt double %40, 0xC00921FB54442D18
  br i1 %41, label %42, label %50

42:                                               ; preds = %35
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.modemcf_s, ptr %43, i32 0, i32 8
  %45 = getelementptr inbounds %struct.anon.6, ptr %44, i32 0, i32 0
  %46 = load float, ptr %45, align 8, !tbaa !13
  %47 = fpext float %46 to double
  %48 = fadd double %47, 0x401921FB54442D18
  %49 = fptrunc double %48 to float
  store float %49, ptr %45, align 8, !tbaa !13
  br label %50

50:                                               ; preds = %42, %35
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.modemcf_s, ptr %51, i32 0, i32 8
  %53 = getelementptr inbounds %struct.anon.6, ptr %52, i32 0, i32 0
  %54 = load float, ptr %53, align 8, !tbaa !13
  %55 = call float @cosf(float noundef %54) #3
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.modemcf_s, ptr %56, i32 0, i32 8
  %58 = getelementptr inbounds %struct.anon.6, ptr %57, i32 0, i32 0
  %59 = load float, ptr %58, align 8, !tbaa !13
  %60 = call float @sinf(float noundef %59) #3
  %61 = fmul float 0.000000e+00, %60
  %62 = fmul float 1.000000e+00, %60
  %63 = fadd float %55, %61
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds { float, float }, ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds { float, float }, ptr %64, i32 0, i32 1
  store float %63, ptr %65, align 4
  store float %62, ptr %66, align 4
  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"="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 #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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!7, !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"

@switch.table.modemcf_modulate_pi4dqpsk = private unnamed_addr constant [4 x float] [float 0x3FE921FB60000000, float 0x4002D97C80000000, float 0xBFE921FB60000000, float 0xC002D97C80000000], align 4

; 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: mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local noundef i32 @modemcf_modulate_pi4dqpsk(ptr nocapture noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = icmp ult i32 %1, 4
  br i1 %4, label %switch.lookup, label %6

switch.lookup:                                    ; preds = %3
  %5 = zext nneg i32 %1 to i64
  %switch.gep = getelementptr inbounds [4 x float], ptr @switch.table.modemcf_modulate_pi4dqpsk, i64 0, i64 %5
  %switch.load = load float, ptr %switch.gep, align 4
  br label %6

6:                                                ; preds = %switch.lookup, %3
  %.0 = phi float [ 0.000000e+00, %3 ], [ %switch.load, %switch.lookup ]
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load float, ptr %7, align 8, !tbaa !5
  %9 = fadd float %.0, %8
  %10 = fpext float %9 to double
  %11 = fcmp ogt double %10, 0x400921FB54442D18
  %12 = fadd double %10, 0xC01921FB54442D18
  %13 = fptrunc double %12 to float
  %storemerge = select i1 %11, float %13, float %9
  %14 = fpext float %storemerge to double
  %15 = fcmp olt double %14, 0xC00921FB54442D18
  %16 = fadd double %14, 0x401921FB54442D18
  %17 = fptrunc double %16 to float
  %storemerge11 = select i1 %15, float %17, float %storemerge
  store float %storemerge11, ptr %7, align 8, !tbaa !5
  %18 = tail call float @cosf(float noundef %storemerge11) #2
  %19 = load float, ptr %7, align 8, !tbaa !5
  %20 = tail call float @sinf(float noundef %19) #2
  %21 = fmul float %20, 0.000000e+00
  %22 = fadd float %18, %21
  %23 = getelementptr inbounds i8, ptr %2, i64 4
  store float %22, ptr %2, align 4
  store float %20, ptr %23, align 4
  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 = { mustprogress nofree nounwind willreturn memory(write, 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass