// File: /workspace/github_c_makefile_star2_O2/enzo1982[P]smooth/libraries/libwebp/src/dec/webp_dec.c
// Function: WebPIoInitFromOptions
int WebPIoInitFromOptions(const WebPDecoderOptions* const options,
                          VP8Io* const io, WEBP_CSP_MODE src_colorspace) {
  const int W = io->width;
  const int H = io->height;
  int x = 0, y = 0, w = W, h = H;

  // Cropping
  io->use_cropping = (options != NULL) && options->use_cropping;
  if (io->use_cropping) {
    w = options->crop_width;
    h = options->crop_height;
    x = options->crop_left;
    y = options->crop_top;
    if (!WebPIsRGBMode(src_colorspace)) {   // only snap for YUV420
      x &= ~1;
      y &= ~1;
    }
    if (!WebPCheckCropDimensions(W, H, x, y, w, h)) {
      return 0;  // out of frame boundary error
    }
  }
  io->crop_left   = x;
  io->crop_top    = y;
  io->crop_right  = x + w;
  io->crop_bottom = y + h;
  io->mb_w = w;
  io->mb_h = h;

  // Scaling
  io->use_scaling = (options != NULL) && options->use_scaling;
  if (io->use_scaling) {
    int scaled_width = options->scaled_width;
    int scaled_height = options->scaled_height;
    if (!WebPRescalerGetScaledDimensions(w, h, &scaled_width, &scaled_height)) {
      return 0;
    }
    io->scaled_width = scaled_width;
    io->scaled_height = scaled_height;
  }

  // Filter
  io->bypass_filtering = (options != NULL) && options->bypass_filtering;

  // Fancy upsampler
#ifdef FANCY_UPSAMPLING
  io->fancy_upsampling = (options == NULL) || (!options->no_fancy_upsampling);
#endif

  if (io->use_scaling) {
    // disable filter (only for large downscaling ratio).
    io->bypass_filtering |= (io->scaled_width < W * 3 / 4) &&
                            (io->scaled_height < H * 3 / 4);
    io->fancy_upsampling = 0;
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r12
movl (%rsi), %r13d
movl 0x4(%rsi), %esi
testq %rdi, %rdi
je 0xc77b6
xorl %eax, %eax
cmpl $0x0, 0x8(%r12)
setne %al
movl %eax, 0x74(%rbx)
je 0xc77ba
movl 0x14(%r12), %r8d
movq %r8, 0x8(%rsp)
movl 0x18(%r12), %ebp
movl 0xc(%r12), %eax
movl 0x10(%r12), %ecx
movl %eax, %r14d
andl $-0x2, %r14d
movl %ecx, %r15d
andl $-0x2, %r15d
cmpl $0xb, %edx
cmovbl %eax, %r14d
cmovbl %ecx, %r15d
movl %r13d, %edi
movl %r14d, %edx
movl %r15d, %ecx
movq %rsi, 0x10(%rsp)
movl %ebp, %r9d
callq 0xc76d6
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
testl %eax, %eax
jne 0xc77c5
jmp 0xc785c
andl $0x0, 0x74(%rbx)
xorl %r14d, %r14d
xorl %r15d, %r15d
movl %r13d, %edi
movl %esi, %ebp
leal (%rdi,%r14), %eax
leal (%r15,%rbp), %ecx
movl %r14d, 0x78(%rbx)
movl %r15d, 0x80(%rbx)
movl %eax, 0x7c(%rbx)
movl %ecx, 0x84(%rbx)
movl %edi, 0xc(%rbx)
movl %ebp, 0x10(%rbx)
testq %r12, %r12
je 0xc7845
xorl %eax, %eax
cmpl $0x0, 0x1c(%r12)
setne %al
movl %eax, 0x88(%rbx)
je 0xc7860
movq %rsi, %r14
movl 0x20(%r12), %eax
leaq 0x4(%rsp), %rdx
movl %eax, (%rdx)
movl 0x24(%r12), %eax
movq %rsp, %rcx
movl %eax, (%rcx)
movl %ebp, %esi
callq 0xc79e5
testl %eax, %eax
je 0xc785c
movl 0x4(%rsp), %eax
movl %eax, 0x8c(%rbx)
movl (%rsp), %eax
movl %eax, 0x90(%rbx)
cmpl $0x0, 0x88(%rbx)
sete %al
movq %r14, %rsi
jmp 0xc7862
andl $0x0, 0x88(%rbx)
andl $0x0, 0x70(%rbx)
movl $0x1, 0x58(%rbx)
pushq $0x1
popq %rcx
jmp 0xc78bf
xorl %ecx, %ecx
jmp 0xc78bf
movb $0x1, %al
xorl %r9d, %r9d
cmpl $0x0, (%r12)
setne %r9b
movl %r9d, 0x70(%rbx)
xorl %ecx, %ecx
cmpl $0x0, 0x4(%r12)
sete %cl
movl %ecx, 0x58(%rbx)
pushq $0x1
popq %rcx
testb %al, %al
jne 0xc78bf
movl 0x8c(%rbx), %r8d
leal (%r13,%r13,2), %eax
pushq $0x4
popq %rdi
cltd
idivl %edi
xorl %edx, %edx
cmpl %eax, %r8d
jge 0xc78b5
movl 0x90(%rbx), %r8d
leal (%rsi,%rsi,2), %eax
cltd
idivl %edi
xorl %edx, %edx
cmpl %eax, %r8d
setl %dl
orl %r9d, %edx
movl %edx, 0x70(%rbx)
andl $0x0, 0x58(%rbx)
movl %ecx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq