// File: /workspace/github_cpp_makefile_star2_O1/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 $0x398, %rsp            # imm = 0x398
movq %rsi, 0xb0(%rsp)
xorl %r14d, %r14d
movq %r14, 0x1d(%rsp)
movq %r14, 0x18(%rsp)
movl $0x1, 0x28(%rsp)
movb %r14b, 0x2c(%rsp)
movabsq $0x5000000000, %rax     # imm = 0x5000000000
movq %rax, 0x30(%rsp)
movb %r14b, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movq %r14, 0x50(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
cmpl $0x2, %edi
setge %r13b
jl 0x1ddcf
leaq 0xc8(%rsp), %rbx
movl %edi, %eax
movq %rax, 0xa8(%rsp)
movl $0x1, %ebp
xorl %r14d, %r14d
leaq 0x58f9(%rip), %r15      # 0x2300c
movq 0xb0(%rsp), %rax
movq (%rax,%rbp,8), %rsi
leaq 0xb8(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x20c0
movq 0xc0(%rsp), %rax
cmpq $0x2, %rax
jb 0x1d7e9
movq 0xb8(%rsp), %rcx
cmpb $0x2d, (%rcx)
jne 0x1d75d
cmpb $0x2d, 0x1(%rcx)
jne 0x1d833
cmpq $0x2, %rax
jb 0x1d7e9
movq 0xb8(%rsp), %rcx
cmpb $0x2d, (%rcx)
jne 0x1d7e9
cmpb $0x2d, 0x1(%rcx)
jne 0x1d7e9
movl $0x2, %r12d
cmpq $0x2, %rax
je 0x1d798
cmpb $0x3d, (%rcx,%r12)
je 0x1d798
incq %r12
cmpq %r12, %rax
jne 0x1d786
movq %rax, %r12
leaq -0x2(%r12), %rcx
movl $0x2, %edx
leaq 0x80(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x2250
incq %r12
cmpq 0xc0(%rsp), %r12
jae 0x1daea
leaq 0x58(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
movq %r12, %rdx
movq $-0x1, %rcx
callq 0x2250
jmp 0x1db08
movb $0x1, %r12b
leaq 0x40(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x14ec4
movq 0xb8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x1d810
callq 0x2200
testb %r12b, %r12b
je 0x1ddcf
incq %rbp
cmpq 0xa8(%rsp), %rbp
setb %r13b
jne 0x1d713
jmp 0x1ddcf
leaq 0xb8(%rsp), %rdi
leaq 0x6cd7(%rip), %rsi      # 0x24519
callq 0x2090
testl %eax, %eax
je 0x1d886
leaq 0xb8(%rsp), %rdi
leaq 0x6cc2(%rip), %rsi      # 0x2451c
callq 0x2090
testl %eax, %eax
je 0x1d886
leaq 0xb8(%rsp), %rdi
leaq 0x6cad(%rip), %rsi      # 0x2451f
callq 0x2090
testl %eax, %eax
movzbl %r14b, %r14d
movl $0x1, %eax
cmovnel %eax, %r14d
movq 0xc0(%rsp), %r8
movb 0x38(%rsp), %dl
movb 0x18(%rsp), %al
movb 0x2c(%rsp), %cl
cmpq $0x2, %r8
jb 0x1dad6
movq %r14, 0x78(%rsp)
movq 0xb8(%rsp), %r12
movq 0xd718(%rip), %rsi      # 0x2afd0
movq (%rsi), %rsi
movq %rsi, 0xa0(%rsp)
movb 0x3c(%rsp), %sil
movb %sil, 0x10(%rsp)
movb 0x3b(%rsp), %sil
movb %sil, 0x12(%rsp)
movb 0x3a(%rsp), %sil
movb %sil, 0x13(%rsp)
movb 0x39(%rsp), %sil
movb %sil, 0xc(%rsp)
movb 0x24(%rsp), %sil
movb %sil, 0xd(%rsp)
movb 0x23(%rsp), %sil
movb %sil, 0x14(%rsp)
movb 0x22(%rsp), %sil
movb %sil, 0x11(%rsp)
movb 0x19(%rsp), %sil
movb %sil, 0x17(%rsp)
movb 0x1b(%rsp), %r11b
movb 0x1c(%rsp), %sil
movb %sil, 0x15(%rsp)
movb 0x21(%rsp), %sil
movb %sil, 0x16(%rsp)
movb 0x20(%rsp), %sil
movb %sil, 0xe(%rsp)
movb 0x1f(%rsp), %r10b
movb 0x1e(%rsp), %sil
movb %sil, 0xb(%rsp)
movl $0x1, %esi
movb 0x1d(%rsp), %dil
movb %dil, 0xf(%rsp)
movb (%r12,%rsi), %bl
movzbl %bl, %r14d
leal -0x61(%r14), %r9d
cmpl $0x19, %r9d
ja 0x1d97a
movslq (%r15,%r9,4), %r9
addq %r15, %r9
jmpq *%r9
movb $0x1, 0x15(%rsp)
jmp 0x1da31
leal -0x43(%r14), %r9d
cmpl $0x9, %r9d
ja 0x1dbbf
leaq 0x5655(%rip), %rdi      # 0x22fe4
movslq (%rdi,%r9,4), %r9
addq %rdi, %r9
jmpq *%r9
movb $0x1, 0xc(%rsp)
jmp 0x1da31
movq 0xa0(%rsp), %rdi
movq -0x18(%rdi), %r9
movq 0xd61a(%rip), %r14      # 0x2afd0
movl 0x18(%r14,%r9), %ebx
andl $-0x4b, %ebx
orl $0x8, %ebx
movl %ebx, 0x18(%r14,%r9)
movb $0x1, 0x10(%rsp)
jmp 0x1da31
movb $0x1, %al
jmp 0x1da31
movb $0x1, %cl
jmp 0x1da31
movb $0x1, 0x14(%rsp)
jmp 0x1da31
movb $0x1, %r11b
movb $0x1, 0x11(%rsp)
jmp 0x1da31
movb $0x1, 0x17(%rsp)
jmp 0x1da31
movb $0x1, 0xf(%rsp)
jmp 0x1da31
movb $0x1, 0x16(%rsp)
jmp 0x1da31
movb $0x1, 0x13(%rsp)
jmp 0x1da31
movb $0x1, %dl
jmp 0x1da31
movb $0x1, %r10b
jmp 0x1da31
movb $0x1, 0x12(%rsp)
jmp 0x1da31
movb $0x1, 0x1a(%rsp)
jmp 0x1da31
movb $0x1, 0xb(%rsp)
jmp 0x1da31
movb $0x1, 0xe(%rsp)
jmp 0x1da31
movb $0x1, %r11b
jmp 0x1da31
movb $0x1, 0xd(%rsp)
incq %rsi
cmpq %rsi, %r8
jne 0x1d954
movb %r10b, 0x1f(%rsp)
movb 0xb(%rsp), %sil
movb %sil, 0x1e(%rsp)
movb 0xf(%rsp), %sil
movb %sil, 0x1d(%rsp)
movb 0x10(%rsp), %sil
movb %sil, 0x3c(%rsp)
movb 0x12(%rsp), %sil
movb %sil, 0x3b(%rsp)
movb 0x13(%rsp), %sil
movb %sil, 0x3a(%rsp)
movb 0xc(%rsp), %sil
movb %sil, 0x39(%rsp)
movb 0xd(%rsp), %sil
movb %sil, 0x24(%rsp)
movb 0x14(%rsp), %sil
movb %sil, 0x23(%rsp)
movb 0x11(%rsp), %sil
movb %sil, 0x22(%rsp)
movb %r11b, 0x1b(%rsp)
movb 0x15(%rsp), %sil
movb %sil, 0x1c(%rsp)
movb 0x16(%rsp), %sil
movb %sil, 0x21(%rsp)
movb 0x17(%rsp), %sil
movb %sil, 0x19(%rsp)
movb 0xe(%rsp), %sil
movb %sil, 0x20(%rsp)
leaq 0xc8(%rsp), %rbx
movq 0x78(%rsp), %r14
movb %dl, 0x38(%rsp)
movb %cl, 0x2c(%rsp)
movb %al, 0x18(%rsp)
movb $0x1, %r12b
jmp 0x1d7fe
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x66f6(%rip), %rdx      # 0x241f6
movq %rdx, %rsi
callq 0x150da
leaq 0x80(%rsp), %rdi
leaq 0x6a2e(%rip), %rsi      # 0x24545
callq 0x2090
testl %eax, %eax
setne %r12b
je 0x1dbae
leaq 0x80(%rsp), %rdi
leaq 0x6a13(%rip), %rsi      # 0x2454a
callq 0x2090
testl %eax, %eax
jne 0x1dcfc
leaq 0x58(%rsp), %rdi
leaq 0x69ff(%rip), %rsi      # 0x2454f
callq 0x2090
testl %eax, %eax
je 0x1dbb8
leaq 0x58(%rsp), %rdi
leaq 0x658e(%rip), %rsi      # 0x240f3
callq 0x2090
testl %eax, %eax
je 0x1dcec
leaq 0x58(%rsp), %rdi
leaq 0x69d7(%rip), %rsi      # 0x24555
callq 0x2090
testl %eax, %eax
je 0x1dcf3
leaq 0x58(%rsp), %rdi
leaq 0x4dd3(%rip), %rsi      # 0x2296a
callq 0x2090
testl %eax, %eax
jne 0x1dcfc
movl $0x3, %eax
jmp 0x1dcf8
callq 0x16390
jmp 0x1dd98
xorl %eax, %eax
jmp 0x1dcf8
movb %r10b, 0x1f(%rsp)
movb 0xb(%rsp), %sil
movb %sil, 0x1e(%rsp)
movb 0xf(%rsp), %sil
movb %sil, 0x1d(%rsp)
movb 0x10(%rsp), %sil
movb %sil, 0x3c(%rsp)
movb 0x12(%rsp), %sil
movb %sil, 0x3b(%rsp)
movb 0x13(%rsp), %sil
movb %sil, 0x3a(%rsp)
movb 0xc(%rsp), %sil
movb %sil, 0x39(%rsp)
movb 0xd(%rsp), %sil
movb %sil, 0x24(%rsp)
movb 0x14(%rsp), %sil
movb %sil, 0x23(%rsp)
movb 0x11(%rsp), %sil
movb %sil, 0x22(%rsp)
movb %r11b, 0x1b(%rsp)
movb 0x15(%rsp), %sil
movb %sil, 0x1c(%rsp)
movb 0x16(%rsp), %sil
movb %sil, 0x21(%rsp)
movb 0x17(%rsp), %sil
movb %sil, 0x19(%rsp)
movb 0xe(%rsp), %sil
movb %sil, 0x20(%rsp)
movb %dl, 0x38(%rsp)
movb %cl, 0x2c(%rsp)
movb %al, 0x18(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x68bc(%rip), %rsi      # 0x24522
callq 0x2090
testl %eax, %eax
je 0x1dcd2
cmpl $0x3f, %r14d
je 0x1dcd2
cmpl $0x68, %r14d
je 0x1dcd2
movl $0xe, %edx
movq 0xd349(%rip), %rdi      # 0x2afd0
leaq 0x689b(%rip), %rsi      # 0x24529
callq 0x2280
movb %bl, 0x80(%rsp)
movl $0x1, %edx
movq 0xd32a(%rip), %rdi      # 0x2afd0
leaq 0x80(%rsp), %rsi
callq 0x2280
movq %rax, %r12
movl $0x11, %edx
movq %rax, %rdi
leaq 0x6873(%rip), %rsi      # 0x24538
callq 0x2280
movq %r12, %rdi
callq 0x2100
callq 0x16390
xorl %r12d, %r12d
leaq 0xc8(%rsp), %rbx
movq 0x78(%rsp), %r14
jmp 0x1d7fe
movl $0x1, %eax
jmp 0x1dcf8
movl $0x2, %eax
movl %eax, 0x30(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x3f31(%rip), %rsi      # 0x21c3c
callq 0x2090
testl %eax, %eax
jne 0x1dd2d
leaq 0x58(%rsp), %rdi
callq 0x1e761
leal -0x1(%rax), %ecx
cmpl $0xfff, %ecx            # imm = 0xFFF
ja 0x1dd2d
movl %eax, 0x34(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x65d7(%rip), %rsi      # 0x24313
callq 0x2090
testl %eax, %eax
jne 0x1dd98
leaq 0x58(%rsp), %rdi
leaq 0x680a(%rip), %rsi      # 0x2455b
callq 0x2090
testl %eax, %eax
je 0x1dd8b
leaq 0x58(%rsp), %rdi
leaq 0x638d(%rip), %rsi      # 0x240f3
callq 0x2090
testl %eax, %eax
je 0x1dd92
leaq 0x58(%rsp), %rdi
leaq 0x67e4(%rip), %rsi      # 0x2455f
callq 0x2090
testl %eax, %eax
jne 0x1dd98
movl $0x2, %eax
jmp 0x1dd94
movl $0x1, %eax
jmp 0x1dd94
xorl %eax, %eax
movl %eax, 0x28(%rsp)
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1ddac
callq 0x2200
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x1d7fe
callq 0x2200
jmp 0x1d7fe
testb $0x1, %r13b
jne 0x1dfba
movq 0x40(%rsp), %rax
cmpq 0x48(%rsp), %rax
je 0x1df6f
testb $0x1, %r14b
jne 0x1de0a
movb $0x1, %al
movb %al, 0x1b(%rsp)
movb %al, 0x22(%rsp)
movb %al, 0x39(%rsp)
cmpb %al, 0x18(%rsp)
jne 0x1de0a
movw $0x1, 0x38(%rsp)
movq 0x48(%rsp), %rax
subq 0x40(%rsp), %rax
je 0x1dfba
leaq 0x110(%rsp), %rbx
cmpq $0x21, %rax
setae %al
xorl %r15d, %r15d
movq 0xd19d(%rip), %r14      # 0x2afd0
leaq 0xb8(%rsp), %r13
leaq 0x18(%rsp), %rbp
xorl %r12d, %r12d
testb $0x1, %al
je 0x1deec
testq %r12, %r12
je 0x1de7e
cmpb $0x0, 0x1a(%rsp)
jne 0x1de7e
movq (%r14), %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 0x40(%rsp), %rax
movq (%rax,%r15), %rsi
movq 0x8(%rax,%r15), %rdx
movq %r14, %rdi
callq 0x2280
movl $0x1, %edx
movq %rax, %rdi
leaq 0x5a0c(%rip), %rsi      # 0x238af
callq 0x2280
cmpb $0x0, 0x1a(%rsp)
je 0x1dec5
movl $0x1, %edx
movq %r14, %rdi
leaq 0x6264(%rip), %rsi      # 0x24122
callq 0x2280
jmp 0x1deec
movq (%r14), %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 0x40(%rsp), %rsi
addq %r15, %rsi
movq %r13, %rdi
callq 0x1e66c
movq %r13, %rdi
movq %rbp, %rsi
callq 0x1d58e
movq %rbx, %rdi
callq 0xd128
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1df21
callq 0x2200
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x1df33
callq 0x2200
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x1df4d
callq 0x2200
incq %r12
movq 0x48(%rsp), %rcx
subq 0x40(%rsp), %rcx
sarq $0x5, %rcx
addq $0x20, %r15
movb $0x1, %al
cmpq %rcx, %r12
jb 0x1de43
jmp 0x1dfba
movq 0xd05a(%rip), %rbx      # 0x2afd0
leaq 0x65e6(%rip), %rsi      # 0x24563
movl $0x24, %edx
movq %rbx, %rdi
callq 0x2280
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2210
movsbl %al, %esi
movq 0xd028(%rip), %rdi      # 0x2afd0
callq 0x2040
movq %rax, %rdi
callq 0x2160
callq 0x16390
leaq 0x40(%rsp), %rdi
callq 0x1e3f6
xorl %eax, %eax
addq $0x398, %rsp            # imm = 0x398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1e057
jmp 0x1dfea
jmp 0x1dfde
movq %rax, %rbx
jmp 0x1e001
jmp 0x1e057
jmp 0x1e076
movq %rax, %rbx
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x1e001
callq 0x2200
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
jne 0x1e04e
jmp 0x1e05a
jmp 0x1e076
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x1e6f8
jmp 0x1e079
movq %rax, %rbx
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x1e041
callq 0x2200
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x1e05a
callq 0x2200
jmp 0x1e05a
jmp 0x1e076
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x1e079
callq 0x2200
jmp 0x1e079
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1e3f6
movq %rbx, %rdi
callq 0x2390
movq %rax, %rdi
callq 0x14eb9
nop