// File: /workspace/github_cpp_makefile_star2_O1/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 0x112bf
cmpq $0x8, %rax
jl 0x112bf
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4e89
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 0x1517a
movl $0x1, %r14d
cmpq $0x4, 0x38(%rsp)
jne 0x1127e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4fe2
movq %rax, %r15
movq %rbp, %rdi
leaq 0x635b1(%rip), %rsi     # 0x74753
callq 0x20b0
xorl %r14d, %r14d
testl %eax, %eax
je 0x1125c
movq %rbp, %rdi
leaq 0x6359c(%rip), %rsi     # 0x74758
callq 0x20b0
testl %eax, %eax
je 0x11269
movq %rbp, %rdi
leaq 0x649cf(%rip), %rsi     # 0x75ba2
callq 0x20b0
testl %eax, %eax
je 0x11273
movq %rbp, %rdi
leaq 0x65d92(%rip), %rsi     # 0x76f7c
callq 0x20b0
testl %eax, %eax
je 0x1129d
cmpq %r12, %r15
jae 0x112a5
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 0x14f64
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq 0x12(%rsp), %rcx
callq 0x14fce
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%rax,%rcx,8), %rdi
leaq 0x50(%rsp), %rsi
callq 0x14fa2
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x1127b
callq 0x2200
jmp 0x1127b
movq %r15, %rbx
movl $0x0, 0xc(%rsp)
jmp 0x1127e
movl $0x1, 0xc(%rsp)
jmp 0x1127b
movl $0x2, 0xc(%rsp)
movq %r15, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x11292
callq 0x2200
testl %r14d, %r14d
je 0x11132
jmp 0x112ad
movl $0x3, %r14d
jmp 0x1127e
movl $0x1, %r14d
jmp 0x1127e
cmpl $0x3, %r14d
movl $0x0, %eax
je 0x112c1
movl $0x1, %eax
jmp 0x112c1
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 0x112e9
callq 0x2200
jmp 0x112e9
jmp 0x112e6
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x112fd
callq 0x2200
movq %rbx, %rdi
callq 0x23b0