// File: /workspace/github_cpp_makefile_star2_O3/tlaloc1313[P]chess-project/Board.cpp
// Function: Board::checkCheck(int, int)
int Board::checkCheck(int inputWhite, int inputBlack) {

	//Declaring variables
	bool whiteInCheck = 0;
	bool blackInCheck = 0;

  int kingSquare, kingRow, kingCol;

	int edges[4];					//Array of squares at the edge of board that could be attacking king, 0-3, anticlockwise starting east
	int pieceSquares[4];	//Array of squares with pieces, -1 if no piece

	//Increments for king row and column
	int kingRowIncr;
	int kingColIncr;

	//Squares that knighs could be on
	int knightSquares[8] = {17,10,-6,-15,-17,-10,6,15};

	//WHITE KING

	//Find what square the king is on, if it isn't passed
  if (inputWhite == -1) {
    for (int i = 0; i < 64; i++) {
  		if (activeArray[i]) {
  			if (pieceArray[i]->getType() == 'k' && pieceArray[i]->getIsWhite()) {
  				kingSquare = i;
  				break;
  			}
  		}
  	}
  } else {
    kingSquare = inputWhite;
  }

	//Find straight destinations
	kingRow = row(kingSquare);
	kingCol = col(kingSquare);

	edges[0] = 56 + kingRow;
	edges[1] = (8 * kingCol) + 7;
	edges[2] = 0 + kingRow;
	edges[3] = 8 * kingCol;

	//Find if pieces are on squares
	for (int i = 0; i < 4; i++) {
		pieceSquares[i] = pieceArray[kingSquare]->checkStraight(edges[i], activeArray);
		//checkStraight ignores the final square, so if it doesn't find anything, edges[i] is checked as well
		if (pieceSquares[i] == -1) {
			if (activeArray[edges[i]] == 1) {
				pieceSquares[i] = edges[i];
			}
		}
	}

	//Check squares
	for (int i = 0; i < 4; i++) {
		if (pieceSquares[i] != -1) {
			//If the piece is a black rook or queen
			if (strcmp(getPiece(pieceSquares[i]), u8"\u265C") == 0 || strcmp(getPiece(pieceSquares[i]), u8"\u265B") == 0) {
				whiteInCheck = 1;
			} else if ((abs(kingRow - row(pieceSquares[i])) <= 1 && abs(kingCol - col(pieceSquares[i])) <= 1) && strcmp(getPiece(pieceSquares[i]), u8"\u265A") == 0) {	//If the piece is a black king and within 1 square of the white king
				whiteInCheck = 1;
				blackInCheck = 1;
			}
		}
	}

	if (!whiteInCheck) {
		//Find diagonal destinations - edges now 0-3, anticlockwise starting north-east

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr < 7 && kingColIncr < 7) {
			kingRowIncr++;
			kingColIncr++;
		}

		edges[0] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr < 7 && kingColIncr > 0) {
			kingRowIncr++;
			kingColIncr--;
		}

		edges[1] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr > 0 && kingColIncr > 0) {
			kingRowIncr--;
			kingColIncr--;
		}

		edges[2] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr > 0 && kingColIncr < 7) {
			kingRowIncr--;
			kingColIncr++;
		}

		edges[3] = (kingColIncr * 8) + kingRowIncr;

		//Find if pieces are on squares
		for (int i = 0; i < 4; i++) {
			pieceSquares[i] = pieceArray[kingSquare]->checkDiagonal(edges[i], activeArray);
			//checkDiagonal ignores the final square, so if it doesn't find anything, edges[i] is checked as well
			if (pieceSquares[i] == -1) {
				if (activeArray[edges[i]] == 1) {
					pieceSquares[i] = edges[i];
				}
			}
		}

		//Check squares
		for (int i = 0; i < 4; i++) {
			if (pieceSquares[i] != -1) {
				//If the piece is a black bishop, queen or a pawn that is above white king on board
				if (strcmp(getPiece(pieceSquares[i]), u8"\u265D") == 0 || strcmp(getPiece(pieceSquares[i]), u8"\u265B") == 0 || (strcmp(getPiece(pieceSquares[i]), u8"\u265F") == 0 && row(pieceSquares[i]) - kingRow == 1)) {
					whiteInCheck = 1;
				} else if ((abs(kingRow - row(pieceSquares[i])) <= 1 && abs(kingCol - col(pieceSquares[i])) <= 1) && strcmp(getPiece(pieceSquares[i]), u8"\u265A") == 0) {	//If the piece is a black king and within 1 square of the white king
					whiteInCheck = 1;
					blackInCheck = 1;
				}
			}
		}
	}

	if (!whiteInCheck) {
		for (int i = 0; i < 8; i++) {
			knightSquares[i] += kingSquare;
		}

		for (int i = 0; i < 8; i++) {
			//If knightSquares[i] is an actual square
			if (knightSquares[i] >= 0 && knightSquares[i] <= 63) {
				//If there is a piece on knightSquares[i]
				if (activeArray[knightSquares[i]]) {
					//If the piece is a black knight and the within a radius of 2 squares from the king
					if (strcmp(getPiece(knightSquares[i]), u8"\u265E") == 0 && (abs(kingRow - row(knightSquares[i])) <= 2 && abs(kingCol - col(knightSquares[i])) <= 2)) {
						whiteInCheck = 1;
					}
				}
			}
		}
	}
	//BLACK KING
	//Find what square the king is on, if it isn't passed
  if (inputBlack == -1) {
    for (int i = 0; i < 64; i++) {
  		if (activeArray[i]) {
  			if (pieceArray[i]->getType() == 'k' && !pieceArray[i]->getIsWhite()) {
  				kingSquare = i;
  				break;
  			}
  		}
  	}
  } else {
    kingSquare = inputBlack;
  }

	kingRow = row(kingSquare);
	kingCol = col(kingSquare);

	//Find straight destinations
	edges[0] = 56 + kingRow;
	edges[1] = (8 * kingCol) + 7;
	edges[2] = 0 + kingRow;
	edges[3] = 8 * kingCol;

	//Find if pieces are on squares
	for (int i = 0; i < 4; i++) {
		pieceSquares[i] = pieceArray[kingSquare]->checkStraight(edges[i], activeArray);
		//checkStraight ignores the final square, so if it doesn't find anything, edges[i] is checked as well
		if (pieceSquares[i] == -1) {
			if (activeArray[edges[i]] == 1) {
				pieceSquares[i] = edges[i];
			}
		}
	}

	//Check squares
	for (int i = 0; i < 4; i++) {
		if (pieceSquares[i] != -1) {
			//If the piece is a white rook or queen
			if (strcmp(getPiece(pieceSquares[i]), u8"\u2656") == 0 || strcmp(getPiece(pieceSquares[i]), u8"\u2655") == 0) {
				blackInCheck = 1;
			}
		}
	}

	if (!blackInCheck) {
		//Find diagonal destinations - edges now 0-3, anticlockwise starting north-east
		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr < 7 && kingColIncr < 7) {
			kingRowIncr++;
			kingColIncr++;
		}

		edges[0] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr < 7 && kingColIncr > 0) {
			kingRowIncr++;
			kingColIncr--;
		}

		edges[1] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr > 0 && kingColIncr > 0) {
			kingRowIncr--;
			kingColIncr--;
		}

		edges[2] = (kingColIncr * 8) + kingRowIncr;

		kingRowIncr = kingRow;
		kingColIncr = kingCol;

		while (kingRowIncr > 0 && kingColIncr < 7) {
			kingRowIncr--;
			kingColIncr++;
		}

		edges[3] = (kingColIncr * 8) + kingRowIncr;

		//Find if pieces are on squares
		for (int i = 0; i < 4; i++) {
			pieceSquares[i] = pieceArray[kingSquare]->checkDiagonal(edges[i], activeArray);
			//checkDiagonal ignores the final square, so if it doesn't find anything, edges[i] is checked as well
			if (pieceSquares[i] == -1) {
				if (activeArray[edges[i]] == 1) {
					pieceSquares[i] = edges[i];
				}
			}
		}

		//Check squares
		for (int i = 0; i < 4; i++) {
			if (pieceSquares[i] != -1) {
				//If the piece is a white bishop, queen or a pawn that is below black king on board
				if (strcmp(getPiece(pieceSquares[i]), u8"\u2657") == 0 || strcmp(getPiece(pieceSquares[i]), u8"\u2655") == 0 || (strcmp(getPiece(pieceSquares[i]), u8"\u2659") == 0 && row(pieceSquares[i]) - kingRow == -1)) {
					blackInCheck = 1;
				} else if ((abs(kingRow - row(pieceSquares[i])) <= 1 && abs(kingCol - col(pieceSquares[i])) <= 1) && strcmp(getPiece(pieceSquares[i]), u8"♔") == 0) {	//If the piece is a white king and within 1 square of the black king
					whiteInCheck = 1;
					blackInCheck = 1;
				}
			}
		}
	}

	if (!blackInCheck) {

		for (int i = 0; i < 8; i++) {
			knightSquares[i] += kingSquare;
		}

		for (int i = 0; i < 8; i++) {
			//If knightSquares[i] is an actual square
			if (knightSquares[i] >= 0 && knightSquares[i] <= 63) {
				//If there is a piece on knightSquares[i]
				if (activeArray[knightSquares[i]]) {
					//If the piece is a white knight and the within a radius of 2 squares from the king
					if (strcmp(getPiece(knightSquares[i]), u8"\u2658") == 0 && (abs(kingRow - row(knightSquares[i])) <= 2 && abs(kingCol - col(knightSquares[i])) <= 2)) {
						blackInCheck = 1;
					}
				}
			}
		}
	}

	if (whiteInCheck && blackInCheck) {
		return 3;
	} else if (blackInCheck) {
		return 2;
	} else if (whiteInCheck) {
		return 1;
	}
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %edx, %r14d
movl %esi, %r12d
movq %rdi, %rbx
movaps 0x2252(%rip), %xmm0     # 0x6510
movaps %xmm0, -0xa0(%rbp)
movaps 0x2234(%rip), %xmm0     # 0x6500
movaps %xmm0, -0xb0(%rbp)
cmpl $-0x1, %esi
jne 0x4311
xorl %r12d, %r12d
cmpb $0x1, 0x208(%rbx,%r12)
jne 0x4302
movq 0x8(%rbx,%r12,8), %rdi
callq 0x5c48
cmpb $0x6b, %al
jne 0x4302
movq 0x8(%rbx,%r12,8), %rdi
callq 0x5c52
testb %al, %al
jne 0x4311
incq %r12
cmpq $0x40, %r12
jne 0x42db
movl $0x40, %r12d
movq %r14, -0x88(%rbp)
movl %r12d, %edi
callq 0x3a20
movl %eax, %r14d
movl %r12d, %edi
callq 0x3a35
leal 0x38(%r14), %ecx
movl %ecx, -0x50(%rbp)
leal (,%rax,8), %ecx
movq %rax, -0x58(%rbp)
leal 0x7(,%rax,8), %eax
movl %eax, -0x4c(%rbp)
movq %r14, -0x38(%rbp)
movl %r14d, -0x48(%rbp)
movl %ecx, -0x64(%rbp)
movl %ecx, -0x44(%rbp)
movslq %r12d, %r15
leaq 0x208(%rbx), %rax
movq %rax, -0x60(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx,%r15,8), %rdi
movl -0x50(%rbp,%r14,4), %r13d
movl %r13d, %esi
movq -0x60(%rbp), %rdx
callq 0x5a9a
movl %eax, -0x80(%rbp,%r14,4)
cmpl $-0x1, %eax
jne 0x4398
movslq %r13d, %rax
movq -0x60(%rbp), %rcx
cmpb $0x1, (%rcx,%rax)
jne 0x4398
movl %r13d, -0x80(%rbp,%r14,4)
incq %r14
cmpq $0x4, %r14
jne 0x4366
xorl %r14d, %r14d
movl $0x0, -0x30(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x80(%rbp,%r14,4), %r13d
cmpl $-0x1, %r13d
je 0x4475
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x20e9(%rip), %rsi      # 0x64bf
callq 0x2160
testl %eax, %eax
je 0x4470
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x20d7(%rip), %rsi      # 0x64cf
callq 0x2160
testl %eax, %eax
je 0x4470
movl %r13d, %edi
callq 0x3a20
movq -0x38(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x4475
movl %r13d, %edi
callq 0x3a35
movq -0x58(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x4475
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x2081(%rip), %rsi      # 0x64cb
callq 0x2160
testl %eax, %eax
movl -0x2c(%rbp), %eax
movzbl %al, %eax
movl $0x1, %ecx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x30(%rbp), %eax
movzbl %al, %eax
cmovel %ecx, %eax
movl %eax, -0x30(%rbp)
jmp 0x4475
movb $0x1, %al
movl %eax, -0x2c(%rbp)
incq %r14
cmpq $0x4, %r14
jne 0x43b2
testb $0x1, -0x2c(%rbp)
je 0x4980
movl -0x30(%rbp), %r14d
testb $0x1, -0x2c(%rbp)
movl %r14d, -0x30(%rbp)
jne 0x4539
xorl %eax, %eax
addl %r12d, -0xb0(%rbp,%rax,4)
incq %rax
cmpq $0x8, %rax
jne 0x44a0
xorl %r14d, %r14d
movl $0x1, %r15d
movl -0xb0(%rbp,%r14,4), %r13d
cmpq $0x3f, %r13
ja 0x4530
movq -0x60(%rbp), %rax
cmpb $0x1, (%rax,%r13)
jne 0x4530
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x1fdf(%rip), %rsi      # 0x64c7
callq 0x2160
testl %eax, %eax
jne 0x4530
movl %r13d, %edi
callq 0x3a20
movq -0x38(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x2, %eax
ja 0x4530
movl %r13d, %edi
callq 0x3a35
movq -0x58(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x3, %eax
movl -0x2c(%rbp), %eax
movzbl %al, %eax
cmovbl %r15d, %eax
movl %eax, -0x2c(%rbp)
incq %r14
cmpq $0x8, %r14
jne 0x44ba
movq -0x88(%rbp), %r14
cmpl $-0x1, %r14d
movq -0x60(%rbp), %r13
jne 0x4583
xorl %r14d, %r14d
cmpb $0x1, (%r13,%r14)
jne 0x4577
movq -0x200(%r13,%r14,8), %rdi
callq 0x5c48
cmpb $0x6b, %al
jne 0x4577
movq -0x200(%r13,%r14,8), %rdi
callq 0x5c52
testb %al, %al
je 0x4583
incq %r14
cmpq $0x40, %r14
jne 0x454d
movl %r12d, %r14d
movl %r14d, %edi
callq 0x3a20
movl %eax, %r15d
movl %r14d, %edi
callq 0x3a35
leal 0x38(%r15), %ecx
movl %ecx, -0x50(%rbp)
leal (,%rax,8), %ecx
movq %rax, -0x58(%rbp)
leal 0x7(,%rax,8), %eax
movl %eax, -0x4c(%rbp)
movq %r15, -0x38(%rbp)
movl %r15d, -0x48(%rbp)
movl %ecx, -0x64(%rbp)
movl %ecx, -0x44(%rbp)
movq %r14, -0x88(%rbp)
movslq %r14d, %r15
xorl %r14d, %r14d
movq 0x8(%rbx,%r15,8), %rdi
movl -0x50(%rbp,%r14,4), %r12d
movl %r12d, %esi
movq %r13, %rdx
callq 0x5a9a
movl %eax, -0x80(%rbp,%r14,4)
cmpl $-0x1, %eax
jne 0x45fc
movslq %r12d, %rax
cmpb $0x1, (%r13,%rax)
jne 0x45fc
movl %r12d, -0x80(%rbp,%r14,4)
incq %r14
cmpq $0x4, %r14
jne 0x45cd
xorl %r14d, %r14d
leaq 0x1e98(%rip), %r12      # 0x64a7
movl -0x80(%rbp,%r14,4), %r13d
cmpl $-0x1, %r13d
je 0x4657
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
movq %r12, %rsi
callq 0x2160
testl %eax, %eax
je 0x4652
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x1e6e(%rip), %rsi      # 0x64b7
callq 0x2160
testl %eax, %eax
jne 0x4657
movb $0x1, %al
movl %eax, -0x30(%rbp)
incq %r14
cmpq $0x4, %r14
jne 0x460f
movl -0x30(%rbp), %r14d
testb $0x1, %r14b
jne 0x4899
movq -0x38(%rbp), %rdi
cmpl $0x7, %edi
setge %al
movq -0x58(%rbp), %r8
cmpl $0x7, %r8d
setge %cl
orb %al, %cl
movl -0x64(%rbp), %r9d
movl %r9d, %eax
movl %edi, %ecx
jne 0x46b4
movl $0x6, %eax
movl $0x6, %ecx
subl %r8d, %ecx
subl %edi, %eax
cmpl %eax, %ecx
cmovbl %ecx, %eax
leal (%r8,%rax), %edx
leal (%rdi,%rax), %ecx
incl %ecx
leal 0x8(,%rdx,8), %eax
cmpl $0x7, %edi
setge %dl
addl %ecx, %eax
movl %eax, -0x50(%rbp)
testl %r8d, %r8d
setle %al
orb %dl, %al
movl %r9d, %eax
movl %edi, %ecx
jne 0x46e8
leal -0x1(%r8), %eax
movl $0x6, %edx
subl %edi, %edx
cmpl %edx, %eax
cmovbl %eax, %edx
leal (%rdi,%rdx), %ecx
incl %ecx
subl %edx, %eax
shll $0x3, %eax
testl %r8d, %r8d
setle %dl
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
testl %edi, %edi
setle %al
orb %dl, %al
movl %r9d, %eax
movl %edi, %ecx
movq -0x60(%rbp), %r13
jne 0x471a
leal -0x1(%rdi), %ecx
leal -0x1(%r8), %eax
cmpl %ecx, %eax
movl %ecx, %edx
cmovbl %eax, %edx
subl %edx, %ecx
subl %edx, %eax
shll $0x3, %eax
testl %edi, %edi
setle %dl
cmpl $0x7, %r8d
setge %sil
addl %ecx, %eax
movl %eax, -0x48(%rbp)
orb %dl, %sil
movl %edi, %eax
jne 0x4751
leal -0x1(%rdi), %eax
movl $0x6, %ecx
subl %r8d, %ecx
cmpl %ecx, %eax
cmovbl %eax, %ecx
leal (%r8,%rcx), %edx
subl %ecx, %eax
leal 0x8(,%rdx,8), %r9d
addl %eax, %r9d
movl %r9d, -0x44(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx,%r15,8), %rdi
movl -0x50(%rbp,%r14,4), %r12d
movl %r12d, %esi
movq %r13, %rdx
callq 0x5b62
movl %eax, -0x80(%rbp,%r14,4)
cmpl $-0x1, %eax
jne 0x478a
movslq %r12d, %rax
cmpb $0x1, (%r13,%rax)
jne 0x478a
movl %r12d, -0x80(%rbp,%r14,4)
incq %r14
cmpq $0x4, %r14
jne 0x475b
xorl %r15d, %r15d
leaq 0x1d0e(%rip), %r13      # 0x64ab
movl -0x30(%rbp), %r14d
movl -0x80(%rbp,%r15,4), %r12d
cmpl $-0x1, %r12d
je 0x488c
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4092
movq %rax, %rdi
movq %r13, %rsi
callq 0x2160
testl %eax, %eax
je 0x4889
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x1cd4(%rip), %rsi      # 0x64b7
callq 0x2160
testl %eax, %eax
je 0x4889
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x1c9e(%rip), %rsi      # 0x64a3
callq 0x2160
testl %eax, %eax
jne 0x481e
movl %r12d, %edi
callq 0x3a20
subl -0x38(%rbp), %eax
cmpl $-0x1, %eax
je 0x4889
movl %r12d, %edi
callq 0x3a20
movq -0x38(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x488c
movl %r12d, %edi
callq 0x3a35
movq -0x58(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x488c
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x1c4c(%rip), %rsi      # 0x64b3
callq 0x2160
testl %eax, %eax
movl -0x2c(%rbp), %eax
movzbl %al, %eax
movl $0x1, %ecx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
movzbl %r14b, %r14d
cmovel %ecx, %r14d
jmp 0x488c
movb $0x1, %r14b
incq %r15
cmpq $0x4, %r15
jne 0x47a1
movl %r14d, %r13d
testb $0x1, %r14b
jne 0x4944
xorl %eax, %eax
movq -0x88(%rbp), %rcx
addl %ecx, -0xb0(%rbp,%rax,4)
incq %rax
cmpq $0x8, %rax
jne 0x48af
xorl %r14d, %r14d
leaq 0x1be6(%rip), %r15      # 0x64af
movl -0xb0(%rbp,%r14,4), %r12d
cmpq $0x3f, %r12
ja 0x493b
movq -0x60(%rbp), %rax
cmpb $0x1, (%rax,%r12)
jne 0x493b
movq %rbx, %rdi
movl %r12d, %esi
callq 0x4092
movq %rax, %rdi
movq %r15, %rsi
callq 0x2160
testl %eax, %eax
jne 0x493b
movl %r12d, %edi
callq 0x3a20
movq -0x38(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x2, %eax
ja 0x493b
movl %r12d, %edi
callq 0x3a35
movq -0x58(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x3, %eax
movzbl %r13b, %r13d
movl $0x1, %eax
cmovbl %eax, %r13d
incq %r14
cmpq $0x8, %r14
jne 0x48c9
movl -0x2c(%rbp), %eax
andb $0x1, %al
movzbl %al, %ecx
testb $0x1, %r13b
movl $0x2, %edx
cmovel %ecx, %edx
testb %cl, %cl
cmovnel %ecx, %edx
testb $0x1, %r13b
movl $0x3, %eax
cmovel %edx, %eax
testb %cl, %cl
cmovel %edx, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x38(%rbp), %rdi
cmpl $0x7, %edi
setge %al
movq -0x58(%rbp), %r8
cmpl $0x7, %r8d
setge %cl
orb %al, %cl
movl -0x64(%rbp), %r9d
movl %r9d, %eax
movl %edi, %ecx
jne 0x49c6
movl $0x6, %eax
movl $0x6, %ecx
subl %r8d, %ecx
subl %edi, %eax
cmpl %eax, %ecx
cmovbl %ecx, %eax
leal (%r8,%rax), %edx
leal (%rdi,%rax), %ecx
incl %ecx
leal 0x8(,%rdx,8), %eax
cmpl $0x7, %edi
setge %dl
addl %ecx, %eax
movl %eax, -0x50(%rbp)
testl %r8d, %r8d
setle %al
orb %dl, %al
movl %r9d, %eax
movl %edi, %ecx
jne 0x49fa
leal -0x1(%r8), %eax
movl $0x6, %edx
subl %edi, %edx
cmpl %edx, %eax
cmovbl %eax, %edx
leal (%rdi,%rdx), %ecx
incl %ecx
subl %edx, %eax
shll $0x3, %eax
testl %r8d, %r8d
setle %dl
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
testl %edi, %edi
setle %al
orb %dl, %al
movl %r9d, %eax
movl %edi, %ecx
jne 0x4a28
leal -0x1(%rdi), %ecx
leal -0x1(%r8), %eax
cmpl %ecx, %eax
movl %ecx, %edx
cmovbl %eax, %edx
subl %edx, %ecx
subl %edx, %eax
shll $0x3, %eax
testl %edi, %edi
setle %dl
cmpl $0x7, %r8d
setge %sil
addl %ecx, %eax
movl %eax, -0x48(%rbp)
orb %dl, %sil
movl %edi, %eax
jne 0x4a5f
leal -0x1(%rdi), %eax
movl $0x6, %ecx
subl %r8d, %ecx
cmpl %ecx, %eax
cmovbl %eax, %ecx
leal (%r8,%rcx), %edx
subl %ecx, %eax
leal 0x8(,%rdx,8), %r9d
addl %eax, %r9d
movl %r9d, -0x44(%rbp)
xorl %r14d, %r14d
movq 0x8(%rbx,%r15,8), %rdi
movl -0x50(%rbp,%r14,4), %r13d
movl %r13d, %esi
movq -0x60(%rbp), %rdx
callq 0x5b62
movl %eax, -0x80(%rbp,%r14,4)
cmpl $-0x1, %eax
jne 0x4a9b
movslq %r13d, %rax
movq -0x60(%rbp), %rcx
cmpb $0x1, (%rcx,%rax)
jne 0x4a9b
movl %r13d, -0x80(%rbp,%r14,4)
incq %r14
cmpq $0x4, %r14
jne 0x4a69
xorl %r15d, %r15d
movl -0x30(%rbp), %r14d
movl -0x80(%rbp,%r15,4), %r13d
cmpl $-0x1, %r13d
je 0x4b25
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x19f8(%rip), %rsi      # 0x64c3
callq 0x2160
testl %eax, %eax
je 0x4b20
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x19e6(%rip), %rsi      # 0x64cf
callq 0x2160
testl %eax, %eax
je 0x4b20
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x19b4(%rip), %rsi      # 0x64bb
callq 0x2160
testl %eax, %eax
jne 0x4b37
movl %r13d, %edi
callq 0x3a20
subl -0x38(%rbp), %eax
cmpl $0x1, %eax
jne 0x4b37
movb $0x1, %al
movl %eax, -0x2c(%rbp)
incq %r15
cmpq $0x4, %r15
jne 0x4aab
jmp 0x4490
movl %r13d, %edi
callq 0x3a20
movq -0x38(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x4b25
movl %r13d, %edi
callq 0x3a35
movq -0x58(%rbp), %rcx
subl %eax, %ecx
movl %ecx, %eax
negl %eax
cmovsl %ecx, %eax
cmpl $0x1, %eax
ja 0x4b25
movq %rbx, %rdi
movl %r13d, %esi
callq 0x4092
movq %rax, %rdi
leaq 0x194b(%rip), %rsi      # 0x64cb
callq 0x2160
testl %eax, %eax
movl -0x2c(%rbp), %eax
movzbl %al, %eax
movl $0x1, %ecx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
movzbl %r14b, %r14d
cmovel %ecx, %r14d
jmp 0x4b25