// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x2
popq %rbp
testl %esi, %esi
jle 0xc650c
testl %edi, %edi
jle 0xc650c
movq %rcx, %rbx
testq %rcx, %rcx
je 0xc650c
movq %rdx, %r14
movl %esi, %r15d
testq %rdx, %rdx
je 0xc63a8
cmpl $0x0, 0x8(%r14)
je 0xc6372
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 0xc76d6
movl %r13d, %r15d
movl %r12d, %edi
testl %eax, %eax
je 0xc650c
cmpl $0x0, 0x1c(%r14)
je 0xc63a8
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 0xc79e5
testl %eax, %eax
je 0xc650c
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 0xc650c
cmpl $0x0, 0xc(%rbx)
jg 0xc63d9
cmpq $0x0, 0x70(%rbx)
je 0xc6415
testq %r14, %r14
sete %r15b
movq %rbx, %rdi
callq 0xc6776
movl %eax, %ebp
testl %eax, %eax
setne %al
orb %r15b, %al
jne 0xc650c
cmpl $0x0, 0x30(%r14)
je 0xc640e
movq %rbx, %rdi
callq 0xc626c
movl %eax, %ebp
jmp 0xc650c
xorl %ebp, %ebp
jmp 0xc650c
movl %eax, %ecx
movl %edi, %r12d
leaq 0x5231c(%rip), %rax     # 0x11873d
movzbl (%rcx,%rax), %r13d
movq %r13, %rax
imulq %r12, %rax
cmpq $0x7fffffff, %rax       # imm = 0x7FFFFFFF
ja 0xc650c
imull %edi, %r13d
movl %r15d, %eax
movq %r13, %rbp
imulq %rax, %rbp
cmpl $0xb, %ecx
movq %rcx, 0x20(%rsp)
jb 0xc6480
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 0xc6498
xorl %r12d, %r12d
xorl %r15d, %r15d
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
leaq (%r12,%rbp), %rax
leaq (%rax,%r15,2), %rdi
pushq $0x1
popq %rsi
callq 0x57c90
testq %rax, %rax
je 0xc6509
movq %rax, 0x70(%rbx)
movq %rax, 0x10(%rbx)
movq 0x20(%rsp), %rdx
cmpl $0xb, %edx
jb 0xc651d
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 0xc64f8
addq %r15, %r15
addq %r15, %rax
movq %rax, 0x28(%rbx)
movq %r12, 0x58(%rbx)
movq 0x18(%rsp), %rax
movl %eax, 0x3c(%rbx)
jmp 0xc63d9
pushq $0x1
popq %rbp
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 0xc63d9