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

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

@fec_scheme_str = external dso_local global [28 x [2 x ptr]], align 16
@.str.54 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @liquid_print_fec_schemes() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 10, ptr %2, align 4, !tbaa !5
  %3 = call i32 (ptr, ...) @printf(ptr noundef @.str.54)
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %4

4:                                                ; preds = %46, %0
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 28
  br i1 %6, label %7, label %49

7:                                                ; preds = %4
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = call i32 @fec_scheme_is_convolutional(i32 noundef %8)
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %15, label %11

11:                                               ; preds = %7
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = call i32 @fec_scheme_is_reedsolomon(i32 noundef %12)
  %14 = icmp ne i32 %13, 0
  br i1 %14, label %15, label %16

15:                                               ; preds = %11, %7
  br label %46

16:                                               ; preds = %11
  %17 = load i32, ptr %1, align 4, !tbaa !5
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [28 x [2 x ptr]], ptr @fec_scheme_str, i64 0, i64 %18
  %20 = getelementptr inbounds [2 x ptr], ptr %19, i64 0, i64 0
  %21 = load ptr, ptr %20, align 16, !tbaa !9
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.55, ptr noundef %21)
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = icmp ne i32 %23, 27
  br i1 %24, label %25, label %27

25:                                               ; preds = %16
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.56)
  br label %27

27:                                               ; preds = %25, %16
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [28 x [2 x ptr]], ptr @fec_scheme_str, i64 0, i64 %29
  %31 = getelementptr inbounds [2 x ptr], ptr %30, i64 0, i64 0
  %32 = load ptr, ptr %31, align 16, !tbaa !9
  %33 = call i64 @strlen(ptr noundef %32) #5
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = zext i32 %34 to i64
  %36 = add i64 %35, %33
  %37 = trunc i64 %36 to i32
  store i32 %37, ptr %2, align 4, !tbaa !5
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = icmp ugt i32 %38, 48
  br i1 %39, label %40, label %45

40:                                               ; preds = %27
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = icmp ne i32 %41, 27
  br i1 %42, label %43, label %45

43:                                               ; preds = %40
  store i32 10, ptr %2, align 4, !tbaa !5
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str.57)
  br label %45

45:                                               ; preds = %43, %40, %27
  br label %46

46:                                               ; preds = %45, %15
  %47 = load i32, ptr %1, align 4, !tbaa !5
  %48 = add i32 %47, 1
  store i32 %48, ptr %1, align 4, !tbaa !5
  br label %4, !llvm.loop !11

49:                                               ; preds = %4
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.58)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 0
}

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

declare i32 @printf(ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_scheme_is_convolutional(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_scheme_is_reedsolomon(i32 noundef) #0

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(read) "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 = { nounwind willreturn memory(read) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

@fec_scheme_str = external dso_local local_unnamed_addr global [28 x [2 x ptr]], align 16
@.str.54 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.55 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.56 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @liquid_print_fec_schemes() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.54)
  br label %2

2:                                                ; preds = %0, %22
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %22 ]
  %.014 = phi i32 [ 10, %0 ], [ %.1, %22 ]
  %3 = trunc nuw nsw i64 %indvars.iv to i32
  %4 = tail call i32 @fec_scheme_is_convolutional(i32 noundef %3)
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %22

5:                                                ; preds = %2
  %6 = tail call i32 @fec_scheme_is_reedsolomon(i32 noundef %3)
  %.not12 = icmp eq i32 %6, 0
  br i1 %.not12, label %7, label %22

7:                                                ; preds = %5
  %8 = getelementptr inbounds [28 x [2 x ptr]], ptr @fec_scheme_str, i64 0, i64 %indvars.iv
  %9 = load ptr, ptr %8, align 16, !tbaa !5
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.55, ptr noundef %9)
  %11 = icmp ne i64 %indvars.iv, 27
  br i1 %11, label %12, label %14

12:                                               ; preds = %7
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.56)
  br label %14

14:                                               ; preds = %12, %7
  %15 = load ptr, ptr %8, align 16, !tbaa !5
  %16 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %15) #3
  %17 = trunc i64 %16 to i32
  %18 = add i32 %.014, %17
  %19 = icmp ugt i32 %18, 48
  %or.cond = and i1 %11, %19
  br i1 %or.cond, label %20, label %22

20:                                               ; preds = %14
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.57)
  br label %22

22:                                               ; preds = %14, %20, %2, %5
  %.1 = phi i32 [ %.014, %2 ], [ %.014, %5 ], [ 10, %20 ], [ %18, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 28
  br i1 %exitcond.not, label %23, label %2, !llvm.loop !9

23:                                               ; preds = %22
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.58)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_scheme_is_convolutional(i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @fec_scheme_is_reedsolomon(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture 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 = { nofree 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 willreturn memory(read) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass