// File: /workspace/github_c_makefile_star2_O1/enzo1982[P]smooth/libraries/libwebp/src/dec/buffer_dec.c
// Function: WebPAllocateDecBuffer
VP8StatusCode WebPAllocateDecBuffer(int width, int height,
                                    const WebPDecoderOptions* const options,
                                    WebPDecBuffer* const buffer) {
  VP8StatusCode status;
  if (buffer == NULL || width <= 0 || height <= 0) {
    return VP8_STATUS_INVALID_PARAM;
  }
  if (options != NULL) {    // First, apply options if there is any.
    if (options->use_cropping) {
      const int cw = options->crop_width;
      const int ch = options->crop_height;
      const int x = options->crop_left & ~1;
      const int y = options->crop_top & ~1;
      if (!WebPCheckCropDimensions(width, height, x, y, cw, ch)) {
        return VP8_STATUS_INVALID_PARAM;   // out of frame boundary.
      }
      width = cw;
      height = ch;
    }

    if (options->use_scaling) {
#if !defined(WEBP_REDUCE_SIZE)
      int scaled_width = options->scaled_width;
      int scaled_height = options->scaled_height;
      if (!WebPRescalerGetScaledDimensions(
              width, height, &scaled_width, &scaled_height)) {
        return VP8_STATUS_INVALID_PARAM;
      }
      width = scaled_width;
      height = scaled_height;
#else
      return VP8_STATUS_INVALID_PARAM;   // rescaling not supported
#endif
    }
  }
  buffer->width = width;
  buffer->height = height;

  // Then, allocate buffer for real.
  status = AllocateBuffer(buffer);
  if (status != VP8_STATUS_OK) return status;

  // Use the stride trick if vertical flip is needed.
  if (options != NULL && options->flip) {
    status = WebPFlipBuffer(buffer);
  }
  return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl $0x2, %ebp
testl %esi, %esi
jle 0xcdf4f
movl %edi, %r12d
testl %edi, %edi
jle 0xcdf4f
movq %rcx, %rbx
testq %rcx, %rcx
je 0xcdf4f
movq %rdx, %r14
movl %esi, %r15d
testq %rdx, %rdx
je 0xcddc8
cmpl $0x0, 0x8(%r14)
je 0xcdd8c
movl 0x14(%r14), %r13d
movq %rbx, 0x8(%rsp)
movl 0x18(%r14), %ebx
movl 0xc(%r14), %edx
movl 0x10(%r14), %ecx
andl $-0x2, %edx
andl $-0x2, %ecx
movl %r12d, %edi
movl %r15d, %esi
movl %r13d, %r8d
movl %ebx, %r9d
callq 0xcf1b9
testl %eax, %eax
cmovnel %ebx, %r15d
movq 0x8(%rsp), %rbx
cmovnel %r13d, %r12d
je 0xcdf4f
cmpl $0x0, 0x1c(%r14)
je 0xcddc8
movl 0x20(%r14), %eax
leaq 0x14(%rsp), %rdx
movl %eax, (%rdx)
movl 0x24(%r14), %eax
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
movl %r12d, %edi
movl %r15d, %esi
callq 0xcf7be
testl %eax, %eax
je 0xcddc2
movl 0x10(%rsp), %r15d
movl 0x14(%rsp), %r12d
je 0xcdf4f
movl %r12d, 0x4(%rbx)
movl %r15d, 0x8(%rbx)
movl (%rbx), %eax
testl %r12d, %r12d
setle %cl
testl %r15d, %r15d
setle %dl
orb %cl, %dl
cmpl $0xd, %eax
setae %cl
orb %dl, %cl
movl $0x2, %ebp
jne 0xcdf2b
cmpl $0x0, 0xc(%rbx)
jg 0xcdf21
cmpq $0x0, 0x70(%rbx)
jne 0xcdf21
movq %rbx, 0x8(%rsp)
movl %eax, %ebp
movl %r12d, %r13d
leaq 0x5b884(%rip), %rax     # 0x12969d
movzbl (%rbp,%rax), %ebx
movq %rbx, %rax
imulq %r13, %rax
xorl %ecx, %ecx
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
jbe 0xcde39
movl $0x2, %ebp
jmp 0xcdf18
imull %r12d, %ebx
movl %r15d, %eax
movq %rbx, %rcx
imulq %rax, %rcx
cmpl $0xb, %ebp
jb 0xcde7e
leal 0x1(%r12), %edx
shrl %edx
incl %r15d
shrl %r15d
movq %rdx, 0x18(%rsp)
imulq %rdx, %r15
imulq %rax, %r13
xorl %eax, %eax
cmpl $0xc, %ebp
cmovneq %rax, %r13
cmpq $0xc, %rbp
cmovel %r12d, %eax
movq %rax, 0x20(%rsp)
jmp 0xcde96
movq $0x0, 0x20(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
movq %rcx, %r12
leaq (%rcx,%r13), %rax
leaq (%rax,%r15,2), %rdi
movl $0x1, %esi
callq 0x56b20
testq %rax, %rax
je 0xcdf11
movq 0x8(%rsp), %rdx
movq %rax, 0x70(%rdx)
movq %rax, 0x10(%rdx)
cmpl $0xb, %ebp
jb 0xcdf60
movl %ebx, 0x30(%rdx)
movq %r12, 0x40(%rdx)
addq %r12, %rax
movq %rax, 0x18(%rdx)
movq 0x18(%rsp), %rsi
movl %esi, 0x34(%rdx)
movq %r15, 0x48(%rdx)
leaq (%rax,%r15), %rcx
movq %rcx, 0x20(%rdx)
movl %esi, 0x38(%rdx)
movq %r15, 0x50(%rdx)
cmpl $0xc, %ebp
movq %rdx, %rbx
jne 0xcdf01
addq %r15, %r15
addq %r15, %rax
movq %rax, 0x28(%rbx)
movq %r13, 0x58(%rbx)
movq 0x20(%rsp), %rax
movl %eax, 0x3c(%rbx)
movb $0x1, %cl
jmp 0xcdf1d
movl $0x1, %ebp
xorl %ecx, %ecx
movq 0x8(%rsp), %rbx
testb %cl, %cl
je 0xcdf2b
movq %rbx, %rdi
callq 0xce1da
movl %eax, %ebp
testq %r14, %r14
sete %al
testl %ebp, %ebp
setne %cl
orb %al, %cl
jne 0xcdf4f
cmpl $0x0, 0x30(%r14)
je 0xcdf4d
movq %rbx, %rdi
callq 0xcdc6c
movl %eax, %ebp
jmp 0xcdf4f
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebx, 0x18(%rdx)
movq %r12, 0x20(%rdx)
movb $0x1, %cl
movq %rdx, %rbx
jmp 0xcdf1d