; 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.5 = type { ptr }

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.34 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [40 x i8], align 1

; 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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @modemcf_modulate_sqam128(ptr noundef %0, i32 noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = lshr i32 %12, 5
  %14 = and i32 %13, 3
  store i32 %14, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = and i32 %15, 31
  store i32 %16, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.modemcf_s, ptr %17, i32 0, i32 8
  %19 = getelementptr inbounds %struct.anon.5, ptr %18, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = load i32, ptr %9, align 4, !tbaa !9
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds { float, float }, ptr %20, i64 %22
  %24 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 0
  %25 = load float, ptr %24, align 4
  %26 = getelementptr inbounds { float, float }, ptr %23, i32 0, i32 1
  %27 = load float, ptr %26, align 4
  %28 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %29 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %25, ptr %28, align 4
  store float %27, ptr %29, align 4
  %30 = load i32, ptr %8, align 4, !tbaa !9
  switch i32 %30, label %69 [
    i32 0, label %31
    i32 1, label %39
    i32 2, label %48
    i32 3, label %59
  ]

31:                                               ; preds = %3
  %32 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %33 = load float, ptr %32, align 4
  %34 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %35 = load float, ptr %34, align 4
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds { float, float }, ptr %36, i32 0, i32 0
  %38 = getelementptr inbounds { float, float }, ptr %36, i32 0, i32 1
  store float %33, ptr %37, align 4
  store float %35, ptr %38, align 4
  br label %71

39:                                               ; preds = %3
  %40 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %41 = load float, ptr %40, align 4
  %42 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %43 = load float, ptr %42, align 4
  %44 = fneg float %43
  %45 = load ptr, ptr %7, align 8, !tbaa !5
  %46 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %45, i32 0, i32 1
  store float %41, ptr %46, align 4
  store float %44, ptr %47, align 4
  br label %71

48:                                               ; preds = %3
  %49 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %50 = load float, ptr %49, align 4
  %51 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %52 = load float, ptr %51, align 4
  %53 = fneg float %52
  %54 = fneg float %50
  %55 = fneg float %53
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 0
  %58 = getelementptr inbounds { float, float }, ptr %56, i32 0, i32 1
  store float %54, ptr %57, align 4
  store float %55, ptr %58, align 4
  br label %71

59:                                               ; preds = %3
  %60 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = fneg float %61
  %65 = fneg float %63
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  %67 = getelementptr inbounds { float, float }, ptr %66, i32 0, i32 0
  %68 = getelementptr inbounds { float, float }, ptr %66, i32 0, i32 1
  store float %64, ptr %67, align 4
  store float %65, ptr %68, align 4
  br label %71

69:                                               ; preds = %3
  %70 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str.34, i32 noundef 69, ptr noundef @.str.35, ptr noundef @.str.2)
  store i32 %70, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %72

71:                                               ; preds = %59, %48, %39, %31
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %72

72:                                               ; preds = %71, %69
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %73 = load i32, ptr %4, align 4
  ret i32 %73
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 = !{!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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @modemcf_modulate_sqam128(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #0 {
  %4 = lshr i32 %1, 5
  %5 = and i32 %4, 3
  %6 = and i32 %1, 31
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = zext nneg i32 %6 to i64
  %10 = getelementptr inbounds { float, float }, ptr %8, i64 %9
  %11 = load float, ptr %10, align 4
  %12 = getelementptr inbounds i8, ptr %10, i64 4
  %13 = load float, ptr %12, align 4
  switch i32 %5, label %default.unreachable15 [
    i32 0, label %21
    i32 1, label %14
    i32 2, label %16
    i32 3, label %18
  ]

14:                                               ; preds = %3
  %15 = fneg float %13
  br label %21

16:                                               ; preds = %3
  %17 = fneg float %11
  br label %21

18:                                               ; preds = %3
  %19 = fneg float %11
  %20 = fneg float %13
  br label %21

default.unreachable15:                            ; preds = %3
  unreachable

21:                                               ; preds = %3, %14, %16, %18
  %.sink17 = phi float [ %11, %14 ], [ %17, %16 ], [ %19, %18 ], [ %11, %3 ]
  %.sink = phi float [ %15, %14 ], [ %13, %16 ], [ %20, %18 ], [ %13, %3 ]
  %22 = getelementptr inbounds i8, ptr %2, i64 4
  store float %.sink17, ptr %2, align 4
  store float %.sink, ptr %22, align 4
  ret i32 0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass