#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 */
float fclampf(float, float, float);
void rgb2ycbcr(float *io) {
  float WR = 0.2126f;
  float WB = 0.0722f;
  float WG = 1.0f - WR - WB;
  float UMAX = 0.5f;
  float VMAX = 0.5f;
  float r = io[0], g = io[1], b = io[2];
  io[0] = fclampf(WR * r + WG * g + WB * b, 0.0f, 1.0f);
  io[1] = fclampf(UMAX / (1.0f - WB) * (b - io[0]), -UMAX, UMAX);
  io[2] = fclampf(VMAX / (1.0f - WR) * (r - io[0]), -VMAX, VMAX);
}


x86 assembly (clang, -O0):
<rgb2ycbcr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movss  0xee8(%rip),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xed7(%rip),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  0xec2(%rip),%xmm0
subss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xea2(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
movss  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movss  0x4(%rax),%xmm0
movss  %xmm0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
movss  0x8(%rax),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0xc(%rbp),%xmm1
movss  -0x20(%rbp),%xmm2
movss  -0x14(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
movss  -0x28(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
movss  0xe37(%rip),%xmm2
call   1030 <fclampf@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
movss  -0x18(%rbp),%xmm0
movss  0xe1d(%rip),%xmm1
subss  -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  -0x28(%rbp),%xmm1
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  -0x18(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  -0x18(%rbp),%xmm2
call   1030 <fclampf@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,0x4(%rax)
movss  -0x1c(%rbp),%xmm0
movss  0xdd1(%rip),%xmm1
subss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  -0x20(%rbp),%xmm1
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm1
mulss  %xmm1,%xmm0
movss  -0x1c(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
movss  -0x1c(%rbp),%xmm2
call   1030 <fclampf@plt>
mov    -0x8(%rbp),%rax
movss  %xmm0,0x8(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rgb2ycbcr>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movss  (%rdi),%xmm2
movss  %xmm2,0xc(%rsp)
movss  0x4(%rdi),%xmm0
movss  0x8(%rdi),%xmm3
movss  %xmm3,0x8(%rsp)
mulss  0xec6(%rip),%xmm0
movss  0xec2(%rip),%xmm1
mulss  %xmm2,%xmm1
addss  %xmm0,%xmm1
movss  0xeb6(%rip),%xmm0
mulss  %xmm3,%xmm0
addss  %xmm1,%xmm0
movss  0xeaa(%rip),%xmm2
xorps  %xmm1,%xmm1
call   1030 <fclampf@plt>
movss  %xmm0,(%rbx)
movss  0x8(%rsp),%xmm1
subss  %xmm0,%xmm1
mulss  0xe90(%rip),%xmm1
movaps %xmm1,%xmm0
movss  0xe89(%rip),%xmm1
movss  0xe85(%rip),%xmm2
call   1030 <fclampf@plt>
movss  %xmm0,0x4(%rbx)
movss  0xc(%rsp),%xmm0
subss  (%rbx),%xmm0
mulss  0xe6d(%rip),%xmm0
movss  0xe5d(%rip),%xmm1
movss  0xe59(%rip),%xmm2
call   1030 <fclampf@plt>
movss  %xmm0,0x8(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @rgb2ycbcr(float* %0) {
%2 = alloca float*
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
store float* %0, float** %2
store float 0x3FCB367A00000000, float* %3
store float 0x3FB27BB300000000, float* %4
%11 = load float, float* %3
%12 = fsub float 1.000000e+00, %11
%13 = load float, float* %4
%14 = fsub float %12, %13
store float %14, float* %5
store float 5.000000e-01, float* %6
store float 5.000000e-01, float* %7
%15 = load float*, float** %2
%16 = getelementptr inbounds float, float* %15, i64 0
%17 = load float, float* %16
store float %17, float* %8
%18 = load float*, float** %2
%19 = getelementptr inbounds float, float* %18, i64 1
%20 = load float, float* %19
store float %20, float* %9
%21 = load float*, float** %2
%22 = getelementptr inbounds float, float* %21, i64 2
%23 = load float, float* %22
store float %23, float* %10
%24 = load float, float* %3
%25 = load float, float* %8
%26 = load float, float* %5
%27 = load float, float* %9
%28 = fmul float %26, %27
%29 = call float @llvm.fmuladd.f32(float %24, float %25, float %28)
%30 = load float, float* %4
%31 = load float, float* %10
%32 = call float @llvm.fmuladd.f32(float %30, float %31, float %29)
%33 = call float @fclampf(float %32, float 0.000000e+00, float 1.000000e+00)
%34 = load float*, float** %2
%35 = getelementptr inbounds float, float* %34, i64 0
store float %33, float* %35
%36 = load float, float* %6
%37 = load float, float* %4
%38 = fsub float 1.000000e+00, %37
%39 = fdiv float %36, %38
%40 = load float, float* %10
%41 = load float*, float** %2
%42 = getelementptr inbounds float, float* %41, i64 0
%43 = load float, float* %42
%44 = fsub float %40, %43
%45 = fmul float %39, %44
%46 = load float, float* %6
%47 = fneg float %46
%48 = load float, float* %6
%49 = call float @fclampf(float %45, float %47, float %48)
%50 = load float*, float** %2
%51 = getelementptr inbounds float, float* %50, i64 1
store float %49, float* %51
%52 = load float, float* %7
%53 = load float, float* %3
%54 = fsub float 1.000000e+00, %53
%55 = fdiv float %52, %54
%56 = load float, float* %8
%57 = load float*, float** %2
%58 = getelementptr inbounds float, float* %57, i64 0
%59 = load float, float* %58
%60 = fsub float %56, %59
%61 = fmul float %55, %60
%62 = load float, float* %7
%63 = fneg float %62
%64 = load float, float* %7
%65 = call float @fclampf(float %61, float %63, float %64)
%66 = load float*, float** %2
%67 = getelementptr inbounds float, float* %66, i64 2
store float %65, float* %67
ret void
}

LLVM IR (-O2):
define void @rgb2ycbcr(float* nocapture %0) {
%2 = load float, float* %0
%3 = getelementptr inbounds float, float* %0, i64 1
%4 = load float, float* %3
%5 = getelementptr inbounds float, float* %0, i64 2
%6 = load float, float* %5
%7 = fmul float %4, 0x3FE6E2EB20000000
%8 = tail call float @llvm.fmuladd.f32(float %2, float 0x3FCB367A00000000, float %7)
%9 = tail call float @llvm.fmuladd.f32(float %6, float 0x3FB27BB300000000, float %8)
%10 = tail call float @fclampf(float %9, float 0.000000e+00, float 1.000000e+00)
store float %10, float* %0
%11 = fsub float %6, %10
%12 = fmul float %11, 0x3FE13EBEA0000000
%13 = tail call float @fclampf(float %12, float -5.000000e-01, float 5.000000e-01)
store float %13, float* %3
%14 = load float, float* %0
%15 = fsub float %2, %14
%16 = fmul float %15, 0x3FE451EE20000000
%17 = tail call float @fclampf(float %16, float -5.000000e-01, float 5.000000e-01)
store float %17, float* %5
ret void
}