// File: 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
movq %rsp, %rbp
subq $0x4f0, %rsp            # imm = 0x4F0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x32a80
movb $0x0, -0x39(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x31cb0
movl $0x1, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x314da
movq -0x10(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x3f0(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x3e8(%rbp)
callq 0x2440
movq -0x3f0(%rbp), %rsi
movq -0x3e8(%rbp), %rdx
leaq -0x80(%rbp), %rdi
callq 0x2360
jmp 0x30b31
leaq -0x81(%rbp), %rdi
callq 0x22b0
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq %rax, -0x3f8(%rbp)
jmp 0x30b4f
movq -0x3f8(%rbp), %rax
cmpq $0x1, %rax
jbe 0x30f7d
xorl %eax, %eax
movl %eax, %esi
leaq -0x80(%rbp), %rdi
callq 0x2480
movq %rax, -0x400(%rbp)
jmp 0x30b76
movq -0x400(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x30f7d
leaq -0x80(%rbp), %rdi
movl $0x1, %esi
callq 0x2480
movq %rax, -0x408(%rbp)
jmp 0x30ba0
movq -0x408(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x30f7d
leaq 0xa62a(%rip), %rsi      # 0x3b1e4
leaq -0x80(%rbp), %rdi
callq 0x32790
movb %al, -0x409(%rbp)
jmp 0x30bcb
movb -0x409(%rbp), %al
testb $0x1, %al
jne 0x30bda
jmp 0x30c62
leaq 0xa606(%rip), %rsi      # 0x3b1e7
leaq -0x80(%rbp), %rdi
callq 0x32790
movb %al, -0x40a(%rbp)
jmp 0x30bf2
movb -0x40a(%rbp), %al
testb $0x1, %al
jne 0x30bfe
jmp 0x30c62
leaq 0xa5e5(%rip), %rsi      # 0x3b1ea
leaq -0x80(%rbp), %rdi
callq 0x32790
movb %al, -0x40b(%rbp)
jmp 0x30c16
movb -0x40b(%rbp), %al
testb $0x1, %al
jne 0x30c22
jmp 0x30c62
movb $0x1, -0x39(%rbp)
jmp 0x30c62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x81(%rbp), %rdi
callq 0x22b0
jmp 0x3171b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x314ca
movq $0x1, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x420(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq %rax, -0x418(%rbp)
jmp 0x30c8d
movq -0x420(%rbp), %rax
movq -0x418(%rbp), %rcx
cmpq %rcx, %rax
jae 0x30f78
movq -0xa0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2480
movq %rax, -0x428(%rbp)
jmp 0x30cbd
movq -0x428(%rbp), %rax
movb (%rax), %al
movb %al, -0xa1(%rbp)
movsbl -0xa1(%rbp), %eax
cmpl $0x6f, %eax
jne 0x30ce1
movb $0x1, -0x36(%rbp)
jmp 0x30f5f
movsbl -0xa1(%rbp), %eax
cmpl $0x48, %eax
jne 0x30cf6
movb $0x1, -0x35(%rbp)
jmp 0x30f5d
movsbl -0xa1(%rbp), %eax
cmpl $0x69, %eax
jne 0x30d0b
movb $0x1, -0x33(%rbp)
jmp 0x30f5b
movsbl -0xa1(%rbp), %eax
cmpl $0x49, %eax
jne 0x30d20
movb $0x1, -0x32(%rbp)
jmp 0x30f59
movsbl -0xa1(%rbp), %eax
cmpl $0x65, %eax
jne 0x30d35
movb $0x1, -0x31(%rbp)
jmp 0x30f57
movsbl -0xa1(%rbp), %eax
cmpl $0x45, %eax
jne 0x30d4a
movb $0x1, -0x30(%rbp)
jmp 0x30f55
movsbl -0xa1(%rbp), %eax
cmpl $0x76, %eax
jne 0x30d5f
movb $0x1, -0x38(%rbp)
jmp 0x30f53
movsbl -0xa1(%rbp), %eax
cmpl $0x74, %eax
jne 0x30d74
movb $0x1, -0x37(%rbp)
jmp 0x30f51
movsbl -0xa1(%rbp), %eax
cmpl $0x73, %eax
jne 0x30d89
movb $0x1, -0x2f(%rbp)
jmp 0x30f4f
movsbl -0xa1(%rbp), %eax
cmpl $0x61, %eax
jne 0x30d9e
movb $0x1, -0x34(%rbp)
jmp 0x30f4d
movsbl -0xa1(%rbp), %eax
cmpl $0x70, %eax
jne 0x30db7
movb $0x1, -0x2e(%rbp)
movb $0x1, -0x35(%rbp)
jmp 0x30f4b
movsbl -0xa1(%rbp), %eax
cmpl $0x72, %eax
jne 0x30dcc
movb $0x1, -0x24(%rbp)
jmp 0x30f49
movsbl -0xa1(%rbp), %eax
cmpl $0x6c, %eax
jne 0x30de1
movb $0x1, -0x2d(%rbp)
jmp 0x30f47
movsbl -0xa1(%rbp), %eax
cmpl $0x4c, %eax
jne 0x30df6
movb $0x1, -0x2c(%rbp)
jmp 0x30f45
movsbl -0xa1(%rbp), %eax
cmpl $0x63, %eax
jne 0x30e0b
movb $0x1, -0x18(%rbp)
jmp 0x30f43
movsbl -0xa1(%rbp), %eax
cmpl $0x43, %eax
jne 0x30e20
movb $0x1, -0x17(%rbp)
jmp 0x30f41
movsbl -0xa1(%rbp), %eax
cmpl $0x66, %eax
jne 0x30e35
movb $0x1, -0x16(%rbp)
jmp 0x30f3f
movsbl -0xa1(%rbp), %eax
cmpl $0x7a, %eax
jne 0x30e4a
movb $0x1, -0x15(%rbp)
jmp 0x30f3d
movsbl -0xa1(%rbp), %eax
cmpl $0x78, %eax
jne 0x30e74
movb $0x1, -0x14(%rbp)
movq 0x1616f(%rip), %rdi     # 0x46fd0
leaq 0xde8(%rip), %rsi       # 0x31c50
callq 0x20b0
jmp 0x30e6f
jmp 0x30f3b
leaq 0xa372(%rip), %rsi      # 0x3b1ed
leaq -0x80(%rbp), %rdi
callq 0x32790
movb %al, -0x429(%rbp)
jmp 0x30e8c
movb -0x429(%rbp), %al
testb $0x1, %al
jne 0x30e9b
jmp 0x30f1e
movsbl -0xa1(%rbp), %eax
cmpl $0x68, %eax
je 0x30f1e
movsbl -0xa1(%rbp), %eax
cmpl $0x3f, %eax
je 0x30f1e
movq 0x16116(%rip), %rdi     # 0x46fd0
leaq 0xa333(%rip), %rsi      # 0x3b1f4
callq 0x2250
movq %rax, -0x438(%rbp)
jmp 0x30ecf
movq -0x438(%rbp), %rdi
movsbl -0xa1(%rbp), %esi
callq 0x22f0
movq %rax, -0x440(%rbp)
jmp 0x30eeb
movq -0x440(%rbp), %rdi
leaq 0xa30a(%rip), %rsi      # 0x3b203
callq 0x2250
movq %rax, -0x448(%rbp)
jmp 0x30f07
movq -0x448(%rbp), %rdi
movq 0x160ab(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x30f1c
jmp 0x30f1e
callq 0x27b40
jmp 0x30f25
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa8(%rbp)
jmp 0x31488
jmp 0x30f3d
jmp 0x30f3f
jmp 0x30f41
jmp 0x30f43
jmp 0x30f45
jmp 0x30f47
jmp 0x30f49
jmp 0x30f4b
jmp 0x30f4d
jmp 0x30f4f
jmp 0x30f51
jmp 0x30f53
jmp 0x30f55
jmp 0x30f57
jmp 0x30f59
jmp 0x30f5b
jmp 0x30f5d
jmp 0x30f5f
jmp 0x30f61
movq -0xa0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xa0(%rbp)
jmp 0x30c6d
jmp 0x3147e
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq %rax, -0x450(%rbp)
jmp 0x30f8f
movq -0x450(%rbp), %rax
cmpq $0x1, %rax
jbe 0x3146b
xorl %eax, %eax
movl %eax, %esi
leaq -0x80(%rbp), %rdi
callq 0x2480
movq %rax, -0x458(%rbp)
jmp 0x30fb6
movq -0x458(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x3146b
leaq -0x80(%rbp), %rdi
movl $0x1, %esi
callq 0x2480
movq %rax, -0x460(%rbp)
jmp 0x30fe0
movq -0x460(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
jne 0x3146b
movq $0x2, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x470(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq %rax, -0x468(%rbp)
jmp 0x3101e
movq -0x470(%rbp), %rcx
movq -0x468(%rbp), %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x471(%rbp)
jae 0x31068
movq -0xb0(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x2480
movq %rax, -0x480(%rbp)
jmp 0x31052
movq -0x480(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
setne %al
movb %al, -0x471(%rbp)
movb -0x471(%rbp), %al
testb $0x1, %al
jne 0x31074
jmp 0x3108b
movq -0xb0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xb0(%rbp)
jmp 0x30ffe
movq -0xb0(%rbp), %rcx
addq $-0x2, %rcx
leaq -0xd0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movl $0x2, %edx
callq 0x2280
jmp 0x310ad
movq -0xb0(%rbp), %rax
incq %rax
movq %rax, -0x490(%rbp)
movb $0x0, -0xf2(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x21a0
movq %rax, -0x488(%rbp)
jmp 0x310d7
movq -0x490(%rbp), %rax
movq -0x488(%rbp), %rcx
cmpq %rcx, %rax
jae 0x3110f
movq -0xb0(%rbp), %rdx
incq %rdx
leaq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq $-0x1, %rcx
callq 0x2280
jmp 0x3110d
jmp 0x31147
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x498(%rbp)
callq 0x2440
movq -0x498(%rbp), %rdx
movb $0x1, -0xf2(%rbp)
leaq 0x9d8a(%rip), %rsi      # 0x3aec1
leaq -0xf0(%rbp), %rdi
callq 0x2360
jmp 0x31145
jmp 0x31147
testb $0x1, -0xf2(%rbp)
jne 0x31152
jmp 0x3115e
leaq -0xf1(%rbp), %rdi
callq 0x22b0
leaq 0xa0ab(%rip), %rsi      # 0x3b210
leaq -0xd0(%rbp), %rdi
callq 0x22220
movb %al, -0x499(%rbp)
jmp 0x31179
movb -0x499(%rbp), %al
testb $0x1, %al
jne 0x31188
jmp 0x3120d
callq 0x27b40
jmp 0x3118f
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa8(%rbp)
jmp 0x3142f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x3145b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
testb $0x1, -0xf2(%rbp)
jne 0x311d9
jmp 0x311e5
leaq -0xf1(%rbp), %rdi
callq 0x22b0
jmp 0x3145b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2170
jmp 0x31459
leaq 0xa001(%rip), %rsi      # 0x3b215
leaq -0xd0(%rbp), %rdi
callq 0x22220
movb %al, -0x49a(%rbp)
jmp 0x31228
movb -0x49a(%rbp), %al
testb $0x1, %al
jne 0x31237
jmp 0x31300
leaq 0x9fdc(%rip), %rsi      # 0x3b21a
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x49b(%rbp)
jmp 0x31252
movb -0x49b(%rbp), %al
testb $0x1, %al
jne 0x3125e
jmp 0x3126a
movl $0x0, -0x20(%rbp)
jmp 0x312fe
leaq 0x9b4d(%rip), %rsi      # 0x3adbe
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x49c(%rbp)
jmp 0x31285
movb -0x49c(%rbp), %al
testb $0x1, %al
jne 0x31291
jmp 0x3129a
movl $0x1, -0x20(%rbp)
jmp 0x312fc
leaq 0x9f7f(%rip), %rsi      # 0x3b220
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x49d(%rbp)
jmp 0x312b5
movb -0x49d(%rbp), %al
testb $0x1, %al
jne 0x312c1
jmp 0x312ca
movl $0x2, -0x20(%rbp)
jmp 0x312fa
leaq 0x84a1(%rip), %rsi      # 0x39772
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x49e(%rbp)
jmp 0x312e5
movb -0x49e(%rbp), %al
testb $0x1, %al
jne 0x312f1
jmp 0x312f8
movl $0x3, -0x20(%rbp)
jmp 0x312fa
jmp 0x312fc
jmp 0x312fe
jmp 0x31300
leaq 0x773d(%rip), %rsi      # 0x38a44
leaq -0xd0(%rbp), %rdi
callq 0x22220
movb %al, -0x49f(%rbp)
jmp 0x3131b
movb -0x49f(%rbp), %al
testb $0x1, %al
jne 0x31327
jmp 0x31367
leaq -0xf0(%rbp), %rdi
callq 0x32af0
movl %eax, -0x4a4(%rbp)
jmp 0x3133b
movl -0x4a4(%rbp), %eax
movl %eax, -0xf8(%rbp)
cmpl $0x1, -0xf8(%rbp)
jl 0x31365
cmpl $0x1000, -0xf8(%rbp)    # imm = 0x1000
jg 0x31365
movl -0xf8(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x31367
leaq 0x9c70(%rip), %rsi      # 0x3afde
leaq -0xd0(%rbp), %rdi
callq 0x22220
movb %al, -0x4a5(%rbp)
jmp 0x31382
movb -0x4a5(%rbp), %al
testb $0x1, %al
jne 0x31391
jmp 0x31425
leaq 0x9e8e(%rip), %rsi      # 0x3b226
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x4a6(%rbp)
jmp 0x313ac
movb -0x4a6(%rbp), %al
testb $0x1, %al
jne 0x313b8
jmp 0x313c1
movl $0x1, -0x28(%rbp)
jmp 0x31423
leaq 0x99f6(%rip), %rsi      # 0x3adbe
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x4a7(%rbp)
jmp 0x313dc
movb -0x4a7(%rbp), %al
testb $0x1, %al
jne 0x313e8
jmp 0x313f1
movl $0x0, -0x28(%rbp)
jmp 0x31421
leaq 0x9e32(%rip), %rsi      # 0x3b22a
leaq -0xf0(%rbp), %rdi
callq 0x22220
movb %al, -0x4a8(%rbp)
jmp 0x3140c
movb -0x4a8(%rbp), %al
testb $0x1, %al
jne 0x31418
jmp 0x3141f
movl $0x2, -0x28(%rbp)
jmp 0x31421
jmp 0x31423
jmp 0x31425
movl $0x0, -0xa8(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x2170
jmp 0x3143d
leaq -0xd0(%rbp), %rdi
callq 0x2170
jmp 0x3144b
movl -0xa8(%rbp), %eax
testl %eax, %eax
jne 0x31488
jmp 0x31457
jmp 0x3147c
jmp 0x3145b
leaq -0xd0(%rbp), %rdi
callq 0x2170
jmp 0x31469
jmp 0x314ca
leaq -0x58(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x22140
jmp 0x3147a
jmp 0x3147c
jmp 0x3147e
movl $0x0, -0xa8(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x2170
jmp 0x31493
movl -0xa8(%rbp), %eax
testl %eax, %eax
jne 0x31706
jmp 0x314a3
jmp 0x314a5
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x30ae6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
jmp 0x3171b
leaq -0x80(%rbp), %rdi
callq 0x2170
jmp 0x314d5
jmp 0x3171b
leaq -0x58(%rbp), %rdi
callq 0x31cf0
movb %al, -0x4a9(%rbp)
jmp 0x314eb
movb -0x4a9(%rbp), %al
testb $0x1, %al
jne 0x314f7
jmp 0x31545
movq 0x15ad2(%rip), %rdi     # 0x46fd0
leaq 0x9d29(%rip), %rsi      # 0x3b22e
callq 0x2250
movq %rax, -0x4b8(%rbp)
jmp 0x31513
movq -0x4b8(%rbp), %rdi
movq 0x15a9f(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x31528
callq 0x27b40
jmp 0x3152f
movl $0x0, -0x4(%rbp)
movl $0x1, -0xa8(%rbp)
jmp 0x31706
testb $0x1, -0x39(%rbp)
jne 0x31567
movb $0x1, -0x35(%rbp)
movb $0x1, -0x2e(%rbp)
movb $0x1, -0x17(%rbp)
testb $0x1, -0x38(%rbp)
je 0x31565
movb $0x0, -0x17(%rbp)
movb $0x1, -0x18(%rbp)
jmp 0x31567
movq $0x0, -0x100(%rbp)
movq -0x100(%rbp), %rax
movq %rax, -0x4c8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x22fe0
movq %rax, -0x4c0(%rbp)
jmp 0x31592
movq -0x4c8(%rbp), %rax
movq -0x4c0(%rbp), %rcx
cmpq %rcx, %rax
jae 0x316fc
leaq -0x58(%rbp), %rdi
callq 0x22fe0
movq %rax, -0x4d0(%rbp)
jmp 0x315bb
movq -0x4d0(%rbp), %rax
cmpq $0x1, %rax
jbe 0x31673
cmpq $0x0, -0x100(%rbp)
jbe 0x315f3
testb $0x1, -0x36(%rbp)
jne 0x315f3
movq 0x159ed(%rip), %rdi     # 0x46fd0
movq 0x159d6(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x315f1
jmp 0x315f3
movq -0x100(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x31db0
movq %rax, -0x4d8(%rbp)
jmp 0x3160c
movq -0x4d8(%rbp), %rsi
movq 0x159b6(%rip), %rdi     # 0x46fd0
callq 0x2210
movq %rax, -0x4e0(%rbp)
jmp 0x31628
movq -0x4e0(%rbp), %rdi
leaq 0x8f41(%rip), %rsi      # 0x3a577
callq 0x2250
jmp 0x3163d
testb $0x1, -0x36(%rbp)
jne 0x3165a
movq 0x15986(%rip), %rdi     # 0x46fd0
movq 0x1596f(%rip), %rsi     # 0x46fc0
callq 0x22a0
jmp 0x31658
jmp 0x31671
movq 0x1596f(%rip), %rdi     # 0x46fd0
leaq 0x9785(%rip), %rsi      # 0x3aded
callq 0x2250
jmp 0x3166f
jmp 0x31671
jmp 0x31673
movq -0x100(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0x31db0
movq %rax, -0x4e8(%rbp)
jmp 0x3168c
movq -0x4e8(%rbp), %rsi
leaq -0x3e0(%rbp), %rdi
callq 0x328d0
jmp 0x316a1
leaq -0x3e0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x30960
jmp 0x316b3
leaq -0x3e0(%rbp), %rdi
callq 0x329c0
jmp 0x316c1
jmp 0x316c3
movq -0x100(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x100(%rbp)
jmp 0x31572
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x90(%rbp)
movl %eax, -0x94(%rbp)
leaq -0x3e0(%rbp), %rdi
callq 0x329c0
jmp 0x316fa
jmp 0x3171b
movl $0x0, -0xa8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x32010
movl -0x4(%rbp), %eax
addq $0x4f0, %rsp            # imm = 0x4F0
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x32010
jmp 0x31726
jmp 0x31728
movq -0x90(%rbp), %rdi
callq 0x2430
movq %rax, %rdi
callq 0x19400
nopl (%rax)