// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/vp8_dec.c
// Function: VP8GetHeaders
int VP8GetHeaders(VP8Decoder* const dec, VP8Io* const io) {
  const uint8_t* buf;
  size_t buf_size;
  VP8FrameHeader* frm_hdr;
  VP8PictureHeader* pic_hdr;
  VP8BitReader* br;
  VP8StatusCode status;

  if (dec == NULL) {
    return 0;
  }
  SetOk(dec);
  if (io == NULL) {
    return VP8SetError(dec, VP8_STATUS_INVALID_PARAM,
                       "null VP8Io passed to VP8GetHeaders()");
  }
  buf = io->data;
  buf_size = io->data_size;
  if (buf_size < 4) {
    return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
                       "Truncated header.");
  }

  // Paragraph 9.1
  {
    const uint32_t bits = buf[0] | (buf[1] << 8) | (buf[2] << 16);
    frm_hdr = &dec->frm_hdr_;
    frm_hdr->key_frame_ = !(bits & 1);
    frm_hdr->profile_ = (bits >> 1) & 7;
    frm_hdr->show_ = (bits >> 4) & 1;
    frm_hdr->partition_length_ = (bits >> 5);
    if (frm_hdr->profile_ > 3) {
      return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
                         "Incorrect keyframe parameters.");
    }
    if (!frm_hdr->show_) {
      return VP8SetError(dec, VP8_STATUS_UNSUPPORTED_FEATURE,
                         "Frame not displayable.");
    }
    buf += 3;
    buf_size -= 3;
  }

  pic_hdr = &dec->pic_hdr_;
  if (frm_hdr->key_frame_) {
    // Paragraph 9.2
    if (buf_size < 7) {
      return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
                         "cannot parse picture header");
    }
    if (!VP8CheckSignature(buf, buf_size)) {
      return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
                         "Bad code word");
    }
    pic_hdr->width_ = ((buf[4] << 8) | buf[3]) & 0x3fff;
    pic_hdr->xscale_ = buf[4] >> 6;   // ratio: 1, 5/4 5/3 or 2
    pic_hdr->height_ = ((buf[6] << 8) | buf[5]) & 0x3fff;
    pic_hdr->yscale_ = buf[6] >> 6;
    buf += 7;
    buf_size -= 7;

    dec->mb_w_ = (pic_hdr->width_ + 15) >> 4;
    dec->mb_h_ = (pic_hdr->height_ + 15) >> 4;

    // Setup default output area (can be later modified during io->setup())
    io->width = pic_hdr->width_;
    io->height = pic_hdr->height_;
    // IMPORTANT! use some sane dimensions in crop_* and scaled_* fields.
    // So they can be used interchangeably without always testing for
    // 'use_cropping'.
    io->use_cropping = 0;
    io->crop_top  = 0;
    io->crop_left = 0;
    io->crop_right  = io->width;
    io->crop_bottom = io->height;
    io->use_scaling  = 0;
    io->scaled_width = io->width;
    io->scaled_height = io->height;

    io->mb_w = io->width;   // for soundness
    io->mb_h = io->height;  // ditto

    VP8ResetProba(&dec->proba_);
    ResetSegmentHeader(&dec->segment_hdr_);
  }

  // Check if we have all the partition #0 available, and initialize dec->br_
  // to read this partition (and this partition only).
  if (frm_hdr->partition_length_ > buf_size) {
    return VP8SetError(dec, VP8_STATUS_NOT_ENOUGH_DATA,
                       "bad partition length");
  }

  br = &dec->br_;
  VP8InitBitReader(br, buf, frm_hdr->partition_length_);
  buf += frm_hdr->partition_length_;
  buf_size -= frm_hdr->partition_length_;

  if (frm_hdr->key_frame_) {
    pic_hdr->colorspace_ = VP8Get(br, "global-header");
    pic_hdr->clamp_type_ = VP8Get(br, "global-header");
  }
  if (!ParseSegmentHeader(br, &dec->segment_hdr_, &dec->proba_)) {
    return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
                       "cannot parse segment header");
  }
  // Filter specs
  if (!ParseFilterHeader(br, dec)) {
    return VP8SetError(dec, VP8_STATUS_BITSTREAM_ERROR,
                       "cannot parse filter header");
  }
  status = ParsePartitions(dec, buf, buf_size);
  if (status != VP8_STATUS_OK) {
    return VP8SetError(dec, status, "cannot parse partitions");
  }

  // quantizer change
  VP8ParseQuant(dec);

  // Frame buffer marking
  if (!frm_hdr->key_frame_) {
    return VP8SetError(dec, VP8_STATUS_UNSUPPORTED_FEATURE,
                       "Not a key frame.");
  }

  VP8Get(br, "global-header");   // ignore the value of update_proba_

  VP8ParseProba(br, dec);

  // sanitized state
  dec->ready_ = 1;
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x1427f3
movl $0x0, -0x4(%rbp)
jmp 0x142cd2
movq -0x10(%rbp), %rdi
callq 0x1423d0
cmpq $0x0, -0x18(%rbp)
jne 0x142820
movq -0x10(%rbp), %rdi
movl $0x2, %esi
leaq 0x7a8ad(%rip), %rdx     # 0x1bd0c0
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x4, -0x28(%rbp)
jae 0x14285c
movq -0x10(%rbp), %rdi
movl $0x7, %esi
leaq 0x7a896(%rip), %rdx     # 0x1bd0e5
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x20(%rbp), %rax
movzbl (%rax), %eax
movq -0x20(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movq -0x20(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
shll $0x10, %ecx
orl %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rax
addq $0x44, %rax
movq %rax, -0x30(%rbp)
movl -0x48(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, (%rax)
movl -0x48(%rbp), %eax
shrl %eax
andl $0x7, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x1(%rax)
movl -0x48(%rbp), %eax
shrl $0x4, %eax
andl $0x1, %eax
movb %al, %cl
movq -0x30(%rbp), %rax
movb %cl, 0x2(%rax)
movl -0x48(%rbp), %ecx
shrl $0x5, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x30(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x3, %eax
jle 0x142901
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x7a803(%rip), %rdx     # 0x1bd0f7
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x30(%rbp), %rax
cmpb $0x0, 0x2(%rax)
jne 0x142928
movq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq 0x7a7fb(%rip), %rdx     # 0x1bd116
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x20(%rbp), %rax
addq $0x3, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
subq $0x3, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
addq $0x4c, %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x142b2c
cmpq $0x7, -0x28(%rbp)
jae 0x14297d
movq -0x10(%rbp), %rdi
movl $0x7, %esi
leaq 0x7a7bd(%rip), %rdx     # 0x1bd12d
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x5b180
cmpl $0x0, %eax
jne 0x1429ac
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x7a7aa(%rip), %rdx     # 0x1bd149
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
shll $0x8, %eax
movq -0x20(%rbp), %rcx
movzbl 0x3(%rcx), %ecx
orl %ecx, %eax
andl $0x3fff, %eax           # imm = 0x3FFF
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, (%rax)
movq -0x20(%rbp), %rax
movzbl 0x4(%rax), %eax
sarl $0x6, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x20(%rbp), %rax
movzbl 0x6(%rax), %eax
shll $0x8, %eax
movq -0x20(%rbp), %rcx
movzbl 0x5(%rcx), %ecx
orl %ecx, %eax
andl $0x3fff, %eax           # imm = 0x3FFF
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x2(%rax)
movq -0x20(%rbp), %rax
movzbl 0x6(%rax), %eax
sarl $0x6, %eax
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x5(%rax)
movq -0x20(%rbp), %rax
addq $0x7, %rax
movq %rax, -0x20(%rbp)
movq -0x28(%rbp), %rax
subq $0x7, %rax
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rax
movzwl (%rax), %ecx
addl $0xf, %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x198(%rax)
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %ecx
addl $0xf, %ecx
sarl $0x4, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x19c(%rax)
movq -0x38(%rbp), %rax
movzwl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x38(%rbp), %rax
movzwl 0x2(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x74(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x80(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x78(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x7c(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x84(%rax)
movq -0x18(%rbp), %rax
movl $0x0, 0x88(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x8c(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x18(%rbp), %rax
movl (%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x10(%rbp), %rdi
addq $0x4a8, %rdi            # imm = 0x4A8
callq 0x185430
movq -0x10(%rbp), %rdi
addq $0x84, %rdi
callq 0x142ce0
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
cmpq -0x28(%rbp), %rax
jbe 0x142b56
movq -0x10(%rbp), %rdi
movl $0x7, %esi
leaq 0x7a60e(%rip), %rdx     # 0x1bd157
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x10(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %edx
callq 0x181c20
movq -0x30(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x30(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, %ecx
movq -0x28(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
je 0x142bd7
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x6(%rax)
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x7(%rax)
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x84, %rsi
movq -0x10(%rbp), %rdx
addq $0x4a8, %rdx            # imm = 0x4A8
callq 0x142d70
cmpl $0x0, %eax
jne 0x142c18
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x7a561(%rip), %rdx     # 0x1bd16c
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x142f80
cmpl $0x0, %eax
jne 0x142c47
movq -0x10(%rbp), %rdi
movl $0x3, %esi
leaq 0x7a54e(%rip), %rdx     # 0x1bd188
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x143110
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x142c79
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
leaq 0x7a534(%rip), %rdx     # 0x1bd1a3
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x10(%rbp), %rdi
callq 0x1850e0
movq -0x30(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x142ca5
movq -0x10(%rbp), %rdi
movl $0x4, %esi
leaq 0x7a520(%rip), %rdx     # 0x1bd1bb
callq 0x142580
movl %eax, -0x4(%rbp)
jmp 0x142cd2
movq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x181ef0
movq -0x40(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x185830
movq -0x10(%rbp), %rax
movl $0x1, 0x4(%rax)
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)