; LLVM IR from jgaeddert/liquid-dsp :: src/modem/tests (fskmodem_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"

@liquid_autotest_verbose = external global i32, align 4
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @fskmodem_test_mod_demod(i32 noundef %0, i32 noundef %1, float noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store float %2, ptr %6, align 4, !tbaa !9
  %15 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %23

17:                                               ; preds = %3
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = load float, ptr %6, align 4, !tbaa !9
  %21 = fpext float %20 to double
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %18, i32 noundef %19, double noundef %21)
  br label %23

23:                                               ; preds = %17, %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load float, ptr %6, align 4, !tbaa !9
  %27 = call ptr @fskmod_create(i32 noundef %24, i32 noundef %25, float noundef %26)
  store ptr %27, ptr %7, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = load float, ptr %6, align 4, !tbaa !9
  %31 = call ptr @fskdem_create(i32 noundef %28, i32 noundef %29, float noundef %30)
  store ptr %31, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = shl i32 1, %32
  store i32 %33, ptr %9, align 4, !tbaa !5
  %34 = load i32, ptr %5, align 4, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = call ptr @llvm.stacksave.p0()
  store ptr %36, ptr %10, align 8
  %37 = alloca { float, float }, i64 %35, align 16
  store i64 %35, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %59, %23
  %39 = load i32, ptr %12, align 4, !tbaa !5
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = icmp ult i32 %39, %40
  br i1 %41, label %42, label %62

42:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %43 = load i32, ptr %12, align 4, !tbaa !5
  store i32 %43, ptr %13, align 4, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !11
  %45 = load i32, ptr %13, align 4, !tbaa !5
  %46 = call i32 @fskmod_modulate(ptr noundef %44, i32 noundef %45, ptr noundef %37)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %47 = load ptr, ptr %8, align 8, !tbaa !11
  %48 = call i32 @fskdem_demodulate(ptr noundef %47, ptr noundef %37)
  store i32 %48, ptr %14, align 4, !tbaa !5
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = load i32, ptr %14, align 4, !tbaa !5
  %51 = icmp ne i32 %49, %50
  br i1 %51, label %52, label %57

52:                                               ; preds = %42
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = uitofp i32 %53 to double
  %55 = load i32, ptr %14, align 4, !tbaa !5
  %56 = uitofp i32 %55 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.1, i32 noundef 54, ptr noundef @.str.2, double noundef %54, ptr noundef @.str.3, ptr noundef @.str.4, double noundef %56)
  br label %58

57:                                               ; preds = %42
  call void (...) @liquid_autotest_passed()
  br label %58

58:                                               ; preds = %57, %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %59

59:                                               ; preds = %58
  %60 = load i32, ptr %12, align 4, !tbaa !5
  %61 = add i32 %60, 1
  store i32 %61, ptr %12, align 4, !tbaa !5
  br label %38, !llvm.loop !13

62:                                               ; preds = %38
  %63 = load ptr, ptr %7, align 8, !tbaa !11
  %64 = call i32 @fskmod_destroy(ptr noundef %63)
  %65 = load ptr, ptr %8, align 8, !tbaa !11
  %66 = call i32 @fskdem_destroy(ptr noundef %65)
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %67 = load ptr, ptr %10, align 8
  call void @llvm.stackrestore.p0(ptr %67)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

declare i32 @printf(ptr noundef, ...) #1

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

declare ptr @fskmod_create(i32 noundef, i32 noundef, float noundef) #1

declare ptr @fskdem_create(i32 noundef, i32 noundef, float noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #3

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

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #1

declare void @liquid_autotest_passed(...) #1

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

declare i32 @fskmod_destroy(ptr noundef) #1

declare i32 @fskdem_destroy(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #3

attributes #0 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind willreturn }
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, !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"}


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

@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [51 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @fskmodem_test_mod_demod(i32 noundef %0, i32 noundef %1, float noundef %2) local_unnamed_addr #0 {
  %4 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %8, label %5

5:                                                ; preds = %3
  %6 = fpext float %2 to double
  %7 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %0, i32 noundef %1, double noundef %6)
  br label %8

8:                                                ; preds = %5, %3
  %9 = tail call ptr @fskmod_create(i32 noundef %0, i32 noundef %1, float noundef %2) #3
  %10 = tail call ptr @fskdem_create(i32 noundef %0, i32 noundef %1, float noundef %2) #3
  %11 = zext i32 %1 to i64
  %12 = alloca { float, float }, i64 %11, align 16
  br label %13

13:                                               ; preds = %8, %20
  %.026 = phi i32 [ 0, %8 ], [ %21, %20 ]
  %14 = call i32 @fskmod_modulate(ptr noundef %9, i32 noundef %.026, ptr noundef nonnull %12) #3
  %15 = call i32 @fskdem_demodulate(ptr noundef %10, ptr noundef nonnull %12) #3
  %.not25 = icmp eq i32 %.026, %15
  br i1 %.not25, label %19, label %16

16:                                               ; preds = %13
  %17 = uitofp i32 %.026 to double
  %18 = uitofp i32 %15 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.1, i32 noundef 54, ptr noundef nonnull @.str.2, double noundef %17, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, double noundef %18) #3
  br label %20

19:                                               ; preds = %13
  call void (...) @liquid_autotest_passed() #3
  br label %20

20:                                               ; preds = %19, %16
  %21 = add i32 %.026, 1
  %.0.highbits = lshr i32 %21, %0
  %22 = icmp eq i32 %.0.highbits, 0
  br i1 %22, label %13, label %23, !llvm.loop !9

23:                                               ; preds = %20
  %24 = call i32 @fskmod_destroy(ptr noundef %9) #3
  %25 = call i32 @fskdem_destroy(ptr noundef %10) #3
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

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

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

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

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #2

declare void @liquid_autotest_passed(...) local_unnamed_addr #2

declare i32 @fskmod_destroy(ptr noundef) local_unnamed_addr #2

declare i32 @fskdem_destroy(ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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