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

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [68 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @freqmod_create(float noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca { float, float }, align 4
  %7 = alloca { float, float }, align 4
  store float %0, ptr %3, align 4, !tbaa !5
  %8 = load float, ptr %3, align 4, !tbaa !5
  %9 = fcmp ole float %8, 0.000000e+00
  br i1 %9, label %10, label %14

10:                                               ; preds = %1
  %11 = load float, ptr %3, align 4, !tbaa !5
  %12 = fpext float %11 to double
  %13 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.82, i32 noundef 51, ptr noundef @.str.83, ptr noundef @.str.2, double noundef %12)
  store ptr %13, ptr %2, align 8
  br label %79

14:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #6
  %15 = call noalias ptr @malloc(i64 noundef 24) #7
  store ptr %15, ptr %4, align 8, !tbaa !9
  %16 = load float, ptr %3, align 4, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct.freqmod_s, ptr %17, i32 0, i32 0
  store float %16, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr %4, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct.freqmod_s, ptr %19, i32 0, i32 0
  %21 = load float, ptr %20, align 8, !tbaa !11
  %22 = fmul float %21, 6.553600e+04
  %23 = load ptr, ptr %4, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct.freqmod_s, ptr %23, i32 0, i32 1
  store float %22, ptr %24, align 4, !tbaa !15
  %25 = load ptr, ptr %4, align 8, !tbaa !9
  %26 = getelementptr inbounds %struct.freqmod_s, ptr %25, i32 0, i32 2
  store i32 1024, ptr %26, align 8, !tbaa !16
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = getelementptr inbounds %struct.freqmod_s, ptr %27, i32 0, i32 2
  %29 = load i32, ptr %28, align 8, !tbaa !16
  %30 = zext i32 %29 to i64
  %31 = mul i64 %30, 8
  %32 = call noalias ptr @malloc(i64 noundef %31) #7
  %33 = load ptr, ptr %4, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct.freqmod_s, ptr %33, i32 0, i32 4
  store ptr %32, ptr %34, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !18
  br label %35

35:                                               ; preds = %72, %14
  %36 = load i32, ptr %5, align 4, !tbaa !18
  %37 = load ptr, ptr %4, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct.freqmod_s, ptr %37, i32 0, i32 2
  %39 = load i32, ptr %38, align 8, !tbaa !16
  %40 = icmp ult i32 %36, %39
  br i1 %40, label %41, label %75

41:                                               ; preds = %35
  %42 = load i32, ptr %5, align 4, !tbaa !18
  %43 = uitofp i32 %42 to float
  %44 = fpext float %43 to double
  %45 = fmul double 0.000000e+00, %44
  %46 = fmul double 0x401921FB54442D18, %44
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct.freqmod_s, ptr %47, i32 0, i32 2
  %49 = load i32, ptr %48, align 8, !tbaa !16
  %50 = uitofp i32 %49 to float
  %51 = fpext float %50 to double
  %52 = fdiv double %45, %51
  %53 = fdiv double %46, %51
  %54 = fptrunc double %52 to float
  %55 = fptrunc double %53 to float
  %56 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 0
  %57 = getelementptr inbounds { float, float }, ptr %6, i32 0, i32 1
  store float %54, ptr %56, align 4
  store float %55, ptr %57, align 4
  %58 = load <2 x float>, ptr %6, align 4
  %59 = call <2 x float> @cexpf(<2 x float> noundef %58) #6
  store <2 x float> %59, ptr %7, align 4
  %60 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 0
  %61 = load float, ptr %60, align 4
  %62 = getelementptr inbounds { float, float }, ptr %7, i32 0, i32 1
  %63 = load float, ptr %62, align 4
  %64 = load ptr, ptr %4, align 8, !tbaa !9
  %65 = getelementptr inbounds %struct.freqmod_s, ptr %64, i32 0, i32 4
  %66 = load ptr, ptr %65, align 8, !tbaa !17
  %67 = load i32, ptr %5, align 4, !tbaa !18
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds { float, float }, ptr %66, i64 %68
  %70 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 0
  %71 = getelementptr inbounds { float, float }, ptr %69, i32 0, i32 1
  store float %61, ptr %70, align 4
  store float %63, ptr %71, align 4
  br label %72

72:                                               ; preds = %41
  %73 = load i32, ptr %5, align 4, !tbaa !18
  %74 = add i32 %73, 1
  store i32 %74, ptr %5, align 4, !tbaa !18
  br label %35, !llvm.loop !19

75:                                               ; preds = %35
  %76 = load ptr, ptr %4, align 8, !tbaa !9
  %77 = call i32 @freqmod_reset(ptr noundef %76)
  %78 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %78, ptr %2, align 8
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #6
  br label %79

79:                                               ; preds = %75, %10
  %80 = load ptr, ptr %2, align 8
  ret ptr %80
}

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @freqmod_reset(ptr noundef) #5

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

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"freqmod_s", !6, i64 0, !6, i64 4, !13, i64 8, !14, i64 12, !10, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 4}
!16 = !{!12, !13, i64 8}
!17 = !{!12, !10, i64 16}
!18 = !{!13, !13, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.82 = external hidden unnamed_addr constant [84 x i8], align 1
@.str.83 = external hidden unnamed_addr constant [68 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @freqmod_create(float noundef %0) local_unnamed_addr #2 {
  %2 = fcmp ugt float %0, 0.000000e+00
  br i1 %2, label %.lr.ph.preheader, label %3

3:                                                ; preds = %1
  %4 = fpext float %0 to double
  %5 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.82, i32 noundef 51, ptr noundef nonnull @.str.83, ptr noundef nonnull @.str.2, double noundef %4) #5
  br label %22

.lr.ph.preheader:                                 ; preds = %1
  %6 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #6
  store float %0, ptr %6, align 8, !tbaa !5
  %7 = fmul float %0, 6.553600e+04
  %8 = getelementptr inbounds i8, ptr %6, i64 4
  store float %7, ptr %8, align 4, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %6, i64 8
  store i32 1024, ptr %9, align 8, !tbaa !14
  %10 = tail call noalias dereferenceable_or_null(8192) ptr @malloc(i64 noundef 8192) #6
  %11 = getelementptr inbounds i8, ptr %6, i64 16
  store ptr %10, ptr %11, align 8, !tbaa !15
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %12 = trunc nuw i64 %indvars.iv to i32
  %13 = uitofp nneg i32 %12 to float
  %14 = fpext float %13 to double
  %15 = fmul double %14, 0x401921FB54442D18
  %16 = fmul double %15, 0x3F50000000000000
  %17 = fptrunc double %16 to float
  %.sroa.01.4.vec.insert = insertelement <2 x float> <float 0.000000e+00, float poison>, float %17, i64 1
  %18 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert) #5
  %19 = getelementptr inbounds { float, float }, ptr %10, i64 %indvars.iv
  store <2 x float> %18, ptr %19, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = icmp ult i64 %indvars.iv, 1023
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %.lr.ph
  %21 = tail call i32 @freqmod_reset(ptr noundef nonnull %6)
  br label %22

22:                                               ; preds = %._crit_edge, %3
  %.0 = phi ptr [ %5, %3 ], [ %6, %._crit_edge ]
  ret ptr %.0
}

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @freqmod_reset(ptr noundef) local_unnamed_addr #4

attributes #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 #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 0}
!6 = !{!"freqmod_s", !7, i64 0, !7, i64 4, !10, i64 8, !11, i64 12, !12, i64 16}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !7, i64 4}
!14 = !{!6, !10, i64 8}
!15 = !{!6, !12, i64 16}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass