; 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
@liquid_autotest_verbose = external global i32, align 4
@.str.2 = external hidden unnamed_addr constant [26 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 nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

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

declare ptr @interleaver_create(i32 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 i32 @interleaver_destroy(ptr noundef) #3

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

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

; Function Attrs: nounwind uwtable
define dso_local void @interleaver_test_soft(i32 noundef %0) #4 {
  %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 = mul i32 8, %9
  %11 = zext i32 %10 to i64
  %12 = call ptr @llvm.stacksave.p0()
  store ptr %12, ptr %4, align 8
  %13 = alloca i8, i64 %11, align 16
  store i64 %11, ptr %5, align 8
  %14 = load i32, ptr %2, align 4, !tbaa !5
  %15 = mul i32 8, %14
  %16 = zext i32 %15 to i64
  %17 = alloca i8, i64 %16, align 16
  store i64 %16, ptr %6, align 8
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = mul i32 8, %18
  %20 = zext i32 %19 to i64
  %21 = alloca i8, i64 %20, align 16
  store i64 %20, ptr %7, align 8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %34, %1
  %23 = load i32, ptr %3, align 4, !tbaa !5
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = mul i32 8, %24
  %26 = icmp ult i32 %23, %25
  br i1 %26, label %27, label %37

27:                                               ; preds = %22
  %28 = call i32 @rand() #5
  %29 = and i32 %28, 255
  %30 = trunc i32 %29 to i8
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = getelementptr inbounds i8, ptr %13, i64 %32
  store i8 %30, ptr %33, align 1, !tbaa !9
  br label %34

34:                                               ; preds = %27
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = add i32 %35, 1
  store i32 %36, ptr %3, align 4, !tbaa !5
  br label %22, !llvm.loop !10

37:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = call ptr @interleaver_create(i32 noundef %38)
  store ptr %39, ptr %8, align 8, !tbaa !12
  %40 = load ptr, ptr %8, align 8, !tbaa !12
  %41 = call i32 @interleaver_encode_soft(ptr noundef %40, ptr noundef %13, ptr noundef %17)
  %42 = load ptr, ptr %8, align 8, !tbaa !12
  %43 = call i32 @interleaver_decode_soft(ptr noundef %42, ptr noundef %17, ptr noundef %21)
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = mul i32 8, %44
  %46 = call i32 @liquid_autotest_same_data(ptr noundef %13, ptr noundef %21, i32 noundef %45)
  %47 = icmp ne i32 %46, 0
  br i1 %47, label %57, label %48

48:                                               ; preds = %37
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 72, ptr noundef @.str.2)
  %49 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %50 = icmp ne i32 %49, 0
  br i1 %50, label %51, label %56

51:                                               ; preds = %48
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = mul i32 8, %52
  call void @liquid_autotest_print_array(ptr noundef %13, i32 noundef %53)
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = mul i32 8, %54
  call void @liquid_autotest_print_array(ptr noundef %21, i32 noundef %55)
  br label %56

56:                                               ; preds = %51, %48
  br label %58

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

58:                                               ; preds = %57, %56
  %59 = load ptr, ptr %8, align 8, !tbaa !12
  %60 = call i32 @interleaver_destroy(ptr noundef %59)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  %61 = load ptr, ptr %4, align 8
  call void @llvm.stackrestore.p0(ptr %61)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  ret void
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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 = { "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 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 #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
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4
@.str.2 = external hidden unnamed_addr constant [26 x i8], align 1

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

declare ptr @interleaver_create(i32 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 i32 @interleaver_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @interleaver_test_soft(i32 noundef %0) local_unnamed_addr #2 {
  %2 = shl i32 %0, 3
  %3 = zext i32 %2 to i64
  %4 = alloca i8, i64 %3, align 16
  %5 = alloca i8, i64 %3, align 16
  %6 = alloca i8, i64 %3, align 16
  %.not17 = icmp eq i32 %2, 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 ]
  %7 = tail call i32 @rand() #3
  %8 = trunc i32 %7 to i8
  %9 = getelementptr inbounds i8, ptr %4, i64 %indvars.iv
  store i8 %8, ptr %9, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %3
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %1
  %10 = tail call ptr @interleaver_create(i32 noundef %0) #3
  %11 = call i32 @interleaver_encode_soft(ptr noundef %10, ptr noundef nonnull %4, ptr noundef nonnull %5) #3
  %12 = call i32 @interleaver_decode_soft(ptr noundef %10, ptr noundef nonnull %5, ptr noundef nonnull %6) #3
  %13 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %4, ptr noundef nonnull %6, i32 noundef %2) #3
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %17

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

16:                                               ; preds = %14
  call void @liquid_autotest_print_array(ptr noundef nonnull %4, i32 noundef %2) #3
  call void @liquid_autotest_print_array(ptr noundef nonnull %6, i32 noundef %2) #3
  br label %18

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

18:                                               ; preds = %14, %16, %17
  %19 = call i32 @interleaver_destroy(ptr noundef %10) #3
  ret void
}

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

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

attributes #0 = { 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 #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 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 #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