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

@.str = external hidden unnamed_addr constant [94 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4
@__const.autotest_unpack_array.input = external hidden unnamed_addr constant [4 x i8], align 1
@__const.autotest_unpack_array.sym_size = external hidden unnamed_addr constant [9 x i32], align 16
@__const.autotest_unpack_array.output_test = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [38 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 nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

declare void @liquid_autotest_passed(...) #2

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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_unpack_array() #3 {
  %1 = alloca [4 x i8], align 1
  %2 = alloca [9 x i32], align 16
  %3 = alloca [9 x i8], align 1
  %4 = alloca [9 x i8], align 1
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %1, ptr align 1 @__const.autotest_unpack_array.input, i64 4, i1 false)
  call void @llvm.lifetime.start.p0(i64 36, ptr %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.autotest_unpack_array.sym_size, i64 36, i1 false)
  call void @llvm.lifetime.start.p0(i64 9, ptr %3) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %3, ptr align 1 @__const.autotest_unpack_array.output_test, i64 9, i1 false)
  call void @llvm.lifetime.start.p0(i64 9, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %27, %0
  %8 = load i32, ptr %6, align 4, !tbaa !5
  %9 = icmp ult i32 %8, 9
  br i1 %9, label %10, label %30

10:                                               ; preds = %7
  %11 = getelementptr inbounds [4 x i8], ptr %1, i64 0, i64 0
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = getelementptr inbounds [9 x i32], ptr %2, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [9 x i8], ptr %4, i64 0, i64 %18
  %20 = call i32 @liquid_unpack_array(ptr noundef %11, i32 noundef 4, i32 noundef %12, i32 noundef %16, ptr noundef %19)
  %21 = load i32, ptr %6, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds [9 x i32], ptr %2, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = add i32 %25, %24
  store i32 %26, ptr %5, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %10
  %28 = load i32, ptr %6, align 4, !tbaa !5
  %29 = add i32 %28, 1
  store i32 %29, ptr %6, align 4, !tbaa !5
  br label %7, !llvm.loop !9

30:                                               ; preds = %7
  %31 = getelementptr inbounds [9 x i8], ptr %4, i64 0, i64 0
  %32 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 0
  %33 = call i32 @liquid_autotest_same_data(ptr noundef %31, ptr noundef %32, i32 noundef 9)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %42, label %35

35:                                               ; preds = %30
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 92, ptr noundef @.str.2)
  %36 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %37 = icmp ne i32 %36, 0
  br i1 %37, label %38, label %41

38:                                               ; preds = %35
  %39 = getelementptr inbounds [9 x i8], ptr %4, i64 0, i64 0
  call void @liquid_autotest_print_array(ptr noundef %39, i32 noundef 9)
  %40 = getelementptr inbounds [9 x i8], ptr %3, i64 0, i64 0
  call void @liquid_autotest_print_array(ptr noundef %40, i32 noundef 9)
  br label %41

41:                                               ; preds = %38, %35
  br label %43

42:                                               ; preds = %30
  call void (...) @liquid_autotest_passed()
  br label %43

43:                                               ; preds = %42, %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 36, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

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

!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"}


; 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 = external hidden unnamed_addr constant [94 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@__const.autotest_unpack_array.input = external hidden unnamed_addr constant [4 x i8], align 1
@__const.autotest_unpack_array.sym_size = external hidden unnamed_addr constant [9 x i32], align 16
@__const.autotest_unpack_array.output_test = external hidden unnamed_addr constant [9 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [38 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

; 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) #1

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

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_unpack_array() local_unnamed_addr #3 {
  %1 = alloca [4 x i8], align 4
  %2 = alloca [9 x i8], align 1
  %3 = alloca [9 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %4 = load i32, ptr @__const.autotest_unpack_array.input, align 1
  store i32 %4, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %2) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(9) %2, ptr noundef nonnull align 1 dereferenceable(9) @__const.autotest_unpack_array.output_test, i64 9, i1 false)
  call void @llvm.lifetime.start.p0(i64 9, ptr nonnull %3) #4
  %5 = load i32, ptr @__const.autotest_unpack_array.sym_size, align 16, !tbaa !5
  %6 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef 0, i32 noundef %5, ptr noundef nonnull %3) #4
  %7 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 4), align 4, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %3, i64 1
  %9 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %5, i32 noundef %7, ptr noundef nonnull %8) #4
  %10 = add i32 %7, %5
  %11 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 8), align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %3, i64 2
  %13 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %10, i32 noundef %11, ptr noundef nonnull %12) #4
  %14 = add i32 %11, %10
  %15 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 12), align 4, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %3, i64 3
  %17 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %14, i32 noundef %15, ptr noundef nonnull %16) #4
  %18 = add i32 %15, %14
  %19 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 16), align 16, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %3, i64 4
  %21 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %18, i32 noundef %19, ptr noundef nonnull %20) #4
  %22 = add i32 %19, %18
  %23 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 20), align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %3, i64 5
  %25 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %22, i32 noundef %23, ptr noundef nonnull %24) #4
  %26 = add i32 %23, %22
  %27 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 24), align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %3, i64 6
  %29 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %26, i32 noundef %27, ptr noundef nonnull %28) #4
  %30 = add i32 %27, %26
  %31 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 28), align 4, !tbaa !5
  %32 = getelementptr inbounds i8, ptr %3, i64 7
  %33 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %30, i32 noundef %31, ptr noundef nonnull %32) #4
  %34 = add i32 %31, %30
  %35 = load i32, ptr getelementptr inbounds (i8, ptr @__const.autotest_unpack_array.sym_size, i64 32), align 16, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %3, i64 8
  %37 = call i32 @liquid_unpack_array(ptr noundef nonnull %1, i32 noundef 4, i32 noundef %34, i32 noundef %35, ptr noundef nonnull %36) #4
  %38 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %3, ptr noundef nonnull %2, i32 noundef 9) #4
  %.not = icmp eq i32 %38, 0
  br i1 %.not, label %39, label %42

39:                                               ; preds = %0
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 92, ptr noundef nonnull @.str.2) #4
  %40 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %.not8 = icmp eq i32 %40, 0
  br i1 %.not8, label %43, label %41

41:                                               ; preds = %39
  call void @liquid_autotest_print_array(ptr noundef nonnull %3, i32 noundef 9) #4
  call void @liquid_autotest_print_array(ptr noundef nonnull %2, i32 noundef 9) #4
  br label %43

42:                                               ; preds = %0
  call void (...) @liquid_autotest_passed() #4
  br label %43

43:                                               ; preds = %39, %41, %42
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 9, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void
}

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

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

!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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,ReassociatePass,SROAPass,SimplifyCFGPass