// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dsp/yuv_sse2.c
// Function: ConvertARGBToUV_SSE2
static void ConvertARGBToUV_SSE2(const uint32_t* argb,
                                 uint8_t* u, uint8_t* v,
                                 int src_width, int do_store) {
  const int max_width = src_width & ~31;
  int i;
  for (i = 0; i < max_width; i += 32, u += 16, v += 16) {
    __m128i rgb[6], U0, V0, U1, V1;
    RGB32PackedToPlanar_SSE2(&argb[i], rgb);
    HorizontalAddPack_SSE2(&rgb[0], &rgb[1], &rgb[0]);
    HorizontalAddPack_SSE2(&rgb[2], &rgb[3], &rgb[2]);
    HorizontalAddPack_SSE2(&rgb[4], &rgb[5], &rgb[4]);
    ConvertRGBToUV_SSE2(&rgb[0], &rgb[2], &rgb[4], &U0, &V0);

    RGB32PackedToPlanar_SSE2(&argb[i + 16], rgb);
    HorizontalAddPack_SSE2(&rgb[0], &rgb[1], &rgb[0]);
    HorizontalAddPack_SSE2(&rgb[2], &rgb[3], &rgb[2]);
    HorizontalAddPack_SSE2(&rgb[4], &rgb[5], &rgb[4]);
    ConvertRGBToUV_SSE2(&rgb[0], &rgb[2], &rgb[4], &U1, &V1);

    U0 = _mm_packus_epi16(U0, U1);
    V0 = _mm_packus_epi16(V0, V1);
    if (!do_store) {
      const __m128i prev_u = LOAD_16(u);
      const __m128i prev_v = LOAD_16(v);
      U0 = _mm_avg_epu8(U0, prev_u);
      V0 = _mm_avg_epu8(V0, prev_v);
    }
    STORE_16(U0, u);
    STORE_16(V0, v);
  }
  if (i < src_width) {  // left-over
    WebPConvertARGBToUV_C(argb + i, u, v, src_width - i, do_store);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rdi, -0xd8(%rbp)
movq %rsi, -0xe0(%rbp)
movq %rdx, -0xe8(%rbp)
movl %ecx, -0xec(%rbp)
movl %r8d, -0xf0(%rbp)
movl -0xec(%rbp), %eax
andl $-0x20, %eax
movl %eax, -0xf4(%rbp)
movl $0x0, -0xf8(%rbp)
movl -0xf8(%rbp), %eax
cmpl -0xf4(%rbp), %eax
jge 0x17d325
movq -0xd8(%rbp), %rdi
movslq -0xf8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
leaq -0x160(%rbp), %rsi
callq 0x180040
leaq -0x160(%rbp), %rdi
leaq -0x160(%rbp), %rsi
addq $0x10, %rsi
leaq -0x160(%rbp), %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
addq $0x20, %rdi
leaq -0x160(%rbp), %rsi
addq $0x30, %rsi
leaq -0x160(%rbp), %rdx
addq $0x20, %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
addq $0x40, %rdi
leaq -0x160(%rbp), %rsi
addq $0x50, %rsi
leaq -0x160(%rbp), %rdx
addq $0x40, %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
leaq -0x160(%rbp), %rsi
addq $0x20, %rsi
leaq -0x160(%rbp), %rdx
addq $0x40, %rdx
leaq -0x170(%rbp), %rcx
leaq -0x180(%rbp), %r8
callq 0x180ce0
movq -0xd8(%rbp), %rdi
movl -0xf8(%rbp), %eax
addl $0x10, %eax
cltq
shlq $0x2, %rax
addq %rax, %rdi
leaq -0x160(%rbp), %rsi
callq 0x180040
leaq -0x160(%rbp), %rdi
leaq -0x160(%rbp), %rsi
addq $0x10, %rsi
leaq -0x160(%rbp), %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
addq $0x20, %rdi
leaq -0x160(%rbp), %rsi
addq $0x30, %rsi
leaq -0x160(%rbp), %rdx
addq $0x20, %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
addq $0x40, %rdi
leaq -0x160(%rbp), %rsi
addq $0x50, %rsi
leaq -0x160(%rbp), %rdx
addq $0x40, %rdx
callq 0x180b80
leaq -0x160(%rbp), %rdi
leaq -0x160(%rbp), %rsi
addq $0x20, %rsi
leaq -0x160(%rbp), %rdx
addq $0x40, %rdx
leaq -0x190(%rbp), %rcx
leaq -0x1a0(%rbp), %r8
callq 0x180ce0
movdqa -0x170(%rbp), %xmm1
movdqa -0x190(%rbp), %xmm0
movdqa %xmm1, -0xa0(%rbp)
movdqa %xmm0, -0xb0(%rbp)
movdqa -0xa0(%rbp), %xmm0
movdqa -0xb0(%rbp), %xmm1
packuswb %xmm1, %xmm0
movdqa %xmm0, -0x170(%rbp)
movdqa -0x180(%rbp), %xmm1
movdqa -0x1a0(%rbp), %xmm0
movdqa %xmm1, -0xc0(%rbp)
movdqa %xmm0, -0xd0(%rbp)
movdqa -0xc0(%rbp), %xmm0
movdqa -0xd0(%rbp), %xmm1
packuswb %xmm1, %xmm0
movdqa %xmm0, -0x180(%rbp)
cmpl $0x0, -0xf0(%rbp)
jne 0x17d29d
movq -0xe0(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movdqu (%rax), %xmm0
movdqa %xmm0, -0x1b0(%rbp)
movq -0xe8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movdqu (%rax), %xmm0
movdqa %xmm0, -0x1c0(%rbp)
movdqa -0x170(%rbp), %xmm1
movdqa -0x1b0(%rbp), %xmm0
movdqa %xmm1, -0x10(%rbp)
movdqa %xmm0, -0x20(%rbp)
movdqa -0x10(%rbp), %xmm0
movdqa -0x20(%rbp), %xmm1
pavgb %xmm1, %xmm0
movdqa %xmm0, -0x170(%rbp)
movdqa -0x180(%rbp), %xmm1
movdqa -0x1c0(%rbp), %xmm0
movdqa %xmm1, -0x30(%rbp)
movdqa %xmm0, -0x40(%rbp)
movdqa -0x30(%rbp), %xmm0
movdqa -0x40(%rbp), %xmm1
pavgb %xmm1, %xmm0
movdqa %xmm0, -0x180(%rbp)
movq -0xe0(%rbp), %rax
movdqa -0x170(%rbp), %xmm0
movq %rax, -0x58(%rbp)
movdqa %xmm0, -0x70(%rbp)
movdqa -0x70(%rbp), %xmm0
movq -0x58(%rbp), %rax
movdqu %xmm0, (%rax)
movq -0xe8(%rbp), %rax
movdqa -0x180(%rbp), %xmm0
movq %rax, -0x78(%rbp)
movdqa %xmm0, -0x90(%rbp)
movdqa -0x90(%rbp), %xmm0
movq -0x78(%rbp), %rax
movdqu %xmm0, (%rax)
movl -0xf8(%rbp), %eax
addl $0x20, %eax
movl %eax, -0xf8(%rbp)
movq -0xe0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xe0(%rbp)
movq -0xe8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xe8(%rbp)
jmp 0x17cff6
movl -0xf8(%rbp), %eax
cmpl -0xec(%rbp), %eax
jge 0x17d36e
movq -0xd8(%rbp), %rdi
movslq -0xf8(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdx
movl -0xec(%rbp), %ecx
subl -0xf8(%rbp), %ecx
movl -0xf0(%rbp), %r8d
callq 0x153bb0
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
nopw (%rax,%rax)