// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x16, -0x44(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x13cefc
jmp 0x13cf1b
leaq 0x7f6ae(%rip), %rdi     # 0x1bc5b1
leaq 0x7f349(%rip), %rsi     # 0x1bc253
movl $0x9f, %edx
leaq 0x7f619(%rip), %rcx     # 0x1bc52f
callq 0x598a0
cmpq $0x0, -0x18(%rbp)
je 0x13cf24
jmp 0x13cf43
leaq 0x7f54b(%rip), %rdi     # 0x1bc476
leaq 0x7f321(%rip), %rsi     # 0x1bc253
movl $0xa0, %edx
leaq 0x7f5f1(%rip), %rcx     # 0x1bc52f
callq 0x598a0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x13cf62
jmp 0x13cf81
leaq 0x7f642(%rip), %rdi     # 0x1bc5ab
leaq 0x7f2e3(%rip), %rsi     # 0x1bc253
movl $0xa4, %edx
leaq 0x7f5b3(%rip), %rcx     # 0x1bc52f
callq 0x598a0
cmpq $0x0, -0x30(%rbp)
je 0x13cf8a
jmp 0x13cfa9
leaq 0x7f62d(%rip), %rdi     # 0x1bc5be
leaq 0x7f2bb(%rip), %rsi     # 0x1bc253
movl $0xa5, %edx
leaq 0x7f58b(%rip), %rcx     # 0x1bc52f
callq 0x598a0
movq -0x28(%rbp), %rax
movq $0x0, (%rax)
movq -0x30(%rbp), %rax
movq $0x0, (%rax)
movq -0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movq -0x40(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
cmpq $0x8, -0x40(%rbp)
jae 0x13cfe8
movl $0x7, -0x4(%rbp)
jmp 0x13d0de
movq -0x38(%rbp), %rdi
addq $0x4, %rdi
callq 0x13d2f0
movl %eax, -0x48(%rbp)
cmpl $-0xa, -0x48(%rbp)
jbe 0x13d00a
movl $0x3, -0x4(%rbp)
jmp 0x13d0de
movl -0x48(%rbp), %eax
addl $0x8, %eax
addl $0x1, %eax
andl $-0x2, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl -0x44(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x20(%rbp)
jbe 0x13d03e
movl -0x44(%rbp), %eax
cmpq -0x20(%rbp), %rax
jbe 0x13d03e
movl $0x3, -0x4(%rbp)
jmp 0x13d0de
movq -0x38(%rbp), %rax
movl (%rax), %eax
subl $0x20385056, %eax       # imm = 0x20385056
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x13d06a
movq -0x38(%rbp), %rax
movl (%rax), %eax
subl $0x4c385056, %eax       # imm = 0x4C385056
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x13d073
movl $0x0, -0x4(%rbp)
jmp 0x13d0de
movq -0x40(%rbp), %rax
movl -0x4c(%rbp), %ecx
cmpq %rcx, %rax
jae 0x13d088
movl $0x7, -0x4(%rbp)
jmp 0x13d0de
movq -0x38(%rbp), %rax
movl (%rax), %eax
subl $0x48504c41, %eax       # imm = 0x48504C41
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x13d0b9
movq -0x38(%rbp), %rcx
addq $0x8, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movl -0x48(%rbp), %eax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl -0x4c(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, %ecx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x13cfbf
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)