; LLVM IR from jgaeddert/liquid-dsp :: src/fec/tests (fec_hamming128_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.7 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = 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 i32 @fec_hamming128_encode_symbol(i32 noundef) #1

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

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

5:                                                ; preds = %107, %0
  %6 = load i32, ptr %1, align 4, !tbaa !5
  %7 = icmp ult i32 %6, 256
  br i1 %7, label %8, label %110

8:                                                ; preds = %5
  %9 = load i32, ptr %1, align 4, !tbaa !5
  %10 = call i32 @fec_hamming128_encode_symbol(i32 noundef %9)
  store i32 %10, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = and i32 %11, 2048
  %13 = icmp ne i32 %12, 0
  %14 = zext i1 %13 to i64
  %15 = select i1 %13, i32 255, i32 0
  %16 = trunc i32 %15 to i8
  %17 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 0
  store i8 %16, ptr %17, align 1, !tbaa !9
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = and i32 %18, 1024
  %20 = icmp ne i32 %19, 0
  %21 = zext i1 %20 to i64
  %22 = select i1 %20, i32 255, i32 0
  %23 = trunc i32 %22 to i8
  %24 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 1
  store i8 %23, ptr %24, align 1, !tbaa !9
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = and i32 %25, 512
  %27 = icmp ne i32 %26, 0
  %28 = zext i1 %27 to i64
  %29 = select i1 %27, i32 255, i32 0
  %30 = trunc i32 %29 to i8
  %31 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 2
  store i8 %30, ptr %31, align 1, !tbaa !9
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = and i32 %32, 256
  %34 = icmp ne i32 %33, 0
  %35 = zext i1 %34 to i64
  %36 = select i1 %34, i32 255, i32 0
  %37 = trunc i32 %36 to i8
  %38 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 3
  store i8 %37, ptr %38, align 1, !tbaa !9
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = and i32 %39, 128
  %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 [12 x i8], ptr %3, i64 0, i64 4
  store i8 %44, ptr %45, align 1, !tbaa !9
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = and i32 %46, 64
  %48 = icmp ne i32 %47, 0
  %49 = zext i1 %48 to i64
  %50 = select i1 %48, i32 255, i32 0
  %51 = trunc i32 %50 to i8
  %52 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 5
  store i8 %51, ptr %52, align 1, !tbaa !9
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = and i32 %53, 32
  %55 = icmp ne i32 %54, 0
  %56 = zext i1 %55 to i64
  %57 = select i1 %55, i32 255, i32 0
  %58 = trunc i32 %57 to i8
  %59 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 6
  store i8 %58, ptr %59, align 1, !tbaa !9
  %60 = load i32, ptr %2, align 4, !tbaa !5
  %61 = and i32 %60, 16
  %62 = icmp ne i32 %61, 0
  %63 = zext i1 %62 to i64
  %64 = select i1 %62, i32 255, i32 0
  %65 = trunc i32 %64 to i8
  %66 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 7
  store i8 %65, ptr %66, align 1, !tbaa !9
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = and i32 %67, 8
  %69 = icmp ne i32 %68, 0
  %70 = zext i1 %69 to i64
  %71 = select i1 %69, i32 255, i32 0
  %72 = trunc i32 %71 to i8
  %73 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 8
  store i8 %72, ptr %73, align 1, !tbaa !9
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = and i32 %74, 4
  %76 = icmp ne i32 %75, 0
  %77 = zext i1 %76 to i64
  %78 = select i1 %76, i32 255, i32 0
  %79 = trunc i32 %78 to i8
  %80 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 9
  store i8 %79, ptr %80, align 1, !tbaa !9
  %81 = load i32, ptr %2, align 4, !tbaa !5
  %82 = and i32 %81, 2
  %83 = icmp ne i32 %82, 0
  %84 = zext i1 %83 to i64
  %85 = select i1 %83, i32 255, i32 0
  %86 = trunc i32 %85 to i8
  %87 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 10
  store i8 %86, ptr %87, align 1, !tbaa !9
  %88 = load i32, ptr %2, align 4, !tbaa !5
  %89 = and i32 %88, 1
  %90 = icmp ne i32 %89, 0
  %91 = zext i1 %90 to i64
  %92 = select i1 %90, i32 255, i32 0
  %93 = trunc i32 %92 to i8
  %94 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 11
  store i8 %93, ptr %94, align 1, !tbaa !9
  %95 = getelementptr inbounds [12 x i8], ptr %3, i64 0, i64 0
  %96 = call i32 @fecsoft_hamming128_decode(ptr noundef %95)
  store i32 %96, ptr %4, align 4, !tbaa !5
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = load i32, ptr %4, align 4, !tbaa !5
  %99 = icmp ne i32 %97, %98
  br i1 %99, label %100, label %105

100:                                              ; preds = %8
  %101 = load i32, ptr %1, align 4, !tbaa !5
  %102 = uitofp i32 %101 to double
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = uitofp i32 %103 to double
  call void @liquid_autotest_failed_expr(ptr noundef @.str.7, i32 noundef 102, ptr noundef @.str.11, double noundef %102, ptr noundef @.str.9, ptr noundef @.str.12, double noundef %104)
  br label %106

105:                                              ; preds = %8
  call void (...) @liquid_autotest_passed()
  br label %106

106:                                              ; preds = %105, %100
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %1, align 4, !tbaa !5
  %109 = add i32 %108, 1
  store i32 %109, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !10

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

declare i32 @fecsoft_hamming128_decode(ptr 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 = !{!"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"}


; 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.7 = external hidden unnamed_addr constant [94 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.12 = 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 i32 @fec_hamming128_encode_symbol(i32 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

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

6:                                                ; preds = %0, %27
  %.031 = phi i32 [ 0, %0 ], [ %28, %27 ]
  %7 = call i32 @fec_hamming128_encode_symbol(i32 noundef %.031) #3
  %8 = insertelement <8 x i32> poison, i32 %7, i64 0
  %9 = shufflevector <8 x i32> %8, <8 x i32> poison, <8 x i32> zeroinitializer
  %10 = shl <8 x i32> %9, <i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27>
  %11 = ashr <8 x i32> %10, <i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31, i32 31>
  %12 = trunc nsw <8 x i32> %11 to <8 x i8>
  store <8 x i8> %12, ptr %1, align 8, !tbaa !5
  %13 = shl i32 %7, 28
  %sext27 = ashr i32 %13, 31
  %14 = trunc nsw i32 %sext27 to i8
  store i8 %14, ptr %2, align 8, !tbaa !5
  %15 = shl i32 %7, 29
  %sext28 = ashr i32 %15, 31
  %16 = trunc nsw i32 %sext28 to i8
  store i8 %16, ptr %3, align 1, !tbaa !5
  %17 = shl i32 %7, 30
  %sext29 = ashr i32 %17, 31
  %18 = trunc nsw i32 %sext29 to i8
  store i8 %18, ptr %4, align 2, !tbaa !5
  %19 = trunc i32 %7 to i8
  %20 = and i8 %19, 1
  %21 = sub nsw i8 0, %20
  store i8 %21, ptr %5, align 1, !tbaa !5
  %22 = call i32 @fecsoft_hamming128_decode(ptr noundef nonnull %1) #3
  %.not = icmp eq i32 %.031, %22
  br i1 %.not, label %26, label %23

23:                                               ; preds = %6
  %24 = uitofp nneg i32 %.031 to double
  %25 = uitofp i32 %22 to double
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str.7, i32 noundef 102, ptr noundef nonnull @.str.11, double noundef %24, ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.12, double noundef %25) #3
  br label %27

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

27:                                               ; preds = %23, %26
  %28 = add nuw nsw i32 %.031, 1
  %exitcond.not = icmp eq i32 %28, 256
  br i1 %exitcond.not, label %29, label %6, !llvm.loop !8

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

declare i32 @fecsoft_hamming128_decode(ptr 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: EarlyCSEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass