// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dsp/filters_sse2.c
// Function: GradientPredictInverse_SSE2
static void GradientPredictInverse_SSE2(const uint8_t* const in,
                                        const uint8_t* const top,
                                        uint8_t* const row, int length) {
  if (length > 0) {
    int i;
    const int max_pos = length & ~7;
    const __m128i zero = _mm_setzero_si128();
    __m128i A = _mm_set_epi32(0, 0, 0, row[-1]);   // left sample
    for (i = 0; i < max_pos; i += 8) {
      const __m128i tmp0 = _mm_loadl_epi64((const __m128i*)&top[i]);
      const __m128i tmp1 = _mm_loadl_epi64((const __m128i*)&top[i - 1]);
      const __m128i B = _mm_unpacklo_epi8(tmp0, zero);
      const __m128i C = _mm_unpacklo_epi8(tmp1, zero);
      const __m128i D = _mm_loadl_epi64((const __m128i*)&in[i]);  // base input
      const __m128i E = _mm_sub_epi16(B, C);  // unclipped gradient basis B - C
      __m128i out = zero;                     // accumulator for output
      __m128i mask_hi = _mm_set_epi32(0, 0, 0, 0xff);
      int k = 8;
      while (1) {
        const __m128i tmp3 = _mm_add_epi16(A, E);           // delta = A + B - C
        const __m128i tmp4 = _mm_packus_epi16(tmp3, zero);  // saturate delta
        const __m128i tmp5 = _mm_add_epi8(tmp4, D);         // add to in[]
        A = _mm_and_si128(tmp5, mask_hi);                   // 1-complement clip
        out = _mm_or_si128(out, A);                         // accumulate output
        if (--k == 0) break;
        A = _mm_slli_si128(A, 1);                        // rotate left sample
        mask_hi = _mm_slli_si128(mask_hi, 1);            // rotate mask
        A = _mm_unpacklo_epi8(A, zero);                  // convert 8b->16b
      }
      A = _mm_srli_si128(A, 7);       // prepare left sample for next iteration
      _mm_storel_epi64((__m128i*)&row[i], out);
    }
    for (; i < length; ++i) {
      const int delta = GradientPredictor_SSE2(row[i - 1], top[i], top[i - 1]);
      row[i] = (uint8_t)(in[i] + delta);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x1f8(%rbp)
movq %rsi, -0x200(%rbp)
movq %rdx, -0x208(%rbp)
movl %ecx, -0x20c(%rbp)
cmpl $0x0, -0x20c(%rbp)
jle 0x164227
movl -0x20c(%rbp), %eax
andl $-0x8, %eax
movl %eax, -0x214(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x110(%rbp)
movaps -0x110(%rbp), %xmm0
movaps %xmm0, -0x230(%rbp)
movq -0x208(%rbp), %rax
movzbl -0x1(%rax), %eax
movl $0x0, -0x1b4(%rbp)
movl $0x0, -0x1b8(%rbp)
movl $0x0, -0x1bc(%rbp)
movl %eax, -0x1c0(%rbp)
movd -0x1b4(%rbp), %xmm0
movd -0x1b8(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd -0x1bc(%rbp), %xmm2
movd -0x1c0(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, -0x1d0(%rbp)
movdqa -0x1d0(%rbp), %xmm0
movdqa %xmm0, -0x240(%rbp)
movl $0x0, -0x210(%rbp)
movl -0x210(%rbp), %eax
cmpl -0x214(%rbp), %eax
jge 0x164181
movq -0x200(%rbp), %rax
movslq -0x210(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq (%rax), %xmm0
movaps %xmm0, -0x170(%rbp)
movaps -0x170(%rbp), %xmm0
movaps %xmm0, -0x250(%rbp)
movq -0x200(%rbp), %rax
movl -0x210(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x178(%rbp)
movq -0x178(%rbp), %rax
movq (%rax), %xmm0
movaps %xmm0, -0x190(%rbp)
movaps -0x190(%rbp), %xmm0
movaps %xmm0, -0x260(%rbp)
movaps -0x250(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movaps -0xb0(%rbp), %xmm0
movaps -0xc0(%rbp), %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movaps %xmm0, -0x270(%rbp)
movaps -0x260(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0xd0(%rbp)
movaps %xmm0, -0xe0(%rbp)
movaps -0xd0(%rbp), %xmm0
movaps -0xe0(%rbp), %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movaps %xmm0, -0x280(%rbp)
movq -0x1f8(%rbp), %rax
movslq -0x210(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x198(%rbp)
movq -0x198(%rbp), %rax
movq (%rax), %xmm0
movaps %xmm0, -0x1b0(%rbp)
movaps -0x1b0(%rbp), %xmm0
movaps %xmm0, -0x290(%rbp)
movaps -0x270(%rbp), %xmm1
movaps -0x280(%rbp), %xmm0
movaps %xmm1, -0x90(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps -0x90(%rbp), %xmm0
movaps -0xa0(%rbp), %xmm1
psubw %xmm1, %xmm0
movaps %xmm0, -0x2a0(%rbp)
movaps -0x230(%rbp), %xmm0
movaps %xmm0, -0x2b0(%rbp)
movl $0x0, -0x1d4(%rbp)
movl $0x0, -0x1d8(%rbp)
movl $0x0, -0x1dc(%rbp)
movl $0xff, -0x1e0(%rbp)
movd -0x1d4(%rbp), %xmm0
movd -0x1d8(%rbp), %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movd -0x1dc(%rbp), %xmm2
movd -0x1e0(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
punpcklqdq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0]
movdqa %xmm0, -0x1f0(%rbp)
movdqa -0x1f0(%rbp), %xmm0
movdqa %xmm0, -0x2c0(%rbp)
movl $0x8, -0x2c4(%rbp)
movdqa -0x240(%rbp), %xmm1
movdqa -0x2a0(%rbp), %xmm0
movdqa %xmm1, -0x70(%rbp)
movdqa %xmm0, -0x80(%rbp)
movdqa -0x70(%rbp), %xmm0
movdqa -0x80(%rbp), %xmm1
paddw %xmm1, %xmm0
movdqa %xmm0, -0x2e0(%rbp)
movdqa -0x2e0(%rbp), %xmm1
movdqa -0x230(%rbp), %xmm0
movdqa %xmm1, -0x50(%rbp)
movdqa %xmm0, -0x60(%rbp)
movdqa -0x50(%rbp), %xmm0
movdqa -0x60(%rbp), %xmm1
packuswb %xmm1, %xmm0
movdqa %xmm0, -0x2f0(%rbp)
movdqa -0x2f0(%rbp), %xmm1
movdqa -0x290(%rbp), %xmm0
movdqa %xmm1, -0x140(%rbp)
movdqa %xmm0, -0x150(%rbp)
movdqa -0x140(%rbp), %xmm0
movdqa -0x150(%rbp), %xmm1
paddb %xmm1, %xmm0
movdqa %xmm0, -0x300(%rbp)
movdqa -0x300(%rbp), %xmm1
movdqa -0x2c0(%rbp), %xmm0
movdqa %xmm1, -0x30(%rbp)
movdqa %xmm0, -0x40(%rbp)
movdqa -0x30(%rbp), %xmm0
pand -0x40(%rbp), %xmm0
movdqa %xmm0, -0x240(%rbp)
movdqa -0x2b0(%rbp), %xmm1
movdqa -0x240(%rbp), %xmm0
movdqa %xmm1, -0x10(%rbp)
movdqa %xmm0, -0x20(%rbp)
movdqa -0x10(%rbp), %xmm0
por -0x20(%rbp), %xmm0
movdqa %xmm0, -0x2b0(%rbp)
movl -0x2c4(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c4(%rbp)
cmpl $0x0, %eax
jne 0x1640c2
jmp 0x164123
movaps -0x240(%rbp), %xmm0
pslldq $0x1, %xmm0             # xmm0 = zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
movaps %xmm0, -0x240(%rbp)
movaps -0x2c0(%rbp), %xmm0
pslldq $0x1, %xmm0             # xmm0 = zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]
movaps %xmm0, -0x2c0(%rbp)
movaps -0x240(%rbp), %xmm1
movaps -0x230(%rbp), %xmm0
movaps %xmm1, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
movaps -0xf0(%rbp), %xmm0
movaps -0x100(%rbp), %xmm1
punpcklbw %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1],xmm0[2],xmm1[2],xmm0[3],xmm1[3],xmm0[4],xmm1[4],xmm0[5],xmm1[5],xmm0[6],xmm1[6],xmm0[7],xmm1[7]
movdqa %xmm0, -0x240(%rbp)
jmp 0x163fb8
movaps -0x240(%rbp), %xmm0
psrldq $0x7, %xmm0             # xmm0 = xmm0[7,8,9,10,11,12,13,14,15],zero,zero,zero,zero,zero,zero,zero
movaps %xmm0, -0x240(%rbp)
movq -0x208(%rbp), %rax
movslq -0x210(%rbp), %rcx
addq %rcx, %rax
movaps -0x2b0(%rbp), %xmm0
movq %rax, -0x118(%rbp)
movaps %xmm0, -0x130(%rbp)
movq -0x130(%rbp), %rcx
movq -0x118(%rbp), %rax
movq %rcx, (%rax)
movl -0x210(%rbp), %eax
addl $0x8, %eax
movl %eax, -0x210(%rbp)
jmp 0x163dd7
jmp 0x164183
movl -0x210(%rbp), %eax
cmpl -0x20c(%rbp), %eax
jge 0x164225
movq -0x208(%rbp), %rax
movl -0x210(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %sil
movq -0x200(%rbp), %rax
movslq -0x210(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x200(%rbp), %rax
movl -0x210(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movzbl %sil, %edi
movzbl %dl, %esi
movzbl (%rax,%rcx), %edx
callq 0x164230
movl %eax, -0x304(%rbp)
movq -0x1f8(%rbp), %rax
movslq -0x210(%rbp), %rcx
movzbl (%rax,%rcx), %eax
addl -0x304(%rbp), %eax
movb %al, %dl
movq -0x208(%rbp), %rax
movslq -0x210(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x210(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x210(%rbp)
jmp 0x164183
jmp 0x164227
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq