; LLVM IR from cpuimage/cpuimagelib :: cpuimage (rgb2ycbcr)

; 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 void @rgb2ycbcr(i8 noundef zeroext %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #0 {
  %7 = alloca i8, align 1
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store i8 %0, ptr %7, align 1, !tbaa !5
  store i8 %1, ptr %8, align 1, !tbaa !5
  store i8 %2, ptr %9, align 1, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !8
  store ptr %4, ptr %11, align 8, !tbaa !8
  store ptr %5, ptr %12, align 8, !tbaa !8
  %13 = load i8, ptr %7, align 1, !tbaa !5
  %14 = zext i8 %13 to i32
  %15 = mul nsw i32 19595, %14
  %16 = load i8, ptr %8, align 1, !tbaa !5
  %17 = zext i8 %16 to i32
  %18 = mul nsw i32 38470, %17
  %19 = add nsw i32 %15, %18
  %20 = load i8, ptr %9, align 1, !tbaa !5
  %21 = zext i8 %20 to i32
  %22 = mul nsw i32 7471, %21
  %23 = add nsw i32 %19, %22
  %24 = ashr i32 %23, 16
  %25 = trunc i32 %24 to i8
  %26 = load ptr, ptr %10, align 8, !tbaa !8
  store i8 %25, ptr %26, align 1, !tbaa !5
  %27 = load i8, ptr %9, align 1, !tbaa !5
  %28 = zext i8 %27 to i32
  %29 = load ptr, ptr %10, align 8, !tbaa !8
  %30 = load i8, ptr %29, align 1, !tbaa !5
  %31 = zext i8 %30 to i32
  %32 = sub nsw i32 %28, %31
  %33 = mul nsw i32 36962, %32
  %34 = ashr i32 %33, 16
  %35 = add nsw i32 %34, 128
  %36 = trunc i32 %35 to i8
  %37 = load ptr, ptr %11, align 8, !tbaa !8
  store i8 %36, ptr %37, align 1, !tbaa !5
  %38 = load i8, ptr %7, align 1, !tbaa !5
  %39 = zext i8 %38 to i32
  %40 = load ptr, ptr %10, align 8, !tbaa !8
  %41 = load i8, ptr %40, align 1, !tbaa !5
  %42 = zext i8 %41 to i32
  %43 = sub nsw i32 %39, %42
  %44 = mul nsw i32 46727, %43
  %45 = ashr i32 %44, 16
  %46 = add nsw i32 %45, 128
  %47 = trunc i32 %46 to i8
  %48 = load ptr, ptr %12, align 8, !tbaa !8
  store i8 %47, ptr %48, align 1, !tbaa !5
  ret void
}

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

!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 = !{!"any pointer", !6, i64 0}


; 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(argmem: readwrite) uwtable
define dso_local void @rgb2ycbcr(i8 noundef zeroext %0, i8 noundef zeroext %1, i8 noundef zeroext %2, ptr nocapture noundef %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #0 {
  %7 = zext i8 %0 to i32
  %8 = mul nuw nsw i32 %7, 19595
  %9 = zext i8 %1 to i32
  %10 = mul nuw nsw i32 %9, 38470
  %11 = add nuw nsw i32 %10, %8
  %12 = zext i8 %2 to i32
  %13 = mul nuw nsw i32 %12, 7471
  %14 = add nuw nsw i32 %11, %13
  %15 = lshr i32 %14, 16
  %16 = trunc nuw i32 %15 to i8
  store i8 %16, ptr %3, align 1, !tbaa !5
  %17 = sub nsw i32 %12, %15
  %18 = mul nsw i32 %17, 36962
  %19 = lshr i32 %18, 16
  %20 = trunc i32 %19 to i8
  %21 = xor i8 %20, -128
  store i8 %21, ptr %4, align 1, !tbaa !5
  %22 = load i8, ptr %3, align 1, !tbaa !5
  %23 = zext i8 %22 to i32
  %24 = sub nsw i32 %7, %23
  %25 = mul nsw i32 %24, 46727
  %26 = lshr i32 %25, 16
  %27 = trunc i32 %26 to i8
  %28 = xor i8 %27, -128
  store i8 %28, ptr %5, align 1, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass