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

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

%struct.div_t = type { i32, i32 }

@secded2216_syndrome_w1 = external dso_local global [22 x i8], align 16
@liquid_c_ones = external constant [256 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @fec_secded2216_compute_syndrome(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @fec_secded2216_estimate_ehat(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i8, align 1
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.div_t, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %11, i64 0
  store i8 0, ptr %12, align 1, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 1
  store i8 0, ptr %14, align 1, !tbaa !9
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %15, i64 2
  store i8 0, ptr %16, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #3
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call zeroext i8 @fec_secded2216_compute_syndrome(ptr noundef %17)
  store i8 %18, ptr %6, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %19 = load i8, ptr %6, align 1, !tbaa !9
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds [256 x i8], ptr @liquid_c_ones, i64 0, i64 %20
  %22 = load i8, ptr %21, align 1, !tbaa !9
  %23 = zext i8 %22 to i32
  store i32 %23, ptr %7, align 4, !tbaa !10
  %24 = load i32, ptr %7, align 4, !tbaa !10
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %27

26:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %63

27:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !10
  br label %28

28:                                               ; preds = %55, %27
  %29 = load i32, ptr %9, align 4, !tbaa !10
  %30 = icmp ult i32 %29, 22
  br i1 %30, label %31, label %58

31:                                               ; preds = %28
  %32 = load i8, ptr %6, align 1, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = load i32, ptr %9, align 4, !tbaa !10
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [22 x i8], ptr @secded2216_syndrome_w1, i64 0, i64 %35
  %37 = load i8, ptr %36, align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = icmp eq i32 %33, %38
  br i1 %39, label %40, label %54

40:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %41 = load i32, ptr %9, align 4, !tbaa !10
  %42 = call i64 @div(i32 noundef %41, i32 noundef 8) #4
  store i64 %42, ptr %10, align 4
  %43 = getelementptr inbounds %struct.div_t, ptr %10, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !12
  %45 = shl i32 1, %44
  %46 = trunc i32 %45 to i8
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.div_t, ptr %10, i32 0, i32 0
  %49 = load i32, ptr %48, align 4, !tbaa !14
  %50 = sub nsw i32 3, %49
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds i8, ptr %47, i64 %52
  store i8 %46, ptr %53, align 1, !tbaa !9
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %59

54:                                               ; preds = %31
  br label %55

55:                                               ; preds = %54
  %56 = load i32, ptr %9, align 4, !tbaa !10
  %57 = add i32 %56, 1
  store i32 %57, ptr %9, align 4, !tbaa !10
  br label %28, !llvm.loop !15

58:                                               ; preds = %28
  store i32 0, ptr %8, align 4
  br label %59

59:                                               ; preds = %58, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %60 = load i32, ptr %8, align 4
  switch i32 %60, label %63 [
    i32 0, label %61
  ]

61:                                               ; preds = %59
  br label %62

62:                                               ; preds = %61
  store i32 2, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %63

63:                                               ; preds = %62, %59, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #3
  %64 = load i32, ptr %3, align 4
  ret i32 %64
}

; Function Attrs: nounwind willreturn memory(none)
declare i64 @div(i32 noundef, i32 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 = { nounwind willreturn memory(none) "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 = { nounwind willreturn memory(none) }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 4}
!13 = !{!"", !11, i64 0, !11, i64 4}
!14 = !{!13, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"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"

@secded2216_syndrome_w1 = external dso_local local_unnamed_addr global [22 x i8], align 16
@liquid_c_ones = external local_unnamed_addr constant [256 x i8], align 16

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @fec_secded2216_compute_syndrome(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @fec_secded2216_estimate_ehat(ptr noundef %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  store i8 0, ptr %1, align 1, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 1
  store i8 0, ptr %3, align 1, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 2
  store i8 0, ptr %4, align 1, !tbaa !5
  %5 = tail call zeroext i8 @fec_secded2216_compute_syndrome(ptr noundef %0)
  %6 = zext i8 %5 to i64
  %7 = getelementptr inbounds [256 x i8], ptr @liquid_c_ones, i64 0, i64 %6
  %8 = load i8, ptr %7, align 1, !tbaa !5
  %9 = icmp eq i8 %8, 0
  br i1 %9, label %.loopexit, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %10 = load i8, ptr @secded2216_syndrome_w1, align 16, !tbaa !5
  %11 = icmp eq i8 %5, %10
  br i1 %11, label %12, label %.preheader.1

12:                                               ; preds = %.preheader.21, %.preheader.20, %.preheader.19, %.preheader.18, %.preheader.17, %.preheader.16, %.preheader.15, %.preheader.14, %.preheader.13, %.preheader.12, %.preheader.11, %.preheader.10, %.preheader.9, %.preheader.8, %.preheader.7, %.preheader.6, %.preheader.5, %.preheader.4, %.preheader.3, %.preheader.2, %.preheader.1, %.preheader.preheader
  %.01416.lcssa.wide = phi i32 [ 0, %.preheader.preheader ], [ 1, %.preheader.1 ], [ 2, %.preheader.2 ], [ 3, %.preheader.3 ], [ 4, %.preheader.4 ], [ 5, %.preheader.5 ], [ 6, %.preheader.6 ], [ 7, %.preheader.7 ], [ 8, %.preheader.8 ], [ 9, %.preheader.9 ], [ 10, %.preheader.10 ], [ 11, %.preheader.11 ], [ 12, %.preheader.12 ], [ 13, %.preheader.13 ], [ 14, %.preheader.14 ], [ 15, %.preheader.15 ], [ 16, %.preheader.16 ], [ 17, %.preheader.17 ], [ 18, %.preheader.18 ], [ 19, %.preheader.19 ], [ 20, %.preheader.20 ], [ 21, %.preheader.21 ]
  %13 = tail call i64 @div(i32 noundef %.01416.lcssa.wide, i32 noundef 8) #2
  %.sroa.4.0.extract.shift = lshr i64 %13, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %14 = shl nuw i32 1, %.sroa.4.0.extract.trunc
  %15 = trunc i32 %14 to i8
  %16 = shl i64 %13, 32
  %sext = sub i64 8589934592, %16
  %17 = ashr exact i64 %sext, 32
  %18 = getelementptr inbounds i8, ptr %1, i64 %17
  store i8 %15, ptr %18, align 1, !tbaa !5
  br label %.loopexit

.preheader.1:                                     ; preds = %.preheader.preheader
  %19 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 1), align 1, !tbaa !5
  %20 = icmp eq i8 %5, %19
  br i1 %20, label %12, label %.preheader.2

.preheader.2:                                     ; preds = %.preheader.1
  %21 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 2), align 2, !tbaa !5
  %22 = icmp eq i8 %5, %21
  br i1 %22, label %12, label %.preheader.3

.preheader.3:                                     ; preds = %.preheader.2
  %23 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 3), align 1, !tbaa !5
  %24 = icmp eq i8 %5, %23
  br i1 %24, label %12, label %.preheader.4

.preheader.4:                                     ; preds = %.preheader.3
  %25 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 4), align 4, !tbaa !5
  %26 = icmp eq i8 %5, %25
  br i1 %26, label %12, label %.preheader.5

.preheader.5:                                     ; preds = %.preheader.4
  %27 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 5), align 1, !tbaa !5
  %28 = icmp eq i8 %5, %27
  br i1 %28, label %12, label %.preheader.6

.preheader.6:                                     ; preds = %.preheader.5
  %29 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 6), align 2, !tbaa !5
  %30 = icmp eq i8 %5, %29
  br i1 %30, label %12, label %.preheader.7

.preheader.7:                                     ; preds = %.preheader.6
  %31 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 7), align 1, !tbaa !5
  %32 = icmp eq i8 %5, %31
  br i1 %32, label %12, label %.preheader.8

.preheader.8:                                     ; preds = %.preheader.7
  %33 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 8), align 8, !tbaa !5
  %34 = icmp eq i8 %5, %33
  br i1 %34, label %12, label %.preheader.9

.preheader.9:                                     ; preds = %.preheader.8
  %35 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 9), align 1, !tbaa !5
  %36 = icmp eq i8 %5, %35
  br i1 %36, label %12, label %.preheader.10

.preheader.10:                                    ; preds = %.preheader.9
  %37 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 10), align 2, !tbaa !5
  %38 = icmp eq i8 %5, %37
  br i1 %38, label %12, label %.preheader.11

.preheader.11:                                    ; preds = %.preheader.10
  %39 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 11), align 1, !tbaa !5
  %40 = icmp eq i8 %5, %39
  br i1 %40, label %12, label %.preheader.12

.preheader.12:                                    ; preds = %.preheader.11
  %41 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 12), align 4, !tbaa !5
  %42 = icmp eq i8 %5, %41
  br i1 %42, label %12, label %.preheader.13

.preheader.13:                                    ; preds = %.preheader.12
  %43 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 13), align 1, !tbaa !5
  %44 = icmp eq i8 %5, %43
  br i1 %44, label %12, label %.preheader.14

.preheader.14:                                    ; preds = %.preheader.13
  %45 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 14), align 2, !tbaa !5
  %46 = icmp eq i8 %5, %45
  br i1 %46, label %12, label %.preheader.15

.preheader.15:                                    ; preds = %.preheader.14
  %47 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 15), align 1, !tbaa !5
  %48 = icmp eq i8 %5, %47
  br i1 %48, label %12, label %.preheader.16

.preheader.16:                                    ; preds = %.preheader.15
  %49 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 16), align 16, !tbaa !5
  %50 = icmp eq i8 %5, %49
  br i1 %50, label %12, label %.preheader.17

.preheader.17:                                    ; preds = %.preheader.16
  %51 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 17), align 1, !tbaa !5
  %52 = icmp eq i8 %5, %51
  br i1 %52, label %12, label %.preheader.18

.preheader.18:                                    ; preds = %.preheader.17
  %53 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 18), align 2, !tbaa !5
  %54 = icmp eq i8 %5, %53
  br i1 %54, label %12, label %.preheader.19

.preheader.19:                                    ; preds = %.preheader.18
  %55 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 19), align 1, !tbaa !5
  %56 = icmp eq i8 %5, %55
  br i1 %56, label %12, label %.preheader.20

.preheader.20:                                    ; preds = %.preheader.19
  %57 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 20), align 4, !tbaa !5
  %58 = icmp eq i8 %5, %57
  br i1 %58, label %12, label %.preheader.21

.preheader.21:                                    ; preds = %.preheader.20
  %59 = load i8, ptr getelementptr inbounds (i8, ptr @secded2216_syndrome_w1, i64 21), align 1, !tbaa !5
  %60 = icmp eq i8 %5, %59
  br i1 %60, label %12, label %.loopexit

.loopexit:                                        ; preds = %.preheader.21, %12, %2
  %.1 = phi i32 [ 0, %2 ], [ 1, %12 ], [ 2, %.preheader.21 ]
  ret i32 %.1
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare i64 @div(i32 noundef, i32 noundef) local_unnamed_addr #1

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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }

!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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass