// File: /workspace/github_cpp_makefile_star2_O2/Luthaf[P]zeopp/networkstorage.cc
// Function: fracSubstituteAtoms(ATOM_NETWORK*, ATOM_NETWORK*, bool, double, int, int*, double*, bool)
bool fracSubstituteAtoms(ATOM_NETWORK *origNet, ATOM_NETWORK *newNet,
                         bool substituteSeed, double frac, int randSeed,
                         int *numSubstitutions, double *fracSub, bool radial){
    int numAtoms = origNet->numAtoms;
    double max_bond_length = 1.95;
    
    if(frac > 0.5){
        cerr << "Fractional atomic network substitution failed because the fraction can not exceed 0.5" << "\n";
        return false;
    }
    if(frac < 0.0){
        cerr << "Fractional atomic network substitution failed because of invalid negative fraction " << frac << "\n";
        return false;
    }
    
    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 << "Fractional 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);
            }
        }
    }
    
    int numSi = 0;
    
    for(int i = 0; i < numAtoms; i++){
        if(origNet->atoms[i].type.compare("Si") == 0){
            if(bonds[i].size() != 4){
                cerr << "Fractional 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;
            }
            numSi++;
        }
        else if(origNet->atoms[i].type.compare("O") == 0){
            if(bonds[i].size() != 2){
                cerr << "Fractional 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 << "Fractional 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: Fractional atomic network 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 << "Fractional 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 << "Fractional 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 << "Fractional 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 << "Fractional 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);
    
    int totalSubs = nearestInt(frac*numSi); // How many substituions to actually perform
    *fracSub = (1.0*totalSubs)/numSi;        // Store the actual substitution fraction
    
    srand(randSeed); // Seed random number generator
    
    // Record all originally substituted atoms
    vector<pair<int, int> > subIDs;
    for(int i = 0; i < numAtoms; i++){
        if(atomSubs[i]){
            subIDs.push_back(pair<int,int> (rand(), i));
        }
    }
    
    sort(subIDs.begin(), subIDs.end(), comparePairs); // Sort the pairs by their random values
    
    // Change atoms that should be substituted
    for(*numSubstitutions = 0; *numSubstitutions < totalSubs; (*numSubstitutions)++){
        int id = subIDs[*numSubstitutions].second;
        newNet->atoms[id].type   = "Al";
        newNet->atoms[id].radius = lookupRadius("Al", radial);
    }
    
    
    // Change Oxygen type if O atom connected to Al
    for(int i=0; i < numAtoms; i++){
        if(origNet->atoms[i].type.compare("O") == 0)
        {
            if(newNet->atoms[(bonds[i].at(0))].type.compare("Al") == 0 || newNet->atoms[(
                                                                                         bonds[i].at(1))].type.compare("Al") == 0)
            {
                newNet->atoms[i].type   = "O_Al";
            };
        };
    };
    
    
    
    // Successful substitution
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
ucomisd 0xba31a(%rip), %xmm0    # 0xfc038
jbe 0x41d35
movq 0x10e2c9(%rip), %rdi    # 0x14fff0
leaq 0xc0048(%rip), %rsi     # 0x101d76
callq 0x4480
jmp 0x41d66
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
movsd %xmm0, 0x38(%rsp)
jbe 0x41d7c
movq 0x10e2a4(%rip), %rdi    # 0x14fff0
leaq 0xc0079(%rip), %rsi     # 0x101dcc
callq 0x4480
movq %rax, %rdi
movsd 0x38(%rsp), %xmm0
callq 0x46c0
leaq 0xc0811(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
xorl %ebx, %ebx
jmp 0x41f76
movq %rdi, %r14
movl %edx, 0x80(%rsp)
movq %r9, 0xb8(%rsp)
movl %ecx, 0x8c(%rsp)
movq %r8, 0xb0(%rsp)
movq %rsi, 0x8(%rsp)
movslq 0x110(%rdi), %rsi
xorpd %xmm0, %xmm0
leaq 0x160(%rsp), %rdx
movapd %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
leaq 0x18(%rsp), %rdi
leaq 0xc8(%rsp), %rcx
movq %rsi, %rbp
callq 0x4b956
leaq 0x160(%rsp), %r12
movq %r12, %rdi
callq 0xb290
xorl %eax, %eax
leaq 0x40(%rsp), %rbx
leaq 0xc8(%rsp), %r15
leaq 0x60(%rsp), %r13
movl %eax, 0x40(%rsp)
cmpl %ebp, %eax
jge 0x41f8a
cltq
imulq $0x98, %rax, %rsi
addq 0x2f0(%r14), %rsi
movq %r12, %rdi
callq 0xa75c
movq %rbx, %rax
movslq (%rax), %rax
incq %rax
movl %eax, 0x60(%rsp)
cmpl %ebp, %eax
jge 0x41eb7
imulq $0x98, %rax, %rsi
addq 0x2f0(%r14), %rsi
movq %r15, %rdi
callq 0xa75c
movq %r14, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3f612
movsd 0xbf884(%rip), %xmm1    # 0x1016e0
ucomisd %xmm0, %xmm1
jbe 0x41ea7
leaq 0x1a0(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x4040
testl %eax, %eax
je 0x41eca
movslq 0x40(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x9434
movslq 0x60(%rsp), %rax
imulq $0x18, %rax, %rdi
addq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x9434
movq %r15, %rdi
callq 0xa808
movq %r13, %rax
jmp 0x41e1e
movq %r12, %rdi
callq 0xa808
movl 0x40(%rsp), %eax
incl %eax
jmp 0x41df7
movq 0x10e11f(%rip), %rdi    # 0x14fff0
leaq 0xbff48(%rip), %rsi     # 0x101e20
callq 0x4480
leaq 0xc069a(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbfb91(%rip), %rsi     # 0x101a84
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x43f0
leaq 0xbfb85(%rip), %rsi     # 0x101a97
movq %rax, %rdi
callq 0x4480
movl 0x40(%rsp), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xc1807(%rip), %rsi     # 0x103734
movq %rax, %rdi
callq 0x4480
movl 0x60(%rsp), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xc0636(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xc8(%rsp), %rdi
callq 0xa808
leaq 0x160(%rsp), %rdi
callq 0xa808
xorl %ebx, %ebx
leaq 0x18(%rsp), %rdi
callq 0xad7e
movl %ebx, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r15d, %r15d
movq %rbp, %rax
testl %eax, %eax
movl $0x0, %ecx
cmovgl %eax, %ecx
movq %rcx, 0x30(%rsp)
pushq $0x8
popq %rbx
pushq $0x40
popq %r12
leaq 0xba83e(%rip), %r13     # 0xfc7eb
movl $0x0, 0x14(%rsp)
cmpq %r15, 0x30(%rsp)
je 0x4202e
movq 0x2f0(%r14), %rdi
addq %r12, %rdi
movq %r13, %rsi
callq 0x4190
testl %eax, %eax
je 0x42002
movq 0x2f0(%r14), %rdi
addq %r12, %rdi
leaq 0xba7fd(%rip), %rsi     # 0xfc7e0
callq 0x4190
testl %eax, %eax
jne 0x42065
movq 0x18(%rsp), %rax
movq (%rax,%rbx), %rcx
subq -0x8(%rax,%rbx), %rcx
cmpq $0x8, %rcx
je 0x4201e
jmp 0x42078
movq 0x18(%rsp), %rax
movq (%rax,%rbx), %rcx
subq -0x8(%rax,%rbx), %rcx
cmpq $0x10, %rcx
jne 0x42311
incl 0x14(%rsp)
incq %r15
addq $0x18, %rbx
addq $0x98, %r12
jmp 0x41fb5
pushq $0x40
popq %r12
xorl %r15d, %r15d
leaq 0xba7af(%rip), %rbx     # 0xfc7eb
cmpq %r15, 0x30(%rsp)
je 0x420b4
movq 0x2f0(%r14), %rdi
addq %r12, %rdi
movq %rbx, %rsi
callq 0x4190
testl %eax, %eax
je 0x420cc
incq %r15
addq $0x98, %r12
jmp 0x4203c
movq 0x10df84(%rip), %rdi    # 0x14fff0
leaq 0xbfea4(%rip), %rsi     # 0x101f17
jmp 0x42348
movq 0x10df71(%rip), %rdi    # 0x14fff0
leaq 0xbfe48(%rip), %rsi     # 0x101ece
callq 0x4480
movq 0x18(%rsp), %rcx
movq (%rcx,%rbx), %rsi
subq -0x8(%rcx,%rbx), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0xbfaa2(%rip), %rsi     # 0x101b51
jmp 0x42348
movq 0x10df35(%rip), %rdi    # 0x14fff0
leaq 0xbfeb2(%rip), %rsi     # 0x101f74
callq 0x4480
jmp 0x41f6a
leaq 0xc8(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0x160(%rsp), %rdi
leaq 0x40(%rsp), %rcx
movq %rbp, %rbx
movq %rbp, %rsi
callq 0x2a0d6
leaq 0x40(%rsp), %rdx
movb $0x0, (%rdx)
leaq 0xc8(%rsp), %rdi
leaq 0x60(%rsp), %rcx
movq %rbx, %rsi
callq 0x2a0d6
xorpd %xmm0, %xmm0
leaq 0x40(%rsp), %rdi
andq $0x0, 0x10(%rdi)
movapd %xmm0, (%rdi)
andq $0x0, 0x70(%rsp)
movapd %xmm0, 0x60(%rsp)
leaq 0xc0(%rsp), %rsi
movl %r15d, (%rsi)
movl 0x80(%rsp), %eax
movb %al, 0x4(%rsi)
callq 0x4b9ac
leaq 0x90(%rsp), %rsi
orl $-0x1, (%rsi)
leaq 0x60(%rsp), %rdi
callq 0x10324
xorl %r12d, %r12d
leaq 0x160(%rsp), %r15
movq 0x48(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x4238a
leaq -0x8(%rax), %rcx
movslq -0x8(%rax), %rsi
movb -0x4(%rax), %r13b
movq %rcx, 0x48(%rsp)
movl %esi, (%rsp)
movq 0x68(%rsp), %rax
movl -0x4(%rax), %ebx
addq $-0x4, %rax
movq %rax, 0x68(%rsp)
movq %r15, %rdi
callq 0x1043e
testq %rdx, (%rax)
je 0x421f7
movslq (%rsp), %rax
movq 0x2f0(%r14), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x40, %rdi
leaq 0xba624(%rip), %rsi     # 0xfc7eb
callq 0x4190
testl %eax, %eax
jne 0x42164
movslq (%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x1043e
testq %rdx, (%rax)
sete %al
xorb %r13b, %al
testb $0x1, %al
jne 0x42164
jmp 0x426ec
movslq (%rsp), %rsi
movq %r15, %rdi
callq 0x1043e
movl %r13d, %r15d
andb $0x1, %r15b
orq %rdx, (%rax)
movslq (%rsp), %rax
movq 0x2f0(%r14), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x40, %rdi
leaq 0xba5b2(%rip), %rsi     # 0xfc7e0
callq 0x4190
movslq (%rsp), %rsi
testl %eax, %eax
je 0x42281
movq 0x2f0(%r14), %rax
imulq $0x98, %rsi, %rcx
leaq (%rax,%rcx), %rdi
addq $0x40, %rdi
leaq 0xba593(%rip), %rsi     # 0xfc7eb
callq 0x4190
testl %eax, %eax
jne 0x42701
movslq (%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x1043e
testb $0x1, %r13b
je 0x4229a
orq %rdx, (%rax)
jmp 0x422a0
leaq 0xc8(%rsp), %rdi
callq 0x1043e
notq %rdx
andq %rdx, (%rax)
xorb $0x1, %r15b
jmp 0x422a0
notq %rdx
andq %rdx, (%rax)
incl %r12d
movl %r12d, %r13d
xorl %r12d, %r12d
movl %r12d, %r12d
movslq (%rsp), %rax
movq 0x18(%rsp), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r12, %rcx
jbe 0x42309
movl (%rax,%r12,4), %eax
cmpl %ebx, %eax
je 0x42304
movl %eax, 0x90(%rsp)
movb %r15b, 0x94(%rsp)
leaq 0x40(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x4cfb6
leaq 0x60(%rsp), %rdi
movq %rsp, %rsi
callq 0x9434
incl %r12d
jmp 0x422a9
movl %r13d, %r12d
jmp 0x4215c
movq 0x10dcd8(%rip), %rdi    # 0x14fff0
leaq 0xbfb65(%rip), %rsi     # 0x101e84
callq 0x4480
movq 0x18(%rsp), %rcx
movq (%rcx,%rbx), %rsi
subq -0x8(%rcx,%rbx), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x42e0
movq %rax, %rdi
leaq 0xbf79e(%rip), %rsi     # 0x101ae6
callq 0x4480
leaq 0xc022a(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf79d(%rip), %rsi     # 0x101b00
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %r15d, %esi
callq 0x4760
leaq 0xc0201(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
jmp 0x41f6a
cmpl %ebp, %r12d
jne 0x42417
imulq $0x18, 0x30(%rsp), %r12
xorl %ebx, %ebx
pushq $0x40
popq %r13
leaq 0xba43a(%rip), %r15     # 0xfc7e0
xorl %ebp, %ebp
cmpq %rbp, %r12
je 0x4248f
movq 0x2f0(%r14), %rdi
addq %r13, %rdi
movq %r15, %rsi
callq 0x4190
testl %eax, %eax
jne 0x42408
movq 0x18(%rsp), %rax
movq (%rax,%rbp), %rax
movslq (%rax), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x1043e
testq %rdx, (%rax)
je 0x42408
movq 0x18(%rsp), %rax
movq (%rax,%rbp), %rax
movslq 0x4(%rax), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x1043e
testq %rdx, (%rax)
jne 0x42781
addq $0x18, %rbp
incl %ebx
addq $0x98, %r13
jmp 0x423a8
movq 0x10dbd2(%rip), %rdi    # 0x14fff0
leaq 0xbfc1e(%rip), %rsi     # 0x102043
callq 0x4480
leaq 0xc014d(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf875(%rip), %rsi     # 0x101cb5
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %r12d, %esi
callq 0x4760
leaq 0xbe71a(%rip), %rsi     # 0x100b74
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %ebp, %esi
callq 0x4760
leaq 0xbf62c(%rip), %rsi     # 0x101a9f
movq %rax, %rdi
callq 0x4480
leaq 0xc00fc(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
jmp 0x4274c
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x3eada
cvtsi2sdl 0x14(%rsp), %xmm1
movsd %xmm1, 0x80(%rsp)
movsd 0x38(%rsp), %xmm0
mulsd %xmm1, %xmm0
addsd 0xb9b7b(%rip), %xmm0    # 0xfc038
callq 0x4720
cvttsd2si %xmm0, %r13d
cvttpd2dq %xmm0, %xmm0
cvtdq2pd %xmm0, %xmm0
divsd 0x80(%rsp), %xmm0
movq 0xb8(%rsp), %rax
movsd %xmm0, (%rax)
movl 0x8c(%rsp), %edi
callq 0x4460
xorpd %xmm0, %xmm0
leaq 0x90(%rsp), %rbx
andq $0x0, 0x10(%rbx)
movapd %xmm0, (%rbx)
xorl %r15d, %r15d
leaq 0xc8(%rsp), %rbp
cmpq %r15, 0x30(%rsp)
je 0x42544
movq %rbp, %rdi
movq %r15, %rsi
callq 0x1043e
testq %rdx, (%rax)
je 0x4253f
callq 0x4170
movl %eax, (%rsp)
movl %r15d, 0x4(%rsp)
movq %rbx, %rdi
movq %rsp, %rsi
callq 0x109e8
incq %r15
jmp 0x42510
movq %r12, 0x38(%rsp)
movq 0x90(%rsp), %rdi
movq 0x98(%rsp), %rsi
leaq -0x861(%rip), %rdx      # 0x41cff
callq 0x4d0b4
xorl %eax, %eax
leaq 0xbfb70(%rip), %rbx     # 0x1020de
leaq 0x1f8(%rsp), %r15
movzbl 0x250(%rsp), %ebp
movq 0xb0(%rsp), %rcx
movl %eax, (%rcx)
cmpl %r13d, %eax
jge 0x42600
cltq
movq 0x90(%rsp), %rcx
movslq 0x4(%rcx,%rax,8), %rax
movq 0x8(%rsp), %rcx
movq 0x2f0(%rcx), %rcx
imulq $0x98, %rax, %r12
leaq (%rcx,%r12), %rdi
addq $0x40, %rdi
movq %rbx, %rsi
callq 0x4810
movq %r15, %rdi
movq %rbx, %rsi
movq %rsp, %rdx
callq 0x1b80e
movq %r15, %rdi
movl %ebp, %esi
callq 0x1b1bb
movq 0x8(%rsp), %rax
movq 0x2f0(%rax), %rax
movsd %xmm0, 0x30(%rax,%r12)
movq %r15, %rdi
callq 0x4210
movq 0xb0(%rsp), %rcx
movl (%rcx), %eax
incl %eax
jmp 0x42586
pushq $0x40
popq %r13
xorl %r12d, %r12d
leaq 0xba1d2(%rip), %rbx     # 0xfc7e0
leaq 0xbfac9(%rip), %r15     # 0x1020de
pushq $0x1
popq %rbp
cmpq %r12, 0x38(%rsp)
je 0x426db
movq 0x2f0(%r14), %rdi
addq %r13, %rdi
movq %rbx, %rsi
callq 0x4190
testl %eax, %eax
jne 0x426cb
movq 0x18(%rsp), %rdi
addq %r12, %rdi
xorl %esi, %esi
callq 0xac00
movslq (%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x2f0(%rcx), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x4190
testl %eax, %eax
je 0x426b0
movq 0x18(%rsp), %rdi
addq %r12, %rdi
movq %rbp, %rsi
callq 0xac00
movslq (%rax), %rax
movq 0x8(%rsp), %rcx
movq 0x2f0(%rcx), %rcx
imulq $0x98, %rax, %rax
leaq (%rcx,%rax), %rdi
addq $0x40, %rdi
movq %r15, %rsi
callq 0x4190
testl %eax, %eax
jne 0x426cb
movq 0x8(%rsp), %rax
movq 0x2f0(%rax), %rdi
addq %r13, %rdi
leaq 0xbfa16(%rip), %rsi     # 0x1020dc
callq 0x4810
addq $0x18, %r12
addq $0x98, %r13
jmp 0x42618
leaq 0x90(%rsp), %rdi
callq 0x10942
movb $0x1, %bl
jmp 0x4274e
movq 0x10d8fd(%rip), %rdi    # 0x14fff0
leaq 0xbf8e1(%rip), %rsi     # 0x101fdb
callq 0x4480
jmp 0x4273d
movq 0x10d8e8(%rip), %rdi    # 0x14fff0
leaq 0xbf808(%rip), %rsi     # 0x101f17
callq 0x4480
leaq 0xbfe63(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf3d6(%rip), %rsi     # 0x101b00
movq %rax, %rdi
callq 0x4480
movl (%rsp), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xbfe3a(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
xorl %ebx, %ebx
leaq 0x60(%rsp), %rdi
callq 0xb290
leaq 0x40(%rsp), %rdi
callq 0x4ce3c
leaq 0xc8(%rsp), %rdi
callq 0xa976
leaq 0x160(%rsp), %rdi
callq 0xa976
jmp 0x41f6c
movq 0x10d868(%rip), %rdi    # 0x14fff0
leaq 0xbf908(%rip), %rsi     # 0x102097
callq 0x4480
leaq 0xbfde3(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf54e(%rip), %rsi     # 0x101cf8
movq %rax, %rdi
callq 0x4480
movq %rax, %rdi
movl %ebx, %esi
callq 0x4760
leaq 0xbf543(%rip), %rsi     # 0x101d06
movq %rax, %rdi
callq 0x4480
movq 0x18(%rsp), %rcx
movq (%rcx,%rbp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xc0f4f(%rip), %rsi     # 0x103734
movq %rax, %rdi
callq 0x4480
movq 0x18(%rsp), %rcx
movq (%rcx,%rbp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x4760
leaq 0xbf512(%rip), %rsi     # 0x101d1a
movq %rax, %rdi
callq 0x4480
leaq 0xbfd67(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf50e(%rip), %rsi     # 0x101d34
movq %rax, %rdi
callq 0x4480
leaq 0xbfd49(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
leaq 0xbf50a(%rip), %rsi     # 0x101d4e
movq %rax, %rdi
callq 0x4480
leaq 0xbfd2b(%rip), %rsi     # 0x10257e
movq %rax, %rdi
callq 0x4480
jmp 0x4274c
jmp 0x428a2
jmp 0x428cc
jmp 0x428cc
movq %rax, %rbx
jmp 0x428f0
jmp 0x428ff
jmp 0x428ff
jmp 0x428cc
jmp 0x428cc
jmp 0x428cc
jmp 0x428cc
jmp 0x428cc
jmp 0x428cc
jmp 0x428cc
jmp 0x428a2
jmp 0x428a2
jmp 0x428cc
movq %rax, %rbx
leaq 0x1f8(%rsp), %rdi
callq 0x4210
jmp 0x428a5
jmp 0x428a2
jmp 0x428a2
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x10942
jmp 0x428cf
jmp 0x428ff
jmp 0x428cc
movq %rax, %rbx
leaq 0x160(%rsp), %rdi
callq 0xb290
jmp 0x42932
jmp 0x428cc
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xb290
leaq 0x40(%rsp), %rdi
callq 0x4ce3c
leaq 0xc8(%rsp), %rdi
callq 0xa976
leaq 0x160(%rsp), %rdi
callq 0xa976
jmp 0x42928
movq %rax, %rbx
jmp 0x42928
jmp 0x4290b
movq %rax, %rbx
jmp 0x4291b
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0xa808
leaq 0x160(%rsp), %rdi
callq 0xa808
leaq 0x18(%rsp), %rdi
callq 0xad7e
movq %rbx, %rdi
callq 0x4780