// File: /workspace/github_c_makefile_star2_O1/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), %edx
cmpq $0xc, %rdx
jbe 0xce1e9
xorl %esi, %esi
jmp 0xce350
movslq 0x4(%rdi), %rax
movslq 0x8(%rdi), %rcx
cmpl $0xb, %edx
jb 0xce306
pushq %rbp
pushq %r14
pushq %rbx
leal 0x1(%rax), %esi
shrl $0x1f, %esi
leal (%rax,%rsi), %r10d
incl %r10d
sarl %r10d
leal 0x1(%rcx), %esi
shrl $0x1f, %esi
leal (%rcx,%rsi), %r11d
incl %r11d
sarl %r11d
movl 0x30(%rdi), %esi
movl 0x34(%rdi), %r9d
movl %esi, %r8d
negl %r8d
cmovsl %esi, %r8d
movl %r9d, %esi
negl %esi
cmovsl %r9d, %esi
movl 0x38(%rdi), %ebx
movl %ebx, %r9d
negl %r9d
cmovsl %ebx, %r9d
decq %rcx
movq %r8, %rbx
imulq %rcx, %rbx
addq %rax, %rbx
decl %r11d
movslq %r11d, %r11
movq %rsi, %r14
imulq %r11, %r14
movslq %r10d, %r10
addq %r10, %r14
imulq %r9, %r11
addq %r10, %r11
cmpq 0x40(%rdi), %rbx
setbe %bl
cmpq 0x48(%rdi), %r14
setbe %bpl
andb %bl, %bpl
cmpq 0x50(%rdi), %r11
setbe %r11b
cmpl %eax, %r8d
setge %r8b
andb %r11b, %r8b
andb %bpl, %r8b
cmpl %r10d, %esi
setge %sil
cmpl %r10d, %r9d
setge %r9b
andb %sil, %r9b
cmpq $0x0, 0x10(%rdi)
setne %sil
andb %r9b, %sil
cmpq $0x0, 0x18(%rdi)
setne %r9b
andb %sil, %r9b
cmpq $0x0, 0x20(%rdi)
setne %sil
andb %r9b, %sil
andb %r8b, %sil
cmpl $0xc, %edx
popq %rbx
popq %r14
popq %rbp
jne 0xce350
movl 0x3c(%rdi), %edx
movl %edx, %r8d
negl %r8d
cmovsl %edx, %r8d
imulq %r8, %rcx
addq %rax, %rcx
cmpl %eax, %r8d
setge %al
cmpq 0x58(%rdi), %rcx
setbe %cl
cmpq $0x0, 0x28(%rdi)
setne %dl
andb %al, %dl
andb %cl, %dl
andb %dl, %sil
jmp 0xce350
movl 0x18(%rdi), %esi
movl %esi, %r8d
negl %r8d
cmovsl %esi, %r8d
decl %ecx
movslq %ecx, %rcx
imulq %r8, %rcx
leaq 0x5b37a(%rip), %rsi     # 0x12969d
movzbl (%rdx,%rsi), %edx
movq %rax, %rsi
imulq %rdx, %rsi
addq %rcx, %rsi
cmpq 0x20(%rdi), %rsi
setbe %cl
imull %eax, %edx
cmpl %edx, %r8d
setge %al
cmpq $0x0, 0x10(%rdi)
setne %sil
andb %al, %sil
andb %cl, %sil
xorb $0x1, %sil
movzbl %sil, %eax
addl %eax, %eax
retq