// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dec/buffer_dec.c
// Function: CheckDecBuffer
static VP8StatusCode CheckDecBuffer(const WebPDecBuffer* const buffer) {
  int ok = 1;
  const WEBP_CSP_MODE mode = buffer->colorspace;
  const int width = buffer->width;
  const int height = buffer->height;
  if (!IsValidColorspace(mode)) {
    ok = 0;
  } else if (!WebPIsRGBMode(mode)) {   // YUV checks
    const WebPYUVABuffer* const buf = &buffer->u.YUVA;
    const int uv_width  = (width  + 1) / 2;
    const int uv_height = (height + 1) / 2;
    const int y_stride = abs(buf->y_stride);
    const int u_stride = abs(buf->u_stride);
    const int v_stride = abs(buf->v_stride);
    const int a_stride = abs(buf->a_stride);
    const uint64_t y_size = MIN_BUFFER_SIZE(width, height, y_stride);
    const uint64_t u_size = MIN_BUFFER_SIZE(uv_width, uv_height, u_stride);
    const uint64_t v_size = MIN_BUFFER_SIZE(uv_width, uv_height, v_stride);
    const uint64_t a_size = MIN_BUFFER_SIZE(width, height, a_stride);
    ok &= (y_size <= buf->y_size);
    ok &= (u_size <= buf->u_size);
    ok &= (v_size <= buf->v_size);
    ok &= (y_stride >= width);
    ok &= (u_stride >= uv_width);
    ok &= (v_stride >= uv_width);
    ok &= (buf->y != NULL);
    ok &= (buf->u != NULL);
    ok &= (buf->v != NULL);
    if (mode == MODE_YUVA) {
      ok &= (a_stride >= width);
      ok &= (a_size <= buf->a_size);
      ok &= (buf->a != NULL);
    }
  } else {    // RGB checks
    const WebPRGBABuffer* const buf = &buffer->u.RGBA;
    const int stride = abs(buf->stride);
    const uint64_t size =
        MIN_BUFFER_SIZE((uint64_t)width * kModeBpp[mode], height, stride);
    ok &= (size <= buf->size);
    ok &= (stride >= width * kModeBpp[mode]);
    ok &= (buf->rgba != NULL);
  }
  return ok ? VP8_STATUS_OK : VP8_STATUS_INVALID_PARAM;
}

// Assembly:
movl (%rdi), %esi
movl $0x2, %eax
cmpq $0xc, %rsi
ja 0xcd520
movslq 0x4(%rdi), %rcx
movslq 0x8(%rdi), %rdx
cmpl $0xb, %esi
jb 0xcd4d3
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
leal 0x1(%rcx), %r8d
shrl $0x1f, %r8d
leal (%rcx,%r8), %r11d
incl %r11d
sarl %r11d
leal 0x1(%rdx), %r8d
shrl $0x1f, %r8d
leal (%rdx,%r8), %ebx
incl %ebx
sarl %ebx
movl 0x30(%rdi), %r8d
movl 0x34(%rdi), %r10d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
movl %r10d, %r8d
negl %r8d
cmovsl %r10d, %r8d
movl 0x38(%rdi), %ebp
movl %ebp, %r10d
negl %r10d
cmovsl %ebp, %r10d
decq %rdx
movq %r9, %r14
imulq %rdx, %r14
addq %rcx, %r14
decl %ebx
movslq %ebx, %rbx
movq %r8, %r15
imulq %rbx, %r15
movslq %r11d, %r11
addq %r11, %r15
imulq %r10, %rbx
addq %r11, %rbx
cmpq 0x40(%rdi), %r14
setbe %bpl
cmpq 0x48(%rdi), %r15
setbe %r14b
andb %bpl, %r14b
cmpq 0x50(%rdi), %rbx
setbe %bl
cmpl %ecx, %r9d
setge %r9b
andb %bl, %r9b
andb %r14b, %r9b
cmpl %r11d, %r8d
setge %r8b
cmpl %r11d, %r10d
setge %r10b
andb %r8b, %r10b
cmpq $0x0, 0x10(%rdi)
setne %r8b
andb %r10b, %r8b
cmpq $0x0, 0x18(%rdi)
setne %r10b
andb %r8b, %r10b
cmpq $0x0, 0x20(%rdi)
setne %r8b
andb %r10b, %r8b
andb %r9b, %r8b
cmpl $0xc, %esi
popq %rbx
popq %r14
popq %r15
popq %rbp
jne 0xcd4cb
movl 0x3c(%rdi), %esi
movl %esi, %r9d
negl %r9d
cmovsl %esi, %r9d
imulq %r9, %rdx
addq %rcx, %rdx
cmpl %ecx, %r9d
setge %cl
cmpq 0x58(%rdi), %rdx
setbe %dl
cmpq $0x0, 0x28(%rdi)
setne %sil
andb %cl, %sil
andb %dl, %sil
andb %sil, %r8b
testb $0x1, %r8b
jne 0xcd51e
jmp 0xcd520
movl 0x18(%rdi), %r8d
movl %r8d, %r9d
negl %r9d
cmovsl %r8d, %r9d
decl %edx
movslq %edx, %rdx
imulq %r9, %rdx
leaq 0x5b3cc(%rip), %r8      # 0x1288bd
movzbl (%rsi,%r8), %esi
movq %rcx, %r8
imulq %rsi, %r8
addq %rdx, %r8
cmpq 0x20(%rdi), %r8
setbe %dl
imull %ecx, %esi
cmpl %esi, %r9d
setge %cl
andb %dl, %cl
cmpq $0x0, 0x10(%rdi)
setne %dl
testb %cl, %dl
je 0xcd520
xorl %eax, %eax
retq