void matrix(unsigned char y, unsigned char cb, unsigned char cr,
            unsigned char *r, unsigned char *g, unsigned char *b) {
  double _Y, _Cr, _Cb;
  double _R, _G, _B;
  _Y = (y - 16.5) / 219.0;
  _Cr = (cr - 128.5) / 112.0;
  _Cb = (cb - 128.5) / 112.0;
  _R = (_Y + _Cr) * 255.0;
  _G = (_Y + (-0.509 * _Cr) + (-0.194 * _Cb)) * 255.0;
  _B = (_Y + _Cb) * 255.0;
  if (_R < 0)
    _R = 0;
  if (_G < 0)
    _G = 0;
  if (_B < 0)
    _B = 0;
  *r = (_R > 255.0) ? 255 : _R;
  *g = (_G > 255.0) ? 255 : _G;
  *b = (_B > 255.0) ? 255 : _B;
}


x86 assembly (clang, -O0):
<matrix>:
push   %rbp
mov    %rsp,%rbp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movzbl -0x1(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xefe(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeea(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movzbl -0x3(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xec9(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xeb5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movzbl -0x2(%rbp),%eax
cvtsi2sd %eax,%xmm0
movsd  0xea4(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xe90(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  0xe52(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
movsd  0xe35(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  0xe02(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    121d <matrix+0x11d>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x48(%rbp),%xmm0
jbe    1233 <matrix+0x133>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x50(%rbp),%xmm0
jbe    1249 <matrix+0x149>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xdaa(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1272 <matrix+0x172>
movsd  0xd98(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    127c <matrix+0x17c>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
movsd  -0x48(%rbp),%xmm0
movsd  0xd66(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12b6 <matrix+0x1b6>
movsd  0xd54(%rip),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12c0 <matrix+0x1c0>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
movsd  -0x50(%rbp),%xmm0
movsd  0xd22(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12fa <matrix+0x1fa>
movsd  0xd10(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
jmp    1304 <matrix+0x204>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %al,%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<matrix>:
cvtsi2sd %edx,%xmm1
addsd  0xef4(%rip),%xmm1
divsd  0xef4(%rip),%xmm1
movd   %edi,%xmm0
pinsrw $0x2,%esi,%xmm0
cvtdq2pd %xmm0,%xmm2
addpd  0xf07(%rip),%xmm2
divpd  0xf0f(%rip),%xmm2
movapd %xmm2,%xmm3
addsd  %xmm1,%xmm3
movsd  0xecf(%rip),%xmm0
mulsd  %xmm0,%xmm3
mulsd  0xecb(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm2,%xmm4
unpckhpd %xmm2,%xmm4
addsd  %xmm4,%xmm2
mulsd  0xebb(%rip),%xmm4
addsd  %xmm1,%xmm4
mulsd  %xmm0,%xmm4
mulsd  %xmm0,%xmm2
xorpd  %xmm1,%xmm1
xorpd  %xmm5,%xmm5
maxsd  %xmm3,%xmm5
xorpd  %xmm3,%xmm3
maxsd  %xmm4,%xmm3
maxsd  %xmm2,%xmm1
movapd %xmm0,%xmm2
minsd  %xmm5,%xmm2
cvttsd2si %xmm2,%eax
mov    %al,(%rcx)
movapd %xmm0,%xmm2
minsd  %xmm3,%xmm2
cvttsd2si %xmm2,%eax
mov    %al,(%r8)
minsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %al,(%r9)
ret

LLVM IR (-O0):
define void @matrix(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i8* %4, i8* %5) {
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i8 %0, i8* %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i8* %5, i8** %12
%19 = load i8, i8* %7
%20 = zext i8 %19 to i32
%21 = sitofp i32 %20 to double
%22 = fsub double %21, 1.650000e+01
%23 = fdiv double %22, 2.190000e+02
store double %23, double* %13
%24 = load i8, i8* %9
%25 = zext i8 %24 to i32
%26 = sitofp i32 %25 to double
%27 = fsub double %26, 1.285000e+02
%28 = fdiv double %27, 1.120000e+02
store double %28, double* %14
%29 = load i8, i8* %8
%30 = zext i8 %29 to i32
%31 = sitofp i32 %30 to double
%32 = fsub double %31, 1.285000e+02
%33 = fdiv double %32, 1.120000e+02
store double %33, double* %15
%34 = load double, double* %13
%35 = load double, double* %14
%36 = fadd double %34, %35
%37 = fmul double %36, 2.550000e+02
store double %37, double* %16
%38 = load double, double* %13
%39 = load double, double* %14
%40 = call double @llvm.fmuladd.f64(double -5.090000e-01, double %39, double %38)
%41 = load double, double* %15
%42 = call double @llvm.fmuladd.f64(double -1.940000e-01, double %41, double %40)
%43 = fmul double %42, 2.550000e+02
store double %43, double* %17
%44 = load double, double* %13
%45 = load double, double* %15
%46 = fadd double %44, %45
%47 = fmul double %46, 2.550000e+02
store double %47, double* %18
%48 = load double, double* %16
%49 = fcmp olt double %48, 0.000000e+00
br i1 %49, label %50, label %51
50: ; preds = %6
store double 0.000000e+00, double* %16
br label %51
51: ; preds = %50, %6
%52 = load double, double* %17
%53 = fcmp olt double %52, 0.000000e+00
br i1 %53, label %54, label %55
54: ; preds = %51
store double 0.000000e+00, double* %17
br label %55
55: ; preds = %54, %51
%56 = load double, double* %18
%57 = fcmp olt double %56, 0.000000e+00
br i1 %57, label %58, label %59
58: ; preds = %55
store double 0.000000e+00, double* %18
br label %59
59: ; preds = %58, %55
%60 = load double, double* %16
%61 = fcmp ogt double %60, 2.550000e+02
br i1 %61, label %62, label %63
62: ; preds = %59
br label %65
63: ; preds = %59
%64 = load double, double* %16
br label %65
65: ; preds = %63, %62
%66 = phi double [ 2.550000e+02, %62 ], [ %64, %63 ]
%67 = fptoui double %66 to i8
%68 = load i8*, i8** %10
store i8 %67, i8* %68
%69 = load double, double* %17
%70 = fcmp ogt double %69, 2.550000e+02
br i1 %70, label %71, label %72
71: ; preds = %65
br label %74
72: ; preds = %65
%73 = load double, double* %17
br label %74
74: ; preds = %72, %71
%75 = phi double [ 2.550000e+02, %71 ], [ %73, %72 ]
%76 = fptoui double %75 to i8
%77 = load i8*, i8** %11
store i8 %76, i8* %77
%78 = load double, double* %18
%79 = fcmp ogt double %78, 2.550000e+02
br i1 %79, label %80, label %81
80: ; preds = %74
br label %83
81: ; preds = %74
%82 = load double, double* %18
br label %83
83: ; preds = %81, %80
%84 = phi double [ 2.550000e+02, %80 ], [ %82, %81 ]
%85 = fptoui double %84 to i8
%86 = load i8*, i8** %12
store i8 %85, i8* %86
ret void
}

LLVM IR (-O2):
define void @matrix(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* nocapture writeonly %3, i8* nocapture writeonly %4, i8* nocapture writeonly %5) {
%7 = uitofp i8 %2 to double
%8 = fadd double %7, -1.285000e+02
%9 = fdiv double %8, 1.120000e+02
%10 = insertelement <2 x i8> poison, i8 %0, i64 0
%11 = insertelement <2 x i8> %10, i8 %1, i64 1
%12 = uitofp <2 x i8> %11 to <2 x double>
%13 = fadd <2 x double> %12, <double -1.650000e+01, double -1.285000e+02>
%14 = fdiv <2 x double> %13, <double 2.190000e+02, double 1.120000e+02>
%15 = extractelement <2 x double> %14, i64 0
%16 = fadd double %15, %9
%17 = fmul double %16, 2.550000e+02
%18 = tail call double @llvm.fmuladd.f64(double %9, double -5.090000e-01, double %15)
%19 = extractelement <2 x double> %14, i64 1
%20 = tail call double @llvm.fmuladd.f64(double %19, double -1.940000e-01, double %18)
%21 = fmul double %20, 2.550000e+02
%22 = fadd double %15, %19
%23 = fmul double %22, 2.550000e+02
%24 = fcmp olt double %17, 0.000000e+00
%25 = select i1 %24, double 0.000000e+00, double %17
%26 = fcmp olt double %21, 0.000000e+00
%27 = select i1 %26, double 0.000000e+00, double %21
%28 = fcmp olt double %23, 0.000000e+00
%29 = select i1 %28, double 0.000000e+00, double %23
%30 = fcmp ogt double %25, 2.550000e+02
%31 = select i1 %30, double 2.550000e+02, double %25
%32 = fptoui double %31 to i8
store i8 %32, i8* %3
%33 = fcmp ogt double %27, 2.550000e+02
%34 = select i1 %33, double 2.550000e+02, double %27
%35 = fptoui double %34 to i8
store i8 %35, i8* %4
%36 = fcmp ogt double %29, 2.550000e+02
%37 = select i1 %36, double 2.550000e+02, double %29
%38 = fptoui double %37 to i8
store i8 %38, i8* %5
ret void
}