// File: Luthaf[P]zeopp/networkstorage.cc
// Function: substituteAtoms(ATOM_NETWORK*, ATOM_NETWORK*, bool, int*, bool)
bool substituteAtoms(ATOM_NETWORK *origNet, ATOM_NETWORK *newNet,
                     bool substituteSeed, int *numSubstitutions, bool radial){
    int numAtoms = origNet->numAtoms;
    double max_bond_length = 1.95;
    
    vector< vector<int> > bonds = vector< vector<int> >(numAtoms, vector<int>());
    for(int i = 0; i < numAtoms; i++){
        ATOM atom_one = origNet->atoms[i];
        for(int j = i + 1; j < numAtoms; j++){
            ATOM atom_two = origNet->atoms[j];
            if(origNet->calcDistance(atom_one, atom_two) < max_bond_length){
                if(atom_one.type.compare(atom_two.type) == 0){
                    cerr << "Atomic network substitution aborted because atoms of same type "
                    "are bonded to one another" << "\n" << "Occurred for type "
                    << atom_one.type << " between atoms " << i << " and " << j << "\n";
                    return false;
                }
                bonds[i].push_back(j);
                bonds[j].push_back(i);
            }
        }
    }
    
    for(int i = 0; i < numAtoms; i++){
        if(origNet->atoms[i].type.compare("Si") == 0){
            if(bonds[i].size() != 4){
                cerr << "Atomic network substitution aborted because Si atom bonded to "
                << bonds[i].size() << " other atoms instead of 4" << "\n"
                << "Occurred for atom " << i << "\n";
                return false;
            }
        }
        else if(origNet->atoms[i].type.compare("O") == 0){
            if(bonds[i].size() != 2){
                cerr << "Atomic network substitution aborted because O atom bonded to "
                << bonds[i].size() << " other atoms instead of 2" << "\n"
                << "Occurred for atom " << i << "\n";
                return false;
            }
        }
        else{
            cerr << "Atomic network substitution aborted because atom type other than "
            "Si or O detected" << "\n" << "Occurred for atom " << i << "\n";
            return false;
        }
    }
    
    int firstSiID = -1;
    for(int i = 0; i < numAtoms; i++){
        if(origNet->atoms[i].type.compare("Si") == 0){
            firstSiID = i;
            break;
        }
    }
    
    if(firstSiID == -1){
        cerr << "Error: Atom substitution failed because structure does not "
        "contain any Si atoms \n";
        return false;
    }
    
    vector<bool> atomProc = vector<bool>(numAtoms, false); // Whether atom has been processed
    vector<bool> atomSubs = vector<bool>(numAtoms, false); // Whether atom has been substituted
    int numProc = 0; // Number of processed atoms
    
    vector< pair<int, bool> > atomsToProcess; // Stack of atom/substituion info
    vector<int> fromIDs; // Stack of where each atom/subst came from
    
    pair<int, bool> seed(firstSiID, substituteSeed);
    atomsToProcess.push_back(seed);  // Seed with the first Si atom and not substituting it
    fromIDs.push_back(-1); // Starting node
    
    while(atomsToProcess.size() != 0){
        pair<int, bool> atomInfo = atomsToProcess.back(); atomsToProcess.pop_back();
        int id = atomInfo.first; bool subst = atomInfo.second;
        int fromID = fromIDs.back(); fromIDs.pop_back();
        
        // Atom previously processed. Ensure that atom substitution agrees with previous results for Si atoms
        if(atomProc[id] ){
            if((origNet->atoms[id].type.compare("Si") == 0) && (atomSubs[id] != subst)){
                cerr << "Atomic network substitution aborted because every other Si atom "
                "substitution criteria failed" << "\n";
                return false;
            }
        }
        // First time atom is processed
        else {
            numProc++;
            // Mark atom as processed
            atomProc[id] = true;
            
            // If oxygen, should not be substituted but reverse substituion state for next set of Si atoms
            if(origNet->atoms[id].type.compare("O") == 0){
                atomSubs[id] = false;
                subst = !subst;
            }
            // If silicon, pass on substitution state to oxygen atoms, who will then reverse it
            // Record substitution status
            else if(origNet->atoms[id].type.compare("Si") == 0){
                atomSubs[id] = subst;
            }
            // Invalid type
            else {
                cerr << "Atomic network substitution aborted because atom type other than Si or O detected" << "\n"
                << "Occurred for atom " << id << "\n";
                return false;
            }
            
            // Added bonded atoms to stack with appropriate subsitution state
            for(unsigned int j = 0; j < bonds[id].size(); j++){
                if(bonds[id][j] != fromID){
                    atomsToProcess.push_back(pair<int, bool>(bonds[id][j], subst));
                    fromIDs.push_back(id);
                }
            }
        }
    }
    
    if(numProc != numAtoms){
        cerr << "Atom network substituion failed because not all atoms are interconnected" << "\n"
        << "Visited " << numProc << " out of " << numAtoms << " atoms " << "\n";
        return false;
    }
    
    // Perform final consistency check
    for(int i = 0; i < numAtoms; i++){
        // Just check pair of atoms bonded to each oxygen
        if(origNet->atoms[i].type.compare("O") == 0){
            if(atomSubs[bonds[i][0]] && atomSubs[bonds[i][1]]){
                cerr << "Atom network substitution failed final consistency check." << "\n"
                << "Oxygen atom #" << i << " is bound to atoms " <<  bonds[i][0] << " and " << bonds[i][1] << " which are of same type. " << "\n"
                << "Algorithmic issue likely." << "\n"
                << "Please contact the source code provider" << "\n";
                return false;
            }
        }
    }
    
    // Copy original information
    origNet->copy(newNet);
    
    // Change atoms that should be subsituted
    *numSubstitutions = 0;
    for(int i = 0; i < numAtoms; i++){
        if(atomSubs[i]){
            newNet->atoms[i].type   = "Al";
            newNet->atoms[i].radius = lookupRadius("Al", radial);
            (*numSubstitutions)++;
        }
    }
    
    // Successful substitution
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x5e0, %rsp            # imm = 0x5E0
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %dl
movb %dl, -0x19(%rbp)
movq %rcx, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movq -0x10(%rbp), %rax
movl 0x110(%rax), %eax
movl %eax, -0x30(%rbp)
movabsq $0x3fff333333333333, %rax # imm = 0x3FFF333333333333
movq %rax, -0x38(%rbp)
movslq -0x30(%rbp), %rax
movq %rax, -0x360(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
leaq -0x70(%rbp), %rdi
movq %rdi, -0x358(%rbp)
callq 0xd0d0
leaq -0x71(%rbp), %rdi
movq %rdi, -0x350(%rbp)
callq 0x12b40
movq -0x360(%rbp), %rsi
movq -0x358(%rbp), %rdx
movq -0x350(%rbp), %rcx
leaq -0x50(%rbp), %rdi
callq 0xaedd0
jmp 0x9b0ba
leaq -0x71(%rbp), %rdi
callq 0x13770
leaq -0x70(%rbp), %rdi
callq 0xec80
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9b3f2
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x88(%rbp), %rsi
callq 0xfcc0
movq %rax, %rsi
leaq -0x120(%rbp), %rdi
callq 0xf0d0
jmp 0x9b10d
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
movl -0x124(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9b3a5
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x124(%rbp), %rsi
callq 0xfcc0
movq %rax, %rsi
leaq -0x1c0(%rbp), %rdi
callq 0xf0d0
jmp 0x9b153
movq -0x10(%rbp), %rdi
leaq -0x120(%rbp), %rsi
leaq -0x1c0(%rbp), %rdx
callq 0x979b0
movsd %xmm0, -0x368(%rbp)
jmp 0x9b174
movsd -0x368(%rbp), %xmm1
movsd -0x38(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x9b36d
leaq -0xe0(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x5050
movl %eax, -0x36c(%rbp)
jmp 0x9b1a6
movl -0x36c(%rbp), %eax
cmpl $0x0, %eax
jne 0x9b329
movq 0x1d7e34(%rip), %rdi    # 0x272ff0
leaq 0x15c9d8(%rip), %rsi    # 0x1f7b9b
callq 0x5540
movq %rax, -0x378(%rbp)
jmp 0x9b1d1
movq -0x378(%rbp), %rdi
leaq 0x15e446(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x380(%rbp)
jmp 0x9b1ed
movq -0x380(%rbp), %rdi
leaq 0x15c9f9(%rip), %rsi    # 0x1f7bf4
callq 0x5540
movq %rax, -0x388(%rbp)
jmp 0x9b209
movq -0x388(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x5480
movq %rax, -0x390(%rbp)
jmp 0x9b225
movq -0x390(%rbp), %rdi
leaq 0x15c9d4(%rip), %rsi    # 0x1f7c07
callq 0x5540
movq %rax, -0x398(%rbp)
jmp 0x9b241
movq -0x398(%rbp), %rdi
movl -0x88(%rbp), %esi
callq 0x58d0
movq %rax, -0x3a0(%rbp)
jmp 0x9b25c
movq -0x3a0(%rbp), %rdi
leaq 0x1601c2(%rip), %rsi    # 0x1fb42c
callq 0x5540
movq %rax, -0x3a8(%rbp)
jmp 0x9b278
movq -0x3a8(%rbp), %rdi
movl -0x124(%rbp), %esi
callq 0x58d0
movq %rax, -0x3b0(%rbp)
jmp 0x9b293
movq -0x3b0(%rbp), %rdi
leaq 0x15e384(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9b2a8
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9b377
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x13770
leaq -0x70(%rbp), %rdi
callq 0xec80
jmp 0x9c44b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x9c442
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x9b3e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xf200
jmp 0x9b3e1
movslq -0x88(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
leaq -0x124(%rbp), %rsi
callq 0xd1b0
jmp 0x9b34a
movslq -0x124(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0xd1b0
jmp 0x9b36b
jmp 0x9b36d
movl $0x0, -0x1c4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0xf200
movl -0x1c4(%rbp), %eax
testl %eax, %eax
jne 0x9b3af
jmp 0x9b38f
jmp 0x9b391
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x9b11c
movl $0x0, -0x1c4(%rbp)
leaq -0x120(%rbp), %rdi
callq 0xf200
movl -0x1c4(%rbp), %eax
testl %eax, %eax
jne 0x9c42b
jmp 0x9b3cb
jmp 0x9b3cd
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x9b0d6
leaq -0x120(%rbp), %rdi
callq 0xf200
jmp 0x9c442
movl $0x0, -0x1c8(%rbp)
movl -0x1c8(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9b734
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x1c8(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x157366(%rip), %rsi    # 0x1f2796
callq 0x51b0
cmpl $0x0, %eax
jne 0x9b548
movslq -0x1c8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
callq 0x10090
cmpq $0x4, %rax
je 0x9b543
movq 0x1d7b89(%rip), %rdi    # 0x272ff0
leaq 0x15c7a9(%rip), %rsi    # 0x1f7c17
callq 0x5540
movq %rax, -0x3b8(%rbp)
jmp 0x9b47c
movslq -0x1c8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
callq 0x10090
movq -0x3b8(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, -0x3c0(%rbp)
jmp 0x9b4ac
movq -0x3c0(%rbp), %rdi
leaq 0x15c79c(%rip), %rsi    # 0x1f7c56
callq 0x5540
movq %rax, -0x3c8(%rbp)
jmp 0x9b4c8
movq -0x3c8(%rbp), %rdi
leaq 0x15e14f(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x3d0(%rbp)
jmp 0x9b4e4
movq -0x3d0(%rbp), %rdi
leaq 0x15c77e(%rip), %rsi    # 0x1f7c70
callq 0x5540
movq %rax, -0x3d8(%rbp)
jmp 0x9b500
movq -0x3d8(%rbp), %rdi
movl -0x1c8(%rbp), %esi
callq 0x58d0
movq %rax, -0x3e0(%rbp)
jmp 0x9b51b
movq -0x3e0(%rbp), %rdi
leaq 0x15e0fc(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9b530
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c42b
jmp 0x9b71e
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x1c8(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x15721e(%rip), %rsi    # 0x1f278b
callq 0x51b0
cmpl $0x0, %eax
jne 0x9b685
movslq -0x1c8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
callq 0x10090
cmpq $0x2, %rax
je 0x9b680
movq 0x1d7a4c(%rip), %rdi    # 0x272ff0
leaq 0x15c6d8(%rip), %rsi    # 0x1f7c83
callq 0x5540
movq %rax, -0x3e8(%rbp)
jmp 0x9b5b9
movslq -0x1c8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
callq 0x10090
movq -0x3e8(%rbp), %rdi
movq %rax, %rsi
callq 0x5160
movq %rax, -0x3f0(%rbp)
jmp 0x9b5e9
movq -0x3f0(%rbp), %rdi
leaq 0x15c6ca(%rip), %rsi    # 0x1f7cc1
callq 0x5540
movq %rax, -0x3f8(%rbp)
jmp 0x9b605
movq -0x3f8(%rbp), %rdi
leaq 0x15e012(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x400(%rbp)
jmp 0x9b621
movq -0x400(%rbp), %rdi
leaq 0x15c641(%rip), %rsi    # 0x1f7c70
callq 0x5540
movq %rax, -0x408(%rbp)
jmp 0x9b63d
movq -0x408(%rbp), %rdi
movl -0x1c8(%rbp), %esi
callq 0x58d0
movq %rax, -0x410(%rbp)
jmp 0x9b658
movq -0x410(%rbp), %rdi
leaq 0x15dfbf(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9b66d
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c42b
jmp 0x9b71c
movq 0x1d7964(%rip), %rdi    # 0x272ff0
leaq 0x15c648(%rip), %rsi    # 0x1f7cdb
callq 0x5540
movq %rax, -0x418(%rbp)
jmp 0x9b6a1
movq -0x418(%rbp), %rdi
leaq 0x15df76(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x420(%rbp)
jmp 0x9b6bd
movq -0x420(%rbp), %rdi
leaq 0x15c5a5(%rip), %rsi    # 0x1f7c70
callq 0x5540
movq %rax, -0x428(%rbp)
jmp 0x9b6d9
movq -0x428(%rbp), %rdi
movl -0x1c8(%rbp), %esi
callq 0x58d0
movq %rax, -0x430(%rbp)
jmp 0x9b6f4
movq -0x430(%rbp), %rdi
leaq 0x15df23(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9b709
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c42b
jmp 0x9b71e
jmp 0x9b720
movl -0x1c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c8(%rbp)
jmp 0x9b3fc
movl $0xffffffff, -0x1cc(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x1d0(%rbp)
movl -0x1d0(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9b7a3
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x1d0(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x15701e(%rip), %rsi    # 0x1f2796
callq 0x51b0
cmpl $0x0, %eax
jne 0x9b790
movl -0x1d0(%rbp), %eax
movl %eax, -0x1cc(%rbp)
jmp 0x9b7a3
jmp 0x9b792
movl -0x1d0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1d0(%rbp)
jmp 0x9b748
cmpl $-0x1, -0x1cc(%rbp)
jne 0x9b7d4
movq 0x1d783d(%rip), %rdi    # 0x272ff0
leaq 0x15c573(%rip), %rsi    # 0x1f7d2d
callq 0x5540
jmp 0x9b7c1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c42b
movslq -0x30(%rbp), %rax
movq %rax, -0x440(%rbp)
movb $0x0, -0x1f9(%rbp)
leaq -0x1fa(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0x64b50
movq -0x440(%rbp), %rsi
movq -0x438(%rbp), %rcx
leaq -0x1f8(%rbp), %rdi
leaq -0x1f9(%rbp), %rdx
callq 0x64b70
jmp 0x9b81c
leaq -0x1fa(%rbp), %rdi
callq 0x64bf0
movslq -0x30(%rbp), %rax
movq %rax, -0x450(%rbp)
movb $0x0, -0x229(%rbp)
leaq -0x22a(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x64b50
movq -0x450(%rbp), %rsi
movq -0x448(%rbp), %rcx
leaq -0x228(%rbp), %rdi
leaq -0x229(%rbp), %rdx
callq 0x64b70
jmp 0x9b870
leaq -0x22a(%rbp), %rdi
callq 0x64bf0
movl $0x0, -0x230(%rbp)
leaq -0x248(%rbp), %rdi
callq 0xaee50
leaq -0x260(%rbp), %rdi
callq 0xd0d0
leaq -0x268(%rbp), %rdi
leaq -0x1cc(%rbp), %rsi
leaq -0x19(%rbp), %rdx
callq 0xaee70
jmp 0x9b8b7
leaq -0x248(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0xaeea0
jmp 0x9b8cc
movl $0xffffffff, -0x26c(%rbp) # imm = 0xFFFFFFFF
leaq -0x260(%rbp), %rdi
leaq -0x26c(%rbp), %rsi
callq 0xffc0
jmp 0x9b8eb
jmp 0x9b8ed
leaq -0x248(%rbp), %rdi
callq 0xaef10
cmpq $0x0, %rax
je 0x9be19
leaq -0x248(%rbp), %rdi
movq %rdi, -0x470(%rbp)
callq 0xaef30
movq -0x470(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x278(%rbp)
callq 0xaef70
movl -0x278(%rbp), %eax
movl %eax, -0x27c(%rbp)
movb -0x274(%rbp), %al
andb $0x1, %al
movb %al, -0x27d(%rbp)
leaq -0x260(%rbp), %rdi
movq %rdi, -0x468(%rbp)
callq 0x29870
movq -0x468(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x284(%rbp)
callq 0xaefa0
movslq -0x27c(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x29990
movq %rdx, -0x460(%rbp)
movq %rax, -0x458(%rbp)
jmp 0x9b990
movq -0x460(%rbp), %rax
movq -0x458(%rbp), %rcx
movq %rcx, -0x298(%rbp)
movq %rax, -0x290(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x101a0
testb $0x1, %al
jne 0x9b9c1
jmp 0x9bb0d
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x27c(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x156db0(%rip), %rsi    # 0x1f2796
callq 0x51b0
movl %eax, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x471(%rbp)
jne 0x9ba61
movslq -0x27c(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x488(%rbp)
movq %rax, -0x480(%rbp)
jmp 0x9ba1d
movq -0x488(%rbp), %rax
movq -0x480(%rbp), %rcx
movq %rcx, -0x2a8(%rbp)
movq %rax, -0x2a0(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x101a0
andb $0x1, %al
movzbl %al, %eax
movb -0x27d(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x471(%rbp)
movb -0x471(%rbp), %al
testb $0x1, %al
jne 0x9ba70
jmp 0x9bb08
movq 0x1d7579(%rip), %rdi    # 0x272ff0
leaq 0x15c301(%rip), %rsi    # 0x1f7d7f
callq 0x5540
movq %rax, -0x490(%rbp)
jmp 0x9ba8c
movq -0x490(%rbp), %rdi
leaq 0x15db8b(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9baa1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c3c7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x1fa(%rbp), %rdi
callq 0x64bf0
jmp 0x9c442
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x22a(%rbp), %rdi
callq 0x64bf0
jmp 0x9c41d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x9c3f9
jmp 0x9be14
movl -0x230(%rbp), %eax
incl %eax
movl %eax, -0x230(%rbp)
movslq -0x27c(%rbp), %rsi
leaq -0x1f8(%rbp), %rdi
callq 0x29990
movq %rdx, -0x4a0(%rbp)
movq %rax, -0x498(%rbp)
jmp 0x9bb3e
movq -0x4a0(%rbp), %rax
movq -0x498(%rbp), %rcx
movq %rcx, -0x2b8(%rbp)
movq %rax, -0x2b0(%rbp)
leaq -0x2b8(%rbp), %rdi
movl $0x1, %esi
callq 0x10040
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x27c(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x156bfb(%rip), %rsi    # 0x1f278b
callq 0x51b0
cmpl $0x0, %eax
jne 0x9bbfc
movslq -0x27c(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x4b0(%rbp)
movq %rax, -0x4a8(%rbp)
jmp 0x9bbbd
movq -0x4b0(%rbp), %rax
movq -0x4a8(%rbp), %rcx
movq %rcx, -0x2c8(%rbp)
movq %rax, -0x2c0(%rbp)
leaq -0x2c8(%rbp), %rdi
xorl %esi, %esi
callq 0x10040
movb -0x27d(%rbp), %al
xorb $-0x1, %al
andb $0x1, %al
movb %al, -0x27d(%rbp)
jmp 0x9bd2c
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x27c(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x156b75(%rip), %rsi    # 0x1f2796
callq 0x51b0
cmpl $0x0, %eax
jne 0x9bc93
movb -0x27d(%rbp), %al
movb %al, -0x4c1(%rbp)
movslq -0x27c(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x4c0(%rbp)
movq %rax, -0x4b8(%rbp)
jmp 0x9bc5a
movb -0x4c1(%rbp), %al
movq -0x4c0(%rbp), %rcx
movq -0x4b8(%rbp), %rdx
movq %rdx, -0x2d8(%rbp)
movq %rcx, -0x2d0(%rbp)
movzbl %al, %esi
andl $0x1, %esi
leaq -0x2d8(%rbp), %rdi
callq 0x10040
jmp 0x9bd2a
movq 0x1d7356(%rip), %rdi    # 0x272ff0
leaq 0x15c03a(%rip), %rsi    # 0x1f7cdb
callq 0x5540
movq %rax, -0x4d0(%rbp)
jmp 0x9bcaf
movq -0x4d0(%rbp), %rdi
leaq 0x15d968(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x4d8(%rbp)
jmp 0x9bccb
movq -0x4d8(%rbp), %rdi
leaq 0x15bf97(%rip), %rsi    # 0x1f7c70
callq 0x5540
movq %rax, -0x4e0(%rbp)
jmp 0x9bce7
movq -0x4e0(%rbp), %rdi
movl -0x27c(%rbp), %esi
callq 0x58d0
movq %rax, -0x4e8(%rbp)
jmp 0x9bd02
movq -0x4e8(%rbp), %rdi
leaq 0x15d915(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9bd17
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c3c7
jmp 0x9bd2c
movl $0x0, -0x2dc(%rbp)
movl -0x2dc(%rbp), %eax
movq %rax, -0x4f0(%rbp)
movslq -0x27c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
callq 0x10090
movq %rax, %rcx
movq -0x4f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x9be12
movslq -0x27c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
movl -0x2dc(%rbp), %eax
movl %eax, %esi
callq 0xed60
movl (%rax), %eax
cmpl -0x284(%rbp), %eax
je 0x9bdfc
movslq -0x27c(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
movl -0x2dc(%rbp), %eax
movl %eax, %esi
callq 0xed60
movq %rax, %rsi
leaq -0x2e4(%rbp), %rdi
leaq -0x27d(%rbp), %rdx
callq 0xaee70
jmp 0x9bdd0
leaq -0x248(%rbp), %rdi
leaq -0x2e4(%rbp), %rsi
callq 0xaefd0
jmp 0x9bde5
leaq -0x260(%rbp), %rdi
leaq -0x27c(%rbp), %rsi
callq 0xd1b0
jmp 0x9bdfa
jmp 0x9bdfc
jmp 0x9bdfe
movl -0x2dc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2dc(%rbp)
jmp 0x9bd36
jmp 0x9be14
jmp 0x9b8ed
movl -0x230(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x9bf0f
movq 0x1d71c1(%rip), %rdi    # 0x272ff0
leaq 0x15bfa6(%rip), %rsi    # 0x1f7ddc
callq 0x5540
movq %rax, -0x4f8(%rbp)
jmp 0x9be44
movq -0x4f8(%rbp), %rdi
leaq 0x15d7d3(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x500(%rbp)
jmp 0x9be60
movq -0x500(%rbp), %rdi
leaq 0x15bfb7(%rip), %rsi    # 0x1f7e25
callq 0x5540
movq %rax, -0x508(%rbp)
jmp 0x9be7c
movq -0x508(%rbp), %rdi
movl -0x230(%rbp), %esi
callq 0x58d0
movq %rax, -0x510(%rbp)
jmp 0x9be97
movq -0x510(%rbp), %rdi
leaq 0x15ad2f(%rip), %rsi    # 0x1f6bd4
callq 0x5540
movq %rax, -0x518(%rbp)
jmp 0x9beb3
movq -0x518(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0x58d0
movq %rax, -0x520(%rbp)
jmp 0x9becb
movq -0x520(%rbp), %rdi
leaq 0x15bd36(%rip), %rsi    # 0x1f7c0f
callq 0x5540
movq %rax, -0x528(%rbp)
jmp 0x9bee7
movq -0x528(%rbp), %rdi
leaq 0x15d730(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9befc
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c3c7
movl $0x0, -0x2e8(%rbp)
movl -0x2e8(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9c222
movq -0x10(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x2e8(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x15683e(%rip), %rsi    # 0x1f278b
callq 0x51b0
cmpl $0x0, %eax
jne 0x9c20c
movslq -0x2e8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xed60
movslq (%rax), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x538(%rbp)
movq %rax, -0x530(%rbp)
jmp 0x9bf96
movq -0x538(%rbp), %rax
movq -0x530(%rbp), %rcx
movq %rcx, -0x2f8(%rbp)
movq %rax, -0x2f0(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x101a0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x539(%rbp)
jne 0x9bfcf
jmp 0x9c039
movslq -0x2e8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
movl $0x1, %esi
callq 0xed60
movslq (%rax), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x550(%rbp)
movq %rax, -0x548(%rbp)
jmp 0x9c00b
movq -0x550(%rbp), %rax
movq -0x548(%rbp), %rcx
movq %rcx, -0x308(%rbp)
movq %rax, -0x300(%rbp)
leaq -0x308(%rbp), %rdi
callq 0x101a0
movb %al, -0x539(%rbp)
movb -0x539(%rbp), %al
testb $0x1, %al
jne 0x9c048
jmp 0x9c20a
movq 0x1d6fa1(%rip), %rdi    # 0x272ff0
leaq 0x15bdd8(%rip), %rsi    # 0x1f7e2e
callq 0x5540
movq %rax, -0x558(%rbp)
jmp 0x9c064
movq -0x558(%rbp), %rdi
leaq 0x15d5b3(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x560(%rbp)
jmp 0x9c080
movq -0x560(%rbp), %rdi
leaq 0x15bdda(%rip), %rsi    # 0x1f7e68
callq 0x5540
movq %rax, -0x568(%rbp)
jmp 0x9c09c
movq -0x568(%rbp), %rdi
movl -0x2e8(%rbp), %esi
callq 0x58d0
movq %rax, -0x570(%rbp)
jmp 0x9c0b7
movq -0x570(%rbp), %rdi
leaq 0x15bdb1(%rip), %rsi    # 0x1f7e76
callq 0x5540
movq %rax, -0x578(%rbp)
jmp 0x9c0d3
movslq -0x2e8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xed60
movq -0x578(%rbp), %rdi
movl (%rax), %esi
callq 0x58d0
movq %rax, -0x580(%rbp)
jmp 0x9c106
movq -0x580(%rbp), %rdi
leaq 0x15f318(%rip), %rsi    # 0x1fb42c
callq 0x5540
movq %rax, -0x588(%rbp)
jmp 0x9c122
movslq -0x2e8(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x10890
movq %rax, %rdi
movl $0x1, %esi
callq 0xed60
movq -0x588(%rbp), %rdi
movl (%rax), %esi
callq 0x58d0
movq %rax, -0x590(%rbp)
jmp 0x9c156
movq -0x590(%rbp), %rdi
leaq 0x15bd26(%rip), %rsi    # 0x1f7e8a
callq 0x5540
movq %rax, -0x598(%rbp)
jmp 0x9c172
movq -0x598(%rbp), %rdi
leaq 0x15d4a5(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x5a0(%rbp)
jmp 0x9c18e
movq -0x5a0(%rbp), %rdi
leaq 0x15bd08(%rip), %rsi    # 0x1f7ea4
callq 0x5540
movq %rax, -0x5a8(%rbp)
jmp 0x9c1aa
movq -0x5a8(%rbp), %rdi
leaq 0x15d46d(%rip), %rsi    # 0x1f9625
callq 0x5540
movq %rax, -0x5b0(%rbp)
jmp 0x9c1c6
movq -0x5b0(%rbp), %rdi
leaq 0x15bcea(%rip), %rsi    # 0x1f7ebe
callq 0x5540
movq %rax, -0x5b8(%rbp)
jmp 0x9c1e2
movq -0x5b8(%rbp), %rdi
leaq 0x15d435(%rip), %rsi    # 0x1f9625
callq 0x5540
jmp 0x9c1f7
movb $0x0, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
jmp 0x9c3c7
jmp 0x9c20c
jmp 0x9c20e
movl -0x2e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e8(%rbp)
jmp 0x9bf19
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x96980
jmp 0x9c231
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x30c(%rbp)
movl -0x30c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x9c3b9
movslq -0x30c(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x29990
movq %rdx, -0x5c8(%rbp)
movq %rax, -0x5c0(%rbp)
jmp 0x9c277
movq -0x5c8(%rbp), %rax
movq -0x5c0(%rbp), %rcx
movq %rcx, -0x320(%rbp)
movq %rax, -0x318(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x101a0
testb $0x1, %al
jne 0x9c2a8
jmp 0x9c3a3
movq -0x18(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x30c(%rbp), %rsi
callq 0xfcc0
movq %rax, %rdi
addq $0x40, %rdi
leaq 0x15bf81(%rip), %rsi    # 0x1f824e
callq 0x5710
jmp 0x9c2d4
leaq -0x341(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x5900
movq -0x5d0(%rbp), %rdx
leaq 0x15bf59(%rip), %rsi    # 0x1f824e
leaq -0x340(%rbp), %rdi
callq 0x47530
jmp 0x9c303
movzbl -0x29(%rbp), %esi
andl $0x1, %esi
leaq -0x340(%rbp), %rdi
callq 0x466e0
movsd %xmm0, -0x5d8(%rbp)
jmp 0x9c320
movq -0x18(%rbp), %rdi
addq $0x2f0, %rdi            # imm = 0x2F0
movslq -0x30c(%rbp), %rsi
callq 0xfcc0
movsd -0x5d8(%rbp), %xmm0
movsd %xmm0, 0x30(%rax)
leaq -0x340(%rbp), %rdi
callq 0x5300
leaq -0x341(%rbp), %rdi
callq 0x55d0
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x9c3a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x9c395
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x340(%rbp), %rdi
callq 0x5300
leaq -0x341(%rbp), %rdi
callq 0x55d0
jmp 0x9c3f9
jmp 0x9c3a5
movl -0x30c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30c(%rbp)
jmp 0x9c245
movb $0x1, -0x1(%rbp)
movl $0x1, -0x1c4(%rbp)
leaq -0x260(%rbp), %rdi
callq 0xec80
leaq -0x248(%rbp), %rdi
callq 0xaf000
leaq -0x228(%rbp), %rdi
callq 0xf9b0
leaq -0x1f8(%rbp), %rdi
callq 0xf9b0
jmp 0x9c42b
leaq -0x260(%rbp), %rdi
callq 0xec80
leaq -0x248(%rbp), %rdi
callq 0xaf000
leaq -0x228(%rbp), %rdi
callq 0xf9b0
leaq -0x1f8(%rbp), %rdi
callq 0xf9b0
jmp 0x9c442
leaq -0x50(%rbp), %rdi
callq 0x108b0
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x5e0, %rsp            # imm = 0x5E0
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x108b0
movq -0x80(%rbp), %rdi
callq 0x58f0
nopw %cs:(%rax,%rax)