; LLVM IR from jgaeddert/liquid-dsp :: src/fec/tests (interleaver_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 [91 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@liquid_autotest_verbose = external global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @interleaver_test_hard(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca ptr, align 8
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %9 = load i32, ptr %2, align 4, !tbaa !5
  %10 = zext i32 %9 to i64
  %11 = call ptr @llvm.stacksave.p0()
  store ptr %11, ptr %4, align 8
  %12 = alloca i8, i64 %10, align 16
  store i64 %10, ptr %5, align 8
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = zext i32 %13 to i64
  %15 = alloca i8, i64 %14, align 16
  store i64 %14, ptr %6, align 8
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = zext i32 %16 to i64
  %18 = alloca i8, i64 %17, align 16
  store i64 %17, ptr %7, align 8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %30, %1
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = icmp ult i32 %20, %21
  br i1 %22, label %23, label %33

23:                                               ; preds = %19
  %24 = call i32 @rand() #5
  %25 = and i32 %24, 255
  %26 = trunc i32 %25 to i8
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %12, i64 %28
  store i8 %26, ptr %29, align 1, !tbaa !9
  br label %30

30:                                               ; preds = %23
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = add i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  br label %19, !llvm.loop !10

33:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = call ptr @interleaver_create(i32 noundef %34)
  store ptr %35, ptr %8, align 8, !tbaa !12
  %36 = load ptr, ptr %8, align 8, !tbaa !12
  %37 = call i32 @interleaver_encode(ptr noundef %36, ptr noundef %12, ptr noundef %15)
  %38 = load ptr, ptr %8, align 8, !tbaa !12
  %39 = call i32 @interleaver_decode(ptr noundef %38, ptr noundef %15, ptr noundef %18)
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = call i32 @liquid_autotest_same_data(ptr noundef %12, ptr noundef %18, i32 noundef %40)
  %42 = icmp ne i32 %41, 0
  br i1 %42, label %50, label %43

43:                                               ; preds = %33
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 47, ptr noundef @.str.1)
  %44 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %45 = icmp ne i32 %44, 0
  br i1 %45, label %46, label %49

46:                                               ; preds = %43
  %47 = load i32, ptr %2, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %12, i32 noundef %47)
  %48 = load i32, ptr %2, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %18, i32 noundef %48)
  br label %49

49:                                               ; preds = %46, %43
  br label %51

50:                                               ; preds = %33
  call void (...) @liquid_autotest_passed()
  br label %51

51:                                               ; preds = %50, %49
  %52 = load ptr, ptr %8, align 8, !tbaa !12
  %53 = call i32 @interleaver_destroy(ptr noundef %52)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %54 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %54)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

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

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

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

declare ptr @interleaver_create(i32 noundef) #4

declare i32 @interleaver_encode(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @interleaver_decode(ptr noundef, ptr noundef, ptr noundef) #4

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

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

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

declare void @liquid_autotest_passed(...) #4

declare i32 @interleaver_destroy(ptr noundef) #4

; 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) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn }
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 = { "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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}


; 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 [91 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @interleaver_test_hard(i32 noundef %0) local_unnamed_addr #0 {
  %2 = zext i32 %0 to i64
  %3 = alloca i8, i64 %2, align 16
  %4 = alloca i8, i64 %2, align 16
  %5 = alloca i8, i64 %2, align 16
  %.not17 = icmp eq i32 %0, 0
  br i1 %.not17, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %1 ]
  %6 = tail call i32 @rand() #3
  %7 = trunc i32 %6 to i8
  %8 = getelementptr inbounds i8, ptr %3, i64 %indvars.iv
  store i8 %7, ptr %8, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %1
  %9 = tail call ptr @interleaver_create(i32 noundef %0) #3
  %10 = call i32 @interleaver_encode(ptr noundef %9, ptr noundef nonnull %3, ptr noundef nonnull %4) #3
  %11 = call i32 @interleaver_decode(ptr noundef %9, ptr noundef nonnull %4, ptr noundef nonnull %5) #3
  %12 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %3, ptr noundef nonnull %5, i32 noundef %0) #3
  %.not = icmp eq i32 %12, 0
  br i1 %.not, label %13, label %16

13:                                               ; preds = %._crit_edge
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 47, ptr noundef nonnull @.str.1) #3
  %14 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !10
  %.not15 = icmp eq i32 %14, 0
  br i1 %.not15, label %17, label %15

15:                                               ; preds = %13
  call void @liquid_autotest_print_array(ptr noundef nonnull %3, i32 noundef %0) #3
  call void @liquid_autotest_print_array(ptr noundef nonnull %5, i32 noundef %0) #3
  br label %17

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

17:                                               ; preds = %13, %15, %16
  %18 = call i32 @interleaver_destroy(ptr noundef %9) #3
  ret void
}

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

declare ptr @interleaver_create(i32 noundef) local_unnamed_addr #2

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

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

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

declare i32 @interleaver_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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = distinct !{!8, !9}
!9 = !{!"llvm.loop.mustprogress"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !6, i64 0}


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