; LLVM IR from jgaeddert/liquid-dsp :: src/fec/tests (fec_hamming74_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
@hamming74_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_hamming74_codec_soft() #2 {
  %1 = alloca i8, align 1
  %2 = alloca i8, align 1
  %3 = alloca [7 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 7, 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 = %84, %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 %87

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 @hamming74_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, 64
  %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 [7 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, 32
  %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 [7 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, 16
  %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 [7 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, 8
  %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 [7 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, 4
  %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 [7 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, 2
  %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 [7 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, 1
  %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 [7 x i8], ptr %3, i64 0, i64 6
  store i8 %68, ptr %69, align 1, !tbaa !5
  %70 = getelementptr inbounds [7 x i8], ptr %3, i64 0, i64 0
  %71 = call zeroext i8 @fecsoft_hamming74_decode(ptr noundef %70)
  store i8 %71, ptr %4, align 1, !tbaa !5
  %72 = load i8, ptr %1, align 1, !tbaa !5
  %73 = zext i8 %72 to i32
  %74 = load i8, ptr %4, align 1, !tbaa !5
  %75 = zext i8 %74 to i32
  %76 = icmp ne i32 %73, %75
  br i1 %76, label %77, label %82

77:                                               ; preds = %9
  %78 = load i8, ptr %1, align 1, !tbaa !5
  %79 = uitofp i8 %78 to double
  %80 = load i8, ptr %4, align 1, !tbaa !5
  %81 = uitofp i8 %80 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 98, ptr noundef @.str.2, double noundef %79, ptr noundef @.str.3, ptr noundef @.str.4, double noundef %81)
  br label %83

82:                                               ; preds = %9
  call void (...) @liquid_autotest_passed()
  br label %83

83:                                               ; preds = %82, %77
  br label %84

84:                                               ; preds = %83
  %85 = load i8, ptr %1, align 1, !tbaa !5
  %86 = add i8 %85, 1
  store i8 %86, ptr %1, align 1, !tbaa !5
  br label %5, !llvm.loop !8

87:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 1, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 7, 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_hamming74_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
@hamming74_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_hamming74_codec_soft() local_unnamed_addr #2 {
  %1 = alloca [7 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 7, 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
  br label %8

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

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

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

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

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

declare zeroext i8 @fecsoft_hamming74_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