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

; Function Attrs: nounwind uwtable
define dso_local void @fec_test_codec(i32 noundef %0, i32 noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !5
  switch i32 %14, label %16 [
    i32 11, label %15
    i32 12, label %15
    i32 13, label %15
    i32 14, label %15
    i32 15, label %15
    i32 16, label %15
    i32 17, label %15
    i32 18, label %15
    i32 19, label %15
    i32 20, label %15
    i32 21, label %15
    i32 22, label %15
    i32 23, label %15
    i32 24, label %15
    i32 25, label %15
    i32 26, label %15
    i32 27, label %15
  ]

15:                                               ; preds = %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3, %3
  call void @liquid_autotest_warn(ptr noundef @.str, i32 noundef 50, ptr noundef @.str.1)
  br label %78

16:                                               ; preds = %3
  br label %17

17:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load ptr, ptr %6, align 8, !tbaa !9
  %20 = call ptr @fec_create(i32 noundef %18, ptr noundef %19)
  store ptr %20, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %21 = load i32, ptr %4, align 4, !tbaa !5
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = call i32 @fec_get_enc_msg_length(i32 noundef %21, i32 noundef %22)
  store i32 %23, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = zext i32 %24 to i64
  %26 = call ptr @llvm.stacksave.p0()
  store ptr %26, ptr %9, align 8
  %27 = alloca i8, i64 %25, align 16
  store i64 %25, ptr %10, align 8
  %28 = load i32, ptr %8, align 4, !tbaa !5
  %29 = zext i32 %28 to i64
  %30 = alloca i8, i64 %29, align 16
  store i64 %29, ptr %11, align 8
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = zext i32 %31 to i64
  %33 = alloca i8, i64 %32, align 16
  store i64 %32, ptr %12, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %48, %17
  %35 = load i32, ptr %13, align 4, !tbaa !5
  %36 = load i32, ptr %5, align 4, !tbaa !5
  %37 = icmp ult i32 %35, %36
  br i1 %37, label %38, label %51

38:                                               ; preds = %34
  %39 = call i32 @rand() #5
  %40 = and i32 %39, 255
  %41 = trunc i32 %40 to i8
  %42 = load i32, ptr %13, align 4, !tbaa !5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds i8, ptr %27, i64 %43
  store i8 %41, ptr %44, align 1, !tbaa !11
  %45 = load i32, ptr %13, align 4, !tbaa !5
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds i8, ptr %33, i64 %46
  store i8 0, ptr %47, align 1, !tbaa !11
  br label %48

48:                                               ; preds = %38
  %49 = load i32, ptr %13, align 4, !tbaa !5
  %50 = add i32 %49, 1
  store i32 %50, ptr %13, align 4, !tbaa !5
  br label %34, !llvm.loop !12

51:                                               ; preds = %34
  %52 = load ptr, ptr %7, align 8, !tbaa !9
  %53 = load i32, ptr %5, align 4, !tbaa !5
  %54 = call i32 @fec_encode(ptr noundef %52, i32 noundef %53, ptr noundef %27, ptr noundef %30)
  %55 = getelementptr inbounds i8, ptr %30, i64 0
  %56 = load i8, ptr %55, align 16, !tbaa !11
  %57 = zext i8 %56 to i32
  %58 = xor i32 %57, 1
  %59 = trunc i32 %58 to i8
  store i8 %59, ptr %55, align 16, !tbaa !11
  %60 = load ptr, ptr %7, align 8, !tbaa !9
  %61 = load i32, ptr %5, align 4, !tbaa !5
  %62 = call i32 @fec_decode(ptr noundef %60, i32 noundef %61, ptr noundef %30, ptr noundef %33)
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = call i32 @liquid_autotest_same_data(ptr noundef %27, ptr noundef %33, i32 noundef %63)
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %73, label %66

66:                                               ; preds = %51
  call void @liquid_autotest_failed_msg(ptr noundef @.str, i32 noundef 82, ptr noundef @.str.2)
  %67 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !5
  %68 = icmp ne i32 %67, 0
  br i1 %68, label %69, label %72

69:                                               ; preds = %66
  %70 = load i32, ptr %5, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %27, i32 noundef %70)
  %71 = load i32, ptr %5, align 4, !tbaa !5
  call void @liquid_autotest_print_array(ptr noundef %33, i32 noundef %71)
  br label %72

72:                                               ; preds = %69, %66
  br label %74

73:                                               ; preds = %51
  call void (...) @liquid_autotest_passed()
  br label %74

74:                                               ; preds = %73, %72
  %75 = load ptr, ptr %7, align 8, !tbaa !9
  %76 = call i32 @fec_destroy(ptr noundef %75)
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  %77 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %77)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %78

78:                                               ; preds = %74, %15
  ret void
}

declare void @liquid_autotest_warn(ptr noundef, i32 noundef, ptr noundef) #1

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

declare ptr @fec_create(i32 noundef, ptr noundef) #1

declare i32 @fec_get_enc_msg_length(i32 noundef, i32 noundef) #1

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

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

declare i32 @fec_encode(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

declare i32 @fec_decode(ptr noundef, i32 noundef, ptr noundef, ptr noundef) #1

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

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

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

declare void @liquid_autotest_passed(...) #1

declare i32 @fec_destroy(ptr noundef) #1

; 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) #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 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
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"

@.str = external hidden unnamed_addr constant [83 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [65 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [32 x i8], align 1
@liquid_autotest_verbose = external local_unnamed_addr global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local void @fec_test_codec(i32 noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %.off = add i32 %0, -11
  %switch = icmp ult i32 %.off, 17
  br i1 %switch, label %4, label %5

4:                                                ; preds = %3
  tail call void @liquid_autotest_warn(ptr noundef nonnull @.str, i32 noundef 50, ptr noundef nonnull @.str.1) #4
  br label %29

5:                                                ; preds = %3
  %6 = tail call ptr @fec_create(i32 noundef %0, ptr noundef %2) #4
  %7 = tail call i32 @fec_get_enc_msg_length(i32 noundef %0, i32 noundef %1) #4
  %8 = zext i32 %1 to i64
  %9 = tail call ptr @llvm.stacksave.p0()
  %10 = alloca i8, i64 %8, align 16
  %11 = zext i32 %7 to i64
  %12 = alloca i8, i64 %11, align 16
  %13 = alloca i8, i64 %8, align 16
  %.not24 = icmp eq i32 %1, 0
  br i1 %.not24, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %.lr.ph, %5
  %18 = call i32 @fec_encode(ptr noundef %6, i32 noundef %1, ptr noundef nonnull %10, ptr noundef nonnull %12) #4
  %19 = load i8, ptr %12, align 16, !tbaa !5
  %20 = xor i8 %19, 1
  store i8 %20, ptr %12, align 16, !tbaa !5
  %21 = call i32 @fec_decode(ptr noundef %6, i32 noundef %1, ptr noundef nonnull %12, ptr noundef nonnull %13) #4
  %22 = call i32 @liquid_autotest_same_data(ptr noundef nonnull %10, ptr noundef nonnull %13, i32 noundef %1) #4
  %.not = icmp eq i32 %22, 0
  br i1 %.not, label %23, label %26

23:                                               ; preds = %._crit_edge
  call void @liquid_autotest_failed_msg(ptr noundef nonnull @.str, i32 noundef 82, ptr noundef nonnull @.str.2) #4
  %24 = load i32, ptr @liquid_autotest_verbose, align 4, !tbaa !10
  %.not22 = icmp eq i32 %24, 0
  br i1 %.not22, label %27, label %25

25:                                               ; preds = %23
  call void @liquid_autotest_print_array(ptr noundef nonnull %10, i32 noundef %1) #4
  call void @liquid_autotest_print_array(ptr noundef nonnull %13, i32 noundef %1) #4
  br label %27

26:                                               ; preds = %._crit_edge
  call void (...) @liquid_autotest_passed() #4
  br label %27

27:                                               ; preds = %23, %25, %26
  %28 = call i32 @fec_destroy(ptr noundef %6) #4
  call void @llvm.stackrestore.p0(ptr %9)
  br label %29

29:                                               ; preds = %27, %4
  ret void
}

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

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

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

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

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

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

declare i32 @fec_decode(ptr noundef, i32 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 i32 @fec_destroy(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 = { "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 = { mustprogress 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 = { 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