; LLVM IR from jgaeddert/liquid-dsp :: src/fec/src (fec_hamming74)

; 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"

@hamming74_dec_gentab = external dso_local global [128 x i8], align 16

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fec_hamming74_decode(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i8, align 1
  %14 = alloca i8, align 1
  %15 = alloca i8, align 1
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = call i32 @fec_block_get_enc_msg_len(i32 noundef %16, i32 noundef 4, i32 noundef 7)
  store i32 %17, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %54, %4
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = icmp ult i32 %19, %20
  br i1 %21, label %22, label %57

22:                                               ; preds = %18
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = load i32, ptr %11, align 4, !tbaa !9
  %25 = load i32, ptr %10, align 4, !tbaa !9
  %26 = call i32 @liquid_unpack_array(ptr noundef %23, i32 noundef %24, i32 noundef %25, i32 noundef 7, ptr noundef %12)
  %27 = load i32, ptr %10, align 4, !tbaa !9
  %28 = add i32 %27, 7
  store i32 %28, ptr %10, align 4, !tbaa !9
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = load i32, ptr %11, align 4, !tbaa !9
  %31 = load i32, ptr %10, align 4, !tbaa !9
  %32 = call i32 @liquid_unpack_array(ptr noundef %29, i32 noundef %30, i32 noundef %31, i32 noundef 7, ptr noundef %13)
  %33 = load i32, ptr %10, align 4, !tbaa !9
  %34 = add i32 %33, 7
  store i32 %34, ptr %10, align 4, !tbaa !9
  %35 = load i8, ptr %12, align 1, !tbaa !11
  %36 = zext i8 %35 to i64
  %37 = getelementptr inbounds [128 x i8], ptr @hamming74_dec_gentab, i64 0, i64 %36
  %38 = load i8, ptr %37, align 1, !tbaa !11
  store i8 %38, ptr %14, align 1, !tbaa !11
  %39 = load i8, ptr %13, align 1, !tbaa !11
  %40 = zext i8 %39 to i64
  %41 = getelementptr inbounds [128 x i8], ptr @hamming74_dec_gentab, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  store i8 %42, ptr %15, align 1, !tbaa !11
  %43 = load i8, ptr %14, align 1, !tbaa !11
  %44 = zext i8 %43 to i32
  %45 = shl i32 %44, 4
  %46 = load i8, ptr %15, align 1, !tbaa !11
  %47 = zext i8 %46 to i32
  %48 = or i32 %45, %47
  %49 = trunc i32 %48 to i8
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %50, i64 %52
  store i8 %49, ptr %53, align 1, !tbaa !11
  br label %54

54:                                               ; preds = %22
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = add i32 %55, 1
  store i32 %56, ptr %9, align 4, !tbaa !9
  br label %18, !llvm.loop !12

57:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 0
}

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

declare i32 @fec_block_get_enc_msg_len(i32 noundef, i32 noundef, i32 noundef) #2

declare i32 @liquid_unpack_array(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !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"

@hamming74_dec_gentab = external dso_local local_unnamed_addr global [128 x i8], align 16

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

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @fec_hamming74_decode(ptr nocapture noundef readnone %0, i32 noundef %1, ptr noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #1 {
  %5 = alloca i8, align 1
  %6 = alloca i8, align 1
  %7 = tail call i32 @fec_block_get_enc_msg_len(i32 noundef %1, i32 noundef 4, i32 noundef 7) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %6) #3
  %.not = icmp eq i32 %1, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %wide.trip.count = zext i32 %1 to i64
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.01516 = phi i32 [ 0, %.lr.ph.preheader ], [ %11, %.lr.ph ]
  %8 = call i32 @liquid_unpack_array(ptr noundef %2, i32 noundef %7, i32 noundef %.01516, i32 noundef 7, ptr noundef nonnull %5) #3
  %9 = add i32 %.01516, 7
  %10 = call i32 @liquid_unpack_array(ptr noundef %2, i32 noundef %7, i32 noundef %9, i32 noundef 7, ptr noundef nonnull %6) #3
  %11 = add i32 %.01516, 14
  %12 = load i8, ptr %5, align 1, !tbaa !5
  %13 = zext i8 %12 to i64
  %14 = getelementptr inbounds [128 x i8], ptr @hamming74_dec_gentab, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !5
  %16 = load i8, ptr %6, align 1, !tbaa !5
  %17 = zext i8 %16 to i64
  %18 = getelementptr inbounds [128 x i8], ptr @hamming74_dec_gentab, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !5
  %20 = shl i8 %15, 4
  %21 = or i8 %19, %20
  %22 = getelementptr inbounds i8, ptr %3, i64 %indvars.iv
  store i8 %21, ptr %22, align 1, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !8

._crit_edge:                                      ; preds = %.lr.ph, %4
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #3
  ret i32 0
}

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

declare i32 @fec_block_get_enc_msg_len(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @liquid_unpack_array(ptr noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass