// File: /workspace/github_cpp_makefile_star2_O3/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 $0x68, %rsp
movq %rsi, 0x20(%rsp)
movq %rdi, 0x28(%rsp)
movq (%rdx), %rbx
movq 0x8(%rdx), %r12
addq $0x8, %rbx
leaq 0x13(%rsp), %r13
leaq 0x30(%rsp), %rbp
movl $0x0, 0xc(%rsp)
movq %r12, %rax
subq %rbx, %rax
jbe 0x10f3d
cmpq $0x8, %rax
jl 0x10f3d
movq %r13, %rdi
movq %rbx, %rsi
callq 0x544e
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %r13, %rdi
callq 0x2100
leaq (%rsp,%rax), %rdx
addq $0x13, %rdx
movq %rbp, %rdi
movq %r13, %rsi
callq 0x14f6e
movl $0x1, %r14d
cmpq $0x4, 0x38(%rsp)
jne 0x10efc
movq %rbx, %rdi
movq %r12, %rsi
callq 0x55b2
movq %rax, %r15
movq %rbp, %rdi
leaq 0x63a57(%rip), %rsi     # 0x74877
callq 0x20b0
xorl %r14d, %r14d
testl %eax, %eax
je 0x10eda
movq %rbp, %rdi
leaq 0x63a42(%rip), %rsi     # 0x7487c
callq 0x20b0
testl %eax, %eax
je 0x10ee7
movq %rbp, %rdi
leaq 0x64e75(%rip), %rsi     # 0x75cc6
callq 0x20b0
testl %eax, %eax
je 0x10ef1
movq %rbp, %rdi
leaq 0x66334(%rip), %rsi     # 0x7719c
callq 0x20b0
testl %eax, %eax
je 0x10f1b
cmpq %r12, %r15
jae 0x10f23
movl 0xc(%rsp), %eax
leaq (%rax,%rax,2), %rcx
movq 0x28(%rsp), %rax
movq %rcx, 0x18(%rsp)
leaq (%rax,%rcx,8), %rdi
movq %rbp, %rsi
callq 0x14d42
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq 0x12(%rsp), %rcx
callq 0x14dac
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
leaq 0x50(%rsp), %rsi
callq 0x14d80
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x10ef9
callq 0x2210
jmp 0x10ef9
movq %r15, %rbx
movl $0x0, 0xc(%rsp)
jmp 0x10efc
movl $0x1, 0xc(%rsp)
jmp 0x10ef9
movl $0x2, 0xc(%rsp)
movq %r15, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x10f10
callq 0x2210
testl %r14d, %r14d
je 0x10db0
jmp 0x10f2b
movl $0x3, %r14d
jmp 0x10efc
movl $0x1, %r14d
jmp 0x10efc
cmpl $0x3, %r14d
movl $0x0, %eax
je 0x10f3f
movl $0x1, %eax
jmp 0x10f3f
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x10f67
callq 0x2210
jmp 0x10f67
jmp 0x10f64
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x10f7b
callq 0x2210
movq %rbx, %rdi
callq 0x23c0