; LLVM IR from DroneBridge/DroneBridge :: control (sumd_test)

; 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 i16 @CRC16(i16 noundef zeroext %0, i8 noundef zeroext %1) #0 {
  %3 = alloca i16, align 2
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store i16 %0, ptr %3, align 2, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  %6 = load i16, ptr %3, align 2, !tbaa !5
  %7 = zext i16 %6 to i32
  %8 = load i8, ptr %4, align 1, !tbaa !9
  %9 = zext i8 %8 to i16
  %10 = sext i16 %9 to i32
  %11 = shl i32 %10, 8
  %12 = xor i32 %7, %11
  %13 = trunc i32 %12 to i16
  store i16 %13, ptr %3, align 2, !tbaa !5
  store i8 0, ptr %5, align 1, !tbaa !9
  br label %14

14:                                               ; preds = %35, %2
  %15 = load i8, ptr %5, align 1, !tbaa !9
  %16 = zext i8 %15 to i32
  %17 = icmp slt i32 %16, 8
  br i1 %17, label %18, label %38

18:                                               ; preds = %14
  %19 = load i16, ptr %3, align 2, !tbaa !5
  %20 = zext i16 %19 to i32
  %21 = and i32 %20, 32768
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %29

23:                                               ; preds = %18
  %24 = load i16, ptr %3, align 2, !tbaa !5
  %25 = zext i16 %24 to i32
  %26 = shl i32 %25, 1
  %27 = xor i32 %26, 4129
  %28 = trunc i32 %27 to i16
  store i16 %28, ptr %3, align 2, !tbaa !5
  br label %34

29:                                               ; preds = %18
  %30 = load i16, ptr %3, align 2, !tbaa !5
  %31 = zext i16 %30 to i32
  %32 = shl i32 %31, 1
  %33 = trunc i32 %32 to i16
  store i16 %33, ptr %3, align 2, !tbaa !5
  br label %34

34:                                               ; preds = %29, %23
  br label %35

35:                                               ; preds = %34
  %36 = load i8, ptr %5, align 1, !tbaa !9
  %37 = add i8 %36, 1
  store i8 %37, ptr %5, align 1, !tbaa !9
  br label %14, !llvm.loop !10

38:                                               ; preds = %14
  %39 = load i16, ptr %3, align 2, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  ret i16 %39
}

; 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 = !{!"short", !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"}


; 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 i16 @CRC16(i16 noundef zeroext %0, i8 noundef zeroext %1) local_unnamed_addr #0 {
  %3 = zext i8 %1 to i16
  %4 = shl nuw i16 %3, 8
  %5 = xor i16 %4, %0
  %6 = shl i16 %5, 1
  %7 = xor i16 %6, 4129
  %.not9 = icmp slt i16 %5, 0
  %.1 = select i1 %.not9, i16 %7, i16 %6
  %8 = shl i16 %.1, 1
  %9 = xor i16 %8, 4129
  %.not9.1 = icmp slt i16 %.1, 0
  %.1.1 = select i1 %.not9.1, i16 %9, i16 %8
  %10 = shl i16 %.1.1, 1
  %11 = xor i16 %10, 4129
  %.not9.2 = icmp slt i16 %.1.1, 0
  %.1.2 = select i1 %.not9.2, i16 %11, i16 %10
  %12 = shl i16 %.1.2, 1
  %13 = xor i16 %12, 4129
  %.not9.3 = icmp slt i16 %.1.2, 0
  %.1.3 = select i1 %.not9.3, i16 %13, i16 %12
  %14 = shl i16 %.1.3, 1
  %15 = xor i16 %14, 4129
  %.not9.4 = icmp slt i16 %.1.3, 0
  %.1.4 = select i1 %.not9.4, i16 %15, i16 %14
  %16 = shl i16 %.1.4, 1
  %17 = xor i16 %16, 4129
  %.not9.5 = icmp slt i16 %.1.4, 0
  %.1.5 = select i1 %.not9.5, i16 %17, i16 %16
  %18 = shl i16 %.1.5, 1
  %19 = xor i16 %18, 4129
  %.not9.6 = icmp slt i16 %.1.5, 0
  %.1.6 = select i1 %.not9.6, i16 %19, i16 %18
  %20 = shl i16 %.1.6, 1
  %21 = xor i16 %20, 4129
  %.not9.7 = icmp slt i16 %.1.6, 0
  %.1.7 = select i1 %.not9.7, i16 %21, i16 %20
  ret i16 %.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,SROAPass,SimplifyCFGPass