// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dec/frame_dec.c
// Function: ReconstructRow
static void ReconstructRow(const VP8Decoder* const dec,
                           const VP8ThreadContext* ctx) {
  int j;
  int mb_x;
  const int mb_y = ctx->mb_y_;
  const int cache_id = ctx->id_;
  uint8_t* const y_dst = dec->yuv_b_ + Y_OFF;
  uint8_t* const u_dst = dec->yuv_b_ + U_OFF;
  uint8_t* const v_dst = dec->yuv_b_ + V_OFF;

  // Initialize left-most block.
  for (j = 0; j < 16; ++j) {
    y_dst[j * BPS - 1] = 129;
  }
  for (j = 0; j < 8; ++j) {
    u_dst[j * BPS - 1] = 129;
    v_dst[j * BPS - 1] = 129;
  }

  // Init top-left sample on left column too.
  if (mb_y > 0) {
    y_dst[-1 - BPS] = u_dst[-1 - BPS] = v_dst[-1 - BPS] = 129;
  } else {
    // we only need to do this init once at block (0,0).
    // Afterward, it remains valid for the whole topmost row.
    memset(y_dst - BPS - 1, 127, 16 + 4 + 1);
    memset(u_dst - BPS - 1, 127, 8 + 1);
    memset(v_dst - BPS - 1, 127, 8 + 1);
  }

  // Reconstruct one row.
  for (mb_x = 0; mb_x < dec->mb_w_; ++mb_x) {
    const VP8MBData* const block = ctx->mb_data_ + mb_x;

    // Rotate in the left samples from previously decoded block. We move four
    // pixels at a time for alignment reason, and because of in-loop filter.
    if (mb_x > 0) {
      for (j = -1; j < 16; ++j) {
        Copy32b(&y_dst[j * BPS - 4], &y_dst[j * BPS + 12]);
      }
      for (j = -1; j < 8; ++j) {
        Copy32b(&u_dst[j * BPS - 4], &u_dst[j * BPS + 4]);
        Copy32b(&v_dst[j * BPS - 4], &v_dst[j * BPS + 4]);
      }
    }
    {
      // bring top samples into the cache
      VP8TopSamples* const top_yuv = dec->yuv_t_ + mb_x;
      const int16_t* const coeffs = block->coeffs_;
      uint32_t bits = block->non_zero_y_;
      int n;

      if (mb_y > 0) {
        memcpy(y_dst - BPS, top_yuv[0].y, 16);
        memcpy(u_dst - BPS, top_yuv[0].u, 8);
        memcpy(v_dst - BPS, top_yuv[0].v, 8);
      }

      // predict and add residuals
      if (block->is_i4x4_) {   // 4x4
        uint32_t* const top_right = (uint32_t*)(y_dst - BPS + 16);

        if (mb_y > 0) {
          if (mb_x >= dec->mb_w_ - 1) {    // on rightmost border
            memset(top_right, top_yuv[0].y[15], sizeof(*top_right));
          } else {
            memcpy(top_right, top_yuv[1].y, sizeof(*top_right));
          }
        }
        // replicate the top-right pixels below
        top_right[BPS] = top_right[2 * BPS] = top_right[3 * BPS] = top_right[0];

        // predict and add residuals for all 4x4 blocks in turn.
        for (n = 0; n < 16; ++n, bits <<= 2) {
          uint8_t* const dst = y_dst + kScan[n];
          VP8PredLuma4[block->imodes_[n]](dst);
          DoTransform(bits, coeffs + n * 16, dst);
        }
      } else {    // 16x16
        const int pred_func = CheckMode(mb_x, mb_y, block->imodes_[0]);
        VP8PredLuma16[pred_func](y_dst);
        if (bits != 0) {
          for (n = 0; n < 16; ++n, bits <<= 2) {
            DoTransform(bits, coeffs + n * 16, y_dst + kScan[n]);
          }
        }
      }
      {
        // Chroma
        const uint32_t bits_uv = block->non_zero_uv_;
        const int pred_func = CheckMode(mb_x, mb_y, block->uvmode_);
        VP8PredChroma8[pred_func](u_dst);
        VP8PredChroma8[pred_func](v_dst);
        DoUVTransform(bits_uv >> 0, coeffs + 16 * 16, u_dst);
        DoUVTransform(bits_uv >> 8, coeffs + 20 * 16, v_dst);
      }

      // stash away top samples for next block
      if (mb_y < dec->mb_h_ - 1) {
        memcpy(top_yuv[0].y, y_dst + 15 * BPS, 16);
        memcpy(top_yuv[0].u, u_dst +  7 * BPS,  8);
        memcpy(top_yuv[0].v, v_dst +  7 * BPS,  8);
      }
    }
    // Transfer reconstructed samples from yuv_b_ cache to final destination.
    {
      const int y_offset = cache_id * 16 * dec->cache_y_stride_;
      const int uv_offset = cache_id * 8 * dec->cache_uv_stride_;
      uint8_t* const y_out = dec->cache_y_ + mb_x * 16 + y_offset;
      uint8_t* const u_out = dec->cache_u_ + mb_x * 8 + uv_offset;
      uint8_t* const v_out = dec->cache_v_ + mb_x * 8 + uv_offset;
      for (j = 0; j < 16; ++j) {
        memcpy(y_out + j * dec->cache_y_stride_, y_dst + j * BPS, 16);
      }
      for (j = 0; j < 8; ++j) {
        memcpy(u_out + j * dec->cache_uv_stride_, u_dst + j * BPS, 8);
        memcpy(v_out + j * dec->cache_uv_stride_, v_dst + j * BPS, 8);
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r12
movl 0x4(%rsi), %eax
movl %eax, 0xc(%rsp)
movq %rsi, 0x80(%rsp)
movslq (%rsi), %rsi
movq 0xb20(%rdi), %rbp
leaq 0x248(%rbp), %rax
movq %rax, 0x38(%rsp)
xorl %eax, %eax
movb $-0x7f, 0x27(%rbp,%rax)
addq $0x20, %rax
cmpq $0x200, %rax            # imm = 0x200
jne 0xcef35
leaq 0x258(%rbp), %r13
xorl %eax, %eax
movb $-0x7f, %cl
movb %cl, 0x247(%rbp,%rax)
movb %cl, 0x257(%rbp,%rax)
addq $0x20, %rax
cmpq $0x100, %rax            # imm = 0x100
jne 0xcef51
cmpl $0x0, 0xc(%rsp)
jle 0xcef85
movb $-0x7f, %al
movb %al, 0x237(%rbp)
movb %al, 0x227(%rbp)
movb %al, 0x7(%rbp)
jmp 0xcefba
leaq 0x227(%rbp), %rax
movabsq $0x7f7f7f7f7f7f7f7f, %rcx # imm = 0x7F7F7F7F7F7F7F7F
movq %rcx, 0x14(%rbp)
movaps 0x59eff(%rip), %xmm0    # 0x128ea0
movups %xmm0, 0x7(%rbp)
movb $0x7f, %dl
movb %dl, 0x8(%rax)
movq %rcx, (%rax)
movb %dl, 0x23f(%rbp)
movq %rcx, 0x237(%rbp)
cmpl $0x0, 0x198(%r12)
jle 0xcf45c
leaq 0x28(%rbp), %rax
movq %rax, 0x18(%rsp)
leaq 0x18(%rbp), %rax
movq %rax, 0x20(%rsp)
leaq 0x8(%rbp), %rax
movq %rax, 0x58(%rsp)
xorl %eax, %eax
cmpl $0x0, 0xc(%rsp)
sete %al
leal (,%rax,4), %ecx
movq %rcx, 0x28(%rsp)
addq $0x5, %rax
movq %rax, 0x30(%rsp)
leaq 0x208(%rbp), %rax
movq %rax, 0x50(%rsp)
movq %rsi, %rax
shlq $0x4, %rax
movq %rax, 0x68(%rsp)
shlq $0x3, %rsi
movq %rsi, 0x78(%rsp)
movl $0x301, %esi            # imm = 0x301
xorl %r15d, %r15d
xorl %r14d, %r14d
movq %r12, 0x60(%rsp)
movq %r13, 0x70(%rsp)
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rbx
testq %r14, %r14
je 0xcf08d
movl $0x14, %eax
movl (%rbp,%rax), %ecx
movl %ecx, -0x10(%rbp,%rax)
addq $0x20, %rax
cmpq $0x234, %rax            # imm = 0x234
jne 0xcf04f
xorl %eax, %eax
movl 0x22c(%rbp,%rax), %ecx
movl 0x23c(%rbp,%rax), %edx
movl %ecx, 0x224(%rbp,%rax)
movl %edx, 0x234(%rbp,%rax)
addq $0x20, %rax
cmpq $0x120, %rax            # imm = 0x120
jne 0xcf065
imulq $0x320, %r14, %rax      # imm = 0x320
addq %rbx, %rax
movq %r14, %rcx
shlq $0x5, %rcx
addq 0xb08(%r12), %rcx
movl 0x314(%rax), %r13d
cmpl $0x0, 0xc(%rsp)
movq %rax, 0x10(%rsp)
movq %rsi, 0x90(%rsp)
movq %r15, 0x40(%rsp)
movq %r14, 0x48(%rsp)
movq %rcx, 0x88(%rsp)
jle 0xcf125
movups (%rcx), %xmm0
movq 0x58(%rsp), %rax
movups %xmm0, (%rax)
movq 0x10(%rcx), %rax
movq %rax, 0x228(%rbp)
movq 0x18(%rcx), %rax
movq %rax, 0x238(%rbp)
movq 0x10(%rsp), %rax
cmpb $0x0, 0x300(%rax)
je 0xcf13a
movslq 0x198(%r12), %rax
decq %rax
cmpq %rax, %r14
jge 0xcf1dd
movl 0x20(%rcx), %eax
movq 0x20(%rsp), %rcx
movl %eax, (%rcx)
jmp 0xcf1fc
cmpb $0x0, 0x300(%rax)
je 0xcf13a
movq 0x20(%rsp), %rax
movl (%rax), %eax
jmp 0xcf1fc
testq %r14, %r14
movzbl 0x301(%rax), %eax
movq 0x28(%rsp), %r15
cmoveq 0x30(%rsp), %r15
testl %eax, %eax
movl %r15d, %ecx
cmovnel %eax, %ecx
movq 0x18(%rsp), %rdi
leaq 0xac10d(%rip), %rax     # 0x17b270
callq *(%rax,%rcx,8)
testl %r13d, %r13d
je 0xcf2aa
addq 0x40(%rsp), %rbx
xorl %r14d, %r14d
leaq 0x59fe2(%rip), %rax     # 0x129160
movzwl (%r14,%rax), %esi
addq 0x18(%rsp), %rsi
movl %r13d, %eax
shrl $0x1e, %eax
leaq 0x59d3b(%rip), %rcx     # 0x128ed0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
leaq 0xac1a8(%rip), %rax     # 0x17b350
jmp 0xcf1b4
movq %rbx, %rdi
leaq 0xac18c(%rip), %rax     # 0x17b340
callq *(%rax)
jmp 0xcf1c6
movq %rbx, %rdi
xorl %edx, %edx
leaq 0xac174(%rip), %rax     # 0x17b338
callq *(%rax)
shll $0x2, %r13d
addq $0x20, %rbx
addq $0x2, %r14
cmpq $0x20, %r14
jne 0xcf177
jmp 0xcf2aa
movzbl 0xf(%rcx), %eax
imull $0x1010101, %eax, %ecx  # imm = 0x1010101
movq 0x20(%rsp), %rdx
movl %ecx, (%rdx)
movl %eax, %ecx
shll $0x8, %ecx
orl %eax, %ecx
movl %ecx, %eax
shll $0x10, %eax
orl %ecx, %eax
movl %eax, 0x198(%rbp)
movl %eax, 0x118(%rbp)
movl %eax, 0x98(%rbp)
addq %rbx, %r15
addq %rsi, %rbx
xorl %r14d, %r14d
leaq 0x59f42(%rip), %rax     # 0x129160
movzwl (%r14,%rax), %r12d
addq 0x18(%rsp), %r12
movzbl (%rbx), %eax
movq %r12, %rdi
leaq 0xac07b(%rip), %rcx     # 0x17b2b0
callq *(%rcx,%rax,8)
movl %r13d, %eax
shrl $0x1e, %eax
leaq 0x59c7b(%rip), %rcx     # 0x128ec0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
movq %r12, %rsi
leaq 0xac0f5(%rip), %rax     # 0x17b350
jmp 0xcf26a
movq %r15, %rdi
movq %r12, %rsi
leaq 0xac0d6(%rip), %rax     # 0x17b340
callq *(%rax)
jmp 0xcf27f
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
leaq 0xac0bb(%rip), %rax     # 0x17b338
callq *(%rax)
shll $0x2, %r13d
addq $0x20, %r15
incq %rbx
addq $0x2, %r14
cmpq $0x20, %r14
jne 0xcf217
cmpq $0x0, 0x48(%rsp)
movq 0x28(%rsp), %r15
cmoveq 0x30(%rsp), %r15
movq 0x60(%rsp), %r12
movq 0x10(%rsp), %rax
movl 0x318(%rax), %ebx
movzbl 0x311(%rax), %eax
testl %eax, %eax
cmovnel %eax, %r15d
movq 0x38(%rsp), %rdi
leaq 0xac032(%rip), %r14     # 0x17b300
callq *(%r14,%r15,8)
movq 0x70(%rsp), %r13
movq %r13, %rdi
callq *(%r14,%r15,8)
testb %bl, %bl
movq 0x40(%rsp), %r15
je 0xcf30d
leaq 0xac05a(%rip), %rax     # 0x17b348
testb $-0x56, %bl
jne 0xcf2fa
leaq 0xac05e(%rip), %rax     # 0x17b358
movq 0x10(%rsp), %rcx
leaq 0x200(%rcx), %rdi
movq 0x38(%rsp), %rsi
callq *(%rax)
testl $0xff00, %ebx           # imm = 0xFF00
movq 0x48(%rsp), %r14
je 0xcf341
leaq 0xac027(%rip), %rax     # 0x17b348
testl $0xaa00, %ebx           # imm = 0xAA00
jne 0xcf330
leaq 0xac028(%rip), %rax     # 0x17b358
movq 0x10(%rsp), %rdi
addq $0x280, %rdi            # imm = 0x280
movq %r13, %rsi
callq *(%rax)
movl 0x19c(%r12), %eax
decl %eax
cmpl %eax, 0xc(%rsp)
jge 0xcf37a
movq 0x50(%rsp), %rax
movups (%rax), %xmm0
movq 0x88(%rsp), %rcx
movups %xmm0, (%rcx)
movq 0x328(%rbp), %rax
movq %rax, 0x10(%rcx)
movq 0x338(%rbp), %rax
movq %rax, 0x18(%rcx)
movslq 0xb40(%r12), %rax
imulq 0x68(%rsp), %rax
movslq 0xb44(%r12), %rdx
movq %r14, %rsi
shlq $0x4, %rsi
addq 0xb28(%r12), %rsi
imulq 0x78(%rsp), %rdx
addq %rax, %rsi
movq 0xb30(%r12), %rax
leaq (,%r14,8), %rdi
movq 0xb38(%r12), %rcx
addq %rdi, %rcx
movq 0x18(%rsp), %r8
xorl %r9d, %r9d
movslq 0xb40(%r12), %r10
movslq %r9d, %r11
imulq %r10, %r11
movups (%r8), %xmm0
movups %xmm0, (%rsi,%r11)
incq %r9
addq $0x20, %r8
cmpq $0x10, %r9
jne 0xcf3cb
addq %rdi, %rax
addq %rdx, %rax
addq %rdx, %rcx
movq %r13, %rdx
xorl %esi, %esi
movslq 0xb44(%r12), %rdi
movslq %esi, %r8
imulq %r8, %rdi
movq -0x10(%rdx), %r9
movq %r9, (%rax,%rdi)
movslq 0xb44(%r12), %rdi
imulq %r8, %rdi
movq (%rdx), %r8
movq %r8, (%rcx,%rdi)
incq %rsi
addq $0x20, %rdx
cmpq $0x8, %rsi
jne 0xcf3fe
incq %r14
movslq 0x198(%r12), %rax
movl $0x320, %ecx            # imm = 0x320
addq %rcx, %r15
movq 0x90(%rsp), %rsi
addq %rcx, %rsi
cmpq %rax, %r14
jl 0xcf039
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq