#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int triplet(int, int, int);
int RGB2YCbCr(int v) {
  float y, cb, cr;
  y = 0.257 * (float)((v >> 16) & 0xff) + 0.504 * (float)((v >> 8) & 0xff) +
      0.098 * (float)(v & 0xff) + 16.0;
  cb = -0.148 * (float)((v >> 16) & 0xff) - 0.291 * (float)((v >> 8) & 0xff) +
       0.439 * (float)(v & 0xff) + 128.0;
  cr = 0.439 * (float)((v >> 16) & 0xff) - 0.368 * (float)((v >> 8) & 0xff) -
       0.071 * (float)(v & 0xff) + 128.0;
  return (triplet((int)y, (int)cb, (int)cr));
}


x86 assembly (clang, -O0):
<RGB2YCbCr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xeff(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  0xeeb(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xec3(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xeab(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xe68(%rip),%xmm0
mulsd  %xmm2,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe3d(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe0d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xded(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x4(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm2
movsd  0xdca(%rip),%xmm0
mulsd  %xmm2,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd9f(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
mov    -0x4(%rbp),%eax
and    $0xff,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd77(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd5f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
cvttss2si -0x8(%rbp),%edi
cvttss2si -0xc(%rbp),%esi
cvttss2si -0x10(%rbp),%edx
call   1030 <triplet@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGB2YCbCr>:
mov    %edi,%eax
movzbl %ah,%ecx
movzbl %al,%edx
shr    $0x10,%eax
movzbl %al,%eax
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
cvtsi2ss %ecx,%xmm1
cvtss2sd %xmm1,%xmm2
movsd  0xeca(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xec6(%rip),%xmm3
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
xorps  %xmm1,%xmm1
cvtsi2ss %edx,%xmm1
cvtss2sd %xmm1,%xmm1
movsd  0xeb3(%rip),%xmm4
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
addsd  0xeab(%rip),%xmm4
xorps  %xmm3,%xmm3
cvtsd2ss %xmm4,%xmm3
movsd  0xea4(%rip),%xmm4
mulsd  %xmm2,%xmm4
movsd  0xea0(%rip),%xmm5
mulsd  %xmm0,%xmm5
addsd  %xmm4,%xmm5
movsd  0xe98(%rip),%xmm4
movapd %xmm1,%xmm6
mulsd  %xmm4,%xmm6
addsd  %xmm5,%xmm6
movsd  0xe8c(%rip),%xmm5
addsd  %xmm5,%xmm6
cvtsd2ss %xmm6,%xmm6
mulsd  0xe84(%rip),%xmm2
mulsd  %xmm4,%xmm0
addsd  %xmm2,%xmm0
mulsd  0xe7c(%rip),%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm5,%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
cvttss2si %xmm3,%edi
cvttss2si %xmm6,%esi
cvttss2si %xmm0,%edx
jmp    1030 <triplet@plt>

LLVM IR (-O0):
define i32 @RGB2YCbCr(i32 %0) {
%2 = alloca i32
%3 = alloca float
%4 = alloca float
%5 = alloca float
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = ashr i32 %6, 16
%8 = and i32 %7, 255
%9 = sitofp i32 %8 to float
%10 = fpext float %9 to double
%11 = load i32, i32* %2
%12 = ashr i32 %11, 8
%13 = and i32 %12, 255
%14 = sitofp i32 %13 to float
%15 = fpext float %14 to double
%16 = fmul double 5.040000e-01, %15
%17 = call double @llvm.fmuladd.f64(double 2.570000e-01, double %10, double %16)
%18 = load i32, i32* %2
%19 = and i32 %18, 255
%20 = sitofp i32 %19 to float
%21 = fpext float %20 to double
%22 = call double @llvm.fmuladd.f64(double 9.800000e-02, double %21, double %17)
%23 = fadd double %22, 1.600000e+01
%24 = fptrunc double %23 to float
store float %24, float* %3
%25 = load i32, i32* %2
%26 = ashr i32 %25, 16
%27 = and i32 %26, 255
%28 = sitofp i32 %27 to float
%29 = fpext float %28 to double
%30 = load i32, i32* %2
%31 = ashr i32 %30, 8
%32 = and i32 %31, 255
%33 = sitofp i32 %32 to float
%34 = fpext float %33 to double
%35 = fmul double 2.910000e-01, %34
%36 = fneg double %35
%37 = call double @llvm.fmuladd.f64(double -1.480000e-01, double %29, double %36)
%38 = load i32, i32* %2
%39 = and i32 %38, 255
%40 = sitofp i32 %39 to float
%41 = fpext float %40 to double
%42 = call double @llvm.fmuladd.f64(double 4.390000e-01, double %41, double %37)
%43 = fadd double %42, 1.280000e+02
%44 = fptrunc double %43 to float
store float %44, float* %4
%45 = load i32, i32* %2
%46 = ashr i32 %45, 16
%47 = and i32 %46, 255
%48 = sitofp i32 %47 to float
%49 = fpext float %48 to double
%50 = load i32, i32* %2
%51 = ashr i32 %50, 8
%52 = and i32 %51, 255
%53 = sitofp i32 %52 to float
%54 = fpext float %53 to double
%55 = fmul double 3.680000e-01, %54
%56 = fneg double %55
%57 = call double @llvm.fmuladd.f64(double 4.390000e-01, double %49, double %56)
%58 = load i32, i32* %2
%59 = and i32 %58, 255
%60 = sitofp i32 %59 to float
%61 = fpext float %60 to double
%62 = call double @llvm.fmuladd.f64(double 0xBFB22D0E56041893, double %61, double %57)
%63 = fadd double %62, 1.280000e+02
%64 = fptrunc double %63 to float
store float %64, float* %5
%65 = load float, float* %3
%66 = fptosi float %65 to i32
%67 = load float, float* %4
%68 = fptosi float %67 to i32
%69 = load float, float* %5
%70 = fptosi float %69 to i32
%71 = call i32 @triplet(i32 %66, i32 %68, i32 %70)
ret i32 %71
}

LLVM IR (-O2):
define i32 @RGB2YCbCr(i32 %0) {
%2 = lshr i32 %0, 16
%3 = and i32 %2, 255
%4 = sitofp i32 %3 to float
%5 = fpext float %4 to double
%6 = lshr i32 %0, 8
%7 = and i32 %6, 255
%8 = sitofp i32 %7 to float
%9 = fpext float %8 to double
%10 = fmul double %9, 5.040000e-01
%11 = tail call double @llvm.fmuladd.f64(double %5, double 2.570000e-01, double %10)
%12 = and i32 %0, 255
%13 = sitofp i32 %12 to float
%14 = fpext float %13 to double
%15 = tail call double @llvm.fmuladd.f64(double %14, double 9.800000e-02, double %11)
%16 = fadd double %15, 1.600000e+01
%17 = fptrunc double %16 to float
%18 = fmul double %9, -2.910000e-01
%19 = tail call double @llvm.fmuladd.f64(double %5, double -1.480000e-01, double %18)
%20 = tail call double @llvm.fmuladd.f64(double %14, double 4.390000e-01, double %19)
%21 = fadd double %20, 1.280000e+02
%22 = fptrunc double %21 to float
%23 = fmul double %9, -3.680000e-01
%24 = tail call double @llvm.fmuladd.f64(double %5, double 4.390000e-01, double %23)
%25 = tail call double @llvm.fmuladd.f64(double %14, double 0xBFB22D0E56041893, double %24)
%26 = fadd double %25, 1.280000e+02
%27 = fptrunc double %26 to float
%28 = fptosi float %17 to i32
%29 = fptosi float %22 to i32
%30 = fptosi float %27 to i32
%31 = tail call i32 @triplet(i32 %28, i32 %29, i32 %30)
ret i32 %31
}