; 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.2 = type { i32, i32, i32, i32, 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

declare i32 @gray_encode(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_demodulate_qam(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #3 {
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, 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) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %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 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.modemcf_s, ptr %15, i32 0, i32 8
  %17 = getelementptr inbounds %struct.anon.2, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.modemcf_s, ptr %19, i32 0, i32 3
  %21 = getelementptr inbounds [8 x float], ptr %20, i64 0, i64 0
  %22 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %12, i32 noundef %18, ptr noundef %21, ptr noundef %7, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %23 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %24 = load float, ptr %23, align 4
  %25 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %26 = load float, ptr %25, align 4
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.modemcf_s, ptr %27, i32 0, i32 8
  %29 = getelementptr inbounds %struct.anon.2, ptr %28, i32 0, i32 1
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.modemcf_s, ptr %31, i32 0, i32 3
  %33 = getelementptr inbounds [8 x float], ptr %32, i64 0, i64 0
  %34 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %26, i32 noundef %30, ptr noundef %33, ptr noundef %9, ptr noundef %10)
  %35 = load i32, ptr %7, align 4, !tbaa !10
  %36 = call i32 @gray_encode(i32 noundef %35)
  store i32 %36, ptr %7, align 4, !tbaa !10
  %37 = load i32, ptr %9, align 4, !tbaa !10
  %38 = call i32 @gray_encode(i32 noundef %37)
  store i32 %38, ptr %9, align 4, !tbaa !10
  %39 = load i32, ptr %7, align 4, !tbaa !10
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.modemcf_s, ptr %40, i32 0, i32 8
  %42 = getelementptr inbounds %struct.anon.2, ptr %41, i32 0, i32 1
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = shl i32 %39, %43
  %45 = load i32, ptr %9, align 4, !tbaa !10
  %46 = add i32 %44, %45
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  store i32 %46, ptr %47, align 4, !tbaa !10
  %48 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %49 = load float, ptr %48, align 4
  %50 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %51 = load float, ptr %50, align 4
  %52 = load float, ptr %8, align 4, !tbaa !12
  %53 = load float, ptr %10, align 4, !tbaa !12
  %54 = fmul float 0.000000e+00, %53
  %55 = fmul float 1.000000e+00, %53
  %56 = fadd float %52, %54
  %57 = fsub float %49, %56
  %58 = fsub float %51, %55
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.modemcf_s, ptr %59, i32 0, i32 7
  %61 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 0
  %62 = getelementptr inbounds { float, float }, ptr %60, i32 0, i32 1
  store float %57, ptr %61, align 4
  store float %58, ptr %62, align 4
  %63 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %64 = load float, ptr %63, align 4
  %65 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %66 = load float, ptr %65, align 4
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.modemcf_s, ptr %67, i32 0, i32 6
  %69 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 1
  store float %64, ptr %69, align 4
  store float %66, ptr %70, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  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 = { "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 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 #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !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 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

declare i32 @gray_encode(i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @modemcf_demodulate_qam(ptr noundef %0, <2 x float> noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #3 {
  %4 = extractelement <2 x float> %1, i64 1
  %5 = extractelement <2 x float> %1, i64 0
  %6 = alloca i32, align 4
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  %10 = getelementptr inbounds i8, ptr %0, i64 80
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 12
  %13 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %5, i32 noundef %11, ptr noundef nonnull %12, ptr noundef nonnull %6, ptr noundef nonnull %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  %14 = getelementptr inbounds i8, ptr %0, i64 84
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = call i32 @modemcf_demodulate_linear_array_ref(float noundef %4, i32 noundef %15, ptr noundef nonnull %12, ptr noundef nonnull %8, ptr noundef nonnull %9)
  %17 = load i32, ptr %6, align 4, !tbaa !8
  %18 = call i32 @gray_encode(i32 noundef %17) #4
  store i32 %18, ptr %6, align 4, !tbaa !8
  %19 = load i32, ptr %8, align 4, !tbaa !8
  %20 = call i32 @gray_encode(i32 noundef %19) #4
  %21 = load i32, ptr %6, align 4, !tbaa !8
  %22 = load i32, ptr %14, align 4, !tbaa !5
  %23 = shl i32 %21, %22
  %24 = add i32 %23, %20
  store i32 %24, ptr %2, align 4, !tbaa !8
  %25 = load float, ptr %7, align 4, !tbaa !10
  %26 = load float, ptr %9, align 4, !tbaa !10
  %27 = fmul float %26, 0.000000e+00
  %28 = fadd float %25, %27
  %29 = getelementptr inbounds i8, ptr %0, i64 68
  %30 = insertelement <2 x float> poison, float %28, i64 0
  %31 = insertelement <2 x float> %30, float %26, i64 1
  %32 = fsub <2 x float> %1, %31
  store <2 x float> %32, ptr %29, align 4
  %33 = getelementptr inbounds i8, ptr %0, i64 60
  store <2 x float> %1, ptr %33, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #4
  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 = { "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 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 #4 = { 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, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !6, i64 0}


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