// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dsp/rescaler_sse2.c
// Function: RescalerExportRowShrink_SSE2
static void RescalerExportRowShrink_SSE2(WebPRescaler* const wrk) {
  int x_out;
  uint8_t* const dst = wrk->dst;
  rescaler_t* const irow = wrk->irow;
  const int x_out_max = wrk->dst_width * wrk->num_channels;
  const rescaler_t* const frow = wrk->frow;
  const uint32_t yscale = wrk->fy_scale * (-wrk->y_accum);
  assert(!WebPRescalerOutputDone(wrk));
  assert(wrk->y_accum <= 0);
  assert(!wrk->y_expand);
  if (yscale) {
    const int scale_xy = wrk->fxy_scale;
    const __m128i mult_xy = _mm_set_epi32(0, scale_xy, 0, scale_xy);
    const __m128i mult_y = _mm_set_epi32(0, yscale, 0, yscale);
    for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
      __m128i A0, A1, A2, A3, B0, B1, B2, B3;
      LoadDispatchAndMult_SSE2(irow + x_out, NULL, &A0, &A1, &A2, &A3);
      LoadDispatchAndMult_SSE2(frow + x_out, &mult_y, &B0, &B1, &B2, &B3);
      {
        const __m128i D0 = _mm_srli_epi64(B0, WEBP_RESCALER_RFIX);   // = frac
        const __m128i D1 = _mm_srli_epi64(B1, WEBP_RESCALER_RFIX);
        const __m128i D2 = _mm_srli_epi64(B2, WEBP_RESCALER_RFIX);
        const __m128i D3 = _mm_srli_epi64(B3, WEBP_RESCALER_RFIX);
        const __m128i E0 = _mm_sub_epi64(A0, D0);   // irow[x] - frac
        const __m128i E1 = _mm_sub_epi64(A1, D1);
        const __m128i E2 = _mm_sub_epi64(A2, D2);
        const __m128i E3 = _mm_sub_epi64(A3, D3);
        const __m128i F2 = _mm_slli_epi64(D2, 32);
        const __m128i F3 = _mm_slli_epi64(D3, 32);
        const __m128i G0 = _mm_or_si128(D0, F2);
        const __m128i G1 = _mm_or_si128(D1, F3);
        _mm_storeu_si128((__m128i*)(irow + x_out + 0), G0);
        _mm_storeu_si128((__m128i*)(irow + x_out + 4), G1);
        ProcessRow_SSE2(&E0, &E1, &E2, &E3, &mult_xy, dst + x_out);
      }
    }
    for (; x_out < x_out_max; ++x_out) {
      const uint32_t frac = (int)MULT_FIX_FLOOR(frow[x_out], yscale);
      const int v = (int)MULT_FIX(irow[x_out] - frac, wrk->fxy_scale);
      dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
      irow[x_out] = frac;   // new fractional start
    }
  } else {
    const uint32_t scale = wrk->fxy_scale;
    const __m128i mult = _mm_set_epi32(0, scale, 0, scale);
    const __m128i zero = _mm_setzero_si128();
    for (x_out = 0; x_out + 8 <= x_out_max; x_out += 8) {
      __m128i A0, A1, A2, A3;
      LoadDispatchAndMult_SSE2(irow + x_out, NULL, &A0, &A1, &A2, &A3);
      _mm_storeu_si128((__m128i*)(irow + x_out + 0), zero);
      _mm_storeu_si128((__m128i*)(irow + x_out + 4), zero);
      ProcessRow_SSE2(&A0, &A1, &A2, &A3, &mult, dst + x_out);
    }
    for (; x_out < x_out_max; ++x_out) {
      const int v = (int)MULT_FIX(irow[x_out], scale);
      dst[x_out] = (v > 255) ? 255u : (uint8_t)v;
      irow[x_out] = 0;
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl 0x40(%rdi), %eax
cmpl 0x38(%rdi), %eax
jge 0xdb31f
movl 0x18(%rdi), %ecx
testl %ecx, %ecx
jg 0xdb33e
cmpl $0x0, 0x4(%rdi)
jne 0xdb35d
movq 0x48(%rdi), %rbp
movq 0x58(%rdi), %r15
movslq 0x34(%rdi), %rax
movslq 0x8(%rdi), %r12
imulq %rax, %r12
imull 0x10(%rdi), %ecx
movl 0x14(%rdi), %r14d
movd %r14d, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
testl %ecx, %ecx
je 0xdb257
movq %rdi, 0x68(%rsp)
movq 0x60(%rdi), %r13
negl %ecx
leaq 0x50(%rsp), %rax
movdqa %xmm0, (%rax)
movl %ecx, 0xc(%rsp)
movd %ecx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq 0x40(%rsp), %rax
movdqa %xmm0, (%rax)
xorl %r14d, %r14d
movq %r13, 0x60(%rsp)
leaq 0x8(%r14), %rbx
cmpq %r12, %rbx
jg 0xdb1ff
movdqu (%r15,%r14,4), %xmm0
movdqa %xmm0, 0x90(%rsp)
movdqu 0x10(%r15,%r14,4), %xmm1
movdqa %xmm1, 0xa0(%rsp)
psrlq $0x20, %xmm0
movdqa %xmm0, 0x70(%rsp)
movdqa %xmm1, %xmm0
psrlq $0x20, %xmm0
movdqa %xmm0, 0x80(%rsp)
movq %r13, %rdi
leaq 0x40(%rsp), %rsi
leaq 0x30(%rsp), %rdx
leaq 0x20(%rsp), %rcx
leaq 0x10(%rsp), %r8
leaq 0xf0(%rsp), %r9
callq 0xdb37c
movdqa 0x30(%rsp), %xmm0
psrlq $0x20, %xmm0
movdqa 0x20(%rsp), %xmm1
psrlq $0x20, %xmm1
movdqa 0x10(%rsp), %xmm2
movdqa %xmm2, %xmm3
psrlq $0x20, %xmm3
movdqa 0x70(%rsp), %xmm5
psubq %xmm3, %xmm5
movdqa 0xf0(%rsp), %xmm3
movdqa %xmm3, %xmm4
psrlq $0x20, %xmm4
movdqa 0x80(%rsp), %xmm6
psubq %xmm4, %xmm6
movdqa 0x90(%rsp), %xmm4
psubq %xmm0, %xmm4
movdqa %xmm4, 0xe0(%rsp)
movdqa 0xa0(%rsp), %xmm4
psubq %xmm1, %xmm4
movdqa %xmm4, 0xd0(%rsp)
movdqa %xmm5, 0xc0(%rsp)
movdqa %xmm6, 0xb0(%rsp)
movdqa 0x41c3a(%rip), %xmm4    # 0x11cde0
pand %xmm4, %xmm2
pand %xmm4, %xmm3
por %xmm0, %xmm2
por %xmm1, %xmm3
movdqu %xmm2, (%r15,%r14,4)
movdqu %xmm3, 0x10(%r15,%r14,4)
addq %rbp, %r14
leaq 0xe0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
leaq 0xc0(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x50(%rsp), %r8
movq %r14, %r9
callq 0xdb3ce
addq $0x20, %r13
movq %rbx, %r14
jmp 0xdb0a5
movl 0xc(%rsp), %eax
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %r8
cmpq %r12, %r14
jge 0xdb30d
movl (%r8,%r14,4), %ecx
imulq %rax, %rcx
shrq $0x20, %rcx
movl (%r15,%r14,4), %esi
subl %ecx, %esi
movl 0x14(%rdi), %edx
imulq %rsi, %rdx
subq $-0x80000000, %rdx      # imm = 0x80000000
shrq $0x20, %rdx
movl $0xff, %esi
cmpl $0x100, %edx            # imm = 0x100
jge 0xdb249
movl %edx, %esi
movb %sil, (%rbp,%r14)
movl %ecx, (%r15,%r14,4)
incq %r14
jmp 0xdb20d
leaq 0x50(%rsp), %rax
movdqa %xmm0, (%rax)
movslq %r12d, %rbx
xorl %eax, %eax
leaq 0x10(%rsp), %r13
leaq 0x8(%rax), %r12
cmpq %rbx, %r12
jg 0xdb2d9
movdqu (%r15,%rax,4), %xmm0
movdqu 0x10(%r15,%rax,4), %xmm1
movdqa %xmm0, 0x40(%rsp)
psrlq $0x20, %xmm0
movdqa %xmm1, 0x30(%rsp)
psrlq $0x20, %xmm1
movdqa %xmm0, 0x20(%rsp)
movdqa %xmm1, 0x10(%rsp)
leaq (%rbp,%rax), %r9
pxor %xmm0, %xmm0
movdqu %xmm0, 0x10(%r15,%rax,4)
movdqu %xmm0, (%r15,%rax,4)
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %r13, %rcx
leaq 0x50(%rsp), %r8
callq 0xdb3ce
movq %r12, %rax
jmp 0xdb26a
movl $0xff, %ecx
cmpq %rbx, %rax
jge 0xdb30d
movl (%r15,%rax,4), %edx
imulq %r14, %rdx
subq $-0x80000000, %rdx      # imm = 0x80000000
shrq $0x20, %rdx
cmpl $0x100, %edx            # imm = 0x100
cmovgel %ecx, %edx
movb %dl, (%rbp,%rax)
andl $0x0, (%r15,%rax,4)
incq %rax
jmp 0xdb2de
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x40c8f(%rip), %rdi     # 0x11bfb5
leaq 0x41ac3(%rip), %rsi     # 0x11cdf0
leaq 0x41bcf(%rip), %rcx     # 0x11cf03
movl $0x125, %edx            # imm = 0x125
callq 0x56770
leaq 0x40cc5(%rip), %rdi     # 0x11c00a
leaq 0x41aa4(%rip), %rsi     # 0x11cdf0
leaq 0x41bb0(%rip), %rcx     # 0x11cf03
movl $0x126, %edx            # imm = 0x126
callq 0x56770
leaq 0x40d00(%rip), %rdi     # 0x11c064
leaq 0x41a85(%rip), %rsi     # 0x11cdf0
leaq 0x41b91(%rip), %rcx     # 0x11cf03
movl $0x127, %edx            # imm = 0x127
callq 0x56770