// File: /workspace/github_cpp_makefile_star2_O1/lvandeve[P]lodepng/pngdetail.cpp
// Function: printZlibInfo(Data&)
void printZlibInfo(Data& data) {
  data.loadFile();
  if(data.error || !data.isPng()) return;
  const std::vector<unsigned char>& png = data.buffer;

  //Read literal data from all IDAT chunks
  const unsigned char *chunk, *begin, *end;
  end = &png.back() + 1;
  begin = chunk = &png.front() + 8;

  std::vector<unsigned char> compressed;

  while(chunk < end && end - chunk >= 8) {
    char type[5];
    lodepng_chunk_type(type, chunk);
    if(std::string(type).size() != 4) {
      std::cout << "invalid png" << std::endl;
      return;
    }

    if(std::string(type) == "IDAT") {
      const unsigned char* cdata = lodepng_chunk_data_const(chunk);
      unsigned clength = lodepng_chunk_length(chunk);
      if(chunk + clength + 12 > end || clength > png.size() || chunk + clength + 12 < begin) {
        std::cout << "corrupt chunk length" << std::endl;
        return;
      }
      compressed.insert(compressed.end(), cdata, cdata + clength);
    }

    chunk = lodepng_chunk_next_const(chunk, end);
  }

  if(compressed.size() >= 3) {
    int bfinal = compressed[2] & 1;
    int btype = (compressed[2] & 6) >> 1;
    if(bfinal) {
      std::cout << "zlib data stored in a single block, btype: " << btype << std::endl;
    } else {
      std::cout << "zlib data spread over multiple blocks. First block btype: " << btype << std::endl;
    }
  }

  std::cout << "zlib compressed size: " << compressed.size() << std::endl;

  //Decompress all IDAT data (if the while loop ended early, this might fail)
  std::vector<unsigned char> uncompressed;
  data.error = lodepng::decompress(uncompressed, compressed.empty() ? NULL : &compressed[0], compressed.size());
  if(data.error) return;

  std::cout << "zlib uncompressed size: " << uncompressed.size() << std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %rcx
xorl %eax, %eax
cmpq 0x28(%rdi), %rcx
jne 0x1852d
leaq 0x20(%rbx), %rdi
movq %rbx, %rsi
callq 0xce6c
movl %eax, 0x2d8(%rbx)
testl %eax, %eax
jne 0x188e6
movq %rbx, %rdi
callq 0x1e4d4
testb %al, %al
je 0x188e6
movq 0x20(%rbx), %rbp
movq %rbx, 0x58(%rsp)
movq 0x28(%rbx), %r14
addq $0x8, %rbp
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x40(%rsp), %rbx
leaq 0xb(%rsp), %r12
movq 0x12a50(%rip), %r15     # 0x2afd0
movq %rbp, 0x60(%rsp)
movq %r14, %rax
subq %rbp, %rax
jbe 0x18726
cmpq $0x8, %rax
jl 0x18726
movq %r12, %rdi
movq %rbp, %rsi
callq 0x4de9
movq %rbx, 0x30(%rsp)
movq %r12, %rdi
callq 0x20e0
leaq (%rsp,%rax), %rdx
addq $0xb, %rdx
leaq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0x150da
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %r13
cmpq %rbx, %rdi
je 0x185dc
callq 0x2200
cmpq $0x4, %r13
jne 0x18642
movq %rbx, 0x30(%rsp)
movq %r12, %rdi
callq 0x20e0
leaq (%rsp,%rax), %rdx
addq $0xb, %rdx
leaq 0x30(%rsp), %r13
movq %r13, %rdi
movq %r12, %rsi
callq 0x150da
movq %r13, %rdi
leaq 0xa591(%rip), %rsi      # 0x22ba2
callq 0x2090
movl %eax, %r13d
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x18628
callq 0x2200
testl %r13d, %r13d
je 0x1867f
movq %rbp, %rdi
movq %r14, %rsi
callq 0x4f42
movq %rax, %rbp
movb $0x1, %al
jmp 0x186ff
movl $0xb, %edx
movq %r15, %rdi
leaq 0xb313(%rip), %rsi      # 0x23964
callq 0x2280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
jmp 0x186fd
movq %rbp, %rdi
callq 0x4e66
movq %rax, %r13
movq %rbp, %rdi
callq 0x4de4
movl %eax, %ecx
leaq (%rcx,%rbp), %rax
addq $0xc, %rax
cmpq %r14, %rax
ja 0x186c2
movq 0x58(%rsp), %rsi
movq 0x28(%rsi), %rdx
subq 0x20(%rsi), %rdx
cmpq %rcx, %rdx
setb %dl
cmpq 0x60(%rsp), %rax
setb %al
orb %dl, %al
cmpb $0x1, %al
jne 0x1870c
movl $0x14, %edx
movq %r15, %rdi
leaq 0xb29f(%rip), %rsi      # 0x23970
callq 0x2280
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r15, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
xorl %eax, %eax
testb %al, %al
jne 0x18585
jmp 0x188d7
movq 0x18(%rsp), %rsi
addq %r13, %rcx
leaq 0x10(%rsp), %rdi
movq %r13, %rdx
callq 0x15d72
jmp 0x1862d
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
cmpq $0x3, %rcx
jb 0x187db
movzbl 0x2(%rax), %eax
movl %eax, %ebp
shrl %ebp
andl $0x3, %ebp
testb $0x1, %al
jne 0x1878b
movq 0x1287d(%rip), %rdi     # 0x2afd0
leaq 0xb257(%rip), %rsi      # 0x239b1
movl $0x3a, %edx
callq 0x2280
movq 0x12865(%rip), %rdi     # 0x2afd0
movl %ebp, %esi
callq 0x2380
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
jmp 0x187c8
movq 0x1283e(%rip), %rdi     # 0x2afd0
leaq 0xb1ec(%rip), %rsi      # 0x23985
movl $0x2b, %edx
callq 0x2280
movq 0x12826(%rip), %rdi     # 0x2afd0
movl %ebp, %esi
callq 0x2380
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq 0x127ee(%rip), %rdi     # 0x2afd0
leaq 0xb203(%rip), %rsi      # 0x239ec
movl $0x16, %edx
callq 0x2280
movq 0x18(%rsp), %rsi
subq 0x10(%rsp), %rsi
movq 0x127cc(%rip), %rdi     # 0x2afd0
callq 0x2150
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %r14, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdi
movaps %xmm0, (%rdi)
xorl %eax, %eax
movq %rax, 0x10(%rdi)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
subq %rsi, %rdx
cmoveq %rax, %rsi
leaq 0x69ec(%rip), %rcx      # 0x1f248
callq 0xcf1a
movq 0x58(%rsp), %rcx
movl %eax, 0x2d8(%rcx)
testl %eax, %eax
jne 0x188c8
movq 0x12759(%rip), %rdi     # 0x2afd0
leaq 0xb185(%rip), %rsi      # 0x23a03
movl $0x18, %edx
callq 0x2280
movq 0x38(%rsp), %rsi
subq 0x30(%rsp), %rsi
movq 0x12737(%rip), %rdi     # 0x2afd0
callq 0x2150
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2160
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x188d7
callq 0x2200
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x188e6
callq 0x2200
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18924
movq %rax, %r14
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
jne 0x18917
jmp 0x18927
jmp 0x18924
jmp 0x18924
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %rbx, %rdi
je 0x18927
callq 0x2200
jmp 0x18927
jmp 0x18924
jmp 0x18924
jmp 0x18924
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x18936
callq 0x2200
movq %r14, %rdi
callq 0x2390