// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/io_dec.c
// Function: InitRGBRescaler
static int InitRGBRescaler(const VP8Io* const io, WebPDecParams* const p) {
  const int has_alpha = WebPIsAlphaMode(p->output->colorspace);
  const int out_width  = io->scaled_width;
  const int out_height = io->scaled_height;
  const int uv_in_width  = (io->mb_w + 1) >> 1;
  const int uv_in_height = (io->mb_h + 1) >> 1;
  // scratch memory for one rescaler
  const size_t work_size = 2 * (size_t)out_width;
  rescaler_t* work;  // rescalers work area
  uint8_t* tmp;   // tmp storage for scaled YUV444 samples before RGB conversion
  uint64_t tmp_size1, tmp_size2, total_size;
  size_t rescaler_size;
  WebPRescaler* scalers;
  const int num_rescalers = has_alpha ? 4 : 3;

  tmp_size1 = (uint64_t)num_rescalers * work_size;
  tmp_size2 = (uint64_t)num_rescalers * out_width;
  total_size = tmp_size1 * sizeof(*work) + tmp_size2 * sizeof(*tmp);
  rescaler_size = num_rescalers * sizeof(*p->scaler_y) + WEBP_ALIGN_CST;
  total_size += rescaler_size;
  if (!CheckSizeOverflow(total_size)) {
    return 0;
  }

  p->memory = WebPSafeMalloc(1ULL, (size_t)total_size);
  if (p->memory == NULL) {
    return 0;   // memory error
  }
  work = (rescaler_t*)p->memory;
  tmp = (uint8_t*)(work + tmp_size1);

  scalers = (WebPRescaler*)WEBP_ALIGN(
      (const uint8_t*)work + total_size - rescaler_size);
  p->scaler_y = &scalers[0];
  p->scaler_u = &scalers[1];
  p->scaler_v = &scalers[2];
  p->scaler_a = has_alpha ? &scalers[3] : NULL;

  if (!WebPRescalerInit(p->scaler_y, io->mb_w, io->mb_h,
                        tmp + 0 * out_width, out_width, out_height, 0, 1,
                        work + 0 * work_size) ||
      !WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
                        tmp + 1 * out_width, out_width, out_height, 0, 1,
                        work + 1 * work_size) ||
      !WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
                        tmp + 2 * out_width, out_width, out_height, 0, 1,
                        work + 2 * work_size)) {
    return 0;
  }
  p->emit = EmitRescaledRGB;
  WebPInitYUV444Converters();

  if (has_alpha) {
    if (!WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
                          tmp + 3 * out_width, out_width, out_height, 0, 1,
                          work + 3 * work_size)) {
      return 0;
    }
    p->emit_alpha = EmitRescaledAlphaRGB;
    if (p->output->colorspace == MODE_RGBA_4444 ||
        p->output->colorspace == MODE_rgbA_4444) {
      p->emit_alpha_row = ExportAlphaRGBA4444;
    } else {
      p->emit_alpha_row = ExportAlpha;
    }
    WebPInitAlphaProcessing();
  }
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movl (%rax), %edi
callq 0x1405d0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movl 0x8c(%rax), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x2c(%rbp)
movslq -0x20(%rbp), %rax
shlq %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %edx
movl $0x3, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x74(%rbp)
movslq -0x74(%rbp), %rax
imulq -0x38(%rbp), %rax
movq %rax, -0x50(%rbp)
movslq -0x74(%rbp), %rax
movslq -0x20(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
shlq $0x2, %rax
movq -0x58(%rbp), %rcx
shlq $0x0, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movslq -0x74(%rbp), %rax
imulq $0x68, %rax, %rax
addq $0x1f, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x141730
cmpl $0x0, %eax
jne 0x140767
movl $0x0, -0x4(%rbp)
jmp 0x140a1e
movq -0x60(%rbp), %rsi
movl $0x1, %edi
callq 0x5b060
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x50(%rax)
jne 0x140797
movl $0x0, -0x4(%rbp)
jmp 0x140a1e
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
addq -0x60(%rbp), %rax
xorl %ecx, %ecx
subq -0x68(%rbp), %rcx
addq %rcx, %rax
addq $0x1f, %rax
andq $-0x20, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x70(%rbp), %rcx
addq $0x68, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x70(%rbp), %rcx
addq $0xd0, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x40(%rax)
cmpl $0x0, -0x1c(%rbp)
je 0x140818
movq -0x70(%rbp), %rax
addq $0x138, %rax            # imm = 0x138
movq %rax, -0x80(%rbp)
jmp 0x140820
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x140820
movq -0x80(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x48(%rbp), %rcx
imull $0x0, -0x20(%rbp), %eax
cltq
addq %rax, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x40(%rbp), %rax
imulq $0x0, -0x38(%rbp), %r10
shlq $0x2, %r10
addq %r10, %rax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
je 0x14093c
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %rcx
movl -0x20(%rbp), %eax
shll $0x0, %eax
cltq
addq %rax, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %r10
shlq $0x0, %r10
shlq $0x2, %r10
addq %r10, %rax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
je 0x14093c
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
movq -0x48(%rbp), %rcx
movl -0x20(%rbp), %eax
shll %eax
cltq
addq %rax, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %r10
shlq %r10
shlq $0x2, %r10
addq %r10, %rax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
jne 0x140948
movl $0x0, -0x4(%rbp)
jmp 0x140a1e
movq -0x18(%rbp), %rax
leaq 0xdfd(%rip), %rcx       # 0x141750
movq %rcx, 0x58(%rax)
callq 0x151b50
cmpl $0x0, -0x1c(%rbp)
je 0x140a17
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
movq -0x10(%rbp), %rax
movl 0x10(%rax), %edx
movq -0x48(%rbp), %rcx
imull $0x3, -0x20(%rbp), %eax
cltq
addq %rax, %rcx
movl -0x20(%rbp), %r8d
movl -0x24(%rbp), %r9d
movq -0x40(%rbp), %rax
imulq $0x3, -0x38(%rbp), %r10
shlq $0x2, %r10
addq %r10, %rax
xorl %r10d, %r10d
movl $0x0, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
jne 0x1409cb
movl $0x0, -0x4(%rbp)
jmp 0x140a1e
movq -0x18(%rbp), %rax
leaq 0xeea(%rip), %rcx       # 0x1418c0
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0x5, (%rax)
je 0x1409f2
movq -0x18(%rbp), %rax
movq (%rax), %rax
cmpl $0xa, (%rax)
jne 0x140a03
movq -0x18(%rbp), %rax
leaq 0xfa3(%rip), %rcx       # 0x1419a0
movq %rcx, 0x68(%rax)
jmp 0x140a12
movq -0x18(%rbp), %rax
leaq 0x1142(%rip), %rcx      # 0x141b50
movq %rcx, 0x68(%rax)
callq 0x1493b0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)