; LLVM IR from jgaeddert/liquid-dsp :: src/framing/src (framingcf)

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

declare i32 @packetizer_decode(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @qpacketmodem_decode(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca { float, float }, align 4
  %10 = alloca float, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, 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) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.qpacketmodem_s, ptr %11, i32 0, i32 10
  store float 0.000000e+00, ptr %12, align 8, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !13
  br label %13

13:                                               ; preds = %62, %3
  %14 = load i32, ptr %7, align 4, !tbaa !13
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.qpacketmodem_s, ptr %15, i32 0, i32 8
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = icmp ult i32 %14, %17
  br i1 %18, label %19, label %65

19:                                               ; preds = %13
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.qpacketmodem_s, ptr %20, i32 0, i32 0
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !13
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds { float, float }, ptr %23, i64 %25
  %27 = getelementptr inbounds { float, float }, ptr %26, i32 0, i32 0
  %28 = load float, ptr %27, align 4
  %29 = getelementptr inbounds { float, float }, ptr %26, i32 0, i32 1
  %30 = load float, ptr %29, align 4
  %31 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 0
  %32 = getelementptr inbounds { float, float }, ptr %9, i32 0, i32 1
  store float %28, ptr %31, align 4
  store float %30, ptr %32, align 4
  %33 = load <2 x float>, ptr %9, align 4
  %34 = call i32 @modemcf_demodulate(ptr noundef %22, <2 x float> noundef %33, ptr noundef %8)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.qpacketmodem_s, ptr %35, i32 0, i32 0
  %37 = load ptr, ptr %36, align 8, !tbaa !15
  %38 = call float @modemcf_get_demodulator_evm(ptr noundef %37)
  store float %38, ptr %10, align 4, !tbaa !16
  %39 = load float, ptr %10, align 4, !tbaa !16
  %40 = load float, ptr %10, align 4, !tbaa !16
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.qpacketmodem_s, ptr %41, i32 0, i32 10
  %43 = load float, ptr %42, align 8, !tbaa !9
  %44 = call float @llvm.fmuladd.f32(float %39, float %40, float %43)
  store float %44, ptr %42, align 8, !tbaa !9
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.qpacketmodem_s, ptr %45, i32 0, i32 4
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.qpacketmodem_s, ptr %48, i32 0, i32 6
  %50 = load i32, ptr %49, align 8, !tbaa !18
  %51 = load i32, ptr %7, align 4, !tbaa !13
  %52 = load ptr, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.qpacketmodem_s, ptr %52, i32 0, i32 2
  %54 = load i32, ptr %53, align 8, !tbaa !19
  %55 = mul i32 %51, %54
  %56 = load ptr, ptr %4, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.qpacketmodem_s, ptr %56, i32 0, i32 2
  %58 = load i32, ptr %57, align 8, !tbaa !19
  %59 = load i32, ptr %8, align 4, !tbaa !13
  %60 = trunc i32 %59 to i8
  %61 = call i32 @liquid_pack_array(ptr noundef %47, i32 noundef %50, i32 noundef %55, i32 noundef %58, i8 noundef zeroext %60)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %62

62:                                               ; preds = %19
  %63 = load i32, ptr %7, align 4, !tbaa !13
  %64 = add i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !13
  br label %13, !llvm.loop !20

65:                                               ; preds = %13
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.qpacketmodem_s, ptr %66, i32 0, i32 10
  %68 = load float, ptr %67, align 8, !tbaa !9
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.qpacketmodem_s, ptr %69, i32 0, i32 8
  %71 = load i32, ptr %70, align 8, !tbaa !14
  %72 = uitofp i32 %71 to float
  %73 = fdiv float %68, %72
  %74 = call float @log10f(float noundef %73) #5
  %75 = fmul float 1.000000e+01, %74
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.qpacketmodem_s, ptr %76, i32 0, i32 10
  store float %75, ptr %77, align 8, !tbaa !9
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.qpacketmodem_s, ptr %78, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !22
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.qpacketmodem_s, ptr %81, i32 0, i32 4
  %83 = load ptr, ptr %82, align 8, !tbaa !17
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = call i32 @packetizer_decode(ptr noundef %80, ptr noundef %83, ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret i32 %85
}

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

declare float @modemcf_get_demodulator_evm(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

declare i32 @liquid_pack_array(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext) #1

; Function Attrs: nounwind
declare float @log10f(float noundef) #4

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


; 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

declare i32 @packetizer_decode(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @qpacketmodem_decode(ptr nocapture noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %5 = getelementptr inbounds i8, ptr %0, i64 56
  store float 0.000000e+00, ptr %5, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %12 = load ptr, ptr %0, align 8, !tbaa !13
  %13 = getelementptr inbounds { float, float }, ptr %1, i64 %indvars.iv
  %14 = load <2 x float>, ptr %13, align 4
  %15 = call i32 @modemcf_demodulate(ptr noundef %12, <2 x float> noundef %14, ptr noundef nonnull %4) #5
  %16 = load ptr, ptr %0, align 8, !tbaa !13
  %17 = call float @modemcf_get_demodulator_evm(ptr noundef %16) #5
  %18 = load float, ptr %5, align 8, !tbaa !5
  %19 = call float @llvm.fmuladd.f32(float %17, float %17, float %18)
  store float %19, ptr %5, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !14
  %21 = load i32, ptr %9, align 8, !tbaa !15
  %22 = load i32, ptr %10, align 8, !tbaa !16
  %23 = trunc nuw i64 %indvars.iv to i32
  %24 = mul i32 %22, %23
  %25 = load i32, ptr %4, align 4, !tbaa !17
  %26 = trunc i32 %25 to i8
  %27 = call i32 @liquid_pack_array(ptr noundef %20, i32 noundef %21, i32 noundef %24, i32 noundef %22, i8 noundef zeroext %26) #5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i32, ptr %6, align 8, !tbaa !12
  %29 = zext i32 %28 to i64
  %30 = icmp ult i64 %indvars.iv.next, %29
  br i1 %30, label %11, label %._crit_edge.loopexit, !llvm.loop !18

._crit_edge.loopexit:                             ; preds = %11
  %.pre = load float, ptr %5, align 8, !tbaa !5
  %31 = uitofp i32 %28 to float
  %32 = fdiv float %.pre, %31
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %33 = phi float [ 0x7FF8000000000000, %3 ], [ %32, %._crit_edge.loopexit ]
  %34 = call float @log10f(float noundef %33) #5
  %35 = fmul float %34, 1.000000e+01
  store float %35, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 8
  %37 = load ptr, ptr %36, align 8, !tbaa !20
  %38 = getelementptr inbounds i8, ptr %0, i64 24
  %39 = load ptr, ptr %38, align 8, !tbaa !14
  %40 = call i32 @packetizer_decode(ptr noundef %37, ptr noundef %39, ptr noundef %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  ret i32 %40
}

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

declare float @modemcf_get_demodulator_evm(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

declare i32 @liquid_pack_array(ptr noundef, i32 noundef, i32 noundef, i32 noundef, i8 noundef zeroext) local_unnamed_addr #1

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

attributes #0 = { mustprogress 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"="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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 #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, !11, i64 56}
!6 = !{!"qpacketmodem_s", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !11, i64 56}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !10, i64 48}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !7, i64 24}
!15 = !{!6, !10, i64 40}
!16 = !{!6, !10, i64 16}
!17 = !{!10, !10, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = !{!6, !7, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass