// File: niekh1234[P]nnchesslib/board.cpp
// Function: nnchesslib::ChessBoard::isValidFen(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool ChessBoard::isValidFen(std::string fen)
{
    // Setup variables
    std::istringstream iss(fen);
    std::string board, sideToMove, castleRights, enpassant, movecount, plycount;

    // check if fen is provided
    if(!iss) return false;

    iss >> board;

    if(!iss) return false;

    iss >> sideToMove;

    if (!iss) 
    {
        castleRights = "-";
        enpassant = "-";
    } 
    else 
    {
        iss >> castleRights;
        if (iss)
            iss >> enpassant;
        else
            enpassant = "-";
    }
    
    iss >> movecount;

    iss >> plycount;

    boardinfo.plyCount = stoi(plycount);
    boardinfo.fiftyMoveRule = stoi(movecount);

    // Let's check that all components of the supposed FEN are OK.
    // Check side to move
    if (sideToMove != "w" && sideToMove != "b") return false;
    
    // Check castling rights
    if (castleRights != "-" && castleRights != "K" && castleRights != "Kk"
        && castleRights != "Kkq" && castleRights != "Kq" && castleRights !="KQ"
        && castleRights != "KQk" && castleRights != "KQq" && castleRights != "KQkq"
        && castleRights != "k" && castleRights != "q" && castleRights != "kq"
        && castleRights != "Q" && castleRights != "Qk" && castleRights != "Qq"
        && castleRights != "Qkq")
        return false;

    // Check valid en passant
    if (enpassant != "-") {
        if (enpassant.length() != 2) return false;
        if (!(enpassant[0] >= 'a' && enpassant[0] <= 'h')) return false;
        if (!((sideToMove == "w" && enpassant[1] == '6') || (sideToMove == "b" && enpassant[1] == '3')))
            return false;
    }

    // Check valid board
    // Seven board dividers
    if (std::count(board.begin(), board.end(), '/') != 7) return false;

    // Board contains only legal characters
    for (int i = 0; i < board.length(); i++)
        if (!(board[i] == '/' || (board[i] >= '1' && board[i] <= '8')
                || board[i] == 'p' || board[i] == 'P' || board[i] == 'r' || board[i] == 'R' || 
                board[i] == 'k' || board[i] == 'K' || board[i] == 'n' || board[i] == 'N' || board[i] == 'b' || board[i] == 'B'
                || board[i] == 'q' || board[i] == 'Q'))
            return false;
    
    // Check king amount
    if (std::count(board.begin(), board.end(), 'K') != 1) return false;
    if (std::count(board.begin(), board.end(), 'k') != 1) return false;

    // Count other piece amounts
    size_t wp = std::count(board.begin(), board.end(), 'P'),
        bp = std::count(board.begin(), board.end(), 'p'),
        wn = std::count(board.begin(), board.end(), 'N'),
        bn = std::count(board.begin(), board.end(), 'n'),
        wb = std::count(board.begin(), board.end(), 'B'),
        bb = std::count(board.begin(), board.end(), 'b'),
        wr = std::count(board.begin(), board.end(), 'R'),
        br = std::count(board.begin(), board.end(), 'r'),
        wq = std::count(board.begin(), board.end(), 'Q'),
        bq = std::count(board.begin(), board.end(), 'q');

    // Check if piece count is valid
    if (wp > 8 || bp > 8 || wn > 10 || bn > 10 || wb > 10 || bb > 10
        || wr > 10 || br > 10 || wq > 9 || bq > 9
        || wp + wn + wb + wr + wq > 15 || bp + bn + bb + br + bq > 15)
        return false;

    // setting some variables now that all the checks have been passed:
    // put this in dedicated function in the future.

    // changing who's turn it is.
    if(sideToMove == "w") boardinfo.whiteToMove = true;
    else boardinfo.whiteToMove = false;

    // setting the castling rights bools
    for (auto c : castleRights)
    {
        switch(c)
        {
            case 'K':
                boardinfo.whiteCastleShort = true;
                break;
            case 'Q':
                boardinfo.whiteCastleLong = true;
                break;
            case 'k':
                boardinfo.blackCastleShort = true;
                break;
            case 'q':
                boardinfo.blackCastleLong = true;
                break;
        }
    }

    // setting en passant bitboard.
    if(enpassant != "-")
    {
        if(boardinfo.whiteToMove)  boardinfo.whiteEnPassantTarget.set(getSquareInt(enpassant), true);
        if(!boardinfo.whiteToMove) boardinfo.blackEnPassantTarget.set(getSquareInt(enpassant), true);
    }
    // All checks passed
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x640, %rsp            # imm = 0x640
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x460(%rbp)
leaq -0x198(%rbp), %rdi
movl $0x8, %edx
callq 0x33e0
leaq -0x1b8(%rbp), %rdi
callq 0x3350
leaq -0x1d8(%rbp), %rdi
callq 0x3350
leaq -0x1f8(%rbp), %rdi
callq 0x3350
leaq -0x218(%rbp), %rdi
callq 0x3350
leaq -0x238(%rbp), %rdi
callq 0x3350
leaq -0x258(%rbp), %rdi
callq 0x3350
movq -0x198(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x198(%rbp,%rax), %rdi
callq 0x30f0
movb %al, -0x451(%rbp)
jmp 0x5e57
movb -0x451(%rbp), %al
testb $0x1, %al
jne 0x5e63
jmp 0x5e8d
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
jmp 0x70d6
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x3320
jmp 0x5ea2
movq -0x198(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x198(%rbp,%rax), %rdi
callq 0x30f0
movb %al, -0x461(%rbp)
jmp 0x5ec2
movb -0x461(%rbp), %al
testb $0x1, %al
jne 0x5ece
jmp 0x5ee1
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq -0x198(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x3320
jmp 0x5ef6
movq -0x198(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x198(%rbp,%rax), %rdi
callq 0x30f0
movb %al, -0x462(%rbp)
jmp 0x5f16
movb -0x462(%rbp), %al
testb $0x1, %al
jne 0x5f22
jmp 0x5f4e
leaq 0x877d(%rip), %rsi      # 0xe6a6
leaq -0x1f8(%rbp), %rdi
callq 0x3340
jmp 0x5f37
leaq 0x8768(%rip), %rsi      # 0xe6a6
leaq -0x218(%rbp), %rdi
callq 0x3340
jmp 0x5f4c
jmp 0x5fbf
leaq -0x198(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0x3320
jmp 0x5f63
movq -0x198(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x198(%rbp,%rax), %rdi
callq 0x3310
movb %al, -0x463(%rbp)
jmp 0x5f83
movb -0x463(%rbp), %al
testb $0x1, %al
jne 0x5f8f
jmp 0x5fa6
leaq -0x198(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x3320
jmp 0x5fa4
jmp 0x5fbd
leaq 0x86f9(%rip), %rsi      # 0xe6a6
leaq -0x218(%rbp), %rdi
callq 0x3340
jmp 0x5fbb
jmp 0x5fbd
jmp 0x5fbf
leaq -0x198(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x3320
jmp 0x5fd4
leaq -0x198(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3320
jmp 0x5fe9
xorl %eax, %eax
movl %eax, %esi
leaq -0x258(%rbp), %rdi
movl $0xa, %edx
callq 0x9a10
movl %eax, -0x468(%rbp)
jmp 0x6006
movq -0x460(%rbp), %rax
movl -0x468(%rbp), %ecx
movl %ecx, 0x4c(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x238(%rbp), %rdi
movl $0xa, %edx
callq 0x9a10
movl %eax, -0x46c(%rbp)
jmp 0x6033
movq -0x460(%rbp), %rax
movl -0x46c(%rbp), %ecx
movl %ecx, 0x48(%rax)
leaq 0x87ee(%rip), %rsi      # 0xe838
leaq -0x1d8(%rbp), %rdi
callq 0x9a50
movb %al, -0x46d(%rbp)
jmp 0x605e
movb -0x46d(%rbp), %al
testb $0x1, %al
jne 0x606a
jmp 0x60a4
leaq 0x87c9(%rip), %rsi      # 0xe83a
leaq -0x1d8(%rbp), %rdi
callq 0x9a50
movb %al, -0x46e(%rbp)
jmp 0x6085
movb -0x46e(%rbp), %al
testb $0x1, %al
jne 0x6091
jmp 0x60a4
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq 0x85fb(%rip), %rsi      # 0xe6a6
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x46f(%rbp)
jmp 0x60bf
movb -0x46f(%rbp), %al
testb $0x1, %al
jne 0x60ce
jmp 0x634e
leaq 0x8853(%rip), %rsi      # 0xe928
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x470(%rbp)
jmp 0x60e9
movb -0x470(%rbp), %al
testb $0x1, %al
jne 0x60f8
jmp 0x634e
leaq 0x873d(%rip), %rsi      # 0xe83c
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x471(%rbp)
jmp 0x6113
movb -0x471(%rbp), %al
testb $0x1, %al
jne 0x6122
jmp 0x634e
leaq 0x8716(%rip), %rsi      # 0xe83f
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x472(%rbp)
jmp 0x613d
movb -0x472(%rbp), %al
testb $0x1, %al
jne 0x614c
jmp 0x634e
leaq 0x86f0(%rip), %rsi      # 0xe843
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x473(%rbp)
jmp 0x6167
movb -0x473(%rbp), %al
testb $0x1, %al
jne 0x6176
jmp 0x634e
leaq 0x86c9(%rip), %rsi      # 0xe846
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x474(%rbp)
jmp 0x6191
movb -0x474(%rbp), %al
testb $0x1, %al
jne 0x61a0
jmp 0x634e
leaq 0x86a2(%rip), %rsi      # 0xe849
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x475(%rbp)
jmp 0x61bb
movb -0x475(%rbp), %al
testb $0x1, %al
jne 0x61ca
jmp 0x634e
leaq 0x867c(%rip), %rsi      # 0xe84d
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x476(%rbp)
jmp 0x61e5
movb -0x476(%rbp), %al
testb $0x1, %al
jne 0x61f4
jmp 0x634e
leaq 0x8656(%rip), %rsi      # 0xe851
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x477(%rbp)
jmp 0x620f
movb -0x477(%rbp), %al
testb $0x1, %al
jne 0x621e
jmp 0x634e
leaq 0x8618(%rip), %rsi      # 0xe83d
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x478(%rbp)
jmp 0x6239
movb -0x478(%rbp), %al
testb $0x1, %al
jne 0x6248
jmp 0x634e
leaq 0x85f5(%rip), %rsi      # 0xe844
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x479(%rbp)
jmp 0x6263
movb -0x479(%rbp), %al
testb $0x1, %al
jne 0x6272
jmp 0x634e
leaq 0x85c7(%rip), %rsi      # 0xe840
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x47a(%rbp)
jmp 0x628d
movb -0x47a(%rbp), %al
testb $0x1, %al
jne 0x629c
jmp 0x634e
leaq 0x85a4(%rip), %rsi      # 0xe847
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x47b(%rbp)
jmp 0x62b7
movb -0x47b(%rbp), %al
testb $0x1, %al
jne 0x62c6
jmp 0x634e
leaq 0x857d(%rip), %rsi      # 0xe84a
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x47c(%rbp)
jmp 0x62e1
movb -0x47c(%rbp), %al
testb $0x1, %al
jne 0x62ed
jmp 0x634e
leaq 0x855a(%rip), %rsi      # 0xe84e
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x47d(%rbp)
jmp 0x6308
movb -0x47d(%rbp), %al
testb $0x1, %al
jne 0x6314
jmp 0x634e
leaq 0x8537(%rip), %rsi      # 0xe852
leaq -0x1f8(%rbp), %rdi
callq 0x9a50
movb %al, -0x47e(%rbp)
jmp 0x632f
movb -0x47e(%rbp), %al
testb $0x1, %al
jne 0x633b
jmp 0x634e
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq 0x8351(%rip), %rsi      # 0xe6a6
leaq -0x218(%rbp), %rdi
callq 0x9a50
movb %al, -0x47f(%rbp)
jmp 0x6369
movb -0x47f(%rbp), %al
testb $0x1, %al
jne 0x6378
jmp 0x64b5
leaq -0x218(%rbp), %rdi
callq 0x3380
cmpq $0x2, %rax
je 0x639d
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
xorl %eax, %eax
movl %eax, %esi
leaq -0x218(%rbp), %rdi
callq 0x3480
movq %rax, -0x488(%rbp)
jmp 0x63b6
movq -0x488(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x61, %eax
jl 0x63ed
xorl %eax, %eax
movl %eax, %esi
leaq -0x218(%rbp), %rdi
callq 0x3480
movq %rax, -0x490(%rbp)
jmp 0x63de
movq -0x490(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x68, %eax
jle 0x6400
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq 0x8431(%rip), %rsi      # 0xe838
leaq -0x1d8(%rbp), %rdi
callq 0x9a80
movb %al, -0x491(%rbp)
jmp 0x641b
movb -0x491(%rbp), %al
testb $0x1, %al
jne 0x6427
jmp 0x6450
leaq -0x218(%rbp), %rdi
movl $0x1, %esi
callq 0x3480
movq %rax, -0x4a0(%rbp)
jmp 0x6441
movq -0x4a0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x36, %eax
je 0x64b3
leaq 0x83e3(%rip), %rsi      # 0xe83a
leaq -0x1d8(%rbp), %rdi
callq 0x9a80
movb %al, -0x4a1(%rbp)
jmp 0x646b
movb -0x4a1(%rbp), %al
testb $0x1, %al
jne 0x6477
jmp 0x64a0
leaq -0x218(%rbp), %rdi
movl $0x1, %esi
callq 0x3480
movq %rax, -0x4b0(%rbp)
jmp 0x6491
movq -0x4b0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x33, %eax
je 0x64b3
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
jmp 0x64b5
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x4c0(%rbp)
callq 0x3200
movq -0x4c0(%rbp), %rdi
movq %rax, -0x270(%rbp)
callq 0x3120
movq %rax, -0x278(%rbp)
movb $0x2f, -0x279(%rbp)
movq -0x270(%rbp), %rdi
movq -0x278(%rbp), %rsi
leaq -0x279(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x4b8(%rbp)
jmp 0x650c
movq -0x4b8(%rbp), %rax
cmpq $0x7, %rax
je 0x652c
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
movl $0x0, -0x280(%rbp)
movslq -0x280(%rbp), %rax
movq %rax, -0x4c8(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x3380
movq %rax, %rcx
movq -0x4c8(%rbp), %rax
cmpq %rcx, %rax
jae 0x683d
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4d0(%rbp)
jmp 0x657f
movq -0x4d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2f, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4d8(%rbp)
jmp 0x65ae
movq -0x4d8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x31, %eax
jl 0x65ec
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4e0(%rbp)
jmp 0x65d9
movq -0x4e0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x38, %eax
jle 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4e8(%rbp)
jmp 0x6608
movq -0x4e8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x70, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4f0(%rbp)
jmp 0x6637
movq -0x4f0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x50, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x4f8(%rbp)
jmp 0x6666
movq -0x4f8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x72, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x500(%rbp)
jmp 0x6695
movq -0x500(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x52, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x508(%rbp)
jmp 0x66c4
movq -0x508(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6b, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x510(%rbp)
jmp 0x66f3
movq -0x510(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4b, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x518(%rbp)
jmp 0x6722
movq -0x518(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x6e, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x520(%rbp)
jmp 0x6751
movq -0x520(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x4e, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x528(%rbp)
jmp 0x6780
movq -0x528(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x62, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x530(%rbp)
jmp 0x67af
movq -0x530(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x42, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x538(%rbp)
jmp 0x67da
movq -0x538(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x71, %eax
je 0x6827
movslq -0x280(%rbp), %rsi
leaq -0x1b8(%rbp), %rdi
callq 0x3480
movq %rax, -0x540(%rbp)
jmp 0x6805
movq -0x540(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x51, %eax
je 0x6827
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
jmp 0x6829
movl -0x280(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x280(%rbp)
jmp 0x6536
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x550(%rbp)
callq 0x3200
movq -0x550(%rbp), %rdi
movq %rax, -0x288(%rbp)
callq 0x3120
movq %rax, -0x290(%rbp)
movb $0x4b, -0x291(%rbp)
movq -0x288(%rbp), %rdi
movq -0x290(%rbp), %rsi
leaq -0x291(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x548(%rbp)
jmp 0x6894
movq -0x548(%rbp), %rax
cmpq $0x1, %rax
je 0x68b4
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x560(%rbp)
callq 0x3200
movq -0x560(%rbp), %rdi
movq %rax, -0x2a0(%rbp)
callq 0x3120
movq %rax, -0x2a8(%rbp)
movb $0x6b, -0x2a9(%rbp)
movq -0x2a0(%rbp), %rdi
movq -0x2a8(%rbp), %rsi
leaq -0x2a9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x558(%rbp)
jmp 0x690b
movq -0x558(%rbp), %rax
cmpq $0x1, %rax
je 0x692b
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x570(%rbp)
callq 0x3200
movq -0x570(%rbp), %rdi
movq %rax, -0x2c0(%rbp)
callq 0x3120
movq %rax, -0x2c8(%rbp)
movb $0x50, -0x2c9(%rbp)
movq -0x2c0(%rbp), %rdi
movq -0x2c8(%rbp), %rsi
leaq -0x2c9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x568(%rbp)
jmp 0x6982
movq -0x568(%rbp), %rax
movq %rax, -0x2b8(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x580(%rbp)
callq 0x3200
movq -0x580(%rbp), %rdi
movq %rax, -0x2e0(%rbp)
callq 0x3120
movq %rax, -0x2e8(%rbp)
movb $0x70, -0x2e9(%rbp)
movq -0x2e0(%rbp), %rdi
movq -0x2e8(%rbp), %rsi
leaq -0x2e9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x578(%rbp)
jmp 0x69e7
movq -0x578(%rbp), %rax
movq %rax, -0x2d8(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x590(%rbp)
callq 0x3200
movq -0x590(%rbp), %rdi
movq %rax, -0x300(%rbp)
callq 0x3120
movq %rax, -0x308(%rbp)
movb $0x4e, -0x309(%rbp)
movq -0x300(%rbp), %rdi
movq -0x308(%rbp), %rsi
leaq -0x309(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x588(%rbp)
jmp 0x6a4c
movq -0x588(%rbp), %rax
movq %rax, -0x2f8(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5a0(%rbp)
callq 0x3200
movq -0x5a0(%rbp), %rdi
movq %rax, -0x320(%rbp)
callq 0x3120
movq %rax, -0x328(%rbp)
movb $0x6e, -0x329(%rbp)
movq -0x320(%rbp), %rdi
movq -0x328(%rbp), %rsi
leaq -0x329(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x598(%rbp)
jmp 0x6ab1
movq -0x598(%rbp), %rax
movq %rax, -0x318(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5b0(%rbp)
callq 0x3200
movq -0x5b0(%rbp), %rdi
movq %rax, -0x340(%rbp)
callq 0x3120
movq %rax, -0x348(%rbp)
movb $0x42, -0x349(%rbp)
movq -0x340(%rbp), %rdi
movq -0x348(%rbp), %rsi
leaq -0x349(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5a8(%rbp)
jmp 0x6b16
movq -0x5a8(%rbp), %rax
movq %rax, -0x338(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5c0(%rbp)
callq 0x3200
movq -0x5c0(%rbp), %rdi
movq %rax, -0x360(%rbp)
callq 0x3120
movq %rax, -0x368(%rbp)
movb $0x62, -0x369(%rbp)
movq -0x360(%rbp), %rdi
movq -0x368(%rbp), %rsi
leaq -0x369(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5b8(%rbp)
jmp 0x6b7b
movq -0x5b8(%rbp), %rax
movq %rax, -0x358(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5d0(%rbp)
callq 0x3200
movq -0x5d0(%rbp), %rdi
movq %rax, -0x380(%rbp)
callq 0x3120
movq %rax, -0x388(%rbp)
movb $0x52, -0x389(%rbp)
movq -0x380(%rbp), %rdi
movq -0x388(%rbp), %rsi
leaq -0x389(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5c8(%rbp)
jmp 0x6be0
movq -0x5c8(%rbp), %rax
movq %rax, -0x378(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5e0(%rbp)
callq 0x3200
movq -0x5e0(%rbp), %rdi
movq %rax, -0x3a0(%rbp)
callq 0x3120
movq %rax, -0x3a8(%rbp)
movb $0x72, -0x3a9(%rbp)
movq -0x3a0(%rbp), %rdi
movq -0x3a8(%rbp), %rsi
leaq -0x3a9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5d8(%rbp)
jmp 0x6c45
movq -0x5d8(%rbp), %rax
movq %rax, -0x398(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x5f0(%rbp)
callq 0x3200
movq -0x5f0(%rbp), %rdi
movq %rax, -0x3c0(%rbp)
callq 0x3120
movq %rax, -0x3c8(%rbp)
movb $0x51, -0x3c9(%rbp)
movq -0x3c0(%rbp), %rdi
movq -0x3c8(%rbp), %rsi
leaq -0x3c9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5e8(%rbp)
jmp 0x6caa
movq -0x5e8(%rbp), %rax
movq %rax, -0x3b8(%rbp)
leaq -0x1b8(%rbp), %rdi
movq %rdi, -0x600(%rbp)
callq 0x3200
movq -0x600(%rbp), %rdi
movq %rax, -0x3e0(%rbp)
callq 0x3120
movq %rax, -0x3e8(%rbp)
movb $0x71, -0x3e9(%rbp)
movq -0x3e0(%rbp), %rdi
movq -0x3e8(%rbp), %rsi
leaq -0x3e9(%rbp), %rdx
callq 0x9ab0
movq %rax, -0x5f8(%rbp)
jmp 0x6d0f
movq -0x5f8(%rbp), %rax
movq %rax, -0x3d8(%rbp)
cmpq $0x8, -0x2b8(%rbp)
ja 0x6de7
cmpq $0x8, -0x2d8(%rbp)
ja 0x6de7
cmpq $0xa, -0x2f8(%rbp)
ja 0x6de7
cmpq $0xa, -0x318(%rbp)
ja 0x6de7
cmpq $0xa, -0x338(%rbp)
ja 0x6de7
cmpq $0xa, -0x358(%rbp)
ja 0x6de7
cmpq $0xa, -0x378(%rbp)
ja 0x6de7
cmpq $0xa, -0x398(%rbp)
ja 0x6de7
cmpq $0x9, -0x3b8(%rbp)
ja 0x6de7
cmpq $0x9, -0x3d8(%rbp)
ja 0x6de7
movq -0x2b8(%rbp), %rax
addq -0x2f8(%rbp), %rax
addq -0x338(%rbp), %rax
addq -0x378(%rbp), %rax
addq -0x3b8(%rbp), %rax
cmpq $0xf, %rax
ja 0x6de7
movq -0x2d8(%rbp), %rax
addq -0x318(%rbp), %rax
addq -0x358(%rbp), %rax
addq -0x398(%rbp), %rax
addq -0x3d8(%rbp), %rax
cmpq $0xf, %rax
jbe 0x6dfa
movb $0x0, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
jmp 0x7074
leaq 0x7a37(%rip), %rsi      # 0xe838
leaq -0x1d8(%rbp), %rdi
callq 0x9a80
movb %al, -0x601(%rbp)
jmp 0x6e15
movb -0x601(%rbp), %al
testb $0x1, %al
jne 0x6e21
jmp 0x6e2e
movq -0x460(%rbp), %rax
movb $0x1, 0x40(%rax)
jmp 0x6e39
movq -0x460(%rbp), %rax
movb $0x0, 0x40(%rax)
leaq -0x1f8(%rbp), %rax
movq %rax, -0x3f8(%rbp)
movq -0x3f8(%rbp), %rdi
callq 0x3200
movq %rax, -0x400(%rbp)
movq -0x3f8(%rbp), %rdi
callq 0x3120
movq %rax, -0x408(%rbp)
leaq -0x400(%rbp), %rdi
leaq -0x408(%rbp), %rsi
callq 0x9b00
testb $0x1, %al
jne 0x6e89
jmp 0x6f11
leaq -0x400(%rbp), %rdi
callq 0x9b40
movb (%rax), %al
movb %al, -0x409(%rbp)
movsbl -0x409(%rbp), %eax
addl $-0x4b, %eax
movl %eax, %ecx
movq %rcx, -0x610(%rbp)
subl $0x26, %eax
ja 0x6efe
movq -0x610(%rbp), %rax
leaq 0x786d(%rip), %rcx      # 0xe730
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x460(%rbp), %rax
movb $0x1, 0x41(%rax)
jmp 0x6efe
movq -0x460(%rbp), %rax
movb $0x1, 0x42(%rax)
jmp 0x6efe
movq -0x460(%rbp), %rax
movb $0x1, 0x43(%rax)
jmp 0x6efe
movq -0x460(%rbp), %rax
movb $0x1, 0x44(%rax)
jmp 0x6f00
leaq -0x400(%rbp), %rdi
callq 0x9b60
jmp 0x6e6d
leaq 0x778e(%rip), %rsi      # 0xe6a6
leaq -0x218(%rbp), %rdi
callq 0x9a50
movb %al, -0x611(%rbp)
jmp 0x6f2c
movb -0x611(%rbp), %al
testb $0x1, %al
jne 0x6f3b
jmp 0x7066
movq -0x460(%rbp), %rax
testb $0x1, 0x40(%rax)
je 0x6fd1
movq -0x460(%rbp), %rax
addq $0x58, %rax
movq %rax, -0x620(%rbp)
leaq -0x430(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x30d0
jmp 0x6f73
leaq -0x430(%rbp), %rdi
callq 0xd820
movl %eax, -0x624(%rbp)
jmp 0x6f87
movl -0x624(%rbp), %esi
movq -0x620(%rbp), %rdi
movl $0x1, %edx
callq 0x4c40
jmp 0x6fa0
leaq -0x430(%rbp), %rdi
callq 0x34a8
jmp 0x6fd1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x430(%rbp), %rdi
callq 0x34a8
jmp 0x70d6
movq -0x460(%rbp), %rax
testb $0x1, 0x40(%rax)
jne 0x7064
movq -0x460(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x630(%rbp)
leaq -0x450(%rbp), %rdi
leaq -0x218(%rbp), %rsi
callq 0x30d0
jmp 0x7009
leaq -0x450(%rbp), %rdi
callq 0xd820
movl %eax, -0x634(%rbp)
jmp 0x701d
movl -0x634(%rbp), %esi
movq -0x630(%rbp), %rdi
movl $0x1, %edx
callq 0x4c40
jmp 0x7036
leaq -0x450(%rbp), %rdi
callq 0x34a8
jmp 0x7064
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x260(%rbp)
movl %eax, -0x264(%rbp)
leaq -0x450(%rbp), %rdi
callq 0x34a8
jmp 0x70d6
jmp 0x7066
movb $0x1, -0x1(%rbp)
movl $0x1, -0x268(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x34a8
leaq -0x238(%rbp), %rdi
callq 0x34a8
leaq -0x218(%rbp), %rdi
callq 0x34a8
leaq -0x1f8(%rbp), %rdi
callq 0x34a8
leaq -0x1d8(%rbp), %rdi
callq 0x34a8
leaq -0x1b8(%rbp), %rdi
callq 0x34a8
leaq -0x198(%rbp), %rdi
callq 0x3100
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x640, %rsp            # imm = 0x640
popq %rbp
retq
leaq -0x258(%rbp), %rdi
callq 0x34a8
leaq -0x238(%rbp), %rdi
callq 0x34a8
leaq -0x218(%rbp), %rdi
callq 0x34a8
leaq -0x1f8(%rbp), %rdi
callq 0x34a8
leaq -0x1d8(%rbp), %rdi
callq 0x34a8
leaq -0x1b8(%rbp), %rdi
callq 0x34a8
leaq -0x198(%rbp), %rdi
callq 0x3100
movq -0x260(%rbp), %rdi
callq 0x3410
nopw %cs:(%rax,%rax)