// File: srajangarg[P]raytracer/src/core/stb_image.hpp
// Function: stbi__YCbCr_to_RGB_row(unsigned char*, unsigned char const*, unsigned char const*, unsigned char const*, int, int)
static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step)
{
   int i;
   for (i=0; i < count; ++i) {
      int y_fixed = (y[i] << 20) + (1<<19); // rounding
      int r,g,b;
      int cr = pcr[i] - 128;
      int cb = pcb[i] - 128;
      r = y_fixed +  cr* float2fixed(1.40200f);
      g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000);
      b = y_fixed                               +   cb* float2fixed(1.77200f);
      r >>= 20;
      g >>= 20;
      b >>= 20;
      if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; }
      if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; }
      if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; }
      out[0] = (stbi_uc)r;
      out[1] = (stbi_uc)g;
      out[2] = (stbi_uc)b;
      out[3] = 255;
      out += step;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl %r9d, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x2bf32
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
shll $0x14, %eax
addl $0x80000, %eax          # imm = 0x80000
movl %eax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
subl $0x80, %eax
movl %eax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movzbl (%rax,%rcx), %eax
subl $0x80, %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %eax
imull $0x166f00, -0x40(%rbp), %ecx # imm = 0x166F00
addl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
imull $0xfff49300, -0x40(%rbp), %ecx # imm = 0xFFF49300
addl %ecx, %eax
imull $0xfffa7e00, -0x44(%rbp), %ecx # imm = 0xFFFA7E00
andl $0xffff0000, %ecx       # imm = 0xFFFF0000
addl %ecx, %eax
movl %eax, -0x38(%rbp)
movl -0x30(%rbp), %eax
imull $0x1c5a00, -0x44(%rbp), %ecx # imm = 0x1C5A00
addl %ecx, %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
sarl $0x14, %eax
movl %eax, -0x34(%rbp)
movl -0x38(%rbp), %eax
sarl $0x14, %eax
movl %eax, -0x38(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x14, %eax
movl %eax, -0x3c(%rbp)
cmpl $0xff, -0x34(%rbp)
jbe 0x2bea6
cmpl $0x0, -0x34(%rbp)
jge 0x2be9d
movl $0x0, -0x34(%rbp)
jmp 0x2bea4
movl $0xff, -0x34(%rbp)
jmp 0x2bea6
cmpl $0xff, -0x38(%rbp)
jbe 0x2bec7
cmpl $0x0, -0x38(%rbp)
jge 0x2bebe
movl $0x0, -0x38(%rbp)
jmp 0x2bec5
movl $0xff, -0x38(%rbp)
jmp 0x2bec7
cmpl $0xff, -0x3c(%rbp)
jbe 0x2bee8
cmpl $0x0, -0x3c(%rbp)
jge 0x2bedf
movl $0x0, -0x3c(%rbp)
jmp 0x2bee6
movl $0xff, -0x3c(%rbp)
jmp 0x2bee8
movl -0x34(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, (%rax)
movl -0x38(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x3c(%rbp), %eax
movb %al, %cl
movq -0x8(%rbp), %rax
movb %cl, 0x2(%rax)
movq -0x8(%rbp), %rax
movb $-0x1, 0x3(%rax)
movl -0x28(%rbp), %ecx
movq -0x8(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x8(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x2bde3
popq %rbp
retq
nopw %cs:(%rax,%rax)