; LLVM IR from LinearTapeFileSystem/ltfs :: src/tape_drivers (reed_solomon_crc)

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

@ltfs_log_level = external global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = 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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @enc4(i8 noundef zeroext, ptr noundef) #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) #1

declare i32 @ltfsmsg_internal(i1 noundef zeroext, i32 noundef, ptr noundef, ptr noundef, ...) #2

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

16:                                               ; preds = %30, %3
  %17 = load i64, ptr %12, align 8, !tbaa !9
  %18 = load i64, ptr %7, align 8, !tbaa !9
  %19 = icmp ult i64 %17, %18
  br i1 %19, label %20, label %33

20:                                               ; preds = %16
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  store i8 %22, ptr %23, align 1, !tbaa !13
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = load i8, ptr %24, align 1, !tbaa !13
  call void @enc4(i8 noundef zeroext %25, ptr noundef %10)
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %26, i32 1
  store ptr %27, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i32 1
  store ptr %29, ptr %9, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %20
  %31 = load i64, ptr %12, align 8, !tbaa !9
  %32 = add i64 %31, 1
  store i64 %32, ptr %12, align 8, !tbaa !9
  br label %16, !llvm.loop !14

33:                                               ; preds = %16
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = load i32, ptr %34, align 4, !tbaa !11
  %36 = call i32 @__bswap_32(i32 noundef %35)
  store i32 %36, ptr %11, align 4, !tbaa !11
  %37 = load i32, ptr %11, align 4, !tbaa !11
  %38 = load i32, ptr %10, align 4, !tbaa !11
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %40, label %53

40:                                               ; preds = %33
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr @ltfs_log_level, align 4, !tbaa !11
  %43 = icmp sle i32 0, %42
  br i1 %43, label %44, label %50

44:                                               ; preds = %41
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = trunc i64 %45 to i32
  %47 = load i32, ptr %10, align 4, !tbaa !11
  %48 = load i32, ptr %11, align 4, !tbaa !11
  %49 = call i32 (i1, i32, ptr, ptr, ...) @ltfsmsg_internal(i1 noundef zeroext true, i32 noundef 0, ptr noundef null, ptr noundef @.str.2, i32 noundef %46, i32 noundef %47, i32 noundef %48)
  br label %50

50:                                               ; preds = %44, %41
  br label %51

51:                                               ; preds = %50
  br label %52

52:                                               ; preds = %51
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %67

53:                                               ; preds = %33
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr @ltfs_log_level, align 4, !tbaa !11
  %56 = icmp sle i32 3, %55
  br i1 %56, label %57, label %62

57:                                               ; preds = %54
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = trunc i64 %58 to i32
  %60 = load i32, ptr %11, align 4, !tbaa !11
  %61 = call i32 (i1, i32, ptr, ptr, ...) @ltfsmsg_internal(i1 noundef zeroext true, i32 noundef 3, ptr noundef null, ptr noundef @.str, ptr noundef @.str.3, i32 noundef %59, i32 noundef %60)
  br label %62

62:                                               ; preds = %57, %54
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63
  %65 = load i64, ptr %7, align 8, !tbaa !9
  %66 = trunc i64 %65 to i32
  store i32 %66, ptr %4, align 4
  store i32 1, ptr %13, align 4
  br label %67

67:                                               ; preds = %64, %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!7, !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"

@ltfs_log_level = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = 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

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @enc4(i8 noundef zeroext, ptr noundef) local_unnamed_addr #1

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @__bswap_32(i32 noundef) local_unnamed_addr #1

declare i32 @ltfsmsg_internal(i1 noundef zeroext, i32 noundef, ptr noundef, ptr noundef, ...) local_unnamed_addr #2

; 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 noundef i32 @memcpy_rs_gf256_check(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, i64 noundef %2) local_unnamed_addr #3 {
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  %.not26 = icmp eq i64 %2, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3, %.lr.ph
  %.025 = phi i64 [ %8, %.lr.ph ], [ 0, %3 ]
  %.01824 = phi ptr [ %7, %.lr.ph ], [ %1, %3 ]
  %.01923 = phi ptr [ %6, %.lr.ph ], [ %0, %3 ]
  %5 = load i8, ptr %.01824, align 1, !tbaa !9
  store i8 %5, ptr %.01923, align 1, !tbaa !9
  call void @enc4(i8 noundef zeroext %5, ptr noundef nonnull %4)
  %6 = getelementptr inbounds i8, ptr %.01923, i64 1
  %7 = getelementptr inbounds i8, ptr %.01824, i64 1
  %8 = add nuw i64 %.025, 1
  %exitcond.not = icmp eq i64 %8, %2
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %3
  %.018.lcssa = phi ptr [ %1, %3 ], [ %7, %.lr.ph ]
  %9 = load i32, ptr %.018.lcssa, align 4, !tbaa !5
  %10 = call i32 @__bswap_32(i32 noundef %9)
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %10, %11
  %12 = load i32, ptr @ltfs_log_level, align 4, !tbaa !5
  br i1 %.not, label %18, label %13

13:                                               ; preds = %._crit_edge
  %14 = icmp sgt i32 %12, -1
  br i1 %14, label %15, label %._crit_edge27

15:                                               ; preds = %13
  %16 = trunc i64 %2 to i32
  %17 = call i32 (i1, i32, ptr, ptr, ...) @ltfsmsg_internal(i1 noundef zeroext true, i32 noundef 0, ptr noundef null, ptr noundef nonnull @.str.2, i32 noundef %16, i32 noundef %11, i32 noundef %10) #4
  br label %._crit_edge27

18:                                               ; preds = %._crit_edge
  %19 = icmp sgt i32 %12, 2
  %20 = trunc i64 %2 to i32
  br i1 %19, label %21, label %._crit_edge27

21:                                               ; preds = %18
  %22 = call i32 (i1, i32, ptr, ptr, ...) @ltfsmsg_internal(i1 noundef zeroext true, i32 noundef 3, ptr noundef null, ptr noundef nonnull @.str, ptr noundef nonnull @.str.3, i32 noundef %20, i32 noundef %10) #4
  br label %._crit_edge27

._crit_edge27:                                    ; preds = %18, %21, %13, %15
  %.017 = phi i32 [ -1, %15 ], [ -1, %13 ], [ %20, %21 ], [ %20, %18 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  ret i32 %.017
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 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 #4 = { 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"}


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