; 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.0 = type { float, float, 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
declare dso_local i32 @modemcf_demodulate_linear_array_ref(float noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind
declare float @cosf(float noundef) #2

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

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

declare i32 @gray_encode(i32 noundef) #3

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_demodulate_dpsk(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #4 {
  %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, float }, align 4
  %11 = alloca i32, align 4
  %12 = 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) #5
  %13 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %14 = load float, ptr %13, align 4
  %15 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %16 = load float, ptr %15, align 4
  %17 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %18 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %14, ptr %17, align 4
  store float %16, ptr %18, align 4
  %19 = load <2 x float>, ptr %8, align 4
  %20 = call float @cargf(<2 x float> noundef %19) #5
  store float %20, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %21 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %22 = load float, ptr %21, align 4
  %23 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %24 = load float, ptr %23, align 4
  %25 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %26 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %22, ptr %25, align 4
  store float %24, ptr %26, align 4
  %27 = load <2 x float>, ptr %10, align 4
  %28 = call float @cargf(<2 x float> noundef %27) #5
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.modemcf_s, ptr %29, i32 0, i32 8
  %31 = getelementptr inbounds %struct.anon.0, ptr %30, i32 0, i32 1
  %32 = load float, ptr %31, align 4, !tbaa !11
  %33 = fsub float %28, %32
  store float %33, ptr %9, align 4, !tbaa !9
  %34 = load float, ptr %7, align 4, !tbaa !9
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.modemcf_s, ptr %35, i32 0, i32 8
  %37 = getelementptr inbounds %struct.anon.0, ptr %36, i32 0, i32 1
  store float %34, ptr %37, align 4, !tbaa !11
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.modemcf_s, ptr %38, i32 0, i32 8
  %40 = getelementptr inbounds %struct.anon.0, ptr %39, i32 0, i32 0
  %41 = load float, ptr %40, align 8, !tbaa !11
  %42 = load float, ptr %9, align 4, !tbaa !9
  %43 = fsub float %42, %41
  store float %43, ptr %9, align 4, !tbaa !9
  %44 = load float, ptr %9, align 4, !tbaa !9
  %45 = fpext float %44 to double
  %46 = fcmp ogt double %45, 0x400921FB54442D18
  br i1 %46, label %47, label %52

47:                                               ; preds = %3
  %48 = load float, ptr %9, align 4, !tbaa !9
  %49 = fpext float %48 to double
  %50 = fsub double %49, 0x401921FB54442D18
  %51 = fptrunc double %50 to float
  store float %51, ptr %9, align 4, !tbaa !9
  br label %62

52:                                               ; preds = %3
  %53 = load float, ptr %9, align 4, !tbaa !9
  %54 = fpext float %53 to double
  %55 = fcmp olt double %54, 0xC00921FB54442D18
  br i1 %55, label %56, label %61

56:                                               ; preds = %52
  %57 = load float, ptr %9, align 4, !tbaa !9
  %58 = fpext float %57 to double
  %59 = fadd double %58, 0x401921FB54442D18
  %60 = fptrunc double %59 to float
  store float %60, ptr %9, align 4, !tbaa !9
  br label %61

61:                                               ; preds = %56, %52
  br label %62

62:                                               ; preds = %61, %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %63 = load float, ptr %9, align 4, !tbaa !9
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.modemcf_s, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 4, !tbaa !12
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.modemcf_s, ptr %67, i32 0, i32 3
  %69 = getelementptr inbounds [8 x float], ptr %68, i64 0, i64 0
  %70 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %63, i32 noundef %66, ptr noundef %69, ptr noundef %11, ptr noundef %12)
  %71 = load i32, ptr %11, align 4, !tbaa !15
  %72 = call i32 @gray_encode(i32 noundef %71)
  %73 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %72, ptr %73, align 4, !tbaa !15
  %74 = load float, ptr %7, align 4, !tbaa !9
  %75 = load float, ptr %12, align 4, !tbaa !9
  %76 = fsub float %74, %75
  %77 = call float @cosf(float noundef %76) #5
  %78 = load float, ptr %7, align 4, !tbaa !9
  %79 = load float, ptr %12, align 4, !tbaa !9
  %80 = fsub float %78, %79
  %81 = call float @sinf(float noundef %80) #5
  %82 = fmul float 0.000000e+00, %81
  %83 = fmul float 1.000000e+00, %81
  %84 = fadd float %77, %82
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.modemcf_s, ptr %85, i32 0, i32 7
  %87 = getelementptr inbounds { float, float }, ptr %86, i32 0, i32 0
  %88 = getelementptr inbounds { float, float }, ptr %86, i32 0, i32 1
  store float %84, ptr %87, align 4
  store float %83, ptr %88, align 4
  %89 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %90 = load float, ptr %89, align 4
  %91 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %92 = load float, ptr %91, align 4
  %93 = load ptr, ptr %5, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.modemcf_s, ptr %93, i32 0, i32 6
  %95 = getelementptr inbounds { float, float }, ptr %94, i32 0, i32 0
  %96 = getelementptr inbounds { float, float }, ptr %94, i32 0, i32 1
  store float %90, ptr %95, align 4
  store float %92, ptr %96, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  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 "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 = { "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 #4 = { 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 #5 = { 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 = !{!13, !14, i64 4}
!13 = !{!"modemcf_s", !14, i64 0, !14, i64 4, !14, i64 8, !7, i64 12, !6, i64 48, !14, i64 56, !7, i64 60, !7, i64 68, !7, i64 80, !6, i64 224, !6, i64 232, !6, i64 240, !14, i64 248}
!14 = !{!"int", !7, i64 0}
!15 = !{!14, !14, 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @modemcf_demodulate_linear_array_ref(float noundef, i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

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

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

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

declare i32 @gray_encode(i32 noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @modemcf_demodulate_dpsk(ptr noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #5 {
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = tail call float @cargf(<2 x float> noundef %1) #6
  %7 = tail call float @cargf(<2 x float> noundef %1) #6
  %8 = getelementptr inbounds i8, ptr %0, i64 80
  %9 = getelementptr inbounds i8, ptr %0, i64 84
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = fsub float %7, %10
  store float %6, ptr %9, align 4, !tbaa !5
  %12 = load float, ptr %8, align 8, !tbaa !5
  %13 = fsub float %11, %12
  %14 = fpext float %13 to double
  %15 = fcmp ogt double %14, 0x400921FB54442D18
  br i1 %15, label %16, label %19

16:                                               ; preds = %3
  %17 = fadd double %14, 0xC01921FB54442D18
  %18 = fptrunc double %17 to float
  br label %24

19:                                               ; preds = %3
  %20 = fcmp olt double %14, 0xC00921FB54442D18
  br i1 %20, label %21, label %24

21:                                               ; preds = %19
  %22 = fadd double %14, 0x401921FB54442D18
  %23 = fptrunc double %22 to float
  br label %24

24:                                               ; preds = %19, %21, %16
  %.0 = phi float [ %18, %16 ], [ %23, %21 ], [ %13, %19 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  %25 = getelementptr inbounds i8, ptr %0, i64 4
  %26 = load i32, ptr %25, align 4, !tbaa !8
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %.0, i32 noundef %26, ptr noundef nonnull %27, ptr noundef nonnull %4, ptr noundef nonnull %5)
  %29 = load i32, ptr %4, align 4, !tbaa !12
  %30 = call i32 @gray_encode(i32 noundef %29) #6
  store i32 %30, ptr %2, align 4, !tbaa !12
  %31 = load float, ptr %5, align 4, !tbaa !13
  %32 = fsub float %6, %31
  %33 = call float @cosf(float noundef %32) #6
  %34 = load float, ptr %5, align 4, !tbaa !13
  %35 = fsub float %6, %34
  %36 = call float @sinf(float noundef %35) #6
  %37 = fmul float %36, 0.000000e+00
  %38 = fadd float %33, %37
  %39 = getelementptr inbounds i8, ptr %0, i64 68
  %40 = getelementptr inbounds i8, ptr %0, i64 72
  store float %38, ptr %39, align 4
  store float %36, ptr %40, align 4
  %41 = getelementptr inbounds i8, ptr %0, i64 60
  store <2 x float> %1, ptr %41, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  ret i32 0
}

attributes #0 = { mustprogress 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 = { 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 #3 = { 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 #4 = { "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 #5 = { 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 #6 = { 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 = !{!9, !10, i64 4}
!9 = !{!"modemcf_s", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 12, !11, i64 48, !10, i64 56, !6, i64 60, !6, i64 68, !6, i64 80, !11, i64 224, !11, i64 232, !11, i64 240, !10, i64 248}
!10 = !{!"int", !6, i64 0}
!11 = !{!"any pointer", !6, i64 0}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !6, i64 0}


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