// File: atfrank[P]PCASA/lib/PDB.cpp
// Function: PDB::readPDB(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, bool)
Molecule* PDB::readPDB(const std::string ifile, const int model, const std::string format, const bool hetFlag, const bool remFlag){
  std::ifstream pdbFile;
  std::istream* inp;
  std::string line;
  int currModel=0;
  bool modelFlag=true;
  bool firstModelFlag=false;
  Molecule *mol;
  Chain *chnEntry=new Chain;
  Residue *resEntry=new Residue;
  Atom *atmEntry; //Created in heap by processAtomLine
  Atom *lastAtom;
  PDB pdb;
  std::string PDBID;
  unsigned int year;

  if (format.compare("CHARMM") == 0){
    mol=new MoleculeCHARMM;
  }
  else{
    mol=new Molecule;
  }

  atmEntry=NULL;
  lastAtom=NULL;
  mol->setCopyFlag(false);

  if (ifile.compare("-") == 0){ //Input from pipe
    inp=&std::cin;
  }
  else{ //Input from file
    pdbFile.open((ifile).c_str(), std::ios::in);
    inp=&pdbFile;
    PDBID=Misc::toupper(ifile.substr(0,4));
    mol->setTag(PDBID);
  }

  while (inp->good() && !(inp->eof())){

    getline(*inp,line);
    if (line.compare(0,6,"HEADER") == 0){
      std::stringstream(line.substr(57,2)) >> year;
      if (year < 71){
        mol->setYear(year+2000);
      }
      else{
        mol->setYear(year+1900);
      }
      if (Misc::trim(line.substr(62,4)).length() == 4){
        PDBID=Misc::toupper(Misc::trim(line.substr(62,4)));
      }
    }
    else if (line.compare(0,6,"EXPDTA") == 0){
      mol->setExp(Misc::trim(line.substr(10,60)));
    }
    else if (line.size() > 6 && line.compare(0,6,"MODEL ") == 0){
      std::stringstream(line.substr(10,4)) >> currModel;
      if ((model==0 && firstModelFlag==false) || currModel==model){
        firstModelFlag=true; //Processed first model
        modelFlag=true;
      }
      else{
        modelFlag=false;
      }
    }
    else if (line.size() > 6 && line.compare(0,6,"REMARK") == 0 && remFlag == true){
      mol->addRemark(line);
    }
    else if (modelFlag && line.size() >= 54 && (line.compare(0,4,"ATOM") == 0 || (line.compare(0,6,"HETATM") == 0 && hetFlag == true) || (line.compare(0,5,"HETAT") == 0 && hetFlag == true))){
      //Atom
      atmEntry=pdb.processAtomLine(line, lastAtom);
      atmEntry->setTag(PDBID);
      if (lastAtom != NULL && lastAtom->getResId() == atmEntry->getResId()){
        if (lastAtom->getResName().compare(atmEntry->getResName()) == 0 && (lastAtom->getAlt().compare(0,1," ") == 0 || lastAtom->getAlt().compare(0,1,atmEntry->getAlt(),0,1) == 0)){
          //Eliminate other alternate locations besides first
          mol->addAtom(atmEntry);
        }
        else{
          continue;
        }
      }
      else{
        mol->addAtom(atmEntry);
      }

      //Residue/Chain
      if (lastAtom != NULL && atmEntry->getChainId().compare(lastAtom->getChainId()) != 0) {
        //Store last
        chnEntry->addResidue(resEntry);
        mol->addResidue(resEntry);
        mol->addChain(chnEntry);
        //Create new
        chnEntry=new Chain;
        resEntry=new Residue;
      }
      else if (lastAtom != NULL && lastAtom->getResId() != atmEntry->getResId()){
        chnEntry->addResidue(resEntry);
        mol->addResidue(resEntry);
        resEntry=new Residue;
      }
      else{
        //Do nothing
      }
      
      atmEntry->setResidue(resEntry);
      atmEntry->setChain(chnEntry);
      resEntry->addAtom(atmEntry);
      chnEntry->addAtom(atmEntry);

      //Update for next atom
      lastAtom=atmEntry;
    }
    else{
      continue;
    }
  }
  //Add remaining residues and chains
  if (resEntry->getAtmVecSize() > 0){
    chnEntry->addResidue(resEntry);
    mol->addResidue(resEntry);
    mol->addChain(chnEntry);
  }
  
  if (ifile.compare("-") != 0 && pdbFile.is_open()){
    pdbFile.close();
  }

  if (mol->getAtmVecSize() == 0){
    std::cerr << std::endl << "Error: The PDB file \"" << ifile << "\" ";
    std::cerr << "did not contain any valid atoms" << std::endl << std::endl;
    exit(1);
  }

  mol->setICodeFlag(mol->checkICode());

  return mol;
}

// Assembly:
subq $0x9a8, %rsp            # imm = 0x9A8
movq %rdx, 0x178(%rsp)
movq %rdi, 0x180(%rsp)
movb %r8b, %al
movq %rdi, 0x9a0(%rsp)
movl %esi, 0x99c(%rsp)
movq %rdx, 0x990(%rsp)
andb $0x1, %cl
movb %cl, 0x98f(%rsp)
andb $0x1, %al
movb %al, 0x98e(%rsp)
leaq 0x780(%rsp), %rdi
callq 0x54c0
leaq 0x758(%rsp), %rdi
callq 0x5600
movl $0x0, 0x754(%rsp)
movb $0x1, 0x753(%rsp)
movb $0x0, 0x752(%rsp)
movl $0x30, %edi
callq 0x5410
movq %rax, 0x188(%rsp)
jmp 0x53d0d
movq 0x188(%rsp), %rdi
callq 0x3a320
jmp 0x53d1c
movq 0x188(%rsp), %rax
movq %rax, 0x740(%rsp)
movl $0x18, %edi
callq 0x5410
movq %rax, 0x170(%rsp)
jmp 0x53d40
movq 0x170(%rsp), %rdi
callq 0x5de80
jmp 0x53d4f
movq 0x170(%rsp), %rax
movq %rax, 0x728(%rsp)
leaq 0x6c8(%rsp), %rdi
callq 0x53000
jmp 0x53d6e
leaq 0x6a8(%rsp), %rdi
callq 0x5600
movq 0x178(%rsp), %rdi
leaq 0x2874c(%rip), %rsi     # 0x7c4d6
callq 0x5140
cmpl $0x0, %eax
jne 0x53e83
movl $0x1a0, %edi            # imm = 0x1A0
callq 0x5410
movq %rax, 0x168(%rsp)
jmp 0x53dac
movq 0x168(%rsp), %rdi
callq 0x56c10
jmp 0x53dbb
movq 0x168(%rsp), %rax
movq %rax, 0x748(%rsp)
jmp 0x53ee3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x54fe8
movq 0x188(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x30, %esi
callq 0x5420
jmp 0x54fe8
movq 0x170(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x18, %esi
callq 0x5420
jmp 0x54fe8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x54fce
movq 0x168(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x1a0, %esi            # imm = 0x1A0
callq 0x5420
jmp 0x54fce
movl $0x1a0, %edi            # imm = 0x1A0
callq 0x5410
movq %rax, 0x160(%rsp)
jmp 0x53e97
movq 0x160(%rsp), %rdi
callq 0x41a20
jmp 0x53ea6
movq 0x160(%rsp), %rax
movq %rax, 0x748(%rsp)
jmp 0x53ee3
movq 0x160(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x1a0, %esi            # imm = 0x1A0
callq 0x5420
jmp 0x54fce
movq $0x0, 0x720(%rsp)
movq $0x0, 0x718(%rsp)
movq 0x748(%rsp), %rdi
xorl %esi, %esi
callq 0x428b0
jmp 0x53f0c
movq 0x180(%rsp), %rdi
leaq 0x284af(%rip), %rsi     # 0x7c3ca
callq 0x5140
cmpl $0x0, %eax
jne 0x53f39
movq 0x3e70a4(%rip), %rax    # 0x43afd0
movq %rax, 0x778(%rsp)
jmp 0x54022
movq 0x180(%rsp), %rdi
callq 0x51a0
movq %rax, %rsi
leaq 0x780(%rsp), %rdi
movl $0x8, %edx
callq 0x5260
jmp 0x53f5d
movq 0x180(%rsp), %rsi
leaq 0x780(%rsp), %rax
movq %rax, 0x778(%rsp)
xorl %eax, %eax
movl %eax, %edx
leaq 0x660(%rsp), %rdi
movl $0x4, %ecx
callq 0x5440
jmp 0x53f8d
leaq 0x680(%rsp), %rdi
leaq 0x660(%rsp), %rsi
callq 0x3e230
jmp 0x53fa4
leaq 0x6a8(%rsp), %rdi
movq %rdi, 0x158(%rsp)
leaq 0x680(%rsp), %rsi
movq %rsi, 0x150(%rsp)
callq 0x5510
movq 0x150(%rsp), %rdi
callq 0x5250
leaq 0x660(%rsp), %rdi
callq 0x5250
movq 0x158(%rsp), %rsi
movq 0x748(%rsp), %rdi
callq 0x42970
jmp 0x53ffa
jmp 0x54022
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x660(%rsp), %rdi
callq 0x5250
jmp 0x54fce
jmp 0x54024
movq 0x778(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x56e0
movb %al, 0x14f(%rsp)
jmp 0x54044
movb 0x14f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x14e(%rsp)
jne 0x5405b
jmp 0x5408b
movq 0x778(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x5760
movb %al, 0x14d(%rsp)
jmp 0x5407b
movb 0x14d(%rsp), %al
xorb $-0x1, %al
movb %al, 0x14e(%rsp)
movb 0x14e(%rsp), %al
testb $0x1, %al
jne 0x5409b
jmp 0x54ddd
movq 0x778(%rsp), %rdi
leaq 0x758(%rsp), %rsi
callq 0x50c0
jmp 0x540b2
leaq 0x284e5(%rip), %rcx     # 0x7c59e
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x6, %edx
callq 0x55a0
movl %eax, 0x148(%rsp)
jmp 0x540d8
movl 0x148(%rsp), %eax
cmpl $0x0, %eax
jne 0x544a2
leaq 0x4b8(%rsp), %rdi
leaq 0x758(%rsp), %rsi
movl $0x39, %edx
movl $0x2, %ecx
callq 0x5440
jmp 0x54109
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x144(%rsp)
jmp 0x54121
movl 0x144(%rsp), %edx
leaq 0x4d8(%rsp), %rdi
leaq 0x4b8(%rsp), %rsi
callq 0x5670
jmp 0x5413f
leaq 0x4d8(%rsp), %rdi
leaq 0x6a4(%rsp), %rsi
callq 0x3c780
jmp 0x54156
leaq 0x4d8(%rsp), %rdi
callq 0x52e0
leaq 0x4b8(%rsp), %rdi
callq 0x5250
cmpl $0x47, 0x6a4(%rsp)
jae 0x541ef
movq 0x748(%rsp), %rdi
movl 0x6a4(%rsp), %eax
addl $0x7d0, %eax            # imm = 0x7D0
movl %eax, 0x4b4(%rsp)
leaq 0x4b4(%rsp), %rsi
callq 0x428d0
jmp 0x541a4
jmp 0x5421b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x541dd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x4d8(%rsp), %rdi
callq 0x52e0
leaq 0x4b8(%rsp), %rdi
callq 0x5250
jmp 0x54fce
movq 0x748(%rsp), %rdi
movl 0x6a4(%rsp), %eax
addl $0x76c, %eax            # imm = 0x76C
movl %eax, 0x4b0(%rsp)
leaq 0x4b0(%rsp), %rsi
callq 0x428d0
jmp 0x54219
jmp 0x5421b
leaq 0x470(%rsp), %rdi
leaq 0x758(%rsp), %rsi
movl $0x3e, %edx
movl $0x4, %ecx
callq 0x5440
jmp 0x5423c
leaq 0x44f(%rsp), %rdi
movq %rdi, 0x138(%rsp)
callq 0x5730
movq 0x138(%rsp), %rdx
leaq 0x28338(%rip), %rsi     # 0x7c598
leaq 0x450(%rsp), %rdi
callq 0x7900
jmp 0x5426f
leaq 0x490(%rsp), %rdi
leaq 0x470(%rsp), %rsi
leaq 0x450(%rsp), %rdx
callq 0x3dee0
jmp 0x5428e
leaq 0x490(%rsp), %rdi
callq 0x5630
movq %rax, 0x130(%rsp)
leaq 0x490(%rsp), %rdi
callq 0x5250
leaq 0x450(%rsp), %rdi
callq 0x5250
leaq 0x44f(%rsp), %rdi
callq 0x5480
leaq 0x470(%rsp), %rdi
callq 0x5250
movq 0x130(%rsp), %rax
cmpq $0x4, %rax
jne 0x5449d
leaq 0x3e8(%rsp), %rdi
leaq 0x758(%rsp), %rsi
movl $0x3e, %edx
movl $0x4, %ecx
callq 0x5440
jmp 0x5430a
leaq 0x3c7(%rsp), %rdi
movq %rdi, 0x128(%rsp)
callq 0x5730
movq 0x128(%rsp), %rdx
leaq 0x2826a(%rip), %rsi     # 0x7c598
leaq 0x3c8(%rsp), %rdi
callq 0x7900
jmp 0x5433d
leaq 0x408(%rsp), %rdi
leaq 0x3e8(%rsp), %rsi
leaq 0x3c8(%rsp), %rdx
callq 0x3dee0
jmp 0x5435c
leaq 0x428(%rsp), %rdi
leaq 0x408(%rsp), %rsi
callq 0x3e230
jmp 0x54373
leaq 0x6a8(%rsp), %rdi
leaq 0x428(%rsp), %rsi
callq 0x5510
leaq 0x428(%rsp), %rdi
callq 0x5250
leaq 0x408(%rsp), %rdi
callq 0x5250
leaq 0x3c8(%rsp), %rdi
callq 0x5250
leaq 0x3c7(%rsp), %rdi
callq 0x5480
leaq 0x3e8(%rsp), %rdi
callq 0x5250
jmp 0x5449d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x54405
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x450(%rsp), %rdi
callq 0x5250
leaq 0x44f(%rsp), %rdi
callq 0x5480
leaq 0x470(%rsp), %rdi
callq 0x5250
jmp 0x54fce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x5447e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x54471
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x408(%rsp), %rdi
callq 0x5250
leaq 0x3c8(%rsp), %rdi
callq 0x5250
leaq 0x3c7(%rsp), %rdi
callq 0x5480
leaq 0x3e8(%rsp), %rdi
callq 0x5250
jmp 0x54fce
jmp 0x54dd8
leaq 0x280fc(%rip), %rcx     # 0x7c5a5
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x6, %edx
callq 0x55a0
movl %eax, 0x124(%rsp)
jmp 0x544c8
movl 0x124(%rsp), %eax
cmpl $0x0, %eax
jne 0x54624
movq 0x748(%rsp), %rax
movq %rax, 0x118(%rsp)
leaq 0x380(%rsp), %rdi
leaq 0x758(%rsp), %rsi
movl $0xa, %edx
movl $0x3c, %ecx
callq 0x5440
jmp 0x54509
leaq 0x35f(%rsp), %rdi
movq %rdi, 0x110(%rsp)
callq 0x5730
movq 0x110(%rsp), %rdx
leaq 0x2806b(%rip), %rsi     # 0x7c598
leaq 0x360(%rsp), %rdi
callq 0x7900
jmp 0x5453c
leaq 0x3a0(%rsp), %rdi
leaq 0x380(%rsp), %rsi
leaq 0x360(%rsp), %rdx
callq 0x3dee0
jmp 0x5455b
movq 0x118(%rsp), %rdi
leaq 0x3a0(%rsp), %rsi
callq 0x42910
jmp 0x54572
leaq 0x3a0(%rsp), %rdi
callq 0x5250
leaq 0x360(%rsp), %rdi
callq 0x5250
leaq 0x35f(%rsp), %rdi
callq 0x5480
leaq 0x380(%rsp), %rdi
callq 0x5250
jmp 0x54dd6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x54605
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x545f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x3a0(%rsp), %rdi
callq 0x5250
leaq 0x360(%rsp), %rdi
callq 0x5250
leaq 0x35f(%rsp), %rdi
callq 0x5480
leaq 0x380(%rsp), %rdi
callq 0x5250
jmp 0x54fce
leaq 0x758(%rsp), %rdi
callq 0x5290
cmpq $0x6, %rax
jbe 0x5478c
leaq 0x27f6a(%rip), %rcx     # 0x7c5ac
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x6, %edx
callq 0x55a0
movl %eax, 0x10c(%rsp)
jmp 0x54661
movl 0x10c(%rsp), %eax
cmpl $0x0, %eax
jne 0x5478c
leaq 0x1b0(%rsp), %rdi
leaq 0x758(%rsp), %rsi
movl $0xa, %edx
movl $0x4, %ecx
callq 0x5440
jmp 0x54692
movl $0x10, %edi
movl $0x8, %esi
callq 0x7850
movl %eax, 0x108(%rsp)
jmp 0x546aa
movl 0x108(%rsp), %edx
leaq 0x1d0(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x5670
jmp 0x546c8
leaq 0x1d0(%rsp), %rdi
leaq 0x754(%rsp), %rsi
callq 0x7820
jmp 0x546df
leaq 0x1d0(%rsp), %rdi
callq 0x52e0
leaq 0x1b0(%rsp), %rdi
callq 0x5250
cmpl $0x0, 0x99c(%rsp)
jne 0x54714
movb 0x752(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x54724
movl 0x754(%rsp), %eax
cmpl 0x99c(%rsp), %eax
jne 0x5477f
movb $0x1, 0x752(%rsp)
movb $0x1, 0x753(%rsp)
jmp 0x54787
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
jmp 0x5476d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x1d0(%rsp), %rdi
callq 0x52e0
leaq 0x1b0(%rsp), %rdi
callq 0x5250
jmp 0x54fce
movb $0x0, 0x753(%rsp)
jmp 0x54dd4
leaq 0x758(%rsp), %rdi
callq 0x5290
cmpq $0x6, %rax
jbe 0x547fe
leaq 0x27e0d(%rip), %rcx     # 0x7c5b3
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x6, %edx
callq 0x55a0
movl %eax, 0x104(%rsp)
jmp 0x547c5
movl 0x104(%rsp), %eax
cmpl $0x0, %eax
jne 0x547fe
movb 0x98e(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x547fe
movq 0x748(%rsp), %rdi
leaq 0x758(%rsp), %rsi
callq 0x46bd0
jmp 0x547f9
jmp 0x54dd2
testb $0x1, 0x753(%rsp)
je 0x54dcb
leaq 0x758(%rsp), %rdi
callq 0x5290
cmpq $0x36, %rax
jb 0x54dcb
leaq 0x26db4(%rip), %rcx     # 0x7b5de
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x4, %edx
callq 0x55a0
movl %eax, 0x100(%rsp)
jmp 0x54849
movl 0x100(%rsp), %eax
cmpl $0x0, %eax
je 0x548e7
leaq 0x27d5a(%rip), %rcx     # 0x7c5ba
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x6, %edx
callq 0x55a0
movl %eax, 0xfc(%rsp)
jmp 0x5487f
movl 0xfc(%rsp), %eax
cmpl $0x0, %eax
jne 0x5489c
movb 0x98f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
je 0x548e7
leaq 0x27d1e(%rip), %rcx     # 0x7c5c1
xorl %eax, %eax
movl %eax, %esi
leaq 0x758(%rsp), %rdi
movl $0x5, %edx
callq 0x55a0
movl %eax, 0xf8(%rsp)
jmp 0x548c2
movl 0xf8(%rsp), %eax
cmpl $0x0, %eax
jne 0x54dcb
movb 0x98f(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x54dcb
leaq 0x190(%rsp), %rdi
leaq 0x758(%rsp), %rsi
callq 0x51b0
jmp 0x548fe
movq 0x718(%rsp), %rdx
leaq 0x6c8(%rsp), %rdi
leaq 0x190(%rsp), %rsi
callq 0x55010
movq %rax, 0xf0(%rsp)
jmp 0x54925
movq 0xf0(%rsp), %rax
movq %rax, 0x720(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x5250
movq 0x720(%rsp), %rdi
leaq 0x6a8(%rsp), %rsi
callq 0x1fc10
jmp 0x54959
cmpq $0x0, 0x718(%rsp)
je 0x54b12
movq 0x718(%rsp), %rdi
callq 0x1f6a0
movq %rax, 0xe8(%rsp)
jmp 0x5497f
movq 0xe8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0xdc(%rsp)
movq 0x720(%rsp), %rdi
callq 0x1f6a0
movq %rax, 0xe0(%rsp)
jmp 0x549a7
movl 0xdc(%rsp), %eax
movq 0xe0(%rsp), %rcx
cmpl (%rcx), %eax
jne 0x54b12
movq 0x718(%rsp), %rdi
callq 0x1f620
movq %rax, 0xd0(%rsp)
jmp 0x549d5
movq 0x720(%rsp), %rdi
callq 0x1f620
movq %rax, 0xc8(%rsp)
jmp 0x549ec
movq 0xc8(%rsp), %rsi
movq 0xd0(%rsp), %rdi
callq 0x5050
movl %eax, 0xc4(%rsp)
jmp 0x54a0a
movl 0xc4(%rsp), %eax
cmpl $0x0, %eax
jne 0x54b0b
movq 0x718(%rsp), %rdi
callq 0x1f5e0
movq %rax, 0xb8(%rsp)
jmp 0x54a31
movq 0xb8(%rsp), %rdi
leaq 0x27b58(%rip), %rcx     # 0x7c598
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %edx
callq 0x55a0
movl %eax, 0xb4(%rsp)
jmp 0x54a57
movl 0xb4(%rsp), %eax
cmpl $0x0, %eax
je 0x54acc
movq 0x718(%rsp), %rdi
callq 0x1f5e0
movq %rax, 0xa8(%rsp)
jmp 0x54a7a
movq 0x720(%rsp), %rdi
callq 0x1f5e0
movq %rax, 0xa0(%rsp)
jmp 0x54a91
movq 0xa0(%rsp), %rcx
movq 0xa8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %r8d
movl $0x1, %r9d
movq %r8, %rsi
movq %r9, %rdx
callq 0x5090
movl %eax, 0x9c(%rsp)
jmp 0x54ac0
movl 0x9c(%rsp), %eax
cmpl $0x0, %eax
jne 0x54b0b
movq 0x748(%rsp), %rdi
movq 0x720(%rsp), %rsi
callq 0x422b0
jmp 0x54ae3
jmp 0x54b10
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
leaq 0x190(%rsp), %rdi
callq 0x5250
jmp 0x54fce
jmp 0x54024
jmp 0x54b2b
movq 0x748(%rsp), %rdi
movq 0x720(%rsp), %rsi
callq 0x422b0
jmp 0x54b29
jmp 0x54b2b
cmpq $0x0, 0x718(%rsp)
je 0x54c84
movq 0x720(%rsp), %rdi
callq 0x1f660
movq %rax, 0x90(%rsp)
jmp 0x54b51
movq 0x718(%rsp), %rdi
callq 0x1f660
movq %rax, 0x88(%rsp)
jmp 0x54b68
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdi
callq 0x5050
movl %eax, 0x84(%rsp)
jmp 0x54b86
movl 0x84(%rsp), %eax
cmpl $0x0, %eax
je 0x54c84
movq 0x740(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x3a3a0
jmp 0x54bad
movq 0x748(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x429d0
jmp 0x54bc4
movq 0x748(%rsp), %rdi
movq 0x740(%rsp), %rsi
callq 0x42a10
jmp 0x54bdb
movl $0x30, %edi
callq 0x5410
movq %rax, 0x78(%rsp)
jmp 0x54bec
movq 0x78(%rsp), %rdi
callq 0x3a320
jmp 0x54bf8
movq 0x78(%rsp), %rax
movq %rax, 0x740(%rsp)
movl $0x18, %edi
callq 0x5410
movq %rax, 0x70(%rsp)
jmp 0x54c16
movq 0x70(%rsp), %rdi
callq 0x5de80
jmp 0x54c22
movq 0x70(%rsp), %rax
movq %rax, 0x728(%rsp)
jmp 0x54d5d
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x30, %esi
callq 0x5420
jmp 0x54fce
movq 0x70(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x18, %esi
callq 0x5420
jmp 0x54fce
cmpq $0x0, 0x718(%rsp)
je 0x54d59
movq 0x718(%rsp), %rdi
callq 0x1f6a0
movq %rax, 0x68(%rsp)
jmp 0x54ca7
movq 0x68(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x5c(%rsp)
movq 0x720(%rsp), %rdi
callq 0x1f6a0
movq %rax, 0x60(%rsp)
jmp 0x54cc6
movl 0x5c(%rsp), %eax
movq 0x60(%rsp), %rcx
cmpl (%rcx), %eax
je 0x54d59
movq 0x740(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x3a3a0
jmp 0x54cee
movq 0x748(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x429d0
jmp 0x54d05
movl $0x18, %edi
callq 0x5410
movq %rax, 0x50(%rsp)
jmp 0x54d16
movq 0x50(%rsp), %rdi
callq 0x5de80
jmp 0x54d22
movq 0x50(%rsp), %rax
movq %rax, 0x728(%rsp)
jmp 0x54d5b
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x738(%rsp)
movl %eax, 0x734(%rsp)
movl $0x18, %esi
callq 0x5420
jmp 0x54fce
jmp 0x54d5b
jmp 0x54d5d
movq 0x720(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x1fd80
jmp 0x54d74
movq 0x720(%rsp), %rdi
movq 0x740(%rsp), %rsi
callq 0x1fdf0
jmp 0x54d8b
movq 0x728(%rsp), %rdi
movq 0x720(%rsp), %rsi
callq 0x5dec0
jmp 0x54da2
movq 0x740(%rsp), %rdi
movq 0x720(%rsp), %rsi
callq 0x3a3e0
jmp 0x54db9
movq 0x720(%rsp), %rax
movq %rax, 0x718(%rsp)
jmp 0x54dd0
jmp 0x54024
jmp 0x54dd2
jmp 0x54dd4
jmp 0x54dd6
jmp 0x54dd8
jmp 0x54024
movq 0x728(%rsp), %rdi
callq 0x5e110
movl %eax, 0x4c(%rsp)
jmp 0x54df0
movl 0x4c(%rsp), %eax
cmpl $0x0, %eax
jbe 0x54e40
movq 0x740(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x3a3a0
jmp 0x54e10
movq 0x748(%rsp), %rdi
movq 0x728(%rsp), %rsi
callq 0x429d0
jmp 0x54e27
movq 0x748(%rsp), %rdi
movq 0x740(%rsp), %rsi
callq 0x42a10
jmp 0x54e3e
jmp 0x54e40
movq 0x180(%rsp), %rdi
leaq 0x2757b(%rip), %rsi     # 0x7c3ca
callq 0x5140
cmpl $0x0, %eax
je 0x54e87
leaq 0x780(%rsp), %rdi
callq 0x5690
movb %al, 0x4b(%rsp)
jmp 0x54e6c
movb 0x4b(%rsp), %al
testb $0x1, %al
jne 0x54e76
jmp 0x54e87
leaq 0x780(%rsp), %rdi
callq 0x50e0
jmp 0x54e85
jmp 0x54e87
movq 0x748(%rsp), %rdi
callq 0x436b0
movl %eax, 0x44(%rsp)
jmp 0x54e9a
movl 0x44(%rsp), %eax
cmpl $0x0, %eax
jne 0x54f54
movq 0x3e6142(%rip), %rdi    # 0x43aff0
movq 0x3e60f3(%rip), %rsi    # 0x43afa8
callq 0x5460
movq %rax, 0x38(%rsp)
jmp 0x54ec1
movq 0x38(%rsp), %rdi
leaq 0x276fa(%rip), %rsi     # 0x7c5c7
callq 0x53f0
movq %rax, 0x30(%rsp)
jmp 0x54ed9
movq 0x180(%rsp), %rsi
movq 0x30(%rsp), %rdi
callq 0x5390
movq %rax, 0x28(%rsp)
jmp 0x54ef2
movq 0x28(%rsp), %rdi
leaq 0x276df(%rip), %rsi     # 0x7c5dd
callq 0x53f0
jmp 0x54f05
movq 0x3e60e4(%rip), %rdi    # 0x43aff0
leaq 0x276cd(%rip), %rsi     # 0x7c5e0
callq 0x53f0
movq %rax, 0x20(%rsp)
jmp 0x54f1f
movq 0x20(%rsp), %rdi
movq 0x3e607d(%rip), %rsi    # 0x43afa8
callq 0x5460
movq %rax, 0x18(%rsp)
jmp 0x54f37
movq 0x18(%rsp), %rdi
movq 0x3e6065(%rip), %rsi    # 0x43afa8
callq 0x5460
jmp 0x54f4a
movl $0x1, %edi
callq 0x5500
movq 0x748(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x42ab0
movb %al, 0x17(%rsp)
jmp 0x54f6c
movq 0x8(%rsp), %rdi
movb 0x17(%rsp), %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x42a80
jmp 0x54f82
movq 0x748(%rsp), %rax
movq %rax, (%rsp)
leaq 0x6a8(%rsp), %rdi
callq 0x5250
leaq 0x6c8(%rsp), %rdi
callq 0x56c40
leaq 0x758(%rsp), %rdi
callq 0x5250
leaq 0x780(%rsp), %rdi
callq 0x5120
movq (%rsp), %rax
addq $0x9a8, %rsp            # imm = 0x9A8
retq
leaq 0x6a8(%rsp), %rdi
callq 0x5250
leaq 0x6c8(%rsp), %rdi
callq 0x56c40
leaq 0x758(%rsp), %rdi
callq 0x5250
leaq 0x780(%rsp), %rdi
callq 0x5120
movq 0x738(%rsp), %rdi
callq 0x5720
nop