// File: /workspace/github_cpp_makefile_star2_O1/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 $0x0, -0x38(%rbp)
movb $0x1, %al
movq %rdi, -0x48(%rbp)
xorl %r9d, %r9d
movq $0x0, -0x50(%rbp)
xorl %r10d, %r10d
movq 0x8(%rsi), %r15
movq %r15, %rcx
subq $0x10, %rcx
setne %bl
je 0x49c6
movb %al, -0x29(%rbp)
negq %rcx
leaq (%r15,%r15,2), %rax
addq $0x2, %rax
movq %rax, -0x60(%rbp)
xorl %r13d, %r13d
movq %rdi, -0x40(%rbp)
xorl %r14d, %r14d
movq %rcx, -0x58(%rbp)
testq %r15, %r15
je 0x492b
movq (%rsi), %rax
movq -0x38(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq (%rcx,%rcx,2), %rcx
addq -0x48(%rbp), %rcx
movb -0x1(%r14,%rcx), %r11b
leal (%r14,%r15), %edx
movslq %edx, %r8
addq %rcx, %r8
xorl %edx, %edx
movb (%rdi,%rdx), %cl
cmpb $0x5f, %cl
je 0x48c3
movq (%rsi), %r12
cmpb (%r12,%rdx), %cl
jne 0x48c6
incl %r10d
cmpb (%rax,%rdx), %cl
jne 0x48f0
cmpb $0x5f, 0x1(%rdi,%rdx)
jne 0x48f0
leal 0x2(%r10), %ecx
cmpb $0x5f, -0x1(%rdi,%rdx)
cmovnel %r10d, %ecx
movzbl %r9b, %r9d
movl $0x1, %r10d
cmovel %r10d, %r9d
movl %ecx, %r10d
cmpb $0x5f, 0xf(%rdi,%rdx)
jne 0x4907
cmpb $0x5f, -0xf(%rdi,%rdx)
leal 0x2(%r10), %ecx
cmovnel %r10d, %ecx
movl %ecx, %r10d
cmpb $0x5f, %r11b
jne 0x4923
leal 0x2(%r10), %ecx
cmpb $0x5f, (%r8)
cmovnel %r10d, %ecx
testq %rdx, %rdx
cmovnel %r10d, %ecx
movl %ecx, %r10d
incq %rdx
cmpq %rdx, %r15
jne 0x48b2
testb $0x1, -0x50(%rbp)
sete %al
movslq %r10d, %rcx
cmpq %rcx, -0x60(%rbp)
sete %cl
andb %r9b, %cl
testb %al, %cl
jne 0x4974
incq %r14
movq -0x58(%rbp), %rcx
cmpq %r14, %rcx
seta %bl
incq %rdi
incl %r13d
xorl %r9d, %r9d
movl $0x0, %r10d
cmpq %rcx, %r14
jne 0x4885
xorl %r10d, %r10d
movb -0x29(%rbp), %al
movq -0x40(%rbp), %rdi
jmp 0x49c6
cmpq $0x0, 0x8(%rsi)
movq -0x40(%rbp), %rdi
je 0x4999
movl %r13d, %eax
addq %rdi, %rax
xorl %ecx, %ecx
movq (%rsi), %rdx
movb (%rdx,%rcx), %dl
movb %dl, (%rax,%rcx)
incq %rcx
cmpq %rcx, 0x8(%rsi)
ja 0x4987
movq -0x48(%rbp), %rcx
movslq 0x408(%rcx), %rax
movq -0x38(%rbp), %rdx
movl %edx, 0xe4(%rcx,%rax,8)
movl %r14d, 0xe8(%rcx,%rax,8)
incl 0x408(%rcx)
movb $0x1, %al
movq %rax, -0x50(%rbp)
movb -0x29(%rbp), %al
testb $0x1, %bl
jne 0x49ec
movq -0x38(%rbp), %rax
cmpq $0xe, %rax
leaq 0x1(%rax), %rcx
setb %al
addq $0xf, %rdi
movq %rcx, -0x38(%rbp)
cmpq $0xf, %rcx
jne 0x4851
andb $0x1, %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop