// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/lodepng_util.cpp
// Function: lodepng::getChunks(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>*, std::vector<std::vector<unsigned char, std::allocator<unsigned char>>, std::allocator<std::vector<unsigned char, std::allocator<unsigned char>>>>*, std::vector<unsigned char, std::allocator<unsigned char>> const&)
unsigned getChunks(std::vector<std::string> names[3],
                   std::vector<std::vector<unsigned char> > chunks[3],
                   const std::vector<unsigned char>& png) {
  const unsigned char *chunk, *next, *end;
  end = &png.back() + 1;
  chunk = &png.front() + 8;

  int location = 0;

  while(chunk < end && end - chunk >= 8) {
    char type[5];
    lodepng_chunk_type(type, chunk);
    std::string name(type);
    if(name.size() != 4) return 1;

    next = lodepng_chunk_next_const(chunk, end);

    if(name == "IHDR") {
      location = 0;
    } else if(name == "PLTE") {
      location = 1;
    } else if(name == "IDAT") {
      location = 2;
    } else if(name == "IEND") {
      break; // anything after IEND is not part of the PNG or the 3 groups here.
    } else {
      if(next >= end) return 1; // invalid chunk, content too far
      names[location].push_back(name);
      chunks[location].push_back(std::vector<unsigned char>(chunk, next));
    }

    chunk = next;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, 0x28(%rsp)
movq %rdi, 0x30(%rsp)
movq (%rdx), %r14
movq 0x8(%rdx), %r12
addq $0x8, %r14
leaq 0x40(%rsp), %r13
movl $0x0, (%rsp)
movq %r12, %rax
subq %r14, %rax
jbe 0xed71
cmpq $0x8, %rax
jl 0xed71
movq %r14, %r15
leaq 0x3b(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4574
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x20c0
cmpq $0x4, 0x10(%rsp)
jne 0xed58
movq %r15, %rdi
movq %r12, %rsi
callq 0x4705
movq %rax, %r14
leaq 0x8(%rsp), %rdi
leaq 0x4fad1(%rip), %rsi     # 0x5e773
callq 0x121b0
xorl %ebx, %ebx
testb %al, %al
jne 0xed46
leaq 0x8(%rsp), %rdi
leaq 0x4fabb(%rip), %rsi     # 0x5e778
callq 0x121b0
pushq $0x1
popq %rbx
testb %al, %al
jne 0xed46
leaq 0x8(%rsp), %rdi
leaq 0x50eed(%rip), %rsi     # 0x5fbc2
callq 0x121b0
pushq $0x2
popq %rbx
testb %al, %al
jne 0xed46
leaq 0x8(%rsp), %rdi
leaq 0x5230f(%rip), %rsi     # 0x60ffc
callq 0x121b0
testb %al, %al
jne 0xed67
cmpq %r12, %r14
jae 0xed58
movl (%rsp), %eax
imulq $0x18, %rax, %rbx
movq 0x30(%rsp), %rax
leaq (%rax,%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x12164
movq %r13, %rbp
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
leaq 0x7(%rsp), %rcx
callq 0x121ea
addq 0x28(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x121be
movq %rbp, %rdi
callq 0xea7c
movl (%rsp), %ebx
leaq 0x8(%rsp), %rdi
callq 0x2270
movl %ebx, (%rsp)
jmp 0xec43
leaq 0x8(%rsp), %rdi
callq 0x2270
pushq $0x1
popq %rax
jmp 0xed73
leaq 0x8(%rsp), %rdi
callq 0x2270
xorl %eax, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0xea7c
jmp 0xed96
jmp 0xed93
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2270
movq %rbx, %rdi
callq 0x2380
movq %rax, %rdi
callq 0xe6cc