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

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

@liquid_autotest_verbose = external global i32, align 4
@__const.autotest_cpfskmodem_spectrum.regions = external hidden unnamed_addr constant [5 x %struct.autotest_psd_s], align 16
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1

; 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
declare ptr @llvm.stacksave.p0() #1

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

; 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 willreturn
declare void @llvm.stackrestore.p0(ptr) #1

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

declare i32 @cpfskmod_destroy(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @autotest_cpfskmodem_spectrum() #3 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca float, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca [5 x %struct.autotest_psd_s], align 16
  %16 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 1, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store float 5.000000e-01, ptr %2, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 4, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 3, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store float 0x3FD6666660000000, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = load float, ptr %2, align 4, !tbaa !9
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = load float, ptr %5, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = call ptr @cpfskmod_create(i32 noundef %17, float noundef %18, i32 noundef %19, i32 noundef %20, float noundef %21, i32 noundef %22)
  store ptr %23, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 2400, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 192000, ptr %9, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = zext i32 %24 to i64
  %26 = call ptr @llvm.stacksave.p0()
  store ptr %26, ptr %10, align 8
  %27 = alloca { float, float }, i64 %25, align 16
  store i64 %25, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %34, %0
  %29 = load i32, ptr %12, align 4, !tbaa !5
  %30 = icmp ult i32 %29, 16777216
  br i1 %30, label %31, label %37

31:                                               ; preds = %28
  %32 = load ptr, ptr %7, align 8, !tbaa !11
  %33 = call i32 @cpfskmod_modulate(ptr noundef %32, i32 noundef 0, ptr noundef %27)
  br label %34

34:                                               ; preds = %31
  %35 = load i32, ptr %12, align 4, !tbaa !5
  %36 = add i32 %35, 1
  store i32 %36, ptr %12, align 4, !tbaa !5
  br label %28, !llvm.loop !13

37:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  %38 = load i32, ptr %8, align 4, !tbaa !5
  %39 = call ptr @spgramcf_create_default(i32 noundef %38)
  store ptr %39, ptr %13, align 8, !tbaa !11
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %55, %37
  %41 = load i32, ptr %12, align 4, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = icmp ult i32 %41, %42
  br i1 %43, label %44, label %58

44:                                               ; preds = %40
  %45 = load ptr, ptr %7, align 8, !tbaa !11
  %46 = call i32 @rand() #6
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = shl i32 1, %47
  %49 = sub nsw i32 %48, 1
  %50 = and i32 %46, %49
  %51 = call i32 @cpfskmod_modulate(ptr noundef %45, i32 noundef %50, ptr noundef %27)
  %52 = load ptr, ptr %13, align 8, !tbaa !11
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = call i32 @spgramcf_write(ptr noundef %52, ptr noundef %27, i32 noundef %53)
  br label %55

55:                                               ; preds = %44
  %56 = load i32, ptr %12, align 4, !tbaa !5
  %57 = add i32 %56, 1
  store i32 %57, ptr %12, align 4, !tbaa !5
  br label %40, !llvm.loop !15

58:                                               ; preds = %40
  %59 = load i32, ptr %8, align 4, !tbaa !5
  %60 = zext i32 %59 to i64
  %61 = alloca float, i64 %60, align 16
  store i64 %60, ptr %14, align 8
  %62 = load ptr, ptr %13, align 8, !tbaa !11
  %63 = call i32 @spgramcf_get_psd(ptr noundef %62, ptr noundef %61)
  %64 = load ptr, ptr %7, align 8, !tbaa !11
  %65 = call i32 @cpfskmod_destroy(ptr noundef %64)
  %66 = load ptr, ptr %13, align 8, !tbaa !11
  %67 = call i32 @spgramcf_destroy(ptr noundef %66)
  call void @llvm.lifetime.start.p0(i64 120, ptr %15) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %15, ptr align 16 @__const.autotest_cpfskmodem_spectrum.regions, i64 120, i1 false)
  call void @llvm.lifetime.start.p0(i64 256, ptr %16) #6
  %68 = getelementptr inbounds [256 x i8], ptr %16, i64 0, i64 0
  %69 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %68, ptr noundef @.str.10) #6
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = getelementptr inbounds [5 x %struct.autotest_psd_s], ptr %15, i64 0, i64 0
  %72 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %58
  %75 = getelementptr inbounds [256 x i8], ptr %16, i64 0, i64 0
  br label %77

76:                                               ; preds = %58
  br label %77

77:                                               ; preds = %76, %74
  %78 = phi ptr [ %75, %74 ], [ null, %76 ]
  %79 = call i32 @liquid_autotest_validate_spectrum(ptr noundef %61, i32 noundef %70, ptr noundef %71, i32 noundef 5, ptr noundef %78)
  call void @llvm.lifetime.end.p0(i64 256, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 120, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  %80 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %80)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

declare ptr @spgramcf_create_default(i32 noundef) #2

; Function Attrs: nounwind
declare i32 @rand() #4

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

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

declare i32 @spgramcf_destroy(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #4

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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 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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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"

%struct.autotest_psd_s = type { float, float, float, float, i32, i32 }

@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@__const.autotest_cpfskmodem_spectrum.regions = external hidden unnamed_addr constant [5 x %struct.autotest_psd_s], align 16
@.str.10 = external hidden unnamed_addr constant [40 x i8], align 1

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

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

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

declare ptr @cpfskmod_create(i32 noundef, float noundef, i32 noundef, i32 noundef, float noundef, i32 noundef) local_unnamed_addr #1

declare i32 @cpfskmod_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_cpfskmodem_spectrum() local_unnamed_addr #2 {
  %1 = alloca [5 x %struct.autotest_psd_s], align 16
  %2 = alloca [256 x i8], align 16
  %3 = tail call ptr @cpfskmod_create(i32 noundef 1, float noundef 5.000000e-01, i32 noundef 4, i32 noundef 3, float noundef 0x3FD6666660000000, i32 noundef 2) #6
  %4 = alloca [4 x { float, float }], align 16
  br label %5

5:                                                ; preds = %0, %5
  %.023 = phi i32 [ 0, %0 ], [ %7, %5 ]
  %6 = call i32 @cpfskmod_modulate(ptr noundef %3, i32 noundef 0, ptr noundef nonnull %4) #6
  %7 = add nuw nsw i32 %.023, 1
  %exitcond.not = icmp eq i32 %7, 16777216
  br i1 %exitcond.not, label %8, label %5, !llvm.loop !5

8:                                                ; preds = %5
  %9 = call ptr @spgramcf_create_default(i32 noundef 2400) #6
  br label %10

10:                                               ; preds = %8, %10
  %.124 = phi i32 [ 0, %8 ], [ %15, %10 ]
  %11 = call i32 @rand() #6
  %12 = and i32 %11, 1
  %13 = call i32 @cpfskmod_modulate(ptr noundef %3, i32 noundef %12, ptr noundef nonnull %4) #6
  %14 = call i32 @spgramcf_write(ptr noundef %9, ptr noundef nonnull %4, i32 noundef 4) #6
  %15 = add nuw nsw i32 %.124, 1
  %exitcond25.not = icmp eq i32 %15, 192000
  br i1 %exitcond25.not, label %16, label %10, !llvm.loop !7

16:                                               ; preds = %10
  %17 = alloca [2400 x float], align 16
  %18 = call i32 @spgramcf_get_psd(ptr noundef %9, ptr noundef nonnull %17) #6
  %19 = call i32 @cpfskmod_destroy(ptr noundef %3) #6
  %20 = call i32 @spgramcf_destroy(ptr noundef %9) #6
  call void @llvm.lifetime.start.p0(i64 120, ptr nonnull %1) #6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(120) %1, ptr noundef nonnull align 16 dereferenceable(120) @__const.autotest_cpfskmodem_spectrum.regions, i64 120, i1 false)
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %2) #6
  %21 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.10) #6
  %22 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !8
  %.not = icmp eq i32 %22, 0
  %23 = select i1 %.not, ptr null, ptr %2
  %24 = call i32 @liquid_autotest_validate_spectrum(ptr noundef nonnull %17, i32 noundef 2400, ptr noundef nonnull %1, i32 noundef 5, ptr noundef %23) #6
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 120, ptr nonnull %1) #6
  ret void
}

declare ptr @spgramcf_create_default(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #3

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

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

declare i32 @spgramcf_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #5

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

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"="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 "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nofree 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 #6 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass