; LLVM IR from jgaeddert/liquid-dsp :: src/framing/tests (qpacketmodem_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 [96 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @qpacketmodem_modulated(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  %18 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %19 = call ptr (...) @qpacketmodem_create()
  store ptr %19, ptr %12, align 8, !tbaa !9
  %20 = load ptr, ptr %12, align 8, !tbaa !9
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = load i32, ptr %7, align 4, !tbaa !5
  %23 = load i32, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %9, align 4, !tbaa !5
  %25 = load i32, ptr %10, align 4, !tbaa !5
  %26 = call i32 @qpacketmodem_configure(ptr noundef %20, i32 noundef %21, i32 noundef %22, i32 noundef %23, i32 noundef %24, i32 noundef %25)
  %27 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %5
  %30 = load ptr, ptr %12, align 8, !tbaa !9
  %31 = call i32 @qpacketmodem_print(ptr noundef %30)
  br label %32

32:                                               ; preds = %29, %5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = zext i32 %33 to i64
  %35 = call ptr @llvm.stacksave.p0()
  store ptr %35, ptr %13, align 8
  %36 = alloca i8, i64 %34, align 16
  store i64 %34, ptr %14, align 8
  %37 = load i32, ptr %6, align 4, !tbaa !5
  %38 = zext i32 %37 to i64
  %39 = alloca i8, i64 %38, align 16
  store i64 %38, ptr %15, align 8
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %57, %32
  %41 = load i32, ptr %11, align 4, !tbaa !5
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = icmp ult i32 %41, %42
  br i1 %43, label %44, label %60

44:                                               ; preds = %40
  %45 = call i32 @rand() #5
  %46 = and i32 %45, 255
  %47 = trunc i32 %46 to i8
  %48 = load i32, ptr %11, align 4, !tbaa !5
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds i8, ptr %36, i64 %49
  store i8 %47, ptr %50, align 1, !tbaa !11
  %51 = call i32 @rand() #5
  %52 = and i32 %51, 255
  %53 = trunc i32 %52 to i8
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %39, i64 %55
  store i8 %53, ptr %56, align 1, !tbaa !11
  br label %57

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

60:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  %61 = load ptr, ptr %12, align 8, !tbaa !9
  %62 = call i32 @qpacketmodem_get_frame_len(ptr noundef %61)
  store i32 %62, ptr %16, align 4, !tbaa !5
  %63 = load i32, ptr %16, align 4, !tbaa !5
  %64 = zext i32 %63 to i64
  %65 = alloca { float, float }, i64 %64, align 16
  store i64 %64, ptr %17, align 8
  %66 = load ptr, ptr %12, align 8, !tbaa !9
  %67 = call i32 @qpacketmodem_encode(ptr noundef %66, ptr noundef %36, ptr noundef %65)
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %68 = load ptr, ptr %12, align 8, !tbaa !9
  %69 = call i32 @qpacketmodem_decode_soft(ptr noundef %68, ptr noundef %65, ptr noundef %39)
  store i32 %69, ptr %18, align 4, !tbaa !5
  %70 = load ptr, ptr %12, align 8, !tbaa !9
  %71 = call i32 @qpacketmodem_destroy(ptr noundef %70)
  %72 = load i32, ptr %18, align 4, !tbaa !5
  %73 = icmp ne i32 %72, 1
  br i1 %73, label %74, label %77

74:                                               ; preds = %60
  %75 = load i32, ptr %18, align 4, !tbaa !5
  %76 = sitofp i32 %75 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 73, ptr noundef @.str.1, double noundef %76, ptr noundef @.str.2, ptr noundef @.str.3, double noundef 1.000000e+00)
  br label %78

77:                                               ; preds = %60
  call void (...) @liquid_autotest_passed()
  br label %78

78:                                               ; preds = %77, %74
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = call i32 @liquid_autotest_same_data(ptr noundef %36, ptr noundef %39, i32 noundef %79)
  %81 = icmp ne i32 %80, 0
  br i1 %81, label %89, label %82

82:                                               ; preds = %78
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 74, ptr noundef @.str.4)
  %83 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %88

85:                                               ; preds = %82
  %86 = load i32, ptr %6, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %36, i32 noundef %86)
  %87 = load i32, ptr %6, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %39, i32 noundef %87)
  br label %88

88:                                               ; preds = %85, %82
  br label %90

89:                                               ; preds = %78
  call void (...) @liquid_autotest_passed()
  br label %90

90:                                               ; preds = %89, %88
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  %91 = load ptr, ptr %13, align 8
  call void @llvm.stackrestore.p0(ptr %91)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret void
}

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

declare ptr @qpacketmodem_create(...) #2

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

declare i32 @qpacketmodem_print(ptr noundef) #2

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

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

declare i32 @qpacketmodem_get_frame_len(ptr noundef) #2

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

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

declare i32 @qpacketmodem_destroy(ptr noundef) #2

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

declare void @liquid_autotest_passed(...) #2

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

declare void @liquid_autotest_failed_msg(ptr noundef, i32 noundef, ptr noundef) #2

declare void @liquid_autotest_print_array(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nocallback nofree nosync nounwind willreturn }
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 = !{!"int", !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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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 [96 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [52 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @qpacketmodem_modulated(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = tail call ptr (...) @qpacketmodem_create() #3
  %7 = tail call i32 @qpacketmodem_configure(ptr noundef %6, i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #3
  %8 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %11, label %9

9:                                                ; preds = %5
  %10 = tail call i32 @qpacketmodem_print(ptr noundef %6) #3
  br label %11

11:                                               ; preds = %9, %5
  %12 = zext i32 %0 to i64
  %13 = alloca i8, i64 %12, align 16
  %14 = alloca i8, i64 %12, align 16
  %.not30 = icmp eq i32 %0, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %11, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %11 ]
  %15 = tail call i32 @rand() #3
  %16 = trunc i32 %15 to i8
  %17 = getelementptr inbounds i8, ptr %13, i64 %indvars.iv
  store i8 %16, ptr %17, align 1, !tbaa !9
  %18 = tail call i32 @rand() #3
  %19 = trunc i32 %18 to i8
  %20 = getelementptr inbounds i8, ptr %14, i64 %indvars.iv
  store i8 %19, ptr %20, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %12
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %11
  %21 = tail call i32 @qpacketmodem_get_frame_len(ptr noundef %6) #3
  %22 = zext i32 %21 to i64
  %23 = alloca { float, float }, i64 %22, align 16
  %24 = call i32 @qpacketmodem_encode(ptr noundef %6, ptr noundef nonnull %13, ptr noundef nonnull %23) #3
  %25 = call i32 @qpacketmodem_decode_soft(ptr noundef %6, ptr noundef nonnull %23, ptr noundef nonnull %14) #3
  %26 = call i32 @qpacketmodem_destroy(ptr noundef %6) #3
  %.not26 = icmp eq i32 %25, 1
  br i1 %.not26, label %29, label %27

27:                                               ; preds = %._crit_edge
  %28 = sitofp i32 %25 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 73, ptr noundef nonnull @.str.1, double noundef %28, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 1.000000e+00) #3
  br label %30

29:                                               ; preds = %._crit_edge
  call void (...) @liquid_autotest_passed() #3
  br label %30

30:                                               ; preds = %29, %27
  %31 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %13, ptr noundef nonnull %14, i32 noundef %0) #3
  %.not27 = icmp eq i32 %31, 0
  br i1 %.not27, label %32, label %35

32:                                               ; preds = %30
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 74, ptr noundef nonnull @.str.4) #3
  %33 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not28 = icmp eq i32 %33, 0
  br i1 %.not28, label %36, label %34

34:                                               ; preds = %32
  call void @liquid_autotest_print_array(ptr noundef nonnull %13, i32 noundef %0) #3
  call void @liquid_autotest_print_array(ptr noundef nonnull %14, i32 noundef %0) #3
  br label %36

35:                                               ; preds = %30
  call void (...) @liquid_autotest_passed() #3
  br label %36

36:                                               ; preds = %32, %34, %35
  ret void
}

declare ptr @qpacketmodem_create(...) local_unnamed_addr #1

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

declare i32 @qpacketmodem_print(ptr noundef) local_unnamed_addr #1

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

declare i32 @qpacketmodem_get_frame_len(ptr noundef) local_unnamed_addr #1

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

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

declare i32 @qpacketmodem_destroy(ptr noundef) local_unnamed_addr #1

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

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

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

declare void @liquid_autotest_failed_msg(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

declare void @liquid_autotest_print_array(ptr noundef, i32 noundef) local_unnamed_addr #1

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 = { 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 }

!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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


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