; LLVM IR from jgaeddert/liquid-dsp :: src/fec/tests (fec_hamming84_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 [93 x i8], align 1
@hamming84_enc_gentab = external global [16 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 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

declare void @liquid_autotest_passed(...) #1

; 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_hamming84_codec_soft() #2 {
  %1 = alloca i8, align 1
  %2 = alloca i8, align 1
  %3 = alloca [8 x i8], align 1
  %4 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 1, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %4) #3
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %5

5:                                                ; preds = %92, %0
  %6 = load i8, ptr %1, align 1, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = icmp slt i32 %7, 16
  br i1 %8, label %9, label %95

9:                                                ; preds = %5
  %10 = load i8, ptr %1, align 1, !tbaa !5
  %11 = zext i8 %10 to i64
  %12 = getelementptr inbounds [16 x i8], ptr @hamming84_enc_gentab, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !5
  store i8 %13, ptr %2, align 1, !tbaa !5
  %14 = load i8, ptr %2, align 1, !tbaa !5
  %15 = zext i8 %14 to i32
  %16 = and i32 %15, 128
  %17 = icmp ne i32 %16, 0
  %18 = zext i1 %17 to i64
  %19 = select i1 %17, i32 255, i32 0
  %20 = trunc i32 %19 to i8
  %21 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 0
  store i8 %20, ptr %21, align 1, !tbaa !5
  %22 = load i8, ptr %2, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = and i32 %23, 64
  %25 = icmp ne i32 %24, 0
  %26 = zext i1 %25 to i64
  %27 = select i1 %25, i32 255, i32 0
  %28 = trunc i32 %27 to i8
  %29 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 1
  store i8 %28, ptr %29, align 1, !tbaa !5
  %30 = load i8, ptr %2, align 1, !tbaa !5
  %31 = zext i8 %30 to i32
  %32 = and i32 %31, 32
  %33 = icmp ne i32 %32, 0
  %34 = zext i1 %33 to i64
  %35 = select i1 %33, i32 255, i32 0
  %36 = trunc i32 %35 to i8
  %37 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 2
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = load i8, ptr %2, align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = and i32 %39, 16
  %41 = icmp ne i32 %40, 0
  %42 = zext i1 %41 to i64
  %43 = select i1 %41, i32 255, i32 0
  %44 = trunc i32 %43 to i8
  %45 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 3
  store i8 %44, ptr %45, align 1, !tbaa !5
  %46 = load i8, ptr %2, align 1, !tbaa !5
  %47 = zext i8 %46 to i32
  %48 = and i32 %47, 8
  %49 = icmp ne i32 %48, 0
  %50 = zext i1 %49 to i64
  %51 = select i1 %49, i32 255, i32 0
  %52 = trunc i32 %51 to i8
  %53 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 4
  store i8 %52, ptr %53, align 1, !tbaa !5
  %54 = load i8, ptr %2, align 1, !tbaa !5
  %55 = zext i8 %54 to i32
  %56 = and i32 %55, 4
  %57 = icmp ne i32 %56, 0
  %58 = zext i1 %57 to i64
  %59 = select i1 %57, i32 255, i32 0
  %60 = trunc i32 %59 to i8
  %61 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 5
  store i8 %60, ptr %61, align 1, !tbaa !5
  %62 = load i8, ptr %2, align 1, !tbaa !5
  %63 = zext i8 %62 to i32
  %64 = and i32 %63, 2
  %65 = icmp ne i32 %64, 0
  %66 = zext i1 %65 to i64
  %67 = select i1 %65, i32 255, i32 0
  %68 = trunc i32 %67 to i8
  %69 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 6
  store i8 %68, ptr %69, align 1, !tbaa !5
  %70 = load i8, ptr %2, align 1, !tbaa !5
  %71 = zext i8 %70 to i32
  %72 = and i32 %71, 1
  %73 = icmp ne i32 %72, 0
  %74 = zext i1 %73 to i64
  %75 = select i1 %73, i32 255, i32 0
  %76 = trunc i32 %75 to i8
  %77 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 7
  store i8 %76, ptr %77, align 1, !tbaa !5
  %78 = getelementptr inbounds [8 x i8], ptr %3, i64 0, i64 0
  %79 = call zeroext i8 @fecsoft_hamming84_decode(ptr noundef %78)
  store i8 %79, ptr %4, align 1, !tbaa !5
  %80 = load i8, ptr %1, align 1, !tbaa !5
  %81 = zext i8 %80 to i32
  %82 = load i8, ptr %4, align 1, !tbaa !5
  %83 = zext i8 %82 to i32
  %84 = icmp ne i32 %81, %83
  br i1 %84, label %85, label %90

85:                                               ; preds = %9
  %86 = load i8, ptr %1, align 1, !tbaa !5
  %87 = uitofp i8 %86 to double
  %88 = load i8, ptr %4, align 1, !tbaa !5
  %89 = uitofp i8 %88 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 98, ptr noundef @.str.2, double noundef %87, ptr noundef @.str.3, ptr noundef @.str.4, double noundef %89)
  br label %91

90:                                               ; preds = %9
  call void (...) @liquid_autotest_passed()
  br label %91

91:                                               ; preds = %90, %85
  br label %92

92:                                               ; preds = %91
  %93 = load i8, ptr %1, align 1, !tbaa !5
  %94 = add i8 %93, 1
  store i8 %94, ptr %1, align 1, !tbaa !5
  br label %5, !llvm.loop !8

95:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %1) #3
  ret void
}

declare zeroext i8 @fecsoft_hamming84_decode(ptr noundef) #1

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

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


; 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 [93 x i8], align 1
@hamming84_enc_gentab = external local_unnamed_addr global [16 x i8], align 16
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [6 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

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

; 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_hamming84_codec_soft() local_unnamed_addr #2 {
  %1 = alloca [8 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #3
  %2 = getelementptr inbounds i8, ptr %1, i64 1
  %3 = getelementptr inbounds i8, ptr %1, i64 2
  %4 = getelementptr inbounds i8, ptr %1, i64 3
  %5 = getelementptr inbounds i8, ptr %1, i64 4
  %6 = getelementptr inbounds i8, ptr %1, i64 5
  %7 = getelementptr inbounds i8, ptr %1, i64 6
  %8 = getelementptr inbounds i8, ptr %1, i64 7
  br label %9

9:                                                ; preds = %0, %33
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %33 ]
  %10 = getelementptr inbounds [16 x i8], ptr @hamming84_enc_gentab, i64 0, i64 %indvars.iv
  %11 = load i8, ptr %10, align 1, !tbaa !5
  %12 = zext i8 %11 to i32
  %.lobit = ashr i8 %11, 7
  store i8 %.lobit, ptr %1, align 1, !tbaa !5
  %13 = shl i32 %12, 25
  %sext = ashr i32 %13, 31
  %14 = trunc nsw i32 %sext to i8
  store i8 %14, ptr %2, align 1, !tbaa !5
  %15 = shl i32 %12, 26
  %sext16 = ashr i32 %15, 31
  %16 = trunc nsw i32 %sext16 to i8
  store i8 %16, ptr %3, align 1, !tbaa !5
  %17 = shl i32 %12, 27
  %sext17 = ashr i32 %17, 31
  %18 = trunc nsw i32 %sext17 to i8
  store i8 %18, ptr %4, align 1, !tbaa !5
  %19 = shl i32 %12, 28
  %sext18 = ashr i32 %19, 31
  %20 = trunc nsw i32 %sext18 to i8
  store i8 %20, ptr %5, align 1, !tbaa !5
  %21 = shl i32 %12, 29
  %sext19 = ashr i32 %21, 31
  %22 = trunc nsw i32 %sext19 to i8
  store i8 %22, ptr %6, align 1, !tbaa !5
  %23 = shl i32 %12, 30
  %sext20 = ashr i32 %23, 31
  %24 = trunc nsw i32 %sext20 to i8
  store i8 %24, ptr %7, align 1, !tbaa !5
  %25 = and i8 %11, 1
  %sext21 = sub nsw i8 0, %25
  store i8 %sext21, ptr %8, align 1, !tbaa !5
  %26 = call zeroext i8 @fecsoft_hamming84_decode(ptr noundef nonnull %1) #3
  %27 = zext i8 %26 to i64
  %.not = icmp eq i64 %indvars.iv, %27
  br i1 %.not, label %32, label %28

28:                                               ; preds = %9
  %29 = trunc nuw nsw i64 %indvars.iv to i8
  %30 = uitofp nneg i8 %29 to double
  %31 = uitofp i8 %26 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 98, ptr noundef nonnull @.str.2, double noundef %30, ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.4, double noundef %31) #3
  br label %33

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

33:                                               ; preds = %28, %32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 16
  br i1 %exitcond.not, label %34, label %9, !llvm.loop !8

34:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #3
  ret void
}

declare zeroext i8 @fecsoft_hamming84_decode(ptr noundef) 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

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass