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

; Function Attrs: nounwind uwtable
define dso_local void @packetizer_test_codec(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !5
  %17 = load i32, ptr %5, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = call ptr @llvm.stacksave.p0()
  store ptr %19, ptr %9, align 8
  %20 = alloca i8, i64 %18, align 16
  store i64 %18, ptr %10, align 8
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = alloca i8, i64 %22, align 16
  store i64 %22, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %26 = load i32, ptr %7, align 4, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = call i32 @packetizer_compute_enc_msg_len(i32 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27)
  store i32 %28, ptr %12, align 4, !tbaa !5
  %29 = load i32, ptr %12, align 4, !tbaa !5
  %30 = zext i32 %29 to i64
  %31 = alloca i8, i64 %30, align 16
  store i64 %30, ptr %13, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = load i32, ptr %6, align 4, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = call ptr @packetizer_create(i32 noundef %32, i32 noundef %33, i32 noundef %34, i32 noundef %35)
  store ptr %36, ptr %14, align 8, !tbaa !9
  %37 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %4
  %40 = load ptr, ptr %14, align 8, !tbaa !9
  %41 = call i32 @packetizer_print(ptr noundef %40)
  br label %42

42:                                               ; preds = %39, %4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %57, %42
  %44 = load i32, ptr %15, align 4, !tbaa !5
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = icmp ult i32 %44, %45
  br i1 %46, label %47, label %60

47:                                               ; preds = %43
  %48 = load i32, ptr %15, align 4, !tbaa !5
  %49 = urem i32 %48, 256
  %50 = trunc i32 %49 to i8
  %51 = load i32, ptr %15, align 4, !tbaa !5
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %20, i64 %52
  store i8 %50, ptr %53, align 1, !tbaa !11
  %54 = load i32, ptr %15, align 4, !tbaa !5
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds i8, ptr %23, i64 %55
  store i8 0, ptr %56, align 1, !tbaa !11
  br label %57

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

60:                                               ; preds = %43
  %61 = load ptr, ptr %14, align 8, !tbaa !9
  %62 = call i32 @packetizer_encode(ptr noundef %61, ptr noundef %20, ptr noundef %31)
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %63 = load ptr, ptr %14, align 8, !tbaa !9
  %64 = call i32 @packetizer_decode(ptr noundef %63, ptr noundef %31, ptr noundef %23)
  store i32 %64, ptr %16, align 4, !tbaa !5
  %65 = load i32, ptr %5, align 4, !tbaa !5
  %66 = call i32 @liquid_autotest_same_data(ptr noundef %20, ptr noundef %23, i32 noundef %65)
  %67 = icmp ne i32 %66, 0
  br i1 %67, label %75, label %68

68:                                               ; preds = %60
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 54, ptr noundef @.str.1)
  %69 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load i32, ptr %5, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %20, i32 noundef %72)
  %73 = load i32, ptr %5, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %23, i32 noundef %73)
  br label %74

74:                                               ; preds = %71, %68
  br label %76

75:                                               ; preds = %60
  call void (...) @liquid_autotest_passed()
  br label %76

76:                                               ; preds = %75, %74
  %77 = load i32, ptr %16, align 4, !tbaa !5
  %78 = icmp ne i32 %77, 1
  br i1 %78, label %79, label %82

79:                                               ; preds = %76
  %80 = load i32, ptr %16, align 4, !tbaa !5
  %81 = sitofp i32 %80 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 55, ptr noundef @.str.2, double noundef %81, ptr noundef @.str.3, ptr noundef @.str.4, double noundef 1.000000e+00)
  br label %83

82:                                               ; preds = %76
  call void (...) @liquid_autotest_passed()
  br label %83

83:                                               ; preds = %82, %79
  %84 = load ptr, ptr %14, align 8, !tbaa !9
  %85 = call i32 @packetizer_destroy(ptr noundef %84)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %86 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %86)
  ret void
}

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

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

declare i32 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare ptr @packetizer_create(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #3

declare i32 @packetizer_print(ptr noundef) #3

declare i32 @packetizer_encode(ptr noundef, ptr noundef, ptr noundef) #3

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

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

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

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

declare void @liquid_autotest_passed(...) #3

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

declare i32 @packetizer_destroy(ptr noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #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 = { nocallback nofree nosync nounwind willreturn }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { "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 }

!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 [90 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @packetizer_test_codec(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = zext i32 %0 to i64
  %6 = alloca i8, i64 %5, align 16
  %7 = alloca i8, i64 %5, align 16
  %8 = tail call i32 @packetizer_compute_enc_msg_len(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #3
  %9 = zext i32 %8 to i64
  %10 = alloca i8, i64 %9, align 16
  %11 = tail call ptr @packetizer_create(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3) #3
  %12 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %15, label %13

13:                                               ; preds = %4
  %14 = tail call i32 @packetizer_print(ptr noundef %11) #3
  br label %15

15:                                               ; preds = %13, %4
  %.not32 = icmp eq i32 %0, 0
  br i1 %.not32, label %._crit_edge, label %iter.check

iter.check:                                       ; preds = %15
  call void @llvm.memset.p0.i64(ptr nonnull align 16 %7, i8 0, i64 %5, i1 false), !tbaa !9
  %min.iters.check = icmp ult i32 %0, 8
  br i1 %min.iters.check, label %.lr.ph.preheader, label %vector.main.loop.iter.check

vector.main.loop.iter.check:                      ; preds = %iter.check
  %min.iters.check34 = icmp ult i32 %0, 16
  br i1 %min.iters.check34, label %vec.epilog.ph, label %vector.ph

vector.ph:                                        ; preds = %vector.main.loop.iter.check
  %n.vec = and i64 %5, 4294967280
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %16 = getelementptr inbounds i8, ptr %6, i64 %index
  store <16 x i8> %vec.ind, ptr %16, align 16, !tbaa !9
  %index.next = add nuw i64 %index, 16
  %vec.ind.next = add <16 x i8> %vec.ind, <i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16, i8 16>
  %17 = icmp eq i64 %index.next, %n.vec
  br i1 %17, label %middle.block, label %vector.body, !llvm.loop !10

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %5
  br i1 %cmp.n, label %._crit_edge, label %vec.epilog.iter.check

vec.epilog.iter.check:                            ; preds = %middle.block
  %n.vec.remaining = and i64 %5, 8
  %min.epilog.iters.check.not.not = icmp eq i64 %n.vec.remaining, 0
  br i1 %min.epilog.iters.check.not.not, label %.lr.ph.preheader, label %vec.epilog.ph

vec.epilog.ph:                                    ; preds = %vector.main.loop.iter.check, %vec.epilog.iter.check
  %vec.epilog.resume.val = phi i64 [ %n.vec, %vec.epilog.iter.check ], [ 0, %vector.main.loop.iter.check ]
  %n.vec36 = and i64 %5, 4294967288
  %18 = trunc i64 %vec.epilog.resume.val to i8
  %.splatinsert = insertelement <8 x i8> poison, i8 %18, i64 0
  %.splat = shufflevector <8 x i8> %.splatinsert, <8 x i8> poison, <8 x i32> zeroinitializer
  %induction = or disjoint <8 x i8> %.splat, <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7>
  br label %vec.epilog.vector.body

vec.epilog.vector.body:                           ; preds = %vec.epilog.vector.body, %vec.epilog.ph
  %index38 = phi i64 [ %vec.epilog.resume.val, %vec.epilog.ph ], [ %index.next41, %vec.epilog.vector.body ]
  %vec.ind39 = phi <8 x i8> [ %induction, %vec.epilog.ph ], [ %vec.ind.next40, %vec.epilog.vector.body ]
  %19 = getelementptr inbounds i8, ptr %6, i64 %index38
  store <8 x i8> %vec.ind39, ptr %19, align 8, !tbaa !9
  %index.next41 = add nuw i64 %index38, 8
  %vec.ind.next40 = add <8 x i8> %vec.ind39, <i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8, i8 8>
  %20 = icmp eq i64 %index.next41, %n.vec36
  br i1 %20, label %vec.epilog.middle.block, label %vec.epilog.vector.body, !llvm.loop !14

vec.epilog.middle.block:                          ; preds = %vec.epilog.vector.body
  %cmp.n42 = icmp eq i64 %n.vec36, %5
  br i1 %cmp.n42, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %vec.epilog.middle.block, %iter.check, %vec.epilog.iter.check
  %indvars.iv.ph = phi i64 [ 0, %iter.check ], [ %n.vec, %vec.epilog.iter.check ], [ %n.vec36, %vec.epilog.middle.block ]
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader ]
  %21 = trunc i64 %indvars.iv to i8
  %22 = getelementptr inbounds i8, ptr %6, i64 %indvars.iv
  store i8 %21, ptr %22, align 1, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %5
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %vec.epilog.middle.block, %15
  %23 = call i32 @packetizer_encode(ptr noundef %11, ptr noundef nonnull %6, ptr noundef nonnull %10) #3
  %24 = call i32 @packetizer_decode(ptr noundef %11, ptr noundef nonnull %10, ptr noundef nonnull %7) #3
  %25 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %6, ptr noundef nonnull %7, i32 noundef %0) #3
  %.not28 = icmp eq i32 %25, 0
  br i1 %.not28, label %26, label %29

26:                                               ; preds = %._crit_edge
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 54, ptr noundef nonnull @.str.1) #3
  %27 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not29 = icmp eq i32 %27, 0
  br i1 %.not29, label %30, label %28

28:                                               ; preds = %26
  call void @liquid_autotest_print_array(ptr noundef nonnull %6, i32 noundef %0) #3
  call void @liquid_autotest_print_array(ptr noundef nonnull %7, i32 noundef %0) #3
  br label %30

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

30:                                               ; preds = %26, %28, %29
  %.not30 = icmp eq i32 %24, 1
  br i1 %.not30, label %33, label %31

31:                                               ; preds = %30
  %32 = sitofp i32 %24 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 55, ptr noundef nonnull @.str.2, double noundef %32, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, double noundef 1.000000e+00) #3
  br label %34

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

34:                                               ; preds = %33, %31
  %35 = call i32 @packetizer_destroy(ptr noundef %11) #3
  ret void
}

declare i32 @packetizer_compute_enc_msg_len(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

declare i32 @packetizer_print(ptr noundef) local_unnamed_addr #1

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

declare i32 @packetizer_decode(ptr noundef, ptr noundef, ptr noundef) 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

declare void @liquid_autotest_passed(...) 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 i32 @packetizer_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { "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 nounwind willreturn memory(argmem: write) }
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, !12, !13}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !11, !12, !13}
!15 = distinct !{!15, !11, !13, !12}


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