// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/dec/io_dec.c
// Function: EmitFancyRGB
static int EmitFancyRGB(const VP8Io* const io, WebPDecParams* const p) {
  int num_lines_out = io->mb_h;   // a priori guess
  const WebPRGBABuffer* const buf = &p->output->u.RGBA;
  uint8_t* dst = buf->rgba + (size_t)io->mb_y * buf->stride;
  WebPUpsampleLinePairFunc upsample = WebPUpsamplers[p->output->colorspace];
  const uint8_t* cur_y = io->y;
  const uint8_t* cur_u = io->u;
  const uint8_t* cur_v = io->v;
  const uint8_t* top_u = p->tmp_u;
  const uint8_t* top_v = p->tmp_v;
  int y = io->mb_y;
  const int y_end = io->mb_y + io->mb_h;
  const int mb_w = io->mb_w;
  const int uv_w = (mb_w + 1) / 2;

  if (y == 0) {
    // First line is special cased. We mirror the u/v samples at boundary.
    upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v, dst, NULL, mb_w);
  } else {
    // We can finish the left-over line from previous call.
    upsample(p->tmp_y, cur_y, top_u, top_v, cur_u, cur_v,
             dst - buf->stride, dst, mb_w);
    ++num_lines_out;
  }
  // Loop over each output pairs of row.
  for (; y + 2 < y_end; y += 2) {
    top_u = cur_u;
    top_v = cur_v;
    cur_u += io->uv_stride;
    cur_v += io->uv_stride;
    dst += 2 * buf->stride;
    cur_y += 2 * io->y_stride;
    upsample(cur_y - io->y_stride, cur_y,
             top_u, top_v, cur_u, cur_v,
             dst - buf->stride, dst, mb_w);
  }
  // move to last row
  cur_y += io->y_stride;
  if (io->crop_top + y_end < io->crop_bottom) {
    // Save the unfinished samples for next call (as we're not done yet).
    memcpy(p->tmp_y, cur_y, mb_w * sizeof(*p->tmp_y));
    memcpy(p->tmp_u, cur_u, uv_w * sizeof(*p->tmp_u));
    memcpy(p->tmp_v, cur_v, uv_w * sizeof(*p->tmp_v));
    // The fancy upsampler leaves a row unfinished behind
    // (except for the very last row)
    num_lines_out--;
  } else {
    // Process the very last row of even-sized picture
    if (!(y_end & 1)) {
      upsample(cur_y, NULL, cur_u, cur_v, cur_u, cur_v,
               dst + buf->stride, NULL, mb_w);
    }
  }
  return num_lines_out;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl 0x10(%rdi), %r13d
movq (%rsi), %rcx
movslq 0x8(%rdi), %r14
movslq 0x18(%rcx), %rax
movq %rax, %r15
imulq %r14, %r15
addq 0x10(%rcx), %r15
movslq 0xc(%rdi), %r11
movq %rcx, 0x28(%rsp)
movl (%rcx), %ecx
leaq 0xaaca6(%rip), %rdx     # 0x17c600
movq (%rdx,%rcx,8), %r10
movq 0x18(%rdi), %r12
movq 0x20(%rdi), %rbx
movq %rdi, 0x8(%rsp)
movq 0x28(%rdi), %r9
testq %r14, %r14
movq %r11, 0x10(%rsp)
movq %r10, 0x20(%rsp)
movq %rsi, 0x30(%rsp)
movq %r9, 0x18(%rsp)
je 0xd19b9
movq 0x18(%rsi), %rcx
movq 0x8(%rsi), %rdi
movq 0x10(%rsi), %rdx
movq %r10, %rbp
movq %r15, %r10
subq %rax, %r10
subq $0x8, %rsp
movq %r12, %rsi
movq %rbx, %r8
pushq %r11
pushq %r15
pushq %r10
callq *%rbp
addq $0x20, %rsp
leal 0x1(%r13), %eax
jmp 0xd19db
subq $0x8, %rsp
movq %r12, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r9, %rcx
movq %rbx, %r8
pushq %r11
pushq $0x0
pushq %r15
callq *%r10
addq $0x20, %rsp
movl %r13d, %eax
movl %eax, 0x4(%rsp)
leal (%r14,%r13), %r8d
cmpl $0x3, %r13d
movq 0x28(%rsp), %rdi
jl 0xd1a6c
addl $0x2, %r14d
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %rdx
movq 0x18(%rsp), %rcx
movslq 0x34(%rdx), %r13
leaq (%rbx,%r13), %rbp
addq %rcx, %r13
movslq 0x18(%rdi), %rax
leaq (%r15,%rax,2), %r15
movslq 0x30(%rdx), %rdx
leaq (%r12,%rdx,2), %r12
movq %r12, %rdi
subq %rdx, %rdi
movq %r15, %r10
subq %rax, %r10
subq $0x8, %rsp
movq %r12, %rsi
movq %rbx, %rdx
movl %r8d, %ebx
movq %rbp, %r8
movq %r13, %r9
pushq %r11
pushq %r15
pushq %r10
callq *0x40(%rsp)
movl %ebx, %r8d
movq 0x28(%rsp), %rdx
movq 0x48(%rsp), %rdi
movq 0x30(%rsp), %r11
addq $0x20, %rsp
addl $0x2, %r14d
movq %r13, %rcx
movq %rbp, %rbx
cmpl %r8d, %r14d
jl 0xd1a01
jmp 0xd1a7e
movq %rbx, %rbp
movq 0x18(%rsp), %r13
movq 0x10(%rsp), %r11
movq 0x8(%rsp), %rdx
movslq 0x30(%rdx), %rsi
addq %r12, %rsi
movl 0x80(%rdx), %eax
addl %r8d, %eax
cmpl 0x84(%rdx), %eax
jge 0xd1adf
leal 0x1(%r11), %eax
shrl $0x1f, %eax
leal (%r11,%rax), %ebx
incl %ebx
sarl %ebx
movq 0x30(%rsp), %r14
movq 0x8(%r14), %rdi
movq %r11, %rdx
callq 0x552d0
movq 0x10(%r14), %rdi
movslq %ebx, %rbx
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x552d0
movq 0x18(%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x552d0
movl 0x4(%rsp), %eax
decl %eax
jmp 0xd1b13
testb $0x1, %r8b
jne 0xd1b0f
movslq 0x18(%rdi), %rax
addq %rax, %r15
subq $0x8, %rsp
movq %rsi, %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r13, %rcx
movq %rbp, %r8
movq %r13, %r9
pushq %r11
pushq $0x0
pushq %r15
callq *0x40(%rsp)
addq $0x20, %rsp
movl 0x4(%rsp), %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq