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

; 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
@hamming128_enc_gentab = external global [256 x i16], align 16
@.str.3 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__.fec_hamming128_encode = external hidden unnamed_addr constant [79 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

; 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 i32 @fec_hamming128_encode(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 i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  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) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  store i32 0, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = urem i32 %16, 2
  store i32 %17, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %79, %4
  %19 = load i32, ptr %9, align 4, !tbaa !9
  %20 = load i32, ptr %6, align 4, !tbaa !9
  %21 = load i32, ptr %15, align 4, !tbaa !9
  %22 = sub i32 %20, %21
  %23 = icmp ult i32 %19, %22
  br i1 %23, label %24, label %82

24:                                               ; preds = %18
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = add i32 %26, 0
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds i8, ptr %25, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !11
  store i8 %30, ptr %11, align 1, !tbaa !11
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = add i32 %32, 1
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds i8, ptr %31, i64 %34
  %36 = load i8, ptr %35, align 1, !tbaa !11
  store i8 %36, ptr %12, align 1, !tbaa !11
  %37 = load i8, ptr %11, align 1, !tbaa !11
  %38 = zext i8 %37 to i64
  %39 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %38
  %40 = load i16, ptr %39, align 2, !tbaa !12
  %41 = zext i16 %40 to i32
  store i32 %41, ptr %13, align 4, !tbaa !9
  %42 = load i8, ptr %12, align 1, !tbaa !11
  %43 = zext i8 %42 to i64
  %44 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %43
  %45 = load i16, ptr %44, align 2, !tbaa !12
  %46 = zext i16 %45 to i32
  store i32 %46, ptr %14, align 4, !tbaa !9
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = lshr i32 %47, 4
  %49 = and i32 %48, 255
  %50 = trunc i32 %49 to i8
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i32, ptr %10, align 4, !tbaa !9
  %53 = add i32 %52, 0
  %54 = zext i32 %53 to i64
  %55 = getelementptr inbounds i8, ptr %51, i64 %54
  store i8 %50, ptr %55, align 1, !tbaa !11
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = shl i32 %56, 4
  %58 = and i32 %57, 240
  %59 = load i32, ptr %14, align 4, !tbaa !9
  %60 = lshr i32 %59, 8
  %61 = and i32 %60, 15
  %62 = or i32 %58, %61
  %63 = trunc i32 %62 to i8
  %64 = load ptr, ptr %8, align 8, !tbaa !5
  %65 = load i32, ptr %10, align 4, !tbaa !9
  %66 = add i32 %65, 1
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds i8, ptr %64, i64 %67
  store i8 %63, ptr %68, align 1, !tbaa !11
  %69 = load i32, ptr %14, align 4, !tbaa !9
  %70 = and i32 %69, 255
  %71 = trunc i32 %70 to i8
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = add i32 %73, 2
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds i8, ptr %72, i64 %75
  store i8 %71, ptr %76, align 1, !tbaa !11
  %77 = load i32, ptr %10, align 4, !tbaa !9
  %78 = add i32 %77, 3
  store i32 %78, ptr %10, align 4, !tbaa !9
  br label %79

79:                                               ; preds = %24
  %80 = load i32, ptr %9, align 4, !tbaa !9
  %81 = add i32 %80, 2
  store i32 %81, ptr %9, align 4, !tbaa !9
  br label %18, !llvm.loop !14

82:                                               ; preds = %18
  %83 = load i32, ptr %15, align 4, !tbaa !9
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %117

85:                                               ; preds = %82
  %86 = load ptr, ptr %7, align 8, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !9
  %88 = sub i32 %87, 1
  %89 = zext i32 %88 to i64
  %90 = getelementptr inbounds i8, ptr %86, i64 %89
  %91 = load i8, ptr %90, align 1, !tbaa !11
  store i8 %91, ptr %11, align 1, !tbaa !11
  %92 = load i8, ptr %11, align 1, !tbaa !11
  %93 = zext i8 %92 to i64
  %94 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %93
  %95 = load i16, ptr %94, align 2, !tbaa !12
  %96 = zext i16 %95 to i32
  store i32 %96, ptr %13, align 4, !tbaa !9
  %97 = load i32, ptr %13, align 4, !tbaa !9
  %98 = and i32 %97, 4080
  %99 = lshr i32 %98, 4
  %100 = trunc i32 %99 to i8
  %101 = load ptr, ptr %8, align 8, !tbaa !5
  %102 = load i32, ptr %10, align 4, !tbaa !9
  %103 = add i32 %102, 0
  %104 = zext i32 %103 to i64
  %105 = getelementptr inbounds i8, ptr %101, i64 %104
  store i8 %100, ptr %105, align 1, !tbaa !11
  %106 = load i32, ptr %13, align 4, !tbaa !9
  %107 = and i32 %106, 15
  %108 = shl i32 %107, 4
  %109 = trunc i32 %108 to i8
  %110 = load ptr, ptr %8, align 8, !tbaa !5
  %111 = load i32, ptr %10, align 4, !tbaa !9
  %112 = add i32 %111, 1
  %113 = zext i32 %112 to i64
  %114 = getelementptr inbounds i8, ptr %110, i64 %113
  store i8 %109, ptr %114, align 1, !tbaa !11
  %115 = load i32, ptr %10, align 4, !tbaa !9
  %116 = add i32 %115, 2
  store i32 %116, ptr %10, align 4, !tbaa !9
  br label %117

117:                                              ; preds = %85, %82
  %118 = load i32, ptr %10, align 4, !tbaa !9
  %119 = load i32, ptr %6, align 4, !tbaa !9
  %120 = call i32 @fec_get_enc_msg_length(i32 noundef 6, i32 noundef %119)
  %121 = icmp eq i32 %118, %120
  br i1 %121, label %122, label %123

122:                                              ; preds = %117
  br label %124

123:                                              ; preds = %117
  call void @__assert_fail(ptr noundef @.str.3, ptr noundef @.str, i32 noundef 227, ptr noundef @__PRETTY_FUNCTION__.fec_hamming128_encode) #5
  unreachable

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

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 = { noreturn 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 }
attributes #5 = { noreturn 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 = !{!13, !13, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"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
@hamming128_enc_gentab = external local_unnamed_addr global [256 x i16], align 16
@.str.3 = external hidden unnamed_addr constant [63 x i8], align 1
@__PRETTY_FUNCTION__.fec_hamming128_encode = external hidden unnamed_addr constant [79 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @fec_hamming128_encode(ptr nocapture noundef readnone %0, i32 noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = and i32 %1, 1
  %6 = and i32 %1, -2
  %.not37 = icmp eq i32 %6, 0
  br i1 %.not37, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %7 = zext i32 %6 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 ]
  %.03435 = phi i32 [ 0, %.lr.ph.preheader ], [ %35, %.lr.ph ]
  %8 = getelementptr inbounds i8, ptr %2, i64 %indvars.iv
  %9 = load i8, ptr %8, align 1, !tbaa !5
  %10 = or disjoint i64 %indvars.iv, 1
  %11 = getelementptr inbounds i8, ptr %2, i64 %10
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = zext i8 %9 to i64
  %14 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %13
  %15 = load i16, ptr %14, align 2, !tbaa !8
  %16 = zext i8 %12 to i64
  %17 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %16
  %18 = load i16, ptr %17, align 2, !tbaa !8
  %19 = lshr i16 %15, 4
  %20 = trunc i16 %19 to i8
  %21 = zext i32 %.03435 to i64
  %22 = getelementptr inbounds i8, ptr %3, i64 %21
  store i8 %20, ptr %22, align 1, !tbaa !5
  %23 = shl i16 %15, 4
  %24 = lshr i16 %18, 8
  %25 = and i16 %24, 15
  %26 = or disjoint i16 %25, %23
  %27 = trunc i16 %26 to i8
  %28 = add i32 %.03435, 1
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds i8, ptr %3, i64 %29
  store i8 %27, ptr %30, align 1, !tbaa !5
  %31 = trunc i16 %18 to i8
  %32 = add i32 %.03435, 2
  %33 = zext i32 %32 to i64
  %34 = getelementptr inbounds i8, ptr %3, i64 %33
  store i8 %31, ptr %34, align 1, !tbaa !5
  %35 = add i32 %.03435, 3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %36 = icmp ult i64 %indvars.iv.next, %7
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %4
  %.034.lcssa = phi i32 [ 0, %4 ], [ %35, %.lr.ph ]
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %54, label %37

37:                                               ; preds = %._crit_edge
  %38 = add nsw i32 %1, -1
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds i8, ptr %2, i64 %39
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = zext i8 %41 to i64
  %43 = getelementptr inbounds [256 x i16], ptr @hamming128_enc_gentab, i64 0, i64 %42
  %44 = load i16, ptr %43, align 2, !tbaa !8
  %45 = lshr i16 %44, 4
  %46 = trunc i16 %45 to i8
  %47 = zext i32 %.034.lcssa to i64
  %48 = getelementptr inbounds i8, ptr %3, i64 %47
  store i8 %46, ptr %48, align 1, !tbaa !5
  %.tr = trunc i16 %44 to i8
  %49 = shl i8 %.tr, 4
  %50 = add i32 %.034.lcssa, 1
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds i8, ptr %3, i64 %51
  store i8 %49, ptr %52, align 1, !tbaa !5
  %53 = add i32 %.034.lcssa, 2
  br label %54

54:                                               ; preds = %37, %._crit_edge
  %.1 = phi i32 [ %53, %37 ], [ %.034.lcssa, %._crit_edge ]
  %55 = tail call i32 @fec_get_enc_msg_length(i32 noundef 6, i32 noundef %1) #3
  %56 = icmp eq i32 %.1, %55
  br i1 %56, label %58, label %57

57:                                               ; preds = %54
  tail call void @__assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str, i32 noundef 227, ptr noundef nonnull @__PRETTY_FUNCTION__.fec_hamming128_encode) #4
  unreachable

58:                                               ; preds = %54
  ret i32 0
}

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #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 = { noreturn 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 #3 = { nounwind }
attributes #4 = { noreturn 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 = !{!9, !9, i64 0}
!9 = !{!"short", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass