void VIDEO_Ycc2Rgb(unsigned char *ycc, unsigned short *rgb, unsigned int len) {
  int r_calc_i;
  int g_calc_i;
  int b_calc_i;
  int r_calc_i_incr;
  int g_calc_i_incr;
  int b_calc_i_incr;
  int cr_i;
  int y_i;
  int cb_i;
  int y_i_incr;
  int val;
  int val1;
  int val2;
  int val3;
  int val4;
  int val5;
  int i;
  for (i = 0; i < len; i++) {
    cb_i = (int)ycc[4 * i];
    y_i = (int)ycc[4 * i + 1];
    cr_i = (int)ycc[4 * i + 2];
    y_i_incr = (int)ycc[4 * i + 3];
    val = 1164 * (y_i - 16);
    val1 = 1164 * (y_i_incr - 16);
    val2 = 1596 * (cr_i - 128);
    val3 = 813 * (cb_i - 128);
    val4 = 392 * (cr_i - 128);
    val5 = 2017 * (cb_i - 128);
    r_calc_i = (val + val2) / 1000;
    g_calc_i = (val - val3 - val4) / 1000;
    b_calc_i = (val + val5) / 1000;
    r_calc_i_incr = (val1 + val2) / 1000;
    g_calc_i_incr = (val1 - val3 - val4) / 1000;
    b_calc_i_incr = (val1 + val5) / 1000;
    if (r_calc_i < 0)
      r_calc_i = 0;
    else if (r_calc_i > 255)
      r_calc_i = 255;
    if (g_calc_i < 0)
      g_calc_i = 0;
    else if (g_calc_i > 255)
      g_calc_i = 255;
    if (b_calc_i < 0)
      b_calc_i = 0;
    else if (b_calc_i > 255)
      b_calc_i = 255;
    if (r_calc_i_incr < 0)
      r_calc_i_incr = 0;
    else if (r_calc_i_incr > 255)
      r_calc_i_incr = 255;
    if (g_calc_i_incr < 0)
      g_calc_i_incr = 0;
    else if (g_calc_i_incr > 255)
      g_calc_i_incr = 255;
    if (b_calc_i_incr < 0)
      b_calc_i_incr = 0;
    else if (b_calc_i_incr > 255)
      b_calc_i_incr = 255;
    *rgb++ = (((unsigned short)r_calc_i & 0xF8) >> 3) |
             ((((unsigned short)g_calc_i & 0xF8) >> 3) << 5) |
             ((((unsigned short)b_calc_i & 0xF8) >> 3) << 10);
    *rgb++ = (((unsigned short)r_calc_i_incr & 0xF8) >> 3) |
             ((((unsigned short)g_calc_i_incr & 0xF8) >> 3) << 5) |
             ((((unsigned short)b_calc_i_incr & 0xF8) >> 3) << 10);
  }
}


x86 assembly (clang, -O0):
<VIDEO_Ycc2Rgb>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1407 <VIDEO_Ycc2Rgb+0x307>
mov    -0x8(%rbp),%rax
mov    -0x58(%rbp),%ecx
shl    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x58(%rbp),%ecx
shl    $0x2,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x58(%rbp),%ecx
shl    $0x2,%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x58(%rbp),%ecx
shl    $0x2,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
sub    $0x10,%eax
imul   $0x48c,%eax,%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
sub    $0x10,%eax
imul   $0x48c,%eax,%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x80,%eax
imul   $0x63c,%eax,%eax
mov    %eax,-0x48(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x80,%eax
imul   $0x32d,%eax,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x80,%eax
imul   $0x188,%eax,%eax
mov    %eax,-0x50(%rbp)
mov    -0x38(%rbp),%eax
sub    $0x80,%eax
imul   $0x7e1,%eax,%eax
mov    %eax,-0x54(%rbp)
mov    -0x40(%rbp),%eax
add    -0x48(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x40(%rbp),%eax
sub    -0x4c(%rbp),%eax
sub    -0x50(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0x40(%rbp),%eax
add    -0x54(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x20(%rbp)
mov    -0x44(%rbp),%eax
add    -0x48(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x24(%rbp)
mov    -0x44(%rbp),%eax
sub    -0x4c(%rbp),%eax
sub    -0x50(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x44(%rbp),%eax
add    -0x54(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    125f <VIDEO_Ycc2Rgb+0x15f>
movl   $0x0,-0x18(%rbp)
jmp    1278 <VIDEO_Ycc2Rgb+0x178>
cmpl   $0xff,-0x18(%rbp)
jle    1273 <VIDEO_Ycc2Rgb+0x173>
movl   $0xff,-0x18(%rbp)
jmp    1278 <VIDEO_Ycc2Rgb+0x178>
cmpl   $0x0,-0x1c(%rbp)
jge    128e <VIDEO_Ycc2Rgb+0x18e>
movl   $0x0,-0x1c(%rbp)
jmp    12a7 <VIDEO_Ycc2Rgb+0x1a7>
cmpl   $0xff,-0x1c(%rbp)
jle    12a2 <VIDEO_Ycc2Rgb+0x1a2>
movl   $0xff,-0x1c(%rbp)
jmp    12a7 <VIDEO_Ycc2Rgb+0x1a7>
cmpl   $0x0,-0x20(%rbp)
jge    12bd <VIDEO_Ycc2Rgb+0x1bd>
movl   $0x0,-0x20(%rbp)
jmp    12d6 <VIDEO_Ycc2Rgb+0x1d6>
cmpl   $0xff,-0x20(%rbp)
jle    12d1 <VIDEO_Ycc2Rgb+0x1d1>
movl   $0xff,-0x20(%rbp)
jmp    12d6 <VIDEO_Ycc2Rgb+0x1d6>
cmpl   $0x0,-0x24(%rbp)
jge    12ec <VIDEO_Ycc2Rgb+0x1ec>
movl   $0x0,-0x24(%rbp)
jmp    1305 <VIDEO_Ycc2Rgb+0x205>
cmpl   $0xff,-0x24(%rbp)
jle    1300 <VIDEO_Ycc2Rgb+0x200>
movl   $0xff,-0x24(%rbp)
jmp    1305 <VIDEO_Ycc2Rgb+0x205>
cmpl   $0x0,-0x28(%rbp)
jge    131b <VIDEO_Ycc2Rgb+0x21b>
movl   $0x0,-0x28(%rbp)
jmp    1334 <VIDEO_Ycc2Rgb+0x234>
cmpl   $0xff,-0x28(%rbp)
jle    132f <VIDEO_Ycc2Rgb+0x22f>
movl   $0xff,-0x28(%rbp)
jmp    1334 <VIDEO_Ycc2Rgb+0x234>
cmpl   $0x0,-0x2c(%rbp)
jge    134a <VIDEO_Ycc2Rgb+0x24a>
movl   $0x0,-0x2c(%rbp)
jmp    1363 <VIDEO_Ycc2Rgb+0x263>
cmpl   $0xff,-0x2c(%rbp)
jle    135e <VIDEO_Ycc2Rgb+0x25e>
movl   $0xff,-0x2c(%rbp)
jmp    1363 <VIDEO_Ycc2Rgb+0x263>
mov    -0x18(%rbp),%eax
movzwl %ax,%eax
and    $0xf8,%eax
sar    $0x3,%eax
mov    -0x1c(%rbp),%ecx
movzwl %cx,%ecx
and    $0xf8,%ecx
sar    $0x3,%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x20(%rbp),%ecx
movzwl %cx,%ecx
and    $0xf8,%ecx
sar    $0x3,%ecx
shl    $0xa,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x2,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cx,(%rax)
mov    -0x24(%rbp),%eax
movzwl %ax,%eax
and    $0xf8,%eax
sar    $0x3,%eax
mov    -0x28(%rbp),%ecx
movzwl %cx,%ecx
and    $0xf8,%ecx
sar    $0x3,%ecx
shl    $0x5,%ecx
or     %ecx,%eax
mov    -0x2c(%rbp),%ecx
movzwl %cx,%ecx
and    $0xf8,%ecx
sar    $0x3,%ecx
shl    $0xa,%ecx
or     %ecx,%eax
mov    %ax,%cx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x2,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cx,(%rax)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1116 <VIDEO_Ycc2Rgb+0x16>
pop    %rbp
ret

x86 assembly (clang, -O2):
<VIDEO_Ycc2Rgb>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %edx,%edx
je     1774 <VIDEO_Ycc2Rgb+0x674>
mov    %edx,%ecx
cmp    $0x4,%edx
jb     1133 <VIDEO_Ycc2Rgb+0x33>
lea    (%rdi,%rcx,4),%rax
cmp    %rsi,%rax
jbe    136c <VIDEO_Ycc2Rgb+0x26c>
lea    (%rsi,%rcx,4),%rax
cmp    %rdi,%rax
jbe    136c <VIDEO_Ycc2Rgb+0x26c>
xor    %r8d,%r8d
mov    %rsi,-0x20(%rsp)
lea    (%rdi,%r8,4),%rax
add    $0x3,%rax
mov    %rax,-0x10(%rsp)
sub    %r8,%rcx
xor    %r15d,%r15d
mov    %rcx,-0x8(%rsp)
jmp    11fb <VIDEO_Ycc2Rgb+0xfb>
nopl   0x0(%rax,%rax,1)
shr    $0x3,%edi
and    $0x1f,%edi
cmp    $0xfffffc19,%r10d
mov    $0x0,%esi
cmovl  %esi,%edi
shl    $0x2,%ebp
and    $0x3e0,%ebp
cmp    $0xfffffc19,%r11d
cmovl  %esi,%ebp
shl    $0x7,%edx
and    $0x7c00,%edx
cmp    $0xfffffc19,%r12d
cmovl  %esi,%edx
or     %edi,%edx
or     %ebp,%edx
shr    $0x3,%ebx
and    $0x1f,%ebx
cmpl   $0xfffffc19,-0x14(%rsp)
ff
cmovl  %esi,%ebx
shl    $0x2,%ecx
and    $0x3e0,%ecx
cmp    $0xfffffc19,%r8d
cmovl  %esi,%ecx
or     %ebx,%ecx
shl    $0x7,%eax
and    $0x7c00,%eax
cmp    $0xfffffc19,%r13d
mov    -0x20(%rsp),%rdi
mov    %dx,(%rdi,%r15,4)
cmovl  %esi,%eax
or     %ecx,%eax
mov    %ax,0x2(%rdi,%r15,4)
add    $0x1,%r15
mov    -0x8(%rsp),%rcx
cmp    %r15,%rcx
je     1774 <VIDEO_Ycc2Rgb+0x674>
mov    -0x10(%rsp),%rsi
movzbl -0x3(%rsi,%r15,4),%ecx
movzbl -0x2(%rsi,%r15,4),%eax
movzbl -0x1(%rsi,%r15,4),%edx
movzbl (%rsi,%r15,4),%esi
imul   $0x48c,%eax,%edi
imul   $0x48c,%esi,%r14d
lea    -0x48c0(%r14),%r8d
add    $0xffffff80,%edx
imul   $0x63c,%edx,%ebx
add    $0xffffff80,%ecx
imul   $0x32d,%ecx,%esi
imul   $0x188,%edx,%eax
add    %esi,%eax
imul   $0x7e1,%ecx,%r13d
lea    (%rbx,%rdi,1),%r10d
add    $0xffffb740,%r10d
lea    (%rdi,%r13,1),%r12d
add    $0xffffb740,%r12d
mov    %edi,%r11d
add    $0xffffb740,%r11d
movslq %r10d,%rcx
imul   $0x10624dd3,%rcx,%rdi
mov    %rdi,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rdi
add    %ecx,%edi
sub    %eax,%r11d
movslq %r11d,%rcx
imul   $0x10624dd3,%rcx,%rbp
mov    %rbp,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rbp
add    %ecx,%ebp
movslq %r12d,%rcx
imul   $0x10624dd3,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rdx
lea    (%r14,%rbx,1),%ecx
add    $0xffffb740,%ecx
mov    %ecx,-0x14(%rsp)
movslq %ecx,%rcx
imul   $0x10624dd3,%rcx,%rbx
sub    %eax,%r8d
cmp    $0xff,%edi
jl     12da <VIDEO_Ycc2Rgb+0x1da>
mov    $0xff,%edi
movslq %r8d,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rbx,%r9
shr    $0x3f,%r9
sar    $0x26,%rbx
add    %esi,%edx
cmp    $0xff,%ebp
jl     12fe <VIDEO_Ycc2Rgb+0x1fe>
mov    $0xff,%ebp
add    %r14d,%r13d
add    $0xffffb740,%r13d
movslq %r13d,%rax
imul   $0x10624dd3,%rax,%rax
mov    %rcx,%r14
shr    $0x3f,%r14
sar    $0x26,%rcx
add    %r9d,%ebx
cmp    $0xff,%edx
jl     132d <VIDEO_Ycc2Rgb+0x22d>
mov    $0xff,%edx
mov    %rax,%rsi
shr    $0x3f,%rsi
sar    $0x26,%rax
add    %r14d,%ecx
cmp    $0xff,%ebx
jl     1348 <VIDEO_Ycc2Rgb+0x248>
mov    $0xff,%ebx
add    %esi,%eax
cmp    $0xff,%ecx
jl     1357 <VIDEO_Ycc2Rgb+0x257>
mov    $0xff,%ecx
cmp    $0xff,%eax
jl     1160 <VIDEO_Ycc2Rgb+0x60>
mov    $0xff,%eax
jmp    1160 <VIDEO_Ycc2Rgb+0x60>
mov    %ecx,%r8d
and    $0xfffffffc,%r8d
lea    (%rsi,%r8,4),%rax
mov    %rax,-0x20(%rsp)
lea    0x0(,%rcx,4),%r9
and    $0xfffffffffffffff0,%r9
xor    %eax,%eax
movdqa 0xccd(%rip),%xmm14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movdqu (%rdi,%rax,1),%xmm7
movdqa %xmm7,%xmm5
movdqa 0xc4f(%rip),%xmm0
pand   %xmm0,%xmm5
movdqa %xmm7,%xmm3
psrlw  $0x8,%xmm3
pand   %xmm0,%xmm3
movdqa %xmm7,%xmm2
psrld  $0x10,%xmm2
pand   %xmm0,%xmm2
psrld  $0x18,%xmm7
movdqa 0xc34(%rip),%xmm0
pmaddwd %xmm0,%xmm3
movdqa 0xc38(%rip),%xmm1
paddd  %xmm1,%xmm3
pmaddwd %xmm0,%xmm7
paddd  %xmm1,%xmm7
movdqa 0xc34(%rip),%xmm0
paddd  %xmm0,%xmm2
movdqa %xmm2,%xmm8
pmaddwd 0xc32(%rip),%xmm8
paddd  %xmm0,%xmm5
movdqa %xmm5,%xmm9
pmaddwd 0xc30(%rip),%xmm9
movdqa %xmm8,%xmm10
paddd  %xmm3,%xmm10
pshufd $0xf5,%xmm10,%xmm11
pxor   %xmm12,%xmm12
pcmpgtd %xmm10,%xmm12
movdqa 0xc3e(%rip),%xmm4
movdqa %xmm4,%xmm15
pcmpgtd %xmm10,%xmm15
pmuludq %xmm14,%xmm10
pshufd $0xed,%xmm10,%xmm0
pmuludq %xmm14,%xmm11
pshufd $0xed,%xmm11,%xmm1
punpckldq %xmm1,%xmm0
pand   %xmm14,%xmm12
psubd  %xmm12,%xmm0
movdqa %xmm0,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x6,%xmm0
paddd  %xmm1,%xmm0
packssdw %xmm5,%xmm5
packssdw %xmm2,%xmm2
punpcklwd %xmm5,%xmm2
pmaddwd 0xbda(%rip),%xmm2
movdqa %xmm3,%xmm1
psubd  %xmm2,%xmm1
pshufd $0xf5,%xmm1,%xmm11
pxor   %xmm5,%xmm5
pcmpgtd %xmm1,%xmm5
movdqa %xmm4,%xmm10
pcmpgtd %xmm1,%xmm10
pmuludq %xmm14,%xmm1
pshufd $0xed,%xmm1,%xmm6
pmuludq %xmm14,%xmm11
pshufd $0xed,%xmm11,%xmm1
punpckldq %xmm1,%xmm6
pand   %xmm14,%xmm5
psubd  %xmm5,%xmm6
movdqa %xmm6,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x6,%xmm6
paddd  %xmm1,%xmm6
paddd  %xmm9,%xmm3
pshufd $0xf5,%xmm3,%xmm11
pxor   %xmm1,%xmm1
pcmpgtd %xmm3,%xmm1
movdqa %xmm4,%xmm12
pcmpgtd %xmm3,%xmm12
pmuludq %xmm14,%xmm3
pshufd $0xed,%xmm3,%xmm5
pmuludq %xmm14,%xmm11
pshufd $0xed,%xmm11,%xmm3
punpckldq %xmm3,%xmm5
pand   %xmm14,%xmm1
psubd  %xmm1,%xmm5
movdqa %xmm5,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x6,%xmm5
paddd  %xmm1,%xmm5
paddd  %xmm7,%xmm8
pshufd $0xf5,%xmm8,%xmm1
pxor   %xmm13,%xmm13
pcmpgtd %xmm8,%xmm13
movdqa %xmm4,%xmm11
pcmpgtd %xmm8,%xmm11
pmuludq %xmm14,%xmm8
pshufd $0xed,%xmm8,%xmm3
pmuludq %xmm14,%xmm1
pshufd $0xed,%xmm1,%xmm1
punpckldq %xmm1,%xmm3
pand   %xmm14,%xmm13
psubd  %xmm13,%xmm3
movdqa %xmm3,%xmm1
psrld  $0x1f,%xmm1
psrad  $0x6,%xmm3
paddd  %xmm1,%xmm3
paddd  %xmm7,%xmm9
psubd  %xmm2,%xmm7
pshufd $0xf5,%xmm7,%xmm13
pxor   %xmm2,%xmm2
pcmpgtd %xmm7,%xmm2
movdqa %xmm4,%xmm8
pcmpgtd %xmm7,%xmm8
pmuludq %xmm14,%xmm7
pshufd $0xed,%xmm7,%xmm1
pmuludq %xmm14,%xmm13
pshufd $0xed,%xmm13,%xmm7
punpckldq %xmm7,%xmm1
pand   %xmm14,%xmm2
psubd  %xmm2,%xmm1
movdqa %xmm1,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x6,%xmm1
paddd  %xmm2,%xmm1
pshufd $0xf5,%xmm9,%xmm13
pxor   %xmm2,%xmm2
pcmpgtd %xmm9,%xmm2
movdqa %xmm4,%xmm7
pcmpgtd %xmm9,%xmm7
pmuludq %xmm14,%xmm9
pshufd $0xed,%xmm9,%xmm9
pmuludq %xmm14,%xmm13
pshufd $0xed,%xmm13,%xmm4
punpckldq %xmm4,%xmm9
pand   %xmm14,%xmm2
psubd  %xmm2,%xmm9
movdqa %xmm9,%xmm2
psrld  $0x1f,%xmm2
psrad  $0x6,%xmm9
paddd  %xmm2,%xmm9
movdqa 0x9c1(%rip),%xmm13
movdqa %xmm13,%xmm2
pcmpgtd %xmm0,%xmm2
pand   %xmm2,%xmm0
pandn  %xmm13,%xmm2
por    %xmm0,%xmm2
movdqa %xmm13,%xmm0
pcmpgtd %xmm6,%xmm0
pand   %xmm0,%xmm6
pandn  %xmm13,%xmm0
por    %xmm6,%xmm0
movdqa %xmm13,%xmm4
pcmpgtd %xmm5,%xmm4
pand   %xmm4,%xmm5
pandn  %xmm13,%xmm4
por    %xmm5,%xmm4
movdqa %xmm13,%xmm5
pcmpgtd %xmm3,%xmm5
pand   %xmm5,%xmm3
pandn  %xmm13,%xmm5
por    %xmm3,%xmm5
movdqa %xmm13,%xmm3
pcmpgtd %xmm1,%xmm3
pand   %xmm3,%xmm1
pandn  %xmm13,%xmm3
por    %xmm1,%xmm3
movdqa %xmm13,%xmm1
pcmpgtd %xmm9,%xmm1
pand   %xmm1,%xmm9
pandn  %xmm13,%xmm1
por    %xmm9,%xmm1
psrld  $0x3,%xmm2
pandn  %xmm2,%xmm15
pslld  $0x2,%xmm0
pandn  %xmm0,%xmm10
pslld  $0x7,%xmm4
pandn  %xmm4,%xmm12
movdqa 0x9a4(%rip),%xmm0
pand   %xmm0,%xmm15
movdqa 0x9b7(%rip),%xmm4
pand   %xmm4,%xmm12
por    %xmm15,%xmm12
movdqa 0x995(%rip),%xmm2
pand   %xmm2,%xmm10
por    %xmm10,%xmm12
psrld  $0x3,%xmm5
pandn  %xmm5,%xmm11
pslld  $0x2,%xmm3
pandn  %xmm3,%xmm8
pslld  $0x7,%xmm1
pandn  %xmm1,%xmm7
pand   %xmm0,%xmm11
pand   %xmm4,%xmm7
por    %xmm11,%xmm7
pand   %xmm2,%xmm8
por    %xmm8,%xmm7
packssdw %xmm12,%xmm12
packssdw %xmm7,%xmm7
punpcklwd %xmm7,%xmm12
movdqu %xmm12,(%rsi,%rax,1)
add    $0x10,%rax
cmp    %rax,%r9
jne    13a0 <VIDEO_Ycc2Rgb+0x2a0>
cmp    %rcx,%r8
jne    113b <VIDEO_Ycc2Rgb+0x3b>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @VIDEO_Ycc2Rgb(i8* %0, i16* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i16*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
store i8* %0, i8** %4
store i16* %1, i16** %5
store i32 %2, i32* %6
store i32 0, i32* %23
br label %24
24: ; preds = %204, %3
%25 = load i32, i32* %23
%26 = load i32, i32* %6
%27 = icmp ult i32 %25, %26
br i1 %27, label %28, label %207
28: ; preds = %24
%29 = load i8*, i8** %4
%30 = load i32, i32* %23
%31 = mul nsw i32 4, %30
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %29, i64 %32
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
store i32 %35, i32* %15
%36 = load i8*, i8** %4
%37 = load i32, i32* %23
%38 = mul nsw i32 4, %37
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %36, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
store i32 %43, i32* %14
%44 = load i8*, i8** %4
%45 = load i32, i32* %23
%46 = mul nsw i32 4, %45
%47 = add nsw i32 %46, 2
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %44, i64 %48
%50 = load i8, i8* %49
%51 = zext i8 %50 to i32
store i32 %51, i32* %13
%52 = load i8*, i8** %4
%53 = load i32, i32* %23
%54 = mul nsw i32 4, %53
%55 = add nsw i32 %54, 3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %52, i64 %56
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
store i32 %59, i32* %16
%60 = load i32, i32* %14
%61 = sub nsw i32 %60, 16
%62 = mul nsw i32 1164, %61
store i32 %62, i32* %17
%63 = load i32, i32* %16
%64 = sub nsw i32 %63, 16
%65 = mul nsw i32 1164, %64
store i32 %65, i32* %18
%66 = load i32, i32* %13
%67 = sub nsw i32 %66, 128
%68 = mul nsw i32 1596, %67
store i32 %68, i32* %19
%69 = load i32, i32* %15
%70 = sub nsw i32 %69, 128
%71 = mul nsw i32 813, %70
store i32 %71, i32* %20
%72 = load i32, i32* %13
%73 = sub nsw i32 %72, 128
%74 = mul nsw i32 392, %73
store i32 %74, i32* %21
%75 = load i32, i32* %15
%76 = sub nsw i32 %75, 128
%77 = mul nsw i32 2017, %76
store i32 %77, i32* %22
%78 = load i32, i32* %17
%79 = load i32, i32* %19
%80 = add nsw i32 %78, %79
%81 = sdiv i32 %80, 1000
store i32 %81, i32* %7
%82 = load i32, i32* %17
%83 = load i32, i32* %20
%84 = sub nsw i32 %82, %83
%85 = load i32, i32* %21
%86 = sub nsw i32 %84, %85
%87 = sdiv i32 %86, 1000
store i32 %87, i32* %8
%88 = load i32, i32* %17
%89 = load i32, i32* %22
%90 = add nsw i32 %88, %89
%91 = sdiv i32 %90, 1000
store i32 %91, i32* %9
%92 = load i32, i32* %18
%93 = load i32, i32* %19
%94 = add nsw i32 %92, %93
%95 = sdiv i32 %94, 1000
store i32 %95, i32* %10
%96 = load i32, i32* %18
%97 = load i32, i32* %20
%98 = sub nsw i32 %96, %97
%99 = load i32, i32* %21
%100 = sub nsw i32 %98, %99
%101 = sdiv i32 %100, 1000
store i32 %101, i32* %11
%102 = load i32, i32* %18
%103 = load i32, i32* %22
%104 = add nsw i32 %102, %103
%105 = sdiv i32 %104, 1000
store i32 %105, i32* %12
%106 = load i32, i32* %7
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %109
108: ; preds = %28
store i32 0, i32* %7
br label %114
109: ; preds = %28
%110 = load i32, i32* %7
%111 = icmp sgt i32 %110, 255
br i1 %111, label %112, label %113
112: ; preds = %109
store i32 255, i32* %7
br label %113
113: ; preds = %112, %109
br label %114
114: ; preds = %113, %108
%115 = load i32, i32* %8
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %118
117: ; preds = %114
store i32 0, i32* %8
br label %123
118: ; preds = %114
%119 = load i32, i32* %8
%120 = icmp sgt i32 %119, 255
br i1 %120, label %121, label %122
121: ; preds = %118
store i32 255, i32* %8
br label %122
122: ; preds = %121, %118
br label %123
123: ; preds = %122, %117
%124 = load i32, i32* %9
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %127
126: ; preds = %123
store i32 0, i32* %9
br label %132
127: ; preds = %123
%128 = load i32, i32* %9
%129 = icmp sgt i32 %128, 255
br i1 %129, label %130, label %131
130: ; preds = %127
store i32 255, i32* %9
br label %131
131: ; preds = %130, %127
br label %132
132: ; preds = %131, %126
%133 = load i32, i32* %10
%134 = icmp slt i32 %133, 0
br i1 %134, label %135, label %136
135: ; preds = %132
store i32 0, i32* %10
br label %141
136: ; preds = %132
%137 = load i32, i32* %10
%138 = icmp sgt i32 %137, 255
br i1 %138, label %139, label %140
139: ; preds = %136
store i32 255, i32* %10
br label %140
140: ; preds = %139, %136
br label %141
141: ; preds = %140, %135
%142 = load i32, i32* %11
%143 = icmp slt i32 %142, 0
br i1 %143, label %144, label %145
144: ; preds = %141
store i32 0, i32* %11
br label %150
145: ; preds = %141
%146 = load i32, i32* %11
%147 = icmp sgt i32 %146, 255
br i1 %147, label %148, label %149
148: ; preds = %145
store i32 255, i32* %11
br label %149
149: ; preds = %148, %145
br label %150
150: ; preds = %149, %144
%151 = load i32, i32* %12
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %154
153: ; preds = %150
store i32 0, i32* %12
br label %159
154: ; preds = %150
%155 = load i32, i32* %12
%156 = icmp sgt i32 %155, 255
br i1 %156, label %157, label %158
157: ; preds = %154
store i32 255, i32* %12
br label %158
158: ; preds = %157, %154
br label %159
159: ; preds = %158, %153
%160 = load i32, i32* %7
%161 = trunc i32 %160 to i16
%162 = zext i16 %161 to i32
%163 = and i32 %162, 248
%164 = ashr i32 %163, 3
%165 = load i32, i32* %8
%166 = trunc i32 %165 to i16
%167 = zext i16 %166 to i32
%168 = and i32 %167, 248
%169 = ashr i32 %168, 3
%170 = shl i32 %169, 5
%171 = or i32 %164, %170
%172 = load i32, i32* %9
%173 = trunc i32 %172 to i16
%174 = zext i16 %173 to i32
%175 = and i32 %174, 248
%176 = ashr i32 %175, 3
%177 = shl i32 %176, 10
%178 = or i32 %171, %177
%179 = trunc i32 %178 to i16
%180 = load i16*, i16** %5
%181 = getelementptr inbounds i16, i16* %180, i32 1
store i16* %181, i16** %5
store i16 %179, i16* %180
%182 = load i32, i32* %10
%183 = trunc i32 %182 to i16
%184 = zext i16 %183 to i32
%185 = and i32 %184, 248
%186 = ashr i32 %185, 3
%187 = load i32, i32* %11
%188 = trunc i32 %187 to i16
%189 = zext i16 %188 to i32
%190 = and i32 %189, 248
%191 = ashr i32 %190, 3
%192 = shl i32 %191, 5
%193 = or i32 %186, %192
%194 = load i32, i32* %12
%195 = trunc i32 %194 to i16
%196 = zext i16 %195 to i32
%197 = and i32 %196, 248
%198 = ashr i32 %197, 3
%199 = shl i32 %198, 10
%200 = or i32 %193, %199
%201 = trunc i32 %200 to i16
%202 = load i16*, i16** %5
%203 = getelementptr inbounds i16, i16* %202, i32 1
store i16* %203, i16** %5
store i16 %201, i16* %202
br label %204
204: ; preds = %159
%205 = load i32, i32* %23
%206 = add nsw i32 %205, 1
store i32 %206, i32* %23
br label %24
207: ; preds = %24
ret void
}

LLVM IR (-O2):
define void @VIDEO_Ycc2Rgb(i8* nocapture %0, i16* nocapture writeonly %1, i32 %2) {
%4 = bitcast i16* %1 to i8*
%5 = icmp eq i32 %2, 0
br i1 %5, label %200, label %6
6: ; preds = %3
%7 = zext i32 %2 to i64
%8 = icmp ult i32 %2, 4
br i1 %8, label %109, label %9
9: ; preds = %6
%10 = shl nuw nsw i64 %7, 1
%11 = getelementptr i16, i16* %1, i64 %10
%12 = bitcast i16* %11 to i8*
%13 = shl nuw nsw i64 %7, 2
%14 = getelementptr i8, i8* %0, i64 %13
%15 = icmp ugt i8* %14, %4
%16 = icmp ugt i8* %12, %0
%17 = and i1 %15, %16
br i1 %17, label %109, label %18
18: ; preds = %9
%19 = and i64 %7, 4294967292
%20 = shl nuw nsw i64 %19, 1
%21 = getelementptr i16, i16* %1, i64 %20
br label %22
22: ; preds = %22, %18
%23 = phi i64 [ 0, %18 ], [ %105, %22 ]
%24 = shl i64 %23, 1
%25 = shl nsw i64 %23, 2
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = bitcast i8* %26 to <16 x i8>*
%28 = load <16 x i8>, <16 x i8>* %27
%29 = shufflevector <16 x i8> %28, <16 x i8> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
%30 = shufflevector <16 x i8> %28, <16 x i8> poison, <4 x i32> <i32 1, i32 5, i32 9, i32 13>
%31 = shufflevector <16 x i8> %28, <16 x i8> poison, <4 x i32> <i32 2, i32 6, i32 10, i32 14>
%32 = shufflevector <16 x i8> %28, <16 x i8> poison, <4 x i32> <i32 3, i32 7, i32 11, i32 15>
%33 = zext <4 x i8> %29 to <4 x i32>
%34 = zext <4 x i8> %30 to <4 x i32>
%35 = zext <4 x i8> %31 to <4 x i32>
%36 = zext <4 x i8> %32 to <4 x i32>
%37 = mul nuw nsw <4 x i32> %34, <i32 1164, i32 1164, i32 1164, i32 1164>
%38 = add nsw <4 x i32> %37, <i32 -18624, i32 -18624, i32 -18624, i32 -18624>
%39 = mul nuw nsw <4 x i32> %36, <i32 1164, i32 1164, i32 1164, i32 1164>
%40 = add nsw <4 x i32> %39, <i32 -18624, i32 -18624, i32 -18624, i32 -18624>
%41 = add nsw <4 x i32> %35, <i32 -128, i32 -128, i32 -128, i32 -128>
%42 = mul nsw <4 x i32> %41, <i32 1596, i32 1596, i32 1596, i32 1596>
%43 = add nsw <4 x i32> %33, <i32 -128, i32 -128, i32 -128, i32 -128>
%44 = mul nsw <4 x i32> %43, <i32 813, i32 813, i32 813, i32 813>
%45 = mul nsw <4 x i32> %41, <i32 392, i32 392, i32 392, i32 392>
%46 = mul nsw <4 x i32> %43, <i32 2017, i32 2017, i32 2017, i32 2017>
%47 = add nsw <4 x i32> %42, %38
%48 = sdiv <4 x i32> %47, <i32 1000, i32 1000, i32 1000, i32 1000>
%49 = add nsw <4 x i32> %45, %44
%50 = sub nsw <4 x i32> %38, %49
%51 = sdiv <4 x i32> %50, <i32 1000, i32 1000, i32 1000, i32 1000>
%52 = add nsw <4 x i32> %38, %46
%53 = sdiv <4 x i32> %52, <i32 1000, i32 1000, i32 1000, i32 1000>
%54 = add nsw <4 x i32> %40, %42
%55 = sdiv <4 x i32> %54, <i32 1000, i32 1000, i32 1000, i32 1000>
%56 = sub nsw <4 x i32> %40, %49
%57 = sdiv <4 x i32> %56, <i32 1000, i32 1000, i32 1000, i32 1000>
%58 = add nsw <4 x i32> %40, %46
%59 = sdiv <4 x i32> %58, <i32 1000, i32 1000, i32 1000, i32 1000>
%60 = icmp slt <4 x i32> %47, <i32 -999, i32 -999, i32 -999, i32 -999>
%61 = icmp slt <4 x i32> %48, <i32 255, i32 255, i32 255, i32 255>
%62 = select <4 x i1> %61, <4 x i32> %48, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%63 = icmp slt <4 x i32> %50, <i32 -999, i32 -999, i32 -999, i32 -999>
%64 = icmp slt <4 x i32> %51, <i32 255, i32 255, i32 255, i32 255>
%65 = select <4 x i1> %64, <4 x i32> %51, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%66 = icmp slt <4 x i32> %52, <i32 -999, i32 -999, i32 -999, i32 -999>
%67 = icmp slt <4 x i32> %53, <i32 255, i32 255, i32 255, i32 255>
%68 = select <4 x i1> %67, <4 x i32> %53, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%69 = icmp slt <4 x i32> %54, <i32 -999, i32 -999, i32 -999, i32 -999>
%70 = icmp slt <4 x i32> %55, <i32 255, i32 255, i32 255, i32 255>
%71 = select <4 x i1> %70, <4 x i32> %55, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%72 = icmp slt <4 x i32> %56, <i32 -999, i32 -999, i32 -999, i32 -999>
%73 = icmp slt <4 x i32> %57, <i32 255, i32 255, i32 255, i32 255>
%74 = select <4 x i1> %73, <4 x i32> %57, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%75 = icmp slt <4 x i32> %58, <i32 -999, i32 -999, i32 -999, i32 -999>
%76 = icmp slt <4 x i32> %59, <i32 255, i32 255, i32 255, i32 255>
%77 = select <4 x i1> %76, <4 x i32> %59, <4 x i32> <i32 255, i32 255, i32 255, i32 255>
%78 = lshr <4 x i32> %62, <i32 3, i32 3, i32 3, i32 3>
%79 = and <4 x i32> %78, <i32 31, i32 31, i32 31, i32 31>
%80 = select <4 x i1> %60, <4 x i32> zeroinitializer, <4 x i32> %79
%81 = shl nsw <4 x i32> %65, <i32 2, i32 2, i32 2, i32 2>
%82 = and <4 x i32> %81, <i32 992, i32 992, i32 992, i32 992>
%83 = select <4 x i1> %63, <4 x i32> zeroinitializer, <4 x i32> %82
%84 = shl nsw <4 x i32> %68, <i32 7, i32 7, i32 7, i32 7>
%85 = and <4 x i32> %84, <i32 31744, i32 31744, i32 31744, i32 31744>
%86 = select <4 x i1> %66, <4 x i32> zeroinitializer, <4 x i32> %85
%87 = or <4 x i32> %80, %86
%88 = or <4 x i32> %87, %83
%89 = trunc <4 x i32> %88 to <4 x i16>
%90 = lshr <4 x i32> %71, <i32 3, i32 3, i32 3, i32 3>
%91 = and <4 x i32> %90, <i32 31, i32 31, i32 31, i32 31>
%92 = select <4 x i1> %69, <4 x i32> zeroinitializer, <4 x i32> %91
%93 = shl nsw <4 x i32> %74, <i32 2, i32 2, i32 2, i32 2>
%94 = and <4 x i32> %93, <i32 992, i32 992, i32 992, i32 992>
%95 = select <4 x i1> %72, <4 x i32> zeroinitializer, <4 x i32> %94
%96 = or <4 x i32> %92, %95
%97 = shl nsw <4 x i32> %77, <i32 7, i32 7, i32 7, i32 7>
%98 = and <4 x i32> %97, <i32 31744, i32 31744, i32 31744, i32 31744>
%99 = select <4 x i1> %75, <4 x i32> zeroinitializer, <4 x i32> %98
%100 = or <4 x i32> %96, %99
%101 = trunc <4 x i32> %100 to <4 x i16>
%102 = getelementptr inbounds i16, i16* %1, i64 %24
%103 = bitcast i16* %102 to <8 x i16>*
%104 = shufflevector <4 x i16> %89, <4 x i16> %101, <8 x i32> <i32 0, i32 4, i32 1, i32 5, i32 2, i32 6, i32 3, i32 7>
store <8 x i16> %104, <8 x i16>* %103
%105 = add nuw i64 %23, 4
%106 = icmp eq i64 %105, %19
br i1 %106, label %107, label %22
107: ; preds = %22
%108 = icmp eq i64 %19, %7
br i1 %108, label %200, label %109
109: ; preds = %9, %6, %107
%110 = phi i64 [ 0, %9 ], [ 0, %6 ], [ %19, %107 ]
%111 = phi i16* [ %1, %9 ], [ %1, %6 ], [ %21, %107 ]
br label %112
112: ; preds = %109, %112
%113 = phi i64 [ %198, %112 ], [ %110, %109 ]
%114 = phi i16* [ %197, %112 ], [ %111, %109 ]
%115 = shl nsw i64 %113, 2
%116 = getelementptr inbounds i8, i8* %0, i64 %115
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = or i64 %115, 1
%120 = getelementptr inbounds i8, i8* %0, i64 %119
%121 = load i8, i8* %120
%122 = zext i8 %121 to i32
%123 = or i64 %115, 2
%124 = getelementptr inbounds i8, i8* %0, i64 %123
%125 = load i8, i8* %124
%126 = zext i8 %125 to i32
%127 = or i64 %115, 3
%128 = getelementptr inbounds i8, i8* %0, i64 %127
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = mul nuw nsw i32 %122, 1164
%132 = add nsw i32 %131, -18624
%133 = mul nuw nsw i32 %130, 1164
%134 = add nsw i32 %133, -18624
%135 = add nsw i32 %126, -128
%136 = mul nsw i32 %135, 1596
%137 = add nsw i32 %118, -128
%138 = mul nsw i32 %137, 813
%139 = mul nsw i32 %135, 392
%140 = mul nsw i32 %137, 2017
%141 = add nsw i32 %136, %132
%142 = sdiv i32 %141, 1000
%143 = add nsw i32 %139, %138
%144 = sub nsw i32 %132, %143
%145 = sdiv i32 %144, 1000
%146 = add nsw i32 %132, %140
%147 = sdiv i32 %146, 1000
%148 = add nsw i32 %134, %136
%149 = sdiv i32 %148, 1000
%150 = sub nsw i32 %134, %143
%151 = sdiv i32 %150, 1000
%152 = add nsw i32 %134, %140
%153 = sdiv i32 %152, 1000
%154 = icmp slt i32 %141, -999
%155 = icmp slt i32 %142, 255
%156 = select i1 %155, i32 %142, i32 255
%157 = icmp slt i32 %144, -999
%158 = icmp slt i32 %145, 255
%159 = select i1 %158, i32 %145, i32 255
%160 = icmp slt i32 %146, -999
%161 = icmp slt i32 %147, 255
%162 = select i1 %161, i32 %147, i32 255
%163 = icmp slt i32 %148, -999
%164 = icmp slt i32 %149, 255
%165 = select i1 %164, i32 %149, i32 255
%166 = icmp slt i32 %150, -999
%167 = icmp slt i32 %151, 255
%168 = select i1 %167, i32 %151, i32 255
%169 = icmp slt i32 %152, -999
%170 = icmp slt i32 %153, 255
%171 = select i1 %170, i32 %153, i32 255
%172 = lshr i32 %156, 3
%173 = and i32 %172, 31
%174 = select i1 %154, i32 0, i32 %173
%175 = shl nsw i32 %159, 2
%176 = and i32 %175, 992
%177 = select i1 %157, i32 0, i32 %176
%178 = shl nsw i32 %162, 7
%179 = and i32 %178, 31744
%180 = select i1 %160, i32 0, i32 %179
%181 = or i32 %174, %180
%182 = or i32 %181, %177
%183 = trunc i32 %182 to i16
%184 = getelementptr inbounds i16, i16* %114, i64 1
store i16 %183, i16* %114
%185 = lshr i32 %165, 3
%186 = and i32 %185, 31
%187 = select i1 %163, i32 0, i32 %186
%188 = shl nsw i32 %168, 2
%189 = and i32 %188, 992
%190 = select i1 %166, i32 0, i32 %189
%191 = or i32 %187, %190
%192 = shl nsw i32 %171, 7
%193 = and i32 %192, 31744
%194 = select i1 %169, i32 0, i32 %193
%195 = or i32 %191, %194
%196 = trunc i32 %195 to i16
%197 = getelementptr inbounds i16, i16* %114, i64 2
store i16 %196, i16* %184
%198 = add nuw nsw i64 %113, 1
%199 = icmp eq i64 %198, %7
br i1 %199, label %200, label %112
200: ; preds = %112, %107, %3
ret void
}