// File: /workspace/github_c_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xcf4b6
testq %rsi, %rsi
je 0xcf4d5
testq %rcx, %rcx
je 0xcf4f4
testq %r8, %r8
je 0xcf513
movq (%rdi), %r9
movq (%rsi), %r11
xorl %eax, %eax
movq %rax, (%rcx)
movq %rax, (%r8)
movl $0x16, %r10d
movq %r9, (%rdi)
movq %r11, (%rsi)
cmpq $0x8, %r11
jae 0xcf42d
xorl %ebx, %ebx
movq %r11, %r14
movl $0x7, %eax
jmp 0xcf459
movl 0x4(%r9), %r15d
cmpl $-0xa, %r15d
jbe 0xcf43b
xorl %ebx, %ebx
jmp 0xcf451
leal 0x9(%r15), %ebp
andl $-0x2, %ebp
addl %ebp, %r10d
xorl %ebx, %ebx
testq %rdx, %rdx
je 0xcf462
cmpq %rdx, %r10
jbe 0xcf462
movq %r11, %r14
movl $0x3, %eax
movq %r14, %r11
testb %bl, %bl
jne 0xcf415
jmp 0xcf4ab
cmpl $0x20385056, (%r9)      # imm = 0x20385056
je 0xcf49b
cmpl $0x4c385056, (%r9)      # imm = 0x4C385056
je 0xcf4a2
movl %ebp, %ebx
movq %r11, %r14
subq %rbx, %r14
jb 0xcf421
cmpl $0x48504c41, (%r9)      # imm = 0x48504C41
jne 0xcf494
leaq 0x8(%r9), %r11
movq %r11, (%rcx)
movl %r15d, %r11d
movq %r11, (%r8)
addq %rbx, %r9
movb $0x1, %bl
jmp 0xcf459
movq %r11, %r14
xorl %eax, %eax
jmp 0xcf459
xorl %eax, %eax
movq %r11, %r14
xorl %ebx, %ebx
jmp 0xcf459
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x5a471(%rip), %rdi     # 0x12992e
leaq 0x5a1f6(%rip), %rsi     # 0x1296ba
leaq 0x5a3e1(%rip), %rcx     # 0x1298ac
movl $0x9f, %edx
callq 0x55710
leaq 0x5a3af(%rip), %rdi     # 0x12988b
leaq 0x5a1d7(%rip), %rsi     # 0x1296ba
leaq 0x5a3c2(%rip), %rcx     # 0x1298ac
movl $0xa0, %edx
callq 0x55710
leaq 0x5a42d(%rip), %rdi     # 0x129928
leaq 0x5a1b8(%rip), %rsi     # 0x1296ba
leaq 0x5a3a3(%rip), %rcx     # 0x1298ac
movl $0xa4, %edx
callq 0x55710
leaq 0x5a421(%rip), %rdi     # 0x12993b
leaq 0x5a199(%rip), %rsi     # 0x1296ba
leaq 0x5a384(%rip), %rcx     # 0x1298ac
movl $0xa5, %edx
callq 0x55710