// File: /workspace/github_cpp_makefile_star2_O2/scattana[P]Crossword-Anagram-CPP/board.cpp
// Function: Board::placeNextHor(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool Board::placeNextHor(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(j,i+k)=='_' || getSpot(j,i+k)==word[k]){
						match++;
					}
					if(getSpot(j,i+k)==word[k]){
						if(getSpot(j,i+k+1)=='_' && getSpot(j,i+k-1)=='_'){
							match = match+2;
							key = 1;
						}
					}
					if(getSpot(j+1,i+k)=='_'&&getSpot(j-1,i+k)=='_'){
						match = match + 2;
					}
					if(getSpot(j,i-1)=='_' && getSpot(j,i+word.size())=='_'){
						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], j,i+p);
					}
					locations[place][0] = j;
					locations[place][1] = i;
					place++;

					// set isPlaced to true
					isPlaced = 1;
					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 horizontally
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq 0x8(%rsi), %rdx
movabsq $0x10, %r9
subq %rdx, %r9
leaq (%rdx,%rdx,2), %rax
addq $0x2, %rax
movq %rax, -0x50(%rbp)
xorl %r10d, %r10d
movq %rdi, %r14
movq %rdi, -0x30(%rbp)
cmpq $0xf, %r10
je 0x3b83
leaq 0x1(%r10), %rax
movq %rax, -0x48(%rbp)
movq %r10, -0x40(%rbp)
imulq $0xf, %r10, %rbx
addq %rdi, %rbx
movq %r14, -0x38(%rbp)
xorl %r8d, %r8d
cmpq %r9, %r8
je 0x3b26
leaq (%r8,%rbx), %r15
decq %r15
leal (%rdx,%r8), %eax
movslq %eax, %r12
addq %rbx, %r12
xorl %r13d, %r13d
xorl %eax, %eax
xorl %r11d, %r11d
cmpq %r13, %rdx
je 0x3b0d
movb (%r14,%r13), %dil
movq (%rsi), %rcx
movb (%rcx,%r13), %r10b
cmpb $0x5f, %dil
jne 0x3aab
movl %r10d, %ecx
jmp 0x3ab2
movl %edi, %ecx
cmpb %r10b, %dil
jne 0x3ab7
incl %eax
movl %ecx, %r10d
cmpb %r10b, %dil
jne 0x3ad9
cmpb $0x5f, 0x1(%r14,%r13)
jne 0x3ad9
leal 0x2(%rax), %ecx
cmpb $0x5f, -0x1(%r14,%r13)
sete %dil
cmovnel %eax, %ecx
orb %dil, %r11b
movl %ecx, %eax
cmpb $0x5f, 0xf(%r14,%r13)
jne 0x3aef
cmpb $0x5f, -0xf(%r14,%r13)
leal 0x2(%rax), %ecx
cmovnel %eax, %ecx
movl %ecx, %eax
cmpb $0x5f, (%r15)
jne 0x3b08
leal 0x2(%rax), %ecx
cmpb $0x5f, (%r12)
cmovnel %eax, %ecx
testq %r13, %r13
cmovnel %eax, %ecx
movl %ecx, %eax
incq %r13
jmp 0x3a90
cltq
cmpq %rax, -0x50(%rbp)
sete %al
testb %r11b, %al
jne 0x3b3b
incq %r8
incq %r14
jmp 0x3a6e
movq -0x38(%rbp), %r14
addq $0xf, %r14
movq -0x48(%rbp), %r10
movq -0x30(%rbp), %rdi
jmp 0x3a4a
movl %r8d, %eax
movq -0x38(%rbp), %rdi
addq %rax, %rdi
xorl %eax, %eax
movq -0x40(%rbp), %r10
cmpq %rax, %rdx
jbe 0x3b62
movq (%rsi), %rcx
movb (%rcx,%rax), %cl
movb %cl, (%rdi,%rax)
incq %rax
movq 0x8(%rsi), %rdx
jmp 0x3b4b
movq -0x30(%rbp), %rcx
movslq 0x408(%rcx), %rax
movl %r10d, 0xe4(%rcx,%rax,8)
movl %r8d, 0xe8(%rcx,%rax,8)
incl 0x408(%rcx)
cmpq $0xf, %r10
setb %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop