// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dsp/yuv_sse2.c
// Function: YuvToBgrRow_SSE2
static void YuvToBgrRow_SSE2(const uint8_t* y,
                             const uint8_t* u, const uint8_t* v,
                             uint8_t* dst, int len) {
  int n;
  for (n = 0; n + 32 <= len; n += 32, dst += 32 * 3) {
    __m128i R0, R1, R2, R3, G0, G1, G2, G3, B0, B1, B2, B3;
    __m128i bgr0, bgr1, bgr2, bgr3, bgr4, bgr5;

    YUV420ToRGB_SSE2(y +  0, u +  0, v +  0, &R0, &G0, &B0);
    YUV420ToRGB_SSE2(y +  8, u +  4, v +  4, &R1, &G1, &B1);
    YUV420ToRGB_SSE2(y + 16, u +  8, v +  8, &R2, &G2, &B2);
    YUV420ToRGB_SSE2(y + 24, u + 12, v + 12, &R3, &G3, &B3);

    // Cast to 8b and store as BBBBGGGGRRRR.
    bgr0 = _mm_packus_epi16(B0, B1);
    bgr1 = _mm_packus_epi16(B2, B3);
    bgr2 = _mm_packus_epi16(G0, G1);
    bgr3 = _mm_packus_epi16(G2, G3);
    bgr4 = _mm_packus_epi16(R0, R1);
    bgr5 = _mm_packus_epi16(R2, R3);

    // Pack as BGRBGRBGRBGR.
    PlanarTo24b_SSE2(&bgr0, &bgr1, &bgr2, &bgr3, &bgr4, &bgr5, dst);

    y += 32;
    u += 16;
    v += 16;
  }
  for (; n < len; ++n) {   // Finish off
    VP8YuvToBgr(y[0], u[0], v[0], dst);
    dst += 3;
    y += 1;
    u += (n & 1);
    v += (n & 1);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movl %r8d, 0x14(%rsp)
movq %rcx, %rbx
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, 0x18(%rsp)
xorl %r13d, %r13d
xorl %ecx, %ecx
movq %rbp, %r12
addq %r13, %rbp
leaq (%r15,%r13), %r14
leal 0x20(%rcx), %eax
cmpl 0x14(%rsp), %eax
jg 0xdf64b
movq %rbx, 0x28(%rsp)
movq 0x18(%rsp), %rax
leaq (%rax,%rcx), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
movq %rcx, 0x20(%rsp)
leaq 0x140(%rsp), %rcx
leaq 0x100(%rsp), %r8
leaq 0xc0(%rsp), %r9
callq 0xe0083
movq %r12, %rbp
leaq (%r12,%r13), %rsi
addq $0x4, %rsi
leaq 0x4(%r15,%r13), %rdx
leaq 0x8(%rbx), %rdi
leaq 0x130(%rsp), %rcx
leaq 0xf0(%rsp), %r8
leaq 0xb0(%rsp), %r9
callq 0xe0083
leaq (%r12,%r13), %rsi
addq $0x8, %rsi
leaq 0x8(%r15,%r13), %rdx
leaq 0x10(%rbx), %rdi
leaq 0x120(%rsp), %rcx
leaq 0xe0(%rsp), %r8
leaq 0xa0(%rsp), %r9
callq 0xe0083
leaq (%r12,%r13), %rsi
addq $0xc, %rsi
leaq (%r15,%r13), %rdx
addq $0xc, %rdx
addq $0x18, %rbx
movq %rbx, %rdi
movq 0x28(%rsp), %rbx
leaq 0x110(%rsp), %rcx
leaq 0xd0(%rsp), %r8
leaq 0x90(%rsp), %r9
callq 0xe0083
movdqa 0xc0(%rsp), %xmm0
packuswb 0xb0(%rsp), %xmm0
movdqa %xmm0, 0x80(%rsp)
movdqa 0xa0(%rsp), %xmm0
packuswb 0x90(%rsp), %xmm0
movdqa %xmm0, 0x70(%rsp)
movdqa 0x100(%rsp), %xmm0
packuswb 0xf0(%rsp), %xmm0
movdqa %xmm0, 0x60(%rsp)
movdqa 0xe0(%rsp), %xmm0
packuswb 0xd0(%rsp), %xmm0
movdqa %xmm0, 0x50(%rsp)
movdqa 0x140(%rsp), %xmm0
packuswb 0x130(%rsp), %xmm0
movdqa %xmm0, 0x40(%rsp)
movdqa 0x120(%rsp), %xmm0
packuswb 0x110(%rsp), %xmm0
movdqa %xmm0, 0x30(%rsp)
movq %rbx, (%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x70(%rsp), %rsi
leaq 0x60(%rsp), %rdx
leaq 0x50(%rsp), %rcx
leaq 0x40(%rsp), %r8
leaq 0x30(%rsp), %r9
callq 0xdecb4
movq 0x20(%rsp), %rcx
addq $0x60, %rbx
addq $0x20, %rcx
addq $0x10, %r13
jmp 0xdf45f
movq 0x18(%rsp), %rax
movzbl (%rax,%rcx), %edi
movzbl (%rbp), %esi
movzbl (%r14), %edx
movq %rcx, %r15
movq %rbx, %rcx
callq 0xe021e
movq %r15, %rcx
addq $0x3, %rbx
movl %ecx, %eax
andl $0x1, %eax
addq %rax, %rbp
addq %rax, %r14
incq %rcx
cmpl 0x14(%rsp), %ecx
jl 0xdf61a
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq