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

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @ampmodem_demod_ssb_pll_carrier(ptr noundef %0, <2 x float> noundef %1, ptr noundef %2) #1 {
  %4 = alloca { float, float }, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca { float, float }, align 4
  %8 = alloca { float, float }, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca { float, float }, align 4
  %11 = alloca { float, float }, align 4
  %12 = alloca { float, float }, align 4
  %13 = alloca { float, float }, align 4
  %14 = alloca { float, float }, align 4
  %15 = alloca float, align 4
  %16 = alloca float, align 4
  %17 = alloca float, align 4
  %18 = alloca { float, float }, align 4
  %19 = 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 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ampmodem_s, ptr %20, i32 0, i32 7
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %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 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %28 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %24, ptr %27, align 4
  store float %26, ptr %28, align 4
  %29 = load <2 x float>, ptr %9, align 4
  %30 = call i32 @firfilt_crcf_push(ptr noundef %22, <2 x float> noundef %29)
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ampmodem_s, ptr %31, i32 0, i32 7
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call i32 @firfilt_crcf_execute(ptr noundef %33, ptr noundef %7)
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.ampmodem_s, ptr %35, i32 0, i32 8
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  %38 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 0
  %39 = load float, ptr %38, align 4
  %40 = getelementptr inbounds { float, float }, ptr %4, i32 0, i32 1
  %41 = load float, ptr %40, align 4
  %42 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 0
  %43 = getelementptr inbounds { float, float }, ptr %10, i32 0, i32 1
  store float %39, ptr %42, align 4
  store float %41, ptr %43, align 4
  %44 = load <2 x float>, ptr %10, align 4
  %45 = call i32 @wdelaycf_push(ptr noundef %37, <2 x float> noundef %44)
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ampmodem_s, ptr %46, i32 0, i32 8
  %48 = load ptr, ptr %47, align 8, !tbaa !13
  %49 = call i32 @wdelaycf_read(ptr noundef %48, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ampmodem_s, ptr %50, i32 0, i32 4
  %52 = load ptr, ptr %51, align 8, !tbaa !14
  %53 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %54 = load float, ptr %53, align 4
  %55 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %56 = load float, ptr %55, align 4
  %57 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 0
  %58 = getelementptr inbounds { float, float }, ptr %13, i32 0, i32 1
  store float %54, ptr %57, align 4
  store float %56, ptr %58, align 4
  %59 = load <2 x float>, ptr %13, align 4
  %60 = call i32 @nco_crcf_mix_down(ptr noundef %52, <2 x float> noundef %59, ptr noundef %11)
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.ampmodem_s, ptr %61, i32 0, i32 4
  %63 = load ptr, ptr %62, align 8, !tbaa !14
  %64 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 0
  %65 = load float, ptr %64, align 4
  %66 = getelementptr inbounds { float, float }, ptr %8, i32 0, i32 1
  %67 = load float, ptr %66, align 4
  %68 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 0
  %69 = getelementptr inbounds { float, float }, ptr %14, i32 0, i32 1
  store float %65, ptr %68, align 4
  store float %67, ptr %69, align 4
  %70 = load <2 x float>, ptr %14, align 4
  %71 = call i32 @nco_crcf_mix_down(ptr noundef %63, <2 x float> noundef %70, ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %72 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 0
  %73 = load float, ptr %72, align 4
  %74 = getelementptr inbounds { float, float }, ptr %11, i32 0, i32 1
  %75 = load float, ptr %74, align 4
  store float %75, ptr %15, align 4, !tbaa !15
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ampmodem_s, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !14
  %79 = load float, ptr %15, align 4, !tbaa !15
  %80 = call i32 @nco_crcf_pll_step(ptr noundef %78, float noundef %79)
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.ampmodem_s, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !14
  %84 = call i32 @nco_crcf_step(ptr noundef %83)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ampmodem_s, ptr %85, i32 0, i32 6
  %87 = load ptr, ptr %86, align 8, !tbaa !16
  %88 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 0
  %89 = load float, ptr %88, align 4
  %90 = getelementptr inbounds { float, float }, ptr %12, i32 0, i32 1
  %91 = load float, ptr %90, align 4
  %92 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %93 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  store float %89, ptr %92, align 4
  store float %91, ptr %93, align 4
  %94 = load <2 x float>, ptr %18, align 4
  %95 = call i32 @firhilbf_c2r_execute(ptr noundef %87, <2 x float> noundef %94, ptr noundef %16, ptr noundef %17)
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ampmodem_s, ptr %96, i32 0, i32 1
  %98 = load i32, ptr %97, align 4, !tbaa !17
  %99 = icmp eq i32 %98, 1
  br i1 %99, label %100, label %102

100:                                              ; preds = %3
  %101 = load float, ptr %17, align 4, !tbaa !15
  br label %104

102:                                              ; preds = %3
  %103 = load float, ptr %16, align 4, !tbaa !15
  br label %104

104:                                              ; preds = %102, %100
  %105 = phi float [ %101, %100 ], [ %103, %102 ]
  %106 = fmul float 5.000000e-01, %105
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.ampmodem_s, ptr %107, i32 0, i32 0
  %109 = load float, ptr %108, align 8, !tbaa !18
  %110 = fdiv float %106, %109
  store float %110, ptr %19, align 4, !tbaa !15
  %111 = load ptr, ptr %5, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.ampmodem_s, ptr %111, i32 0, i32 5
  %113 = load ptr, ptr %112, align 8, !tbaa !19
  %114 = load float, ptr %19, align 4, !tbaa !15
  %115 = call i32 @firfilt_rrrf_push(ptr noundef %113, float noundef %114)
  %116 = load ptr, ptr %5, align 8, !tbaa !5
  %117 = getelementptr inbounds %struct.ampmodem_s, ptr %116, i32 0, i32 5
  %118 = load ptr, ptr %117, align 8, !tbaa !19
  %119 = load ptr, ptr %6, align 8, !tbaa !5
  %120 = call i32 @firfilt_rrrf_execute(ptr noundef %118, ptr noundef %119)
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret i32 0
}

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

declare i32 @firfilt_rrrf_push(ptr noundef, float noundef) #2

declare i32 @firfilt_rrrf_execute(ptr noundef, ptr noundef) #2

declare i32 @firfilt_crcf_push(ptr noundef, <2 x float> noundef) #2

declare i32 @firfilt_crcf_execute(ptr noundef, ptr noundef) #2

declare i32 @wdelaycf_push(ptr noundef, <2 x float> noundef) #2

declare i32 @wdelaycf_read(ptr noundef, ptr noundef) #2

declare i32 @nco_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) #2

declare i32 @nco_crcf_pll_step(ptr noundef, float noundef) #2

declare i32 @nco_crcf_step(ptr noundef) #2

declare i32 @firhilbf_c2r_execute(ptr noundef, <2 x float> noundef, ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 40}
!10 = !{!"ampmodem_s", !11, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"float", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, i64 48}
!14 = !{!10, !6, i64 16}
!15 = !{!11, !11, i64 0}
!16 = !{!10, !6, i64 32}
!17 = !{!10, !12, i64 4}
!18 = !{!10, !11, i64 0}
!19 = !{!10, !6, i64 24}


; 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: nounwind uwtable
define dso_local noundef i32 @ampmodem_demod_ssb_pll_carrier(ptr nocapture noundef readonly %0, <2 x float> noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = alloca { float, float }, align 8
  %5 = alloca { float, float }, align 8
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #3
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call i32 @firfilt_crcf_push(ptr noundef %11, <2 x float> noundef %1) #3
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = call i32 @firfilt_crcf_execute(ptr noundef %13, ptr noundef nonnull %4) #3
  %15 = getelementptr inbounds i8, ptr %0, i64 48
  %16 = load ptr, ptr %15, align 8, !tbaa !12
  %17 = call i32 @wdelaycf_push(ptr noundef %16, <2 x float> noundef %1) #3
  %18 = load ptr, ptr %15, align 8, !tbaa !12
  %19 = call i32 @wdelaycf_read(ptr noundef %18, ptr noundef nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %20 = getelementptr inbounds i8, ptr %0, i64 16
  %21 = load ptr, ptr %20, align 8, !tbaa !13
  %22 = load <2 x float>, ptr %4, align 8
  %23 = call i32 @nco_crcf_mix_down(ptr noundef %21, <2 x float> noundef %22, ptr noundef nonnull %6) #3
  %24 = load ptr, ptr %20, align 8, !tbaa !13
  %25 = load <2 x float>, ptr %5, align 8
  %26 = call i32 @nco_crcf_mix_down(ptr noundef %24, <2 x float> noundef %25, ptr noundef nonnull %7) #3
  %27 = getelementptr inbounds i8, ptr %6, i64 4
  %28 = load float, ptr %27, align 4
  %29 = load ptr, ptr %20, align 8, !tbaa !13
  %30 = call i32 @nco_crcf_pll_step(ptr noundef %29, float noundef %28) #3
  %31 = load ptr, ptr %20, align 8, !tbaa !13
  %32 = call i32 @nco_crcf_step(ptr noundef %31) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %33 = getelementptr inbounds i8, ptr %0, i64 32
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  %35 = load <2 x float>, ptr %7, align 8
  %36 = call i32 @firhilbf_c2r_execute(ptr noundef %34, <2 x float> noundef %35, ptr noundef nonnull %8, ptr noundef nonnull %9) #3
  %37 = getelementptr inbounds i8, ptr %0, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !15
  %39 = icmp eq i32 %38, 1
  %40 = load float, ptr %9, align 4
  %41 = load float, ptr %8, align 4
  %42 = select i1 %39, float %40, float %41
  %43 = fmul float %42, 5.000000e-01
  %44 = load float, ptr %0, align 8, !tbaa !16
  %45 = fdiv float %43, %44
  %46 = getelementptr inbounds i8, ptr %0, i64 24
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = call i32 @firfilt_rrrf_push(ptr noundef %47, float noundef %45) #3
  %49 = load ptr, ptr %46, align 8, !tbaa !17
  %50 = call i32 @firfilt_rrrf_execute(ptr noundef %49, ptr noundef %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret i32 0
}

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

declare i32 @firfilt_rrrf_push(ptr noundef, float noundef) local_unnamed_addr #2

declare i32 @firfilt_rrrf_execute(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @firfilt_crcf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

declare i32 @firfilt_crcf_execute(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @wdelaycf_push(ptr noundef, <2 x float> noundef) local_unnamed_addr #2

declare i32 @wdelaycf_read(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_mix_down(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #2

declare i32 @nco_crcf_pll_step(ptr noundef, float noundef) local_unnamed_addr #2

declare i32 @nco_crcf_step(ptr noundef) local_unnamed_addr #2

declare i32 @firhilbf_c2r_execute(ptr noundef, <2 x float> noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !11, i64 40}
!6 = !{!"ampmodem_s", !7, i64 0, !10, i64 4, !10, i64 8, !10, i64 12, !11, i64 16, !11, i64 24, !11, i64 32, !11, i64 40, !11, i64 48, !11, i64 56}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 48}
!13 = !{!6, !11, i64 16}
!14 = !{!6, !11, i64 32}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !7, i64 0}
!17 = !{!6, !11, i64 24}


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