// File: /workspace/github_cpp_makefile_star2_O2/scattana[P]Crossword-Anagram-CPP/board.cpp
// Function: Board::placeNextVer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool Board::placeNextVer(string word){
	int match = 0;
	bool isPlaced = 0, key = 0;
		for(int j=0; j<15; j++){
			for(int i=0; i<15+1-word.size(); i++){
				for(int k=0; k<word.size(); k++){
					if(getSpot(i+k,j)=='_' || getSpot(i+k,j)==word[k]){
						match++;
					}
					if(getSpot(i+k,j)==word[k]){
						if(getSpot(i+k+1,j)=='_' && getSpot(i+k-1,j)=='_'){
							match = match+2;
							key = 1;
						}
					}
					if(getSpot(i+k,j+1)=='_'&&getSpot(i+k,j-1)=='_'){
						match = match + 2;
					}
					if(getSpot(i-1,j)=='_' && getSpot((i+word.size()),j)=='_'){
						if(k==0) match = match + 2;
					}
				} // end of "k" for loop
				if(match == 3*word.size()+2 && key == 1 && isPlaced == 0){
					// place word
					for(int p=0; p<word.size(); p++){
						setSpot(word[p], i+p, j);
					}
					// set isPlaced to true
					isPlaced = 1;
					// assign coordinates to the newly-placed word
					locations[place][0] = i;
					locations[place][1] = j;
					place++;
					return 1;

				}
				match = 0;
				key = 0;
			} // end of second for loop (i)
		} // end of outermost for loop (j)
	return 0; // return false if the word was not able to be placed vertically
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8(%rsi), %rdx
movabsq $0x10, %rax
subq %rdx, %rax
movq %rax, -0x58(%rbp)
leaq (%rdx,%rdx,2), %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
xorl %r9d, %r9d
movq %rdi, -0x30(%rbp)
cmpq $0xf, %r9
je 0x3a03
leaq 0x1(%r9), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
addq %r9, %rax
movq %rax, -0x50(%rbp)
movq %rdi, %rcx
xorl %r8d, %r8d
movq %r9, -0x38(%rbp)
cmpq -0x58(%rbp), %r8
je 0x39ac
imulq $0xf, %r8, %rax
addq -0x30(%rbp), %rax
leaq (%r9,%rax), %r15
addq $-0xf, %r15
leal (%rdx,%r8), %eax
cltq
imulq $0xf, %rax, %r12
addq -0x50(%rbp), %r12
xorl %r13d, %r13d
movq %rcx, %r14
xorl %r10d, %r10d
xorl %r11d, %r11d
cmpq %r13, %rdx
je 0x398d
movb (%r14), %r9b
movq (%rsi), %rax
movb (%rax,%r13), %al
cmpb $0x5f, %r9b
jne 0x391d
movl %eax, %ebx
jmp 0x3925
movl %r9d, %ebx
cmpb %al, %r9b
jne 0x392a
incl %r10d
movl %ebx, %eax
cmpb %al, %r9b
jne 0x394d
cmpb $0x5f, 0xf(%r14)
jne 0x394d
leal 0x2(%r10), %eax
cmpb $0x5f, -0xf(%r14)
sete %r9b
cmovnel %r10d, %eax
orb %r9b, %r11b
movl %eax, %r10d
cmpb $0x5f, 0x1(%r14)
jne 0x3964
cmpb $0x5f, -0x1(%r14)
leal 0x2(%r10), %eax
cmovnel %r10d, %eax
movl %eax, %r10d
cmpb $0x5f, (%r15)
jne 0x3981
leal 0x2(%r10), %eax
cmpb $0x5f, (%r12)
cmovnel %r10d, %eax
testq %r13, %r13
cmovnel %r10d, %eax
movl %eax, %r10d
incq %r13
addq $0xf, %r14
jmp 0x3900
movslq %r10d, %rax
cmpq %rax, -0x48(%rbp)
sete %al
testb %r11b, %al
jne 0x39b8
incq %r8
addq $0xf, %rcx
movq -0x38(%rbp), %r9
jmp 0x38cc
incq %rdi
movq -0x40(%rbp), %r9
jmp 0x38a5
movl %r8d, %eax
imulq $0xf, %rax, %rax
addq %rax, %rdi
xorl %ecx, %ecx
movq -0x38(%rbp), %r9
cmpq %rcx, %rdx
jbe 0x39e2
movq (%rsi), %rax
movb (%rax,%rcx), %al
movb %al, (%rdi)
incq %rcx
movq 0x8(%rsi), %rdx
addq $0xf, %rdi
jmp 0x39c8
movq -0x30(%rbp), %rcx
movslq 0x408(%rcx), %rax
movl %r8d, 0xe4(%rcx,%rax,8)
movl %r9d, 0xe8(%rcx,%rax,8)
incl 0x408(%rcx)
cmpq $0xf, %r9
setb %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop