// File: jeffreyan11[P]go-engine/board.cpp
// Function: Board::doMove(int, unsigned short)
void Board::doMove(Player p, Move m) {
    if (m == MOVE_PASS)
        return;

    int x = getX(m);
    int y = getY(m);

    assert(pieces[index(x, y)] == EMPTY);
    assert(chainID[index(x, y)] == 0);
    
    pieces[index(x, y)] = p;
    zobristKey ^= zobristTable[zobristIndex(p, x, y)];

    Player victim = otherPlayer(p);

    Stone east = pieces[index(x+1, y)];
    Stone west = pieces[index(x-1, y)];
    Stone north = pieces[index(x, y+1)];
    Stone south = pieces[index(x, y-1)];
    int connectionCount = (east == p) + (west == p) + (north == p) + (south == p);

    // If the stone placed is a new chain
    if (connectionCount == 0) {
        // Record which chain this square is a part of
        chainID[index(x, y)] = nextID;

        // Add this chain to the list of chains
        Chain *cargo = new Chain(p, nextID);
        cargo->add(m);
        cargo->liberties = 0;
        if (east == EMPTY)
            cargo->addLiberty(coordToMove(x+1, y));
        if (west == EMPTY)
            cargo->addLiberty(coordToMove(x-1, y));
        if (north == EMPTY)
            cargo->addLiberty(coordToMove(x, y+1));
        if (south == EMPTY)
            cargo->addLiberty(coordToMove(x, y-1));

        chainList.add(cargo);

        nextID++;
    }

    // If the stone placed is added to an existing chain
    else if (connectionCount == 1) {
        // Find the ID of the chain we are adding this stone to
        int thisID;
        if (east == p)
            thisID = chainID[index(x+1, y)];
        else if (west == p)
            thisID = chainID[index(x-1, y)];
        else if (north == p)
            thisID = chainID[index(x, y+1)];
        else
            thisID = chainID[index(x, y-1)];

        chainID[index(x, y)] = thisID;
        Chain *node = nullptr;
        searchChainsByID(node, thisID);
        node->add(m);

        // The new stone occupies a previous liberty, but adds on however many
        // liberties it itself has
        node->removeLiberty(node->findLiberty(m));
        updateLiberty(node, x, y);
    }

    // If the stone possibly connects two existing chains
    else {
        int eastID = (east == p) * chainID[index(x+1, y)];
        int westID = (west == p) * chainID[index(x-1, y)];
        int northID = (north == p) * chainID[index(x, y+1)];
        int southID = (south == p) * chainID[index(x, y-1)];
        Chain *node = nullptr;
        bool added = false;

        if (eastID) {
            chainID[index(x, y)] = eastID;
            searchChainsByID(node, eastID);

            node->add(m);
            node->removeLiberty(node->findLiberty(m));
            updateLiberty(node, x, y);
            added = true;
        }

        if (westID) {
            if (added) {
                // If two stones from the same chain are adjacent, do nothing
                // If they are from different chains, we need to combine...
                if (westID != eastID)
                    mergeChains(node, westID, m);
            }
            else {
                chainID[index(x, y)] = westID;
                searchChainsByID(node, westID);

                node->add(m);
                node->removeLiberty(node->findLiberty(m));
                updateLiberty(node, x, y);
                added = true;
            }
        }

        if (northID) {
            if (added) {
                if (northID != eastID && northID != westID)
                    mergeChains(node, northID, m);
            }
            else {
                chainID[index(x, y)] = northID;
                searchChainsByID(node, northID);

                node->add(m);
                node->removeLiberty(node->findLiberty(m));
                updateLiberty(node, x, y);
                added = true;
            }
        }

        if (southID) {
            if (added) {
                if (southID != eastID && southID != westID && southID != northID)
                    mergeChains(node, southID, m);
            }
            else {
                chainID[index(x, y)] = southID;
                searchChainsByID(node, southID);

                node->add(m);
                node->removeLiberty(node->findLiberty(m));
                updateLiberty(node, x, y);
                added = true;
            }
        }
    }


    // Update opponent liberties
    int eastID = (east == victim) * chainID[index(x+1, y)];
    int westID = (west == victim) * chainID[index(x-1, y)];
    int northID = (north == victim) * chainID[index(x, y+1)];
    int southID = (south == victim) * chainID[index(x, y-1)];

    if (eastID) {
        Chain *node = nullptr;
        int nodeIndex = searchChainsByID(node, eastID);
        node->removeLiberty(node->findLiberty(m));

        if (node->liberties == 0)
            captureChain(node, nodeIndex);
    }

    if (westID && westID != eastID) {
        Chain *node = nullptr;
        int nodeIndex = searchChainsByID(node, westID);
        node->removeLiberty(node->findLiberty(m));

        if (node->liberties == 0)
            captureChain(node, nodeIndex);
    }

    if (northID && northID != eastID && northID != westID) {
        Chain *node = nullptr;
        int nodeIndex = searchChainsByID(node, northID);
        node->removeLiberty(node->findLiberty(m));

        if (node->liberties == 0)
            captureChain(node, nodeIndex);
    }

    if (southID && southID != eastID && southID != westID && southID != northID) {
        Chain *node = nullptr;
        int nodeIndex = searchChainsByID(node, southID);
        node->removeLiberty(node->findLiberty(m));

        if (node->liberties == 0)
            captureChain(node, nodeIndex);
    }

    // Check for a suicide
    int selfID = chainID[index(x, y)];
    Chain *node = nullptr;
    int nodeIndex = searchChainsByID(node, selfID);

    if (node->liberties == 0)
        captureChain(node, nodeIndex);


    // A debugging check
    assert(!checkChains());

    // Check if p captured any of the other player's stones with move m
    /*
    doCaptures<true>(victim, coordToMove(x+1, y));
    doCaptures<true>(victim, coordToMove(x-1, y));
    doCaptures<true>(victim, coordToMove(x, y+1));
    doCaptures<true>(victim, coordToMove(x, y-1));

    // Check if p suicided with move m
    doCaptures<true>(p, coordToMove(x, y));
    */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x270, %rsp            # imm = 0x270
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movzwl -0xe(%rbp), %eax
cmpl $0x8000, %eax           # imm = 0x8000
jne 0x3d84
jmp 0x4acb
movzwl -0xe(%rbp), %edi
callq 0x8b80
movl %eax, -0x14(%rbp)
movzwl -0xe(%rbp), %edi
callq 0x8ba0
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, -0x18(%rbp)
movl -0xc(%rbp), %ecx
movl %ecx, -0x104(%rbp)
movq (%rax), %rax
movq %rax, -0x100(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x104(%rbp), %edx
movl %eax, %ecx
movq -0x100(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %edi
movl -0x14(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x8be0
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movslq %ecx, %rdx
leaq 0x10437(%rip), %rcx     # 0x14230
movq (%rcx,%rdx,8), %rcx
xorq 0x10(%rax), %rcx
movq %rcx, 0x10(%rax)
movl -0xc(%rbp), %edi
callq 0x8c10
movl %eax, %ecx
movq -0xd8(%rbp), %rax
movl %ecx, -0x1c(%rbp)
movq (%rax), %rax
movq %rax, -0xf8(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movq -0xf8(%rbp), %rcx
movl %eax, %edx
movq -0xd8(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x20(%rbp)
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movq -0xf0(%rbp), %rcx
movl %eax, %edx
movq -0xd8(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x24(%rbp)
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8bc0
movq -0xe8(%rbp), %rcx
movl %eax, %edx
movq -0xd8(%rbp), %rax
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
movl %ecx, -0x28(%rbp)
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0xe0(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x2c(%rbp)
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl -0x24(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl -0x28(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl -0x2c(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
jne 0x40b2
movq -0xd8(%rbp), %rax
movl 0x18(%rax), %ecx
movl %ecx, -0x11c(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x118(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x11c(%rbp), %edx
movl %eax, %ecx
movq -0x118(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl $0x610, %edi            # imm = 0x610
callq 0x2200
movq %rax, %rdi
movq -0xd8(%rbp), %rax
movq %rdi, %rcx
movq %rcx, -0x110(%rbp)
movl -0xc(%rbp), %esi
movl 0x18(%rax), %edx
callq 0x92d0
jmp 0x3f8a
movq -0x110(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x38(%rbp), %rax
movl $0x0, 0xc(%rax)
cmpl $0x0, -0x20(%rbp)
jne 0x3fff
movq -0x38(%rbp), %rax
movq %rax, -0x128(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x128(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
jmp 0x3fff
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
movl $0x610, %esi            # imm = 0x610
callq 0x2210
jmp 0x4ad4
cmpl $0x0, -0x24(%rbp)
jne 0x402d
movq -0x38(%rbp), %rax
movq %rax, -0x130(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8c30
movq -0x130(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
cmpl $0x0, -0x28(%rbp)
jne 0x405b
movq -0x38(%rbp), %rax
movq %rax, -0x138(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8c30
movq -0x138(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
cmpl $0x0, -0x2c(%rbp)
jne 0x4089
movq -0x38(%rbp), %rax
movq %rax, -0x140(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8c30
movq -0x140(%rbp), %rdi
movzwl %ax, %esi
callq 0x9470
movq -0xd8(%rbp), %rdi
addq $0x28, %rdi
movq -0x38(%rbp), %rsi
callq 0x8b40
movq -0xd8(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x46c5
cmpl $0x1, -0x30(%rbp)
jne 0x424d
movl -0x20(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x40fb
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x148(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x148(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
jmp 0x41a9
movl -0x24(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x4137
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x150(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x150(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
jmp 0x41a7
movl -0x28(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x4173
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x158(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x158(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
jmp 0x41a5
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x160(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8bc0
movl %eax, %ecx
movq -0x160(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x48(%rbp)
jmp 0x41a7
jmp 0x41a9
movq -0xd8(%rbp), %rax
movl -0x48(%rbp), %ecx
movl %ecx, -0x174(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x170(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x174(%rbp), %edx
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x170(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq $0x0, -0x50(%rbp)
movl -0x48(%rbp), %edx
leaq -0x50(%rbp), %rsi
callq 0x8c50
movq -0x50(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x50(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x50(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x168(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xd8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x4ae0
jmp 0x46c3
movq -0xd8(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x1ac(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1a8(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x1ac(%rbp), %ecx
movq -0x1a8(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x54(%rbp)
movl -0x24(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x19c(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x198(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x19c(%rbp), %ecx
movq -0x198(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x58(%rbp)
movl -0x28(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x18c(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x188(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8bc0
movl -0x18c(%rbp), %ecx
movq -0x188(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x5c(%rbp)
movl -0x2c(%rbp), %ecx
cmpl -0xc(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x178(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x180(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8bc0
movq -0x180(%rbp), %rcx
movl %eax, %edx
movl -0x178(%rbp), %eax
movslq %edx, %rdx
imull (%rcx,%rdx,4), %eax
movl %eax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movb $0x0, -0x69(%rbp)
cmpl $0x0, -0x54(%rbp)
je 0x4436
movq -0xd8(%rbp), %rax
movl -0x54(%rbp), %ecx
movl %ecx, -0x1c4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1c0(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x1c4(%rbp), %edx
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x1c0(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x54(%rbp), %edx
leaq -0x68(%rbp), %rsi
callq 0x8c50
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x68(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x1b8(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x4ae0
movb $0x1, -0x69(%rbp)
cmpl $0x0, -0x58(%rbp)
je 0x4507
testb $0x1, -0x69(%rbp)
je 0x446a
movl -0x58(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x4465
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x58(%rbp), %edx
movzwl -0xe(%rbp), %ecx
callq 0x4cf0
jmp 0x4505
movq -0xd8(%rbp), %rax
movl -0x58(%rbp), %ecx
movl %ecx, -0x1dc(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1d8(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x1dc(%rbp), %edx
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x1d8(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x58(%rbp), %edx
leaq -0x68(%rbp), %rsi
callq 0x8c50
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x68(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x1d0(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x4ae0
movb $0x1, -0x69(%rbp)
jmp 0x4507
cmpl $0x0, -0x5c(%rbp)
je 0x45e0
testb $0x1, -0x69(%rbp)
je 0x4543
movl -0x5c(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x453e
movl -0x5c(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x453e
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x5c(%rbp), %edx
movzwl -0xe(%rbp), %ecx
callq 0x4cf0
jmp 0x45de
movq -0xd8(%rbp), %rax
movl -0x5c(%rbp), %ecx
movl %ecx, -0x1f4(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x1f0(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x1f4(%rbp), %edx
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x1f0(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x5c(%rbp), %edx
leaq -0x68(%rbp), %rsi
callq 0x8c50
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x68(%rbp), %rax
movq %rax, -0x1e8(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x1e8(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x4ae0
movb $0x1, -0x69(%rbp)
jmp 0x45e0
cmpl $0x0, -0x60(%rbp)
je 0x46c1
testb $0x1, -0x69(%rbp)
je 0x4624
movl -0x60(%rbp), %eax
cmpl -0x54(%rbp), %eax
je 0x461f
movl -0x60(%rbp), %eax
cmpl -0x58(%rbp), %eax
je 0x461f
movl -0x60(%rbp), %eax
cmpl -0x5c(%rbp), %eax
je 0x461f
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x60(%rbp), %edx
movzwl -0xe(%rbp), %ecx
callq 0x4cf0
jmp 0x46bf
movq -0xd8(%rbp), %rax
movl -0x60(%rbp), %ecx
movl %ecx, -0x20c(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x208(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x20c(%rbp), %edx
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x208(%rbp), %rax
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x60(%rbp), %edx
leaq -0x68(%rbp), %rsi
callq 0x8c50
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x93d0
movq -0x68(%rbp), %rax
movq %rax, -0x200(%rbp)
movq -0x68(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x200(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xd8(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x4ae0
movb $0x1, -0x69(%rbp)
jmp 0x46c1
jmp 0x46c3
jmp 0x46c5
movq -0xd8(%rbp), %rax
movl -0x20(%rbp), %ecx
cmpl -0x1c(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x244(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x240(%rbp)
movl -0x14(%rbp), %edi
addl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x244(%rbp), %ecx
movq -0x240(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x70(%rbp)
movl -0x24(%rbp), %ecx
cmpl -0x1c(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x234(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x230(%rbp)
movl -0x14(%rbp), %edi
subl $0x1, %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movl -0x234(%rbp), %ecx
movq -0x230(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x74(%rbp)
movl -0x28(%rbp), %ecx
cmpl -0x1c(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x224(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x220(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
addl $0x1, %esi
callq 0x8bc0
movl -0x224(%rbp), %ecx
movq -0x220(%rbp), %rdx
movl %eax, %esi
movq -0xd8(%rbp), %rax
movslq %esi, %rsi
imull (%rdx,%rsi,4), %ecx
movl %ecx, -0x78(%rbp)
movl -0x2c(%rbp), %ecx
cmpl -0x1c(%rbp), %ecx
sete %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x210(%rbp)
movq 0x20(%rax), %rax
movq %rax, -0x218(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
subl $0x1, %esi
callq 0x8bc0
movq -0x218(%rbp), %rcx
movl %eax, %edx
movl -0x210(%rbp), %eax
movslq %edx, %rdx
imull (%rcx,%rdx,4), %eax
movl %eax, -0x7c(%rbp)
cmpl $0x0, -0x70(%rbp)
je 0x487e
movq -0xd8(%rbp), %rdi
movq $0x0, -0x88(%rbp)
movl -0x70(%rbp), %edx
leaq -0x88(%rbp), %rsi
callq 0x8c50
movl %eax, -0x8c(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x250(%rbp)
movq -0x88(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x250(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0x88(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x487c
movq -0xd8(%rbp), %rdi
movq -0x88(%rbp), %rsi
movl -0x8c(%rbp), %edx
callq 0x4e60
jmp 0x487e
cmpl $0x0, -0x74(%rbp)
je 0x490b
movl -0x74(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x490b
movq -0xd8(%rbp), %rdi
movq $0x0, -0x98(%rbp)
movl -0x74(%rbp), %edx
leaq -0x98(%rbp), %rsi
callq 0x8c50
movl %eax, -0x9c(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x258(%rbp)
movq -0x98(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x258(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0x98(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x4909
movq -0xd8(%rbp), %rdi
movq -0x98(%rbp), %rsi
movl -0x9c(%rbp), %edx
callq 0x4e60
jmp 0x490b
cmpl $0x0, -0x78(%rbp)
je 0x49a4
movl -0x78(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x49a4
movl -0x78(%rbp), %eax
cmpl -0x74(%rbp), %eax
je 0x49a4
movq -0xd8(%rbp), %rdi
movq $0x0, -0xa8(%rbp)
movl -0x78(%rbp), %edx
leaq -0xa8(%rbp), %rsi
callq 0x8c50
movl %eax, -0xac(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x260(%rbp)
movq -0xa8(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x260(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xa8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x49a2
movq -0xd8(%rbp), %rdi
movq -0xa8(%rbp), %rsi
movl -0xac(%rbp), %edx
callq 0x4e60
jmp 0x49a4
cmpl $0x0, -0x7c(%rbp)
je 0x4a49
movl -0x7c(%rbp), %eax
cmpl -0x70(%rbp), %eax
je 0x4a49
movl -0x7c(%rbp), %eax
cmpl -0x74(%rbp), %eax
je 0x4a49
movl -0x7c(%rbp), %eax
cmpl -0x78(%rbp), %eax
je 0x4a49
movq -0xd8(%rbp), %rdi
movq $0x0, -0xb8(%rbp)
movl -0x7c(%rbp), %edx
leaq -0xb8(%rbp), %rsi
callq 0x8c50
movl %eax, -0xbc(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x268(%rbp)
movq -0xb8(%rbp), %rdi
movzwl -0xe(%rbp), %esi
callq 0x9400
movq -0x268(%rbp), %rdi
movl %eax, %esi
callq 0x94a0
movq -0xb8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x4a47
movq -0xd8(%rbp), %rdi
movq -0xb8(%rbp), %rsi
movl -0xbc(%rbp), %edx
callq 0x4e60
jmp 0x4a49
movq -0xd8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x270(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
callq 0x8bc0
movq -0xd8(%rbp), %rdi
movl %eax, %ecx
movq -0x270(%rbp), %rax
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0xc0(%rbp)
movq $0x0, -0xc8(%rbp)
movl -0xc0(%rbp), %edx
leaq -0xc8(%rbp), %rsi
callq 0x8c50
movl %eax, -0xcc(%rbp)
movq -0xc8(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jne 0x4acb
movq -0xd8(%rbp), %rdi
movq -0xc8(%rbp), %rsi
movl -0xcc(%rbp), %edx
callq 0x4e60
addq $0x270, %rsp            # imm = 0x270
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2350
nopl (%rax)