// File: /workspace/github_c_makefile_star2_O3/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 0xcd104
testl %edi, %edi
jle 0xcd104
movq %rcx, %rbx
testq %rcx, %rcx
je 0xcd104
movq %rdx, %r14
movl %esi, %r15d
testq %rdx, %rdx
je 0xccf9c
cmpl $0x0, 0x8(%r14)
je 0xccf66
movl 0x14(%r14), %r12d
movl 0x18(%r14), %r13d
movl 0xc(%r14), %edx
movl 0x10(%r14), %ecx
andl $-0x2, %edx
andl $-0x2, %ecx
movl %r15d, %esi
movl %r12d, %r8d
movl %r13d, %r9d
callq 0xce2af
movl %r13d, %r15d
movl %r12d, %edi
testl %eax, %eax
je 0xcd104
cmpl $0x0, 0x1c(%r14)
je 0xccf9c
movl 0x20(%r14), %eax
leaq 0xc(%rsp), %rdx
movl %eax, (%rdx)
movl 0x24(%r14), %eax
leaq 0x8(%rsp), %rcx
movl %eax, (%rcx)
movl %r15d, %esi
callq 0xce882
testl %eax, %eax
je 0xcd104
movl 0xc(%rsp), %edi
movl 0x8(%rsp), %r15d
movl %edi, 0x4(%rbx)
movl %r15d, 0x8(%rbx)
movl (%rbx), %eax
testl %edi, %edi
setle %cl
testl %r15d, %r15d
setle %dl
orb %cl, %dl
cmpl $0xd, %eax
setae %cl
orb %dl, %cl
jne 0xcd104
cmpl $0x0, 0xc(%rbx)
jg 0xccfcd
cmpq $0x0, 0x70(%rbx)
je 0xcd009
testq %r14, %r14
sete %r15b
movq %rbx, %rdi
callq 0xcd395
movl %eax, %ebp
testl %eax, %eax
setne %al
orb %r15b, %al
jne 0xcd104
cmpl $0x0, 0x30(%r14)
je 0xcd002
movq %rbx, %rdi
callq 0xcce5c
movl %eax, %ebp
jmp 0xcd104
xorl %ebp, %ebp
jmp 0xcd104
movl %eax, %ecx
movl %edi, %r12d
leaq 0x5b8a8(%rip), %rax     # 0x1288bd
movzbl (%rcx,%rax), %r13d
movq %r13, %rax
imulq %r12, %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0xcd104
imull %edi, %r13d
movl %r15d, %eax
movq %r13, %rbp
imulq %rax, %rbp
cmpl $0xb, %ecx
movq %rcx, 0x20(%rsp)
jb 0xcd074
leal 0x1(%rdi), %edx
shrl %edx
incl %r15d
shrl %r15d
movq %rdx, 0x10(%rsp)
imulq %rdx, %r15
imulq %rax, %r12
xorl %eax, %eax
cmpl $0xc, %ecx
cmovneq %rax, %r12
cmpq $0xc, %rcx
cmovel %edi, %eax
movq %rax, 0x18(%rsp)
jmp 0xcd08c
xorl %r12d, %r12d
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
leaq (%r12,%rbp), %rax
leaq (%rax,%r15,2), %rdi
movl $0x1, %esi
callq 0x56b20
testq %rax, %rax
je 0xcd0ff
movq %rax, 0x70(%rbx)
movq %rax, 0x10(%rbx)
movq 0x20(%rsp), %rdx
cmpl $0xb, %edx
jb 0xcd115
movl %r13d, 0x30(%rbx)
movq %rbp, 0x40(%rbx)
addq %rbp, %rax
movq %rax, 0x18(%rbx)
movq 0x10(%rsp), %rsi
movl %esi, 0x34(%rbx)
movq %r15, 0x48(%rbx)
leaq (%rax,%r15), %rcx
movq %rcx, 0x20(%rbx)
movl %esi, 0x38(%rbx)
movq %r15, 0x50(%rbx)
cmpl $0xc, %edx
jne 0xcd0ee
addq %r15, %r15
addq %r15, %rax
movq %rax, 0x28(%rbx)
movq %r12, 0x58(%rbx)
movq 0x18(%rsp), %rax
movl %eax, 0x3c(%rbx)
jmp 0xccfcd
movl $0x1, %ebp
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r13d, 0x18(%rbx)
movq %rbp, 0x20(%rbx)
jmp 0xccfcd