; LLVM IR from DroneBridge/DroneBridge :: common (db_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"

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @crc8_dvb_s2(i8 noundef zeroext %0, i8 noundef zeroext %1) #0 {
  %3 = alloca i8, align 1
  %4 = alloca i8, align 1
  %5 = alloca i32, align 4
  store i8 %0, ptr %3, align 1, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !5
  %6 = load i8, ptr %4, align 1, !tbaa !5
  %7 = zext i8 %6 to i32
  %8 = load i8, ptr %3, align 1, !tbaa !5
  %9 = zext i8 %8 to i32
  %10 = xor i32 %9, %7
  %11 = trunc i32 %10 to i8
  store i8 %11, ptr %3, align 1, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 0, ptr %5, align 4, !tbaa !8
  br label %12

12:                                               ; preds = %33, %2
  %13 = load i32, ptr %5, align 4, !tbaa !8
  %14 = icmp slt i32 %13, 8
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %36

16:                                               ; preds = %12
  %17 = load i8, ptr %3, align 1, !tbaa !5
  %18 = zext i8 %17 to i32
  %19 = and i32 %18, 128
  %20 = icmp ne i32 %19, 0
  br i1 %20, label %21, label %27

21:                                               ; preds = %16
  %22 = load i8, ptr %3, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = shl i32 %23, 1
  %25 = xor i32 %24, 213
  %26 = trunc i32 %25 to i8
  store i8 %26, ptr %3, align 1, !tbaa !5
  br label %32

27:                                               ; preds = %16
  %28 = load i8, ptr %3, align 1, !tbaa !5
  %29 = zext i8 %28 to i32
  %30 = shl i32 %29, 1
  %31 = trunc i32 %30 to i8
  store i8 %31, ptr %3, align 1, !tbaa !5
  br label %32

32:                                               ; preds = %27, %21
  br label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %5, align 4, !tbaa !8
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %5, align 4, !tbaa !8
  br label %12, !llvm.loop !10

36:                                               ; preds = %15
  %37 = load i8, ptr %3, align 1, !tbaa !5
  ret i8 %37
}

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

; 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 = { 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 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local zeroext i8 @crc8_dvb_s2(i8 noundef zeroext %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = xor i8 %1, %0
  %4 = shl i8 %3, 1
  %5 = xor i8 %4, -43
  %.not9 = icmp slt i8 %3, 0
  %.1 = select i1 %.not9, i8 %5, i8 %4
  %6 = shl i8 %.1, 1
  %7 = xor i8 %6, -43
  %.not9.1 = icmp slt i8 %.1, 0
  %.1.1 = select i1 %.not9.1, i8 %7, i8 %6
  %8 = shl i8 %.1.1, 1
  %9 = xor i8 %8, -43
  %.not9.2 = icmp slt i8 %.1.1, 0
  %.1.2 = select i1 %.not9.2, i8 %9, i8 %8
  %10 = shl i8 %.1.2, 1
  %11 = xor i8 %10, -43
  %.not9.3 = icmp slt i8 %.1.2, 0
  %.1.3 = select i1 %.not9.3, i8 %11, i8 %10
  %12 = shl i8 %.1.3, 1
  %13 = xor i8 %12, -43
  %.not9.4 = icmp slt i8 %.1.3, 0
  %.1.4 = select i1 %.not9.4, i8 %13, i8 %12
  %14 = shl i8 %.1.4, 1
  %15 = xor i8 %14, -43
  %.not9.5 = icmp slt i8 %.1.4, 0
  %.1.5 = select i1 %.not9.5, i8 %15, i8 %14
  %16 = shl i8 %.1.5, 1
  %17 = xor i8 %16, -43
  %.not9.6 = icmp slt i8 %.1.5, 0
  %.1.6 = select i1 %.not9.6, i8 %17, i8 %16
  %18 = shl i8 %.1.6, 1
  %19 = xor i8 %18, -43
  %.not9.7 = icmp slt i8 %.1.6, 0
  %.1.7 = select i1 %.not9.7, i8 %19, i8 %18
  ret i8 %.1.7
}

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

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


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