; 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.cpfskmod_s = type { i32, i32, i32, float, float, i32, i32, i32, ptr, i32, ptr, ptr, float, float, 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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local i32 @cpfskmod_modulate(ptr noundef %0, i32 noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca float, align 4
  %8 = alloca i32, align 4
  %9 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %10 = load i32, ptr %5, align 4, !tbaa !9
  %11 = uitofp i32 %10 to float
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.cpfskmod_s, ptr %12, i32 0, i32 6
  %14 = load i32, ptr %13, align 8, !tbaa !11
  %15 = uitofp i32 %14 to float
  %16 = fneg float %15
  %17 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %11, float %16)
  %18 = fadd float %17, 1.000000e+00
  store float %18, ptr %7, align 4, !tbaa !14
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.cpfskmod_s, ptr %19, i32 0, i32 10
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load float, ptr %7, align 4, !tbaa !14
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.cpfskmod_s, ptr %23, i32 0, i32 11
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %26 = call i32 @firinterp_rrrf_execute(ptr noundef %21, float noundef %22, ptr noundef %25)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %109, %3
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.cpfskmod_s, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 4, !tbaa !17
  %32 = icmp ult i32 %28, %31
  br i1 %32, label %33, label %112

33:                                               ; preds = %27
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.cpfskmod_s, ptr %34, i32 0, i32 11
  %36 = load ptr, ptr %35, align 8, !tbaa !16
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = getelementptr inbounds float, ptr %36, i64 %38
  %40 = load float, ptr %39, align 4, !tbaa !14
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.cpfskmod_s, ptr %41, i32 0, i32 16
  %43 = load float, ptr %42, align 8, !tbaa !18
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.cpfskmod_s, ptr %44, i32 0, i32 14
  %46 = load float, ptr %45, align 8, !tbaa !19
  %47 = fneg float %43
  %48 = call float @llvm.fmuladd.f32(float %47, float %46, float %40)
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.cpfskmod_s, ptr %49, i32 0, i32 15
  store float %48, ptr %50, align 4, !tbaa !20
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.cpfskmod_s, ptr %51, i32 0, i32 15
  %53 = load float, ptr %52, align 4, !tbaa !20
  %54 = load ptr, ptr %4, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.cpfskmod_s, ptr %54, i32 0, i32 12
  %56 = load float, ptr %55, align 8, !tbaa !21
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.cpfskmod_s, ptr %57, i32 0, i32 16
  %59 = load float, ptr %58, align 8, !tbaa !18
  %60 = load ptr, ptr %4, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.cpfskmod_s, ptr %60, i32 0, i32 13
  %62 = load float, ptr %61, align 4, !tbaa !22
  %63 = fmul float %59, %62
  %64 = call float @llvm.fmuladd.f32(float %53, float %56, float %63)
  store float %64, ptr %9, align 4, !tbaa !14
  %65 = load ptr, ptr %4, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.cpfskmod_s, ptr %65, i32 0, i32 15
  %67 = load float, ptr %66, align 4, !tbaa !20
  %68 = load ptr, ptr %4, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.cpfskmod_s, ptr %68, i32 0, i32 16
  store float %67, ptr %69, align 8, !tbaa !18
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct.cpfskmod_s, ptr %70, i32 0, i32 16
  %72 = load float, ptr %71, align 8, !tbaa !18
  %73 = fpext float %72 to double
  %74 = fcmp ogt double %73, 0x401921FB54442D18
  br i1 %74, label %75, label %82

75:                                               ; preds = %33
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.cpfskmod_s, ptr %76, i32 0, i32 16
  %78 = load float, ptr %77, align 8, !tbaa !18
  %79 = fpext float %78 to double
  %80 = fsub double %79, 0x401921FB54442D18
  %81 = fptrunc double %80 to float
  store float %81, ptr %77, align 8, !tbaa !18
  br label %82

82:                                               ; preds = %75, %33
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  %84 = getelementptr inbounds %struct.cpfskmod_s, ptr %83, i32 0, i32 16
  %85 = load float, ptr %84, align 8, !tbaa !18
  %86 = fpext float %85 to double
  %87 = fcmp olt double %86, 0xC01921FB54442D18
  br i1 %87, label %88, label %95

88:                                               ; preds = %82
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.cpfskmod_s, ptr %89, i32 0, i32 16
  %91 = load float, ptr %90, align 8, !tbaa !18
  %92 = fpext float %91 to double
  %93 = fadd double %92, 0x401921FB54442D18
  %94 = fptrunc double %93 to float
  store float %94, ptr %90, align 8, !tbaa !18
  br label %95

95:                                               ; preds = %88, %82
  %96 = load float, ptr %9, align 4, !tbaa !14
  %97 = call float @cosf(float noundef %96) #5
  %98 = load float, ptr %9, align 4, !tbaa !14
  %99 = call float @sinf(float noundef %98) #5
  %100 = fmul float 0.000000e+00, %99
  %101 = fmul float 1.000000e+00, %99
  %102 = fadd float %97, %100
  %103 = load ptr, ptr %6, align 8, !tbaa !5
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = zext i32 %104 to i64
  %106 = getelementptr inbounds { float, float }, ptr %103, i64 %105
  %107 = getelementptr inbounds { float, float }, ptr %106, i32 0, i32 0
  %108 = getelementptr inbounds { float, float }, ptr %106, i32 0, i32 1
  store float %102, ptr %107, align 4
  store float %101, ptr %108, align 4
  br label %109

109:                                              ; preds = %95
  %110 = load i32, ptr %8, align 4, !tbaa !9
  %111 = add i32 %110, 1
  store i32 %111, ptr %8, align 4, !tbaa !9
  br label %27, !llvm.loop !23

112:                                              ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 0
}

declare i32 @firinterp_rrrf_execute(ptr noundef, float noundef, ptr noundef) #4

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

!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 = !{!12, !10, i64 24}
!12 = !{!"cpfskmod_s", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !6, i64 32, !10, i64 40, !6, i64 48, !6, i64 56, !13, i64 64, !13, i64 68, !13, i64 72, !13, i64 76, !13, i64 80}
!13 = !{!"float", !7, i64 0}
!14 = !{!13, !13, i64 0}
!15 = !{!12, !6, i64 48}
!16 = !{!12, !6, i64 56}
!17 = !{!12, !10, i64 4}
!18 = !{!12, !13, i64 80}
!19 = !{!12, !13, i64 72}
!20 = !{!12, !13, i64 76}
!21 = !{!12, !13, i64 64}
!22 = !{!12, !13, i64 68}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @cpfskmod_modulate(ptr nocapture noundef %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = uitofp i32 %1 to float
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %7 = uitofp i32 %6 to float
  %8 = fneg float %7
  %9 = tail call float @llvm.fmuladd.f32(float %4, float 2.000000e+00, float %8)
  %10 = fadd float %9, 1.000000e+00
  %11 = getelementptr inbounds i8, ptr %0, i64 48
  %12 = load ptr, ptr %11, align 8, !tbaa !12
  %13 = getelementptr inbounds i8, ptr %0, i64 56
  %14 = load ptr, ptr %13, align 8, !tbaa !13
  %15 = tail call i32 @firinterp_rrrf_execute(ptr noundef %12, float noundef %10, ptr noundef %14) #4
  %16 = getelementptr inbounds i8, ptr %0, i64 4
  %17 = load i32, ptr %16, align 4, !tbaa !14
  %.not = icmp eq i32 %17, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %18 = getelementptr inbounds i8, ptr %0, i64 80
  %19 = getelementptr inbounds i8, ptr %0, i64 72
  %20 = getelementptr inbounds i8, ptr %0, i64 76
  %21 = getelementptr inbounds i8, ptr %0, i64 64
  %22 = getelementptr inbounds i8, ptr %0, i64 68
  br label %23

23:                                               ; preds = %.lr.ph, %23
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %24 = load ptr, ptr %13, align 8, !tbaa !13
  %25 = getelementptr inbounds float, ptr %24, i64 %indvars.iv
  %26 = load float, ptr %25, align 4, !tbaa !15
  %27 = load float, ptr %18, align 8, !tbaa !16
  %28 = load float, ptr %19, align 8, !tbaa !17
  %29 = fneg float %27
  %30 = tail call float @llvm.fmuladd.f32(float %29, float %28, float %26)
  store float %30, ptr %20, align 4, !tbaa !18
  %31 = load float, ptr %21, align 8, !tbaa !19
  %32 = load float, ptr %22, align 4, !tbaa !20
  %33 = fmul float %27, %32
  %34 = tail call float @llvm.fmuladd.f32(float %30, float %31, float %33)
  %35 = fpext float %30 to double
  %36 = fcmp ogt double %35, 0x401921FB54442D18
  %37 = fadd double %35, 0xC01921FB54442D18
  %38 = fptrunc double %37 to float
  %storemerge = select i1 %36, float %38, float %30
  %39 = fpext float %storemerge to double
  %40 = fcmp olt double %39, 0xC01921FB54442D18
  %41 = fadd double %39, 0x401921FB54442D18
  %42 = fptrunc double %41 to float
  %storemerge28 = select i1 %40, float %42, float %storemerge
  store float %storemerge28, ptr %18, align 8, !tbaa !16
  %43 = tail call float @cosf(float noundef %34) #4
  %44 = tail call float @sinf(float noundef %34) #4
  %45 = fmul float %44, 0.000000e+00
  %46 = fadd float %43, %45
  %47 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  %48 = getelementptr inbounds i8, ptr %47, i64 4
  store float %46, ptr %47, align 4
  store float %44, ptr %48, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %49 = load i32, ptr %16, align 4, !tbaa !14
  %50 = zext i32 %49 to i64
  %51 = icmp ult i64 %indvars.iv.next, %50
  br i1 %51, label %23, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %23, %3
  ret i32 0
}

declare i32 @firinterp_rrrf_execute(ptr noundef, float noundef, ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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 #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 = { "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, !7, i64 24}
!6 = !{!"cpfskmod_s", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 12, !10, i64 16, !7, i64 20, !7, i64 24, !7, i64 28, !11, i64 32, !7, i64 40, !11, i64 48, !11, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !10, i64 80}
!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, !11, i64 48}
!13 = !{!6, !11, i64 56}
!14 = !{!6, !7, i64 4}
!15 = !{!10, !10, i64 0}
!16 = !{!6, !10, i64 80}
!17 = !{!6, !10, i64 72}
!18 = !{!6, !10, i64 76}
!19 = !{!6, !10, i64 64}
!20 = !{!6, !10, i64 68}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass