// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/libraries/libwebp/src/dec/webp_dec.c
// Function: ParseHeadersInternal
static VP8StatusCode ParseHeadersInternal(const uint8_t* data,
                                          size_t data_size,
                                          int* const width,
                                          int* const height,
                                          int* const has_alpha,
                                          int* const has_animation,
                                          int* const format,
                                          WebPHeaderStructure* const headers) {
  int canvas_width = 0;
  int canvas_height = 0;
  int image_width = 0;
  int image_height = 0;
  int found_riff = 0;
  int found_vp8x = 0;
  int animation_present = 0;
  const int have_all_data = (headers != NULL) ? headers->have_all_data : 0;

  VP8StatusCode status;
  WebPHeaderStructure hdrs;

  if (data == NULL || data_size < RIFF_HEADER_SIZE) {
    return VP8_STATUS_NOT_ENOUGH_DATA;
  }
  memset(&hdrs, 0, sizeof(hdrs));
  hdrs.data = data;
  hdrs.data_size = data_size;

  // Skip over RIFF header.
  status = ParseRIFF(&data, &data_size, have_all_data, &hdrs.riff_size);
  if (status != VP8_STATUS_OK) {
    return status;   // Wrong RIFF header / insufficient data.
  }
  found_riff = (hdrs.riff_size > 0);

  // Skip over VP8X.
  {
    uint32_t flags = 0;
    status = ParseVP8X(&data, &data_size, &found_vp8x,
                       &canvas_width, &canvas_height, &flags);
    if (status != VP8_STATUS_OK) {
      return status;  // Wrong VP8X / insufficient data.
    }
    animation_present = !!(flags & ANIMATION_FLAG);
    if (!found_riff && found_vp8x) {
      // Note: This restriction may be removed in the future, if it becomes
      // necessary to send VP8X chunk to the decoder.
      return VP8_STATUS_BITSTREAM_ERROR;
    }
    if (has_alpha != NULL) *has_alpha = !!(flags & ALPHA_FLAG);
    if (has_animation != NULL) *has_animation = animation_present;
    if (format != NULL) *format = 0;   // default = undefined

    image_width = canvas_width;
    image_height = canvas_height;
    if (found_vp8x && animation_present && headers == NULL) {
      status = VP8_STATUS_OK;
      goto ReturnWidthHeight;  // Just return features from VP8X header.
    }
  }

  if (data_size < TAG_SIZE) {
    status = VP8_STATUS_NOT_ENOUGH_DATA;
    goto ReturnWidthHeight;
  }

  // Skip over optional chunks if data started with "RIFF + VP8X" or "ALPH".
  if ((found_riff && found_vp8x) ||
      (!found_riff && !found_vp8x && !memcmp(data, "ALPH", TAG_SIZE))) {
    status = ParseOptionalChunks(&data, &data_size, hdrs.riff_size,
                                 &hdrs.alpha_data, &hdrs.alpha_data_size);
    if (status != VP8_STATUS_OK) {
      goto ReturnWidthHeight;  // Invalid chunk size / insufficient data.
    }
  }

  // Skip over VP8/VP8L header.
  status = ParseVP8Header(&data, &data_size, have_all_data, hdrs.riff_size,
                          &hdrs.compressed_size, &hdrs.is_lossless);
  if (status != VP8_STATUS_OK) {
    goto ReturnWidthHeight;  // Wrong VP8/VP8L chunk-header / insufficient data.
  }
  if (hdrs.compressed_size > MAX_CHUNK_PAYLOAD) {
    return VP8_STATUS_BITSTREAM_ERROR;
  }

  if (format != NULL && !animation_present) {
    *format = hdrs.is_lossless ? 2 : 1;
  }

  if (!hdrs.is_lossless) {
    if (data_size < VP8_FRAME_HEADER_SIZE) {
      status = VP8_STATUS_NOT_ENOUGH_DATA;
      goto ReturnWidthHeight;
    }
    // Validates raw VP8 data.
    if (!VP8GetInfo(data, data_size, (uint32_t)hdrs.compressed_size,
                    &image_width, &image_height)) {
      return VP8_STATUS_BITSTREAM_ERROR;
    }
  } else {
    if (data_size < VP8L_FRAME_HEADER_SIZE) {
      status = VP8_STATUS_NOT_ENOUGH_DATA;
      goto ReturnWidthHeight;
    }
    // Validates raw VP8L data.
    if (!VP8LGetInfo(data, data_size, &image_width, &image_height, has_alpha)) {
      return VP8_STATUS_BITSTREAM_ERROR;
    }
  }
  // Validates image size coherency.
  if (found_vp8x) {
    if (canvas_width != image_width || canvas_height != image_height) {
      return VP8_STATUS_BITSTREAM_ERROR;
    }
  }
  if (headers != NULL) {
    *headers = hdrs;
    headers->offset = data - headers->data;
    assert((uint64_t)(data - headers->data) < MAX_CHUNK_PAYLOAD);
    assert(headers->offset == headers->data_size - data_size);
  }
 ReturnWidthHeight:
  if (status == VP8_STATUS_OK ||
      (status == VP8_STATUS_NOT_ENOUGH_DATA && found_vp8x && headers == NULL)) {
    if (has_alpha != NULL) {
      // If the data did not contain a VP8X/VP8L chunk the only definitive way
      // to set this is by looking for alpha data (from an ALPH chunk).
      *has_alpha |= (hdrs.alpha_data != NULL);
    }
    if (width != NULL) *width = image_width;
    if (height != NULL) *height = image_height;
    return VP8_STATUS_OK;
  } else {
    return status;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x18(%rbp), %rax
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
cmpq $0x0, 0x18(%rbp)
je 0x13b5f2
movq 0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0xb0(%rbp)
jmp 0x13b5fc
xorl %eax, %eax
movl %eax, -0xb0(%rbp)
jmp 0x13b5fc
movl -0xb0(%rbp), %eax
movl %eax, -0x58(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x13b613
cmpq $0xc, -0x18(%rbp)
jae 0x13b61f
movl $0x7, -0x4(%rbp)
jmp 0x13ba16
leaq -0xa8(%rbp), %rdi
xorl %esi, %esi
movl $0x48, %edx
callq 0x5a200
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl -0x58(%rbp), %edx
leaq -0xa8(%rbp), %rcx
addq $0x38, %rcx
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x13cb70
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x13b677
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13ba16
cmpq $0x0, -0x70(%rbp)
seta %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x4c(%rbp)
movl $0x0, -0xac(%rbp)
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
leaq -0x40(%rbp), %r8
leaq -0xac(%rbp), %r9
callq 0x13ccf0
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x13b6c5
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x13ba16
movl -0xac(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x13b6f8
cmpl $0x0, -0x50(%rbp)
je 0x13b6f8
movl $0x3, -0x4(%rbp)
jmp 0x13ba16
cmpq $0x0, -0x30(%rbp)
je 0x13b71d
movl -0xac(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x38(%rbp)
je 0x13b72d
movl -0x54(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, 0x10(%rbp)
je 0x13b73e
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movl -0x3c(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x50(%rbp)
je 0x13b769
cmpl $0x0, -0x54(%rbp)
je 0x13b769
cmpq $0x0, 0x18(%rbp)
jne 0x13b769
movl $0x0, -0x5c(%rbp)
jmp 0x13b9af
cmpq $0x4, -0x18(%rbp)
jae 0x13b77c
movl $0x7, -0x5c(%rbp)
jmp 0x13b9af
cmpl $0x0, -0x4c(%rbp)
je 0x13b788
cmpl $0x0, -0x50(%rbp)
jne 0x13b7aa
cmpl $0x0, -0x4c(%rbp)
jne 0x13b7e1
cmpl $0x0, -0x50(%rbp)
jne 0x13b7e1
movq -0x10(%rbp), %rax
movl (%rax), %eax
subl $0x48504c41, %eax       # imm = 0x48504C41
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x13b7e1
movq -0x70(%rbp), %rdx
leaq -0xa8(%rbp), %rcx
addq $0x20, %rcx
leaq -0xa8(%rbp), %r8
addq $0x28, %r8
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x13ced0
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x13b7df
jmp 0x13b9af
jmp 0x13b7e1
movl -0x58(%rbp), %edx
movq -0x70(%rbp), %rcx
leaq -0xa8(%rbp), %r8
addq $0x30, %r8
leaq -0xa8(%rbp), %r9
addq $0x40, %r9
leaq -0x10(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x13d0f0
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
je 0x13b819
jmp 0x13b9af
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmpq %rax, -0x78(%rbp)
jbe 0x13b830
movl $0x3, -0x4(%rbp)
jmp 0x13ba16
cmpq $0x0, 0x10(%rbp)
je 0x13b856
cmpl $0x0, -0x54(%rbp)
jne 0x13b856
movl -0x68(%rbp), %edx
movl $0x1, %ecx
movl $0x2, %eax
cmpl $0x0, %edx
cmovnel %eax, %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x68(%rbp)
jne 0x13b89f
cmpq $0xa, -0x18(%rbp)
jae 0x13b86f
movl $0x7, -0x5c(%rbp)
jmp 0x13b9af
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x78(%rbp), %rax
movl %eax, %eax
movl %eax, %edx
leaq -0x44(%rbp), %rcx
leaq -0x48(%rbp), %r8
callq 0x5d160
cmpl $0x0, %eax
jne 0x13b89d
movl $0x3, -0x4(%rbp)
jmp 0x13ba16
jmp 0x13b8de
cmpq $0x5, -0x18(%rbp)
jae 0x13b8b2
movl $0x7, -0x5c(%rbp)
jmp 0x13b9af
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x30(%rbp), %r8
leaq -0x44(%rbp), %rdx
leaq -0x48(%rbp), %rcx
callq 0x5d460
cmpl $0x0, %eax
jne 0x13b8dc
movl $0x3, -0x4(%rbp)
jmp 0x13ba16
jmp 0x13b8de
cmpl $0x0, -0x50(%rbp)
je 0x13b902
movl -0x3c(%rbp), %eax
cmpl -0x44(%rbp), %eax
jne 0x13b8f4
movl -0x40(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x13b900
movl $0x3, -0x4(%rbp)
jmp 0x13ba16
jmp 0x13b902
cmpq $0x0, 0x18(%rbp)
je 0x13b9ad
movq 0x18(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
movl $0x48, %edx
callq 0x593a0
movq -0x10(%rbp), %rcx
movq 0x18(%rbp), %rax
movq (%rax), %rax
subq %rax, %rcx
movq 0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rbp), %rcx
movq (%rcx), %rcx
subq %rcx, %rax
movl $0xfffffff6, %ecx       # imm = 0xFFFFFFF6
cmpq %rcx, %rax
jae 0x13b952
jmp 0x13b971
leaq 0x809d0(%rip), %rdi     # 0x1bc329
leaq 0x808f3(%rip), %rsi     # 0x1bc253
movl $0x18e, %edx            # imm = 0x18E
leaq 0x809f2(%rip), %rcx     # 0x1bc35e
callq 0x598a0
movq 0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x18(%rbp), %rcx
movq 0x8(%rcx), %rcx
subq -0x18(%rbp), %rcx
cmpq %rcx, %rax
jne 0x13b98c
jmp 0x13b9ab
leaq 0x80a5f(%rip), %rdi     # 0x1bc3f2
leaq 0x808b9(%rip), %rsi     # 0x1bc253
movl $0x18f, %edx            # imm = 0x18F
leaq 0x809b8(%rip), %rcx     # 0x1bc35e
callq 0x598a0
jmp 0x13b9ad
jmp 0x13b9af
cmpl $0x0, -0x5c(%rbp)
je 0x13b9c8
cmpl $0x7, -0x5c(%rbp)
jne 0x13ba10
cmpl $0x0, -0x50(%rbp)
je 0x13ba10
cmpq $0x0, 0x18(%rbp)
jne 0x13ba10
cmpq $0x0, -0x30(%rbp)
je 0x13b9e7
cmpq $0x0, -0x88(%rbp)
setne %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x30(%rbp), %rax
orl (%rax), %ecx
movl %ecx, (%rax)
cmpq $0x0, -0x20(%rbp)
je 0x13b9f7
movl -0x44(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpq $0x0, -0x28(%rbp)
je 0x13ba07
movl -0x48(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x13ba16
movl -0x5c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)