// File: /workspace/github_c_makefile_star2_O1/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, %r14
movl 0x4(%rsi), %r15d
movq %rsi, 0x80(%rsp)
movslq (%rsi), %rsi
movq 0xb20(%rdi), %rbp
leaq 0x248(%rbp), %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movb $-0x7f, 0x27(%rbp,%rax)
addq $0x20, %rax
cmpq $0x200, %rax            # imm = 0x200
jne 0xcfe6a
leaq 0x258(%rbp), %r12
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 0xcfe86
testl %r15d, %r15d
jle 0xcfeb8
movb $-0x7f, %al
movb %al, 0x237(%rbp)
movb %al, 0x227(%rbp)
movb %al, 0x7(%rbp)
jmp 0xcfeed
leaq 0x227(%rbp), %rax
movabsq $0x7f7f7f7f7f7f7f7f, %rcx # imm = 0x7F7F7F7F7F7F7F7F
movq %rcx, 0x14(%rbp)
movaps 0x59dac(%rip), %xmm0    # 0x129c80
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(%r14)
jle 0xd0362
leaq 0x28(%rbp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rbp), %rax
movq %rax, 0x58(%rsp)
leaq 0x18(%rbp), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
testl %r15d, %r15d
sete %al
leal (,%rax,4), %ecx
movq %rcx, 0x30(%rsp)
addq $0x5, %rax
movq %rax, 0x38(%rsp)
leaq 0x208(%rbp), %rax
movq %rax, 0x50(%rsp)
movq %rsi, %rax
shlq $0x4, %rax
movq %rax, 0x60(%rsp)
shlq $0x3, %rsi
movq %rsi, 0x70(%rsp)
movl $0x301, %esi            # imm = 0x301
xorl %edi, %edi
xorl %r13d, %r13d
movq %r14, 0x78(%rsp)
movl %r15d, 0x24(%rsp)
movq %r12, 0x68(%rsp)
movq 0x80(%rsp), %rax
movq 0x18(%rax), %rbx
testq %r13, %r13
je 0xcffc1
movl $0x14, %eax
movl (%rbp,%rax), %ecx
movl %ecx, -0x10(%rbp,%rax)
addq $0x20, %rax
cmpq $0x234, %rax            # imm = 0x234
jne 0xcff83
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 0xcff99
imulq $0x320, %r13, %rcx      # imm = 0x320
addq %rbx, %rcx
movq %r13, 0x10(%rsp)
movq %r13, %rdx
shlq $0x5, %rdx
addq 0xb08(%r14), %rdx
movl 0x314(%rcx), %r13d
testl %r15d, %r15d
jle 0xd000b
movups (%rdx), %xmm0
movq 0x58(%rsp), %rax
movups %xmm0, (%rax)
movq 0x10(%rdx), %rax
movq %rax, 0x228(%rbp)
movq 0x18(%rdx), %rax
movq %rax, 0x238(%rbp)
cmpb $0x0, 0x300(%rcx)
movq %rcx, 0x18(%rsp)
movq %rsi, 0x90(%rsp)
movq %rdi, 0x48(%rsp)
movq %rdx, 0x88(%rsp)
je 0xd0054
testl %r15d, %r15d
jle 0xd0107
movslq 0x198(%r14), %rax
decq %rax
cmpq %rax, 0x10(%rsp)
jge 0xd00f6
movl 0x20(%rdx), %eax
jmp 0xd0100
cmpq $0x0, 0x10(%rsp)
movq 0x30(%rsp), %rax
cmovel 0x38(%rsp), %eax
movzbl 0x301(%rcx), %ecx
testl %ecx, %ecx
cmovnel %ecx, %eax
movq 0x8(%rsp), %rdi
leaq 0xac1f4(%rip), %rcx     # 0x17c270
callq *(%rcx,%rax,8)
testl %r13d, %r13d
je 0xd01a3
addq 0x48(%rsp), %rbx
xorl %r14d, %r14d
leaq 0x59e99(%rip), %rax     # 0x129f30
movzwl (%r14,%rax), %esi
addq 0x8(%rsp), %rsi
movl %r13d, %eax
shrl $0x1e, %eax
leaq 0x59bf2(%rip), %rcx     # 0x129ca0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
leaq 0xac28f(%rip), %rax     # 0x17c350
jmp 0xd00cd
movq %rbx, %rdi
leaq 0xac273(%rip), %rax     # 0x17c340
callq *(%rax)
jmp 0xd00df
movq %rbx, %rdi
xorl %edx, %edx
leaq 0xac25b(%rip), %rax     # 0x17c338
callq *(%rax)
shll $0x2, %r13d
addq $0x20, %rbx
addq $0x2, %r14
cmpq $0x20, %r14
jne 0xd0090
jmp 0xd01a3
movzbl 0xf(%rdx), %eax
imull $0x1010101, %eax, %eax  # imm = 0x1010101
movq 0x28(%rsp), %rcx
movl %eax, (%rcx)
movl 0x18(%rbp), %eax
movl %eax, 0x198(%rbp)
movl %eax, 0x118(%rbp)
movl %eax, 0x98(%rbp)
leaq (%rbx,%rdi), %r15
addq %rsi, %rbx
xorl %r14d, %r14d
leaq 0x59e03(%rip), %rax     # 0x129f30
movzwl (%r14,%rax), %r12d
addq 0x8(%rsp), %r12
movzbl (%rbx), %eax
movq %r12, %rdi
leaq 0xac16c(%rip), %rcx     # 0x17c2b0
callq *(%rcx,%rax,8)
movl %r13d, %eax
shrl $0x1e, %eax
leaq 0x59b3c(%rip), %rcx     # 0x129c90
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
movq %r12, %rsi
leaq 0xac1e6(%rip), %rax     # 0x17c350
jmp 0xd0179
movq %r15, %rdi
movq %r12, %rsi
leaq 0xac1c7(%rip), %rax     # 0x17c340
callq *(%rax)
jmp 0xd018e
movq %r15, %rdi
movq %r12, %rsi
xorl %edx, %edx
leaq 0xac1ac(%rip), %rax     # 0x17c338
callq *(%rax)
shll $0x2, %r13d
addq $0x20, %r15
incq %rbx
addq $0x2, %r14
cmpq $0x20, %r14
jne 0xd0126
movq 0x10(%rsp), %r13
testq %r13, %r13
movq 0x18(%rsp), %rax
movl 0x318(%rax), %ebx
movq 0x30(%rsp), %r14
cmovel 0x38(%rsp), %r14d
movzbl 0x311(%rax), %eax
testl %eax, %eax
cmovnel %eax, %r14d
movq 0x40(%rsp), %rdi
leaq 0xac126(%rip), %r15     # 0x17c300
callq *(%r15,%r14,8)
movq 0x68(%rsp), %r12
movq %r12, %rdi
callq *(%r15,%r14,8)
testb %bl, %bl
movq 0x78(%rsp), %r14
movl 0x24(%rsp), %r15d
je 0xd021e
leaq 0xac149(%rip), %rax     # 0x17c348
testb $-0x56, %bl
jne 0xd020b
leaq 0xac14d(%rip), %rax     # 0x17c358
movq 0x18(%rsp), %rcx
leaq 0x200(%rcx), %rdi
movq 0x40(%rsp), %rsi
callq *(%rax)
testl $0xff00, %ebx           # imm = 0xFF00
je 0xd024d
leaq 0xac11b(%rip), %rax     # 0x17c348
testl $0xaa00, %ebx           # imm = 0xAA00
jne 0xd023c
leaq 0xac11c(%rip), %rax     # 0x17c358
movq 0x18(%rsp), %rdi
addq $0x280, %rdi            # imm = 0x280
movq %r12, %rsi
callq *(%rax)
movl 0x19c(%r14), %eax
decl %eax
cmpl %eax, %r15d
jge 0xd0284
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(%r14), %rax
imulq 0x60(%rsp), %rax
movslq 0xb44(%r14), %rdx
movq %r13, %rsi
shlq $0x4, %rsi
addq 0xb28(%r14), %rsi
imulq 0x70(%rsp), %rdx
addq %rax, %rsi
movq 0xb30(%r14), %rax
leaq (,%r13,8), %rdi
movq 0xb38(%r14), %rcx
addq %rdi, %rcx
movq 0x8(%rsp), %r8
xorl %r9d, %r9d
movslq 0xb40(%r14), %r10
movslq %r9d, %r11
imulq %r10, %r11
movups (%r8), %xmm0
movups %xmm0, (%rsi,%r11)
incq %r9
addq $0x20, %r8
cmpq $0x10, %r9
jne 0xd02d0
addq %rdi, %rax
addq %rdx, %rax
addq %rdx, %rcx
movq %r12, %rdx
xorl %esi, %esi
movslq 0xb44(%r14), %rdi
movslq %esi, %r8
imulq %r8, %rdi
movq -0x10(%rdx), %r9
movq %r9, (%rax,%rdi)
movslq 0xb44(%r14), %rdi
imulq %r8, %rdi
movq (%rdx), %r8
movq %r8, (%rcx,%rdi)
incq %rsi
addq $0x20, %rdx
cmpq $0x8, %rsi
jne 0xd0302
incq %r13
movslq 0x198(%r14), %rax
movq 0x48(%rsp), %rdi
movl $0x320, %ecx            # imm = 0x320
addq %rcx, %rdi
movq 0x90(%rsp), %rsi
addq %rcx, %rsi
cmpq %rax, %r13
jl 0xcff6d
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq