; LLVM IR from jgaeddert/liquid-dsp :: src/modem/src (fskdem)

; 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.fskdem_s = type { i32, i32, float, i32, float, i32, ptr, ptr, ptr, ptr, i32 }

; 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 @cabsf(<2 x float> noundef) #1

; Function Attrs: nounwind uwtable
define dso_local float @fskdem_get_frequency_error(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca { float, float }, align 4
  %5 = alloca float, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca float, align 4
  %8 = alloca { float, float }, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.fskdem_s, ptr %9, i32 0, i32 7
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.fskdem_s, ptr %12, i32 0, i32 10
  %14 = load i32, ptr %13, align 8, !tbaa !13
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.fskdem_s, ptr %15, i32 0, i32 5
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %18 = add i32 %14, %17
  %19 = sub i32 %18, 1
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.fskdem_s, ptr %20, i32 0, i32 5
  %22 = load i32, ptr %21, align 4, !tbaa !14
  %23 = urem i32 %19, %22
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds { float, float }, ptr %11, i64 %24
  %26 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 0
  %27 = load float, ptr %26, align 4
  %28 = getelementptr inbounds { float, float }, ptr %25, i32 0, i32 1
  %29 = load float, ptr %28, align 4
  %30 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %31 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  store float %27, ptr %30, align 4
  store float %29, ptr %31, align 4
  %32 = load <2 x float>, ptr %4, align 4
  %33 = call float @cabsf(<2 x float> noundef %32) #3
  store float %33, ptr %3, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %34 = load ptr, ptr %2, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.fskdem_s, ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = load ptr, ptr %2, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.fskdem_s, ptr %37, i32 0, i32 10
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = zext i32 %39 to i64
  %41 = getelementptr inbounds { float, float }, ptr %36, i64 %40
  %42 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 0
  %43 = load float, ptr %42, align 4
  %44 = getelementptr inbounds { float, float }, ptr %41, i32 0, i32 1
  %45 = load float, ptr %44, align 4
  %46 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %47 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %43, ptr %46, align 4
  store float %45, ptr %47, align 4
  %48 = load <2 x float>, ptr %6, align 4
  %49 = call float @cabsf(<2 x float> noundef %48) #3
  store float %49, ptr %5, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.fskdem_s, ptr %50, i32 0, i32 7
  %52 = load ptr, ptr %51, align 8, !tbaa !9
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.fskdem_s, ptr %53, i32 0, i32 10
  %55 = load i32, ptr %54, align 8, !tbaa !13
  %56 = add i32 %55, 1
  %57 = load ptr, ptr %2, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.fskdem_s, ptr %57, i32 0, i32 5
  %59 = load i32, ptr %58, align 4, !tbaa !14
  %60 = urem i32 %56, %59
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds { float, float }, ptr %52, i64 %61
  %63 = getelementptr inbounds { float, float }, ptr %62, i32 0, i32 0
  %64 = load float, ptr %63, align 4
  %65 = getelementptr inbounds { float, float }, ptr %62, i32 0, i32 1
  %66 = load float, ptr %65, align 4
  %67 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %68 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  store float %64, ptr %67, align 4
  store float %66, ptr %68, align 4
  %69 = load <2 x float>, ptr %8, align 4
  %70 = call float @cabsf(<2 x float> noundef %69) #3
  store float %70, ptr %7, align 4, !tbaa !15
  %71 = load float, ptr %7, align 4, !tbaa !15
  %72 = load float, ptr %3, align 4, !tbaa !15
  %73 = fsub float %71, %72
  %74 = load float, ptr %5, align 4, !tbaa !15
  %75 = fdiv float %73, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %75
}

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, !6, i64 32}
!10 = !{!"fskdem_s", !11, i64 0, !11, i64 4, !12, i64 8, !11, i64 12, !12, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!10, !11, i64 56}
!14 = !{!10, !11, i64 20}
!15 = !{!12, !12, 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: nounwind
declare float @cabsf(<2 x float> noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @fskdem_get_frequency_error(ptr nocapture noundef readonly %0) local_unnamed_addr #1 {
  %2 = getelementptr inbounds i8, ptr %0, i64 32
  %3 = load ptr, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 56
  %5 = load i32, ptr %4, align 8, !tbaa !12
  %6 = getelementptr inbounds i8, ptr %0, i64 20
  %7 = load i32, ptr %6, align 4, !tbaa !13
  %8 = add i32 %5, -1
  %9 = add i32 %8, %7
  %10 = urem i32 %9, %7
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds { float, float }, ptr %3, i64 %11
  %13 = load <2 x float>, ptr %12, align 4
  %14 = tail call float @cabsf(<2 x float> noundef %13) #2
  %15 = load ptr, ptr %2, align 8, !tbaa !5
  %16 = load i32, ptr %4, align 8, !tbaa !12
  %17 = zext i32 %16 to i64
  %18 = getelementptr inbounds { float, float }, ptr %15, i64 %17
  %19 = load <2 x float>, ptr %18, align 4
  %20 = tail call float @cabsf(<2 x float> noundef %19) #2
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = load i32, ptr %4, align 8, !tbaa !12
  %23 = add i32 %22, 1
  %24 = load i32, ptr %6, align 4, !tbaa !13
  %25 = urem i32 %23, %24
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds { float, float }, ptr %21, i64 %26
  %28 = load <2 x float>, ptr %27, align 4
  %29 = tail call float @cabsf(<2 x float> noundef %28) #2
  %30 = fsub float %29, %14
  %31 = fdiv float %30, %20
  ret float %31
}

attributes #0 = { 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 #1 = { 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 #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, !11, i64 32}
!6 = !{!"fskdem_s", !7, i64 0, !7, i64 4, !10, i64 8, !7, i64 12, !10, i64 16, !7, i64 20, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !7, i64 56}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !7, i64 56}
!13 = !{!6, !7, i64 20}


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