// File: /workspace/github_c_makefile_star2_O3/enzo1982[P]smooth/libraries/libwebp/src/dec/webp_dec.c
// Function: ParseOptionalChunks
static VP8StatusCode ParseOptionalChunks(const uint8_t** const data,
                                         size_t* const data_size,
                                         size_t const riff_size,
                                         const uint8_t** const alpha_data,
                                         size_t* const alpha_size) {
  const uint8_t* buf;
  size_t buf_size;
  uint32_t total_size = TAG_SIZE +           // "WEBP".
                        CHUNK_HEADER_SIZE +  // "VP8Xnnnn".
                        VP8X_CHUNK_SIZE;     // data.
  assert(data != NULL);
  assert(data_size != NULL);
  buf = *data;
  buf_size = *data_size;

  assert(alpha_data != NULL);
  assert(alpha_size != NULL);
  *alpha_data = NULL;
  *alpha_size = 0;

  while (1) {
    uint32_t chunk_size;
    uint32_t disk_chunk_size;   // chunk_size with padding

    *data = buf;
    *data_size = buf_size;

    if (buf_size < CHUNK_HEADER_SIZE) {  // Insufficient data.
      return VP8_STATUS_NOT_ENOUGH_DATA;
    }

    chunk_size = GetLE32(buf + TAG_SIZE);
    if (chunk_size > MAX_CHUNK_PAYLOAD) {
      return VP8_STATUS_BITSTREAM_ERROR;          // Not a valid chunk size.
    }
    // For odd-sized chunk-payload, there's one byte padding at the end.
    disk_chunk_size = (CHUNK_HEADER_SIZE + chunk_size + 1) & ~1u;
    total_size += disk_chunk_size;

    // Check that total bytes skipped so far does not exceed riff_size.
    if (riff_size > 0 && (total_size > riff_size)) {
      return VP8_STATUS_BITSTREAM_ERROR;          // Not a valid chunk size.
    }

    // Start of a (possibly incomplete) VP8/VP8L chunk implies that we have
    // parsed all the optional chunks.
    // Note: This check must occur before the check 'buf_size < disk_chunk_size'
    // below to allow incomplete VP8/VP8L chunks.
    if (!memcmp(buf, "VP8 ", TAG_SIZE) ||
        !memcmp(buf, "VP8L", TAG_SIZE)) {
      return VP8_STATUS_OK;
    }

    if (buf_size < disk_chunk_size) {             // Insufficient data.
      return VP8_STATUS_NOT_ENOUGH_DATA;
    }

    if (!memcmp(buf, "ALPH", TAG_SIZE)) {         // A valid ALPH header.
      *alpha_data = buf + CHUNK_HEADER_SIZE;
      *alpha_size = chunk_size;
    }

    // We have a full and valid chunk; skip it.
    buf += disk_chunk_size;
    buf_size -= disk_chunk_size;
  }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xce58a
testq %rsi, %rsi
je 0xce5a9
testq %rcx, %rcx
je 0xce5c8
testq %r8, %r8
je 0xce5e7
movq (%rdi), %r9
movq (%rsi), %r10
xorl %eax, %eax
movq %rax, (%rcx)
movq %rax, (%r8)
movq %r9, (%rdi)
movq %r10, (%rsi)
cmpq $0x8, %r10
jae 0xce522
movl $0x7, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x16, %r11d
movl 0x4(%r9), %ebx
movl $0x3, %eax
cmpl $-0xa, %ebx
ja 0xce51d
leal 0x9(%rbx), %ebp
andl $-0x2, %ebp
addl %ebp, %r11d
testq %rdx, %rdx
je 0xce549
cmpq %rdx, %r11
ja 0xce51d
xorl %eax, %eax
cmpl $0x20385056, (%r9)      # imm = 0x20385056
je 0xce51d
cmpl $0x4c385056, (%r9)      # imm = 0x4C385056
je 0xce51d
movl %ebp, %eax
subq %rax, %r10
jb 0xce518
cmpl $0x48504c41, (%r9)      # imm = 0x48504C41
jne 0xce579
leaq 0x8(%r9), %r14
movq %r14, (%rcx)
movl %ebx, %ebx
movq %rbx, (%r8)
addq %rax, %r9
movq %r9, (%rdi)
movq %r10, (%rsi)
cmpq $0x7, %r10
ja 0xce528
jmp 0xce518
leaq 0x5a5bd(%rip), %rdi     # 0x128b4e
leaq 0x5a342(%rip), %rsi     # 0x1288da
leaq 0x5a52d(%rip), %rcx     # 0x128acc
movl $0x9f, %edx
callq 0x55710
leaq 0x5a4fb(%rip), %rdi     # 0x128aab
leaq 0x5a323(%rip), %rsi     # 0x1288da
leaq 0x5a50e(%rip), %rcx     # 0x128acc
movl $0xa0, %edx
callq 0x55710
leaq 0x5a579(%rip), %rdi     # 0x128b48
leaq 0x5a304(%rip), %rsi     # 0x1288da
leaq 0x5a4ef(%rip), %rcx     # 0x128acc
movl $0xa4, %edx
callq 0x55710
leaq 0x5a56d(%rip), %rdi     # 0x128b5b
leaq 0x5a2e5(%rip), %rsi     # 0x1288da
leaq 0x5a4d0(%rip), %rcx     # 0x128acc
movl $0xa5, %edx
callq 0x55710