// File: /workspace/github_cpp_makefile_star2_O2/lvandeve[P]lodepng/pngdetail.cpp
// Function: main
int main(int argc, char *argv[]) {
  Options options;
  bool options_chosen = false;

  std::vector<std::string> filenames;
  for (int i = 1; i < argc; i++) {
    std::string s = argv[i];
    if(s.size() > 1 && s[0] == '-' && s[1] != '-') {
      // anything that chooses actual set disables the defaults
      if(s != "-x" && s != "-v" && s != "-t") options_chosen = true;
      for(size_t j = 1; j < s.size(); j++) {
        char c = s[j];
        if(c == 'o') options.show_one_line_summary = true;
        else if(c == 'H') options.show_header = true;
        else if(c == 'i') options.show_icc_details = true;
        else if(c == 'I') options.show_icc_hex = true;
        else if(c == 'e') options.show_exif = true;
        else if(c == 'E') options.show_exif_hex = true;
        else if(c == 'v') options.verbose = true;
        else if(c == 't') options.expand_long_texts = true;
        else if(c == 's') options.show_color_stats = true;
        else if(c == 'a') options.show_errors = true;
        else if(c == 'p') options.show_header = options.show_png_info = true;
        else if(c == 'r') options.show_render = true;
        else if(c == 'l') options.show_palette = true;
        else if(c == 'L') options.show_palette_pixels = true;
        else if(c == 'c') options.show_chunks = true;
        else if(c == 'C') options.show_chunks2 = true;
        else if(c == 'f') options.show_filters = true;
        else if(c == 'z') options.show_zlib_info = true;
        else if(c == 'x') {
          options.use_hex = true;
          std::cout << std::hex;
        } else {
          if(s != "--help" && c != 'h' && c != '?') std::cout << "Unknown flag: " << c << ". Use -h for help" << std::endl;
          showHelp();
          return 0;
        }

      }
    } else if(s.size() > 1 && s[0] == '-' && s[1] == '-') {
      size_t eqpos = 2;
      while(eqpos < s.size() && s[eqpos] != '=') eqpos++;
      std::string key = s.substr(2, eqpos - 2);
      std::string value = (eqpos + 1) < s.size() ? s.substr(eqpos + 1) : "";
      if(key == "help") {
        showHelp();
        return 0;
      }
      if(key == "mode") {
        if(value == "ascii") options.rendermode = RM_ASCII;
        else if(value == "hex") options.rendermode = RM_HEX;
        else if(value == "hex16") options.rendermode = RM_HEX16;
        else if(value == "palette") options.rendermode = RM_PAL;
      }
      if(key == "size") {
        int size = strtoval<int>(value);
        if(size >= 1 && size <= 4096) options.rendersize = size;
      }
      if(key == "format") {
        if(value == "mix") options.hexformat = HF_MIX;
        else if(value == "hex") options.hexformat = HF_HEX;
        else if(value == "bin") options.hexformat = HF_BIN;
      }
    }
    else filenames.push_back(s);
  }

  if(filenames.empty()) {
    std::cout << "Please provide a filename to preview" << std::endl;
    showHelp();
    return 0;
  }

  if(!options_chosen) {
    //fill in defaults
    options.show_header = true;
    options.show_png_info = true;
    options.show_chunks2 = true;
    // verbose lets individual sections show more, and in addition adds more default unlocked sections if no specific one chosen
    if(options.verbose) {
      options.show_chunks2 = false;
      options.show_chunks = true;
    }
  }

  for(size_t i = 0; i < filenames.size(); i++) {
    if(filenames.size() > 1) {
      if(i > 0 && !options.show_one_line_summary) std::cout << std::endl;
      std::cout << filenames[i] << ":";
      if(!options.show_one_line_summary) std::cout << std::endl; else std::cout << " ";
    }
    Data data(filenames[i]);
    showInfos(data, options);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3b8, %rsp            # imm = 0x3B8
andq $0x0, 0x15(%rsp)
movq %rsi, %rbx
andq $0x0, 0x10(%rsp)
movl $0x1, 0x20(%rsp)
xorl %ecx, %ecx
movb %cl, 0x24(%rsp)
movabsq $0x5000000000, %rax     # imm = 0x5000000000
movq %rax, 0x28(%rsp)
andl $0x0, 0x30(%rsp)
movl $0x0, 0x4c(%rsp)
movb %cl, 0x34(%rsp)
xorps %xmm0, %xmm0
leaq 0x80(%rsp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movslq %edi, %r13
movb 0x17(%rsp), %al
movb %al, 0xe(%rsp)
movb 0x15(%rsp), %al
movb %al, 0xc(%rsp)
movb 0x16(%rsp), %al
movb %al, 0xd(%rsp)
movb 0x12(%rsp), %al
movb %al, 0xf(%rsp)
pushq $0x1
popq %r14
leaq 0xd8(%rsp), %r15
leaq 0x5a84(%rip), %r12      # 0x1e0ac
movl $0x0, 0x74(%rsp)
movl $0x0, 0x70(%rsp)
movl $0x0, 0x6c(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x54(%rsp)
movl $0x0, 0x68(%rsp)
movl $0x0, 0x48(%rsp)
movl $0x0, 0x44(%rsp)
movl $0x0, 0x64(%rsp)
movl $0x0, 0x60(%rsp)
movl $0x0, 0x50(%rsp)
movl $0x0, 0x5c(%rsp)
movl $0x0, 0x58(%rsp)
movl $0x0, 0x78(%rsp)
movl $0x0, 0x38(%rsp)
movl $0x0, 0x40(%rsp)
cmpq %r13, %r14
jge 0x18bd9
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
leaq 0xb8(%rsp), %rdx
callq 0x20b0
movq 0xe0(%rsp), %rbp
cmpq $0x2, %rbp
jb 0x18707
movq 0xd8(%rsp), %rax
cmpb $0x2d, (%rax)
jne 0x18707
cmpb $0x2d, 0x1(%rax)
jne 0x18733
cmpb $0x2d, 0x1(%rax)
jne 0x18707
pushq $0x2
popq %rcx
cmpq %rbp, %rcx
jae 0x18937
cmpb $0x3d, (%rax,%rcx)
je 0x18934
incq %rcx
jmp 0x186ef
movb $0x1, %bpl
leaq 0x80(%rsp), %rdi
movq %r15, %rsi
callq 0x12134
movq %r15, %rdi
callq 0x22a0
incq %r14
testb %bpl, %bpl
jne 0x186a8
jmp 0x18cfb
movq %r15, %rdi
leaq 0x6e0a(%rip), %rsi      # 0x1f547
callq 0x1938b
testb %al, %al
je 0x18772
movq %r15, %rdi
leaq 0x6dfa(%rip), %rsi      # 0x1f54a
callq 0x1938b
testb %al, %al
je 0x18772
movq %r15, %rdi
leaq 0x6dea(%rip), %rsi      # 0x1f54d
callq 0x1938b
movl 0x40(%rsp), %ecx
orb %al, %cl
movl %ecx, 0x40(%rsp)
movq 0xd8(%rsp), %rax
movq 0xe0(%rsp), %rcx
movq 0xe847(%rip), %rdx      # 0x26fd0
movq (%rdx), %rdx
pushq $0x1
popq %rsi
cmpq %rcx, %rsi
jae 0x188ac
movzbl (%rax,%rsi), %ebp
leal -0x61(%rbp), %edi
cmpl $0x19, %edi
ja 0x187b9
movslq (%r12,%rdi,4), %rdi
addq %r12, %rdi
jmpq *%rdi
movb $0x1, %dil
movl %edi, 0x6c(%rsp)
jmp 0x188a4
leal -0x43(%rbp), %edi
cmpl $0x9, %edi
ja 0x18afa
leaq 0x58b8(%rip), %r8       # 0x1e084
movslq (%r8,%rdi,4), %rdi
addq %r8, %rdi
jmpq *%rdi
movb $0x1, %dil
movl %edi, 0x44(%rsp)
jmp 0x188a4
movq -0x18(%rdx), %rdi
movq 0xe7e4(%rip), %r9       # 0x26fd0
movl 0x18(%r9,%rdi), %r8d
andl $-0x4b, %r8d
orl $0x8, %r8d
movl %r8d, 0x18(%r9,%rdi)
movb $0x1, %dil
movl %edi, 0x50(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x38(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x5c(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x68(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x3c(%rsp)
movb $0x1, %dil
movl %edi, 0x54(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x74(%rsp)
jmp 0x188a4
movb $0x1, 0xc(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x70(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x64(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x58(%rsp)
jmp 0x188a4
movb $0x1, 0xe(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x60(%rsp)
jmp 0x188a4
movb $0x1, 0xf(%rsp)
movb $0x1, %dil
movl %edi, 0x78(%rsp)
jmp 0x188a4
movb $0x1, 0xd(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x4c(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x3c(%rsp)
jmp 0x188a4
movb $0x1, %dil
movl %edi, 0x48(%rsp)
incq %rsi
jmp 0x1878f
movb 0xf(%rsp), %al
movb %al, 0x12(%rsp)
movl 0x50(%rsp), %eax
movb %al, 0x34(%rsp)
movl 0x60(%rsp), %eax
movb %al, 0x33(%rsp)
movl 0x64(%rsp), %eax
movb %al, 0x32(%rsp)
movl 0x44(%rsp), %eax
movb %al, 0x31(%rsp)
movl 0x48(%rsp), %eax
movb %al, 0x1c(%rsp)
movl 0x68(%rsp), %eax
movb %al, 0x1b(%rsp)
movl 0x54(%rsp), %eax
movb %al, 0x1a(%rsp)
movl 0x3c(%rsp), %eax
movb %al, 0x13(%rsp)
movl 0x6c(%rsp), %eax
movb %al, 0x14(%rsp)
movl 0x70(%rsp), %eax
movb %al, 0x19(%rsp)
movl 0x74(%rsp), %eax
movb %al, 0x11(%rsp)
movl 0x4c(%rsp), %eax
movb %al, 0x18(%rsp)
movl 0x58(%rsp), %eax
movb %al, 0x30(%rsp)
movl 0x5c(%rsp), %eax
movb %al, 0x24(%rsp)
movl 0x38(%rsp), %eax
movb %al, 0x10(%rsp)
movb $0x1, %bpl
jmp 0x1871a
movq %rcx, %rbp
leaq -0x2(%rbp), %rcx
leaq 0xb8(%rsp), %rdi
movq %r15, %rsi
pushq $0x2
popq %rdx
callq 0x2240
incq %rbp
cmpq 0xe0(%rsp), %rbp
jae 0x18973
leaq 0x98(%rsp), %rdi
movq %r15, %rsi
movq %rbp, %rdx
pushq $-0x1
popq %rcx
callq 0x2240
jmp 0x1898c
leaq 0x98(%rsp), %rdi
leaq 0x68a2(%rip), %rsi      # 0x1f224
leaq 0x7f(%rsp), %rdx
callq 0x20b0
leaq 0xb8(%rsp), %rdi
leaq 0x6bd8(%rip), %rsi      # 0x1f573
callq 0x12180
movl %eax, %ebp
testb %al, %al
je 0x189b0
callq 0x13250
jmp 0x18ad7
leaq 0xb8(%rsp), %rdi
leaq 0x6bb9(%rip), %rsi      # 0x1f578
callq 0x12180
testb %al, %al
je 0x18a37
leaq 0x98(%rsp), %rdi
leaq 0x6ba6(%rip), %rsi      # 0x1f57d
callq 0x12180
xorl %ecx, %ecx
testb %al, %al
jne 0x18a33
leaq 0x98(%rsp), %rdi
leaq 0x6730(%rip), %rsi      # 0x1f121
callq 0x12180
pushq $0x1
popq %rcx
testb %al, %al
jne 0x18a33
leaq 0x98(%rsp), %rdi
leaq 0x6b77(%rip), %rsi      # 0x1f583
callq 0x12180
pushq $0x2
popq %rcx
testb %al, %al
jne 0x18a33
leaq 0x98(%rsp), %rdi
leaq 0x4f63(%rip), %rsi      # 0x1d98a
callq 0x12180
pushq $0x3
popq %rcx
testb %al, %al
je 0x18a37
movl %ecx, 0x28(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x4216(%rip), %rsi      # 0x1cc5c
callq 0x12180
testb %al, %al
je 0x18a6b
leaq 0x98(%rsp), %rdi
callq 0x194a2
leal -0x1(%rax), %ecx
cmpl $0xfff, %ecx            # imm = 0xFFF
ja 0x18a6b
movl %eax, 0x2c(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x68c7(%rip), %rsi      # 0x1f341
callq 0x12180
testb %al, %al
je 0x18ad7
leaq 0x98(%rsp), %rdi
leaq 0x6af7(%rip), %rsi      # 0x1f589
callq 0x12180
pushq $0x1
popq %rcx
testb %al, %al
jne 0x18ad3
leaq 0x98(%rsp), %rdi
leaq 0x6674(%rip), %rsi      # 0x1f121
callq 0x12180
xorl %ecx, %ecx
testb %al, %al
jne 0x18ad3
leaq 0x98(%rsp), %rdi
leaq 0x6ac6(%rip), %rsi      # 0x1f58d
callq 0x12180
pushq $0x2
popq %rcx
testb %al, %al
je 0x18ad7
movl %ecx, 0x20(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x22a0
leaq 0xb8(%rsp), %rdi
callq 0x22a0
xorb $0x1, %bpl
jmp 0x1871a
movb 0xf(%rsp), %al
movb %al, 0x12(%rsp)
movl 0x50(%rsp), %eax
movb %al, 0x34(%rsp)
movl 0x60(%rsp), %eax
movb %al, 0x33(%rsp)
movl 0x64(%rsp), %eax
movb %al, 0x32(%rsp)
movl 0x44(%rsp), %eax
movb %al, 0x31(%rsp)
movl 0x48(%rsp), %eax
movb %al, 0x1c(%rsp)
movl 0x68(%rsp), %eax
movb %al, 0x1b(%rsp)
movl 0x54(%rsp), %eax
movb %al, 0x1a(%rsp)
movl 0x3c(%rsp), %eax
movb %al, 0x13(%rsp)
movl 0x6c(%rsp), %eax
movb %al, 0x14(%rsp)
movl 0x70(%rsp), %eax
movb %al, 0x19(%rsp)
movl 0x74(%rsp), %eax
movb %al, 0x11(%rsp)
movl 0x4c(%rsp), %eax
movb %al, 0x18(%rsp)
movl 0x58(%rsp), %eax
movb %al, 0x30(%rsp)
movl 0x5c(%rsp), %eax
movb %al, 0x24(%rsp)
movl 0x38(%rsp), %eax
movb %al, 0x10(%rsp)
movq %r15, %rdi
leaq 0x69cc(%rip), %rsi      # 0x1f550
callq 0x1938b
testb %al, %al
je 0x18bcd
cmpl $0x3f, %ebp
je 0x18bcd
cmpl $0x68, %ebp
je 0x18bcd
movq 0xe432(%rip), %rdi      # 0x26fd0
leaq 0x69b2(%rip), %rsi      # 0x1f557
callq 0x2210
movsbl %bpl, %esi
movq %rax, %rdi
callq 0x2270
movq %rax, %rdi
leaq 0x69a6(%rip), %rsi      # 0x1f566
callq 0x2210
movq %rax, %rdi
callq 0x2100
callq 0x13250
xorl %ebp, %ebp
jmp 0x1871a
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rax
cmpq %rax, %rsi
je 0x18d15
testb $0x1, 0x40(%rsp)
jne 0x18c2c
movb $0x1, %cl
movb %cl, 0x13(%rsp)
movb %cl, 0x1a(%rsp)
movb %cl, 0x31(%rsp)
testb %cl, 0x38(%rsp)
je 0x18c2c
movw $0x1, 0x30(%rsp)
xorl %ebp, %ebp
movq 0xe39b(%rip), %rbx      # 0x26fd0
leaq 0x5cd7(%rip), %r14      # 0x1e913
leaq 0xd8(%rsp), %r12
leaq 0x10(%rsp), %r13
xorl %r15d, %r15d
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rax, %r15
jae 0x18d35
cmpq $0x2, %rax
jb 0x18cb9
testq %r15, %r15
je 0x18c7e
testb $0x1, 0x78(%rsp)
jne 0x18c7e
movq %rbx, %rdi
callq 0x2100
movq 0x80(%rsp), %rsi
addq %rbp, %rsi
movq %rbx, %rdi
callq 0x21e0
movq %rax, %rdi
movq %r14, %rsi
callq 0x2210
movb 0x12(%rsp), %al
movl %eax, 0x78(%rsp)
testb %al, %al
je 0x18cb1
movq %rbx, %rdi
leaq 0x64a6(%rip), %rsi      # 0x1f150
callq 0x2210
jmp 0x18cb9
movq %rbx, %rdi
callq 0x2100
movq 0x80(%rsp), %rsi
addq %rbp, %rsi
movq %r12, %rdi
callq 0x193d6
movq %r12, %rdi
movq %r13, %rsi
callq 0x18496
movq %r12, %rdi
callq 0x1943a
incq %r15
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rax
addq $0x20, %rbp
jmp 0x18c4c
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
jmp 0x18d35
movq 0xe2b4(%rip), %rdi      # 0x26fd0
leaq 0x686e(%rip), %rsi      # 0x1f591
callq 0x2210
movq %rax, %rdi
callq 0x2100
callq 0x13250
leaq 0x80(%rsp), %rdi
callq 0x1916c
xorl %eax, %eax
addq $0x3b8, %rsp            # imm = 0x3B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x18d83
jmp 0x18deb
jmp 0x18d64
jmp 0x18e17
movq %rax, %rbx
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
jmp 0x18dab
jmp 0x18deb
movq %rax, %rbx
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x22a0
leaq 0xb8(%rsp), %rdi
callq 0x22a0
jmp 0x18e06
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x1943a
jmp 0x18e1a
jmp 0x18dce
movq %rax, %rbx
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
jmp 0x18e1a
movq %rax, %rbx
movb 0xc(%rsp), %al
movb %al, 0x15(%rsp)
movb 0xe(%rsp), %al
movb %al, 0x17(%rsp)
movb 0xd(%rsp), %al
movb %al, 0x16(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x22a0
jmp 0x18e1a
jmp 0x18e17
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0x1916c
movq %rbx, %rdi
callq 0x23a0
movq %rax, %rdi
callq 0xe69c
nop