// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/io_dec.c
// Function: InitYUVRescaler
static int InitYUVRescaler(const VP8Io* const io, WebPDecParams* const p) {
  const int has_alpha = WebPIsAlphaMode(p->output->colorspace);
  const WebPYUVABuffer* const buf = &p->output->u.YUVA;
  const int out_width  = io->scaled_width;
  const int out_height = io->scaled_height;
  const int uv_out_width  = (out_width + 1) >> 1;
  const int uv_out_height = (out_height + 1) >> 1;
  const int uv_in_width  = (io->mb_w + 1) >> 1;
  const int uv_in_height = (io->mb_h + 1) >> 1;
  // scratch memory for luma rescaler
  const size_t work_size = 2 * (size_t)out_width;
  const size_t uv_work_size = 2 * uv_out_width;  // and for each u/v ones
  uint64_t total_size;
  size_t rescaler_size;
  rescaler_t* work;
  WebPRescaler* scalers;
  const int num_rescalers = has_alpha ? 4 : 3;

  total_size = ((uint64_t)work_size + 2 * uv_work_size) * sizeof(*work);
  if (has_alpha) {
    total_size += (uint64_t)work_size * sizeof(*work);
  }
  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;

  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,
                        buf->y, out_width, out_height, buf->y_stride, 1,
                        work) ||
      !WebPRescalerInit(p->scaler_u, uv_in_width, uv_in_height,
                        buf->u, uv_out_width, uv_out_height, buf->u_stride, 1,
                        work + work_size) ||
      !WebPRescalerInit(p->scaler_v, uv_in_width, uv_in_height,
                        buf->v, uv_out_width, uv_out_height, buf->v_stride, 1,
                        work + work_size + uv_work_size)) {
    return 0;
  }
  p->emit = EmitRescaledYUV;

  if (has_alpha) {
    if (!WebPRescalerInit(p->scaler_a, io->mb_w, io->mb_h,
                          buf->a, out_width, out_height, buf->a_stride, 1,
                          work + work_size + 2 * uv_work_size)) {
      return 0;
    }
    p->emit_alpha = EmitRescaledAlphaYUV;
    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 -0x18(%rbp), %rax
movq (%rax), %rax
addq $0x10, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl 0x8c(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movl 0x90(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
movl 0x10(%rax), %eax
addl $0x1, %eax
sarl %eax
movl %eax, -0x40(%rbp)
movslq -0x2c(%rbp), %rax
shlq %rax
movq %rax, -0x48(%rbp)
movl -0x34(%rbp), %eax
shll %eax
cltq
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %edx
movl $0x3, %eax
movl $0x4, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x74(%rbp)
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
shlq %rcx
addq %rcx, %rax
shlq $0x2, %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x140b09
movq -0x48(%rbp), %rax
shlq $0x2, %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movslq -0x74(%rbp), %rax
imulq $0x68, %rax, %rax
addq $0x1f, %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
addq -0x58(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x141730
cmpl $0x0, %eax
jne 0x140b3f
movl $0x0, -0x4(%rbp)
jmp 0x140d9b
movq -0x58(%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 0x140b6f
movl $0x0, -0x4(%rbp)
jmp 0x140d9b
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq -0x58(%rbp), %rax
xorl %ecx, %ecx
subq -0x60(%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 0x140bdd
movq -0x70(%rbp), %rax
addq $0x138, %rax            # imm = 0x138
movq %rax, -0x80(%rbp)
jmp 0x140be5
xorl %eax, %eax
movq %rax, -0x80(%rbp)
jmp 0x140be5
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 -0x28(%rbp), %rax
movq (%rax), %rcx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
movq -0x28(%rbp), %rax
movl 0x20(%rax), %r10d
movq -0x68(%rbp), %rax
movl %r10d, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
je 0x140cec
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movl -0x3c(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rcx
movl -0x34(%rbp), %r8d
movl -0x38(%rbp), %r9d
movq -0x28(%rbp), %rax
movl 0x24(%rax), %r10d
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %r11
shlq $0x2, %r11
addq %r11, %rax
movl %r10d, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
je 0x140cec
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movl -0x3c(%rbp), %esi
movl -0x40(%rbp), %edx
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movl -0x34(%rbp), %r8d
movl -0x38(%rbp), %r9d
movq -0x28(%rbp), %rax
movl 0x28(%rax), %r10d
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %r11
shlq $0x2, %r11
addq %r11, %rax
movq -0x50(%rbp), %r11
shlq $0x2, %r11
addq %r11, %rax
movl %r10d, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
jne 0x140cf8
movl $0x0, -0x4(%rbp)
jmp 0x140d9b
movq -0x18(%rbp), %rax
leaq 0x11fd(%rip), %rcx      # 0x141f00
movq %rcx, 0x58(%rax)
cmpl $0x0, -0x1c(%rbp)
je 0x140d94
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 -0x28(%rbp), %rax
movq 0x18(%rax), %rcx
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
movq -0x28(%rbp), %rax
movl 0x2c(%rax), %r10d
movq -0x68(%rbp), %rax
movq -0x48(%rbp), %r11
shlq $0x2, %r11
addq %r11, %rax
movq -0x50(%rbp), %r11
shlq %r11
shlq $0x2, %r11
addq %r11, %rax
movl %r10d, (%rsp)
movl $0x1, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x13d3b0
cmpl $0x0, %eax
jne 0x140d80
movl $0x0, -0x4(%rbp)
jmp 0x140d9b
movq -0x18(%rbp), %rax
leaq 0x1275(%rip), %rcx      # 0x142000
movq %rcx, 0x60(%rax)
callq 0x1493b0
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)