// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movl (%rsi), %r12d
movl 0x4(%rsi), %r15d
testq %rdi, %rdi
je 0xcf2c5
xorl %eax, %eax
cmpl $0x0, 0x8(%r14)
setne %al
movl %eax, 0x74(%rbx)
je 0xcf2cc
movl 0x14(%r14), %edi
movl 0xc(%r14), %eax
movl 0x10(%r14), %esi
movl %eax, %ecx
andl $-0x2, %ecx
movl %esi, %r8d
andl $-0x2, %r8d
cmpl $0xb, %edx
cmovbl %eax, %ecx
cmovbl %esi, %r8d
movl 0x18(%r14), %esi
movl %r8d, %eax
orl %ecx, %eax
sets %al
testl %edi, %edi
setle %dl
testl %esi, %esi
setle %r9b
orb %dl, %r9b
orb %al, %r9b
movl %r12d, %eax
subl %ecx, %eax
setle %dl
cmpl %r12d, %edi
setg %r10b
orb %dl, %r10b
orb %r9b, %r10b
cmpl %edi, %eax
setl %al
movl %r15d, %edx
subl %r8d, %edx
setle %r9b
orb %al, %r9b
orb %r10b, %r9b
cmpl %r15d, %esi
setg %al
cmpl %esi, %edx
setl %dl
orb %al, %dl
orb %r9b, %dl
xorl %eax, %eax
testb $0x1, %dl
je 0xcf2d7
jmp 0xcf3ca
movl $0x0, 0x74(%rbx)
xorl %ecx, %ecx
xorl %r8d, %r8d
movl %r12d, %edi
movl %r15d, %esi
leal (%rdi,%rcx), %eax
leal (%rsi,%r8), %edx
movl %ecx, 0x78(%rbx)
movl %r8d, 0x80(%rbx)
movl %eax, 0x7c(%rbx)
movl %edx, 0x84(%rbx)
movl %edi, 0xc(%rbx)
movl %esi, 0x10(%rbx)
testq %r14, %r14
je 0xcf306
cmpl $0x0, 0x1c(%r14)
setne %al
jmp 0xcf308
xorl %eax, %eax
movzbl %al, %eax
movl %eax, 0x88(%rbx)
testb %al, %al
je 0xcf349
movl 0x20(%r14), %eax
leaq 0x4(%rsp), %rdx
movl %eax, (%rdx)
movl 0x24(%r14), %eax
movq %rsp, %rcx
movl %eax, (%rcx)
callq 0xcf7be
testl %eax, %eax
je 0xcf3c8
movl 0x4(%rsp), %eax
movl %eax, 0x8c(%rbx)
movl (%rsp), %eax
movl %eax, 0x90(%rbx)
xorl %ecx, %ecx
testq %r14, %r14
je 0xcf357
cmpl $0x0, (%r14)
setne %cl
movl %ecx, 0x70(%rbx)
movl $0x1, %eax
movl $0x1, %edx
testq %r14, %r14
je 0xcf373
xorl %edx, %edx
cmpl $0x0, 0x4(%r14)
sete %dl
movl %edx, 0x58(%rbx)
cmpl $0x0, 0x88(%rbx)
je 0xcf3ca
leal (%r12,%r12,2), %edx
leal (%r12,%r12,2), %esi
addl $0x3, %esi
testl %edx, %edx
cmovnsl %edx, %esi
sarl $0x2, %esi
xorl %edx, %edx
cmpl %esi, 0x8c(%rbx)
jge 0xcf3ba
leal (%r15,%r15,2), %edx
leal (%r15,%r15,2), %esi
addl $0x3, %esi
testl %edx, %edx
cmovnsl %edx, %esi
sarl $0x2, %esi
xorl %edx, %edx
cmpl %esi, 0x90(%rbx)
setl %dl
orl %ecx, %edx
movl %edx, 0x70(%rbx)
movl $0x0, 0x58(%rbx)
jmp 0xcf3ca
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq