// File: /workspace/github_cpp_makefile_star2_O3/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), %r8
movl $0x10, %eax
subq %r8, %rax
movq %rax, -0x58(%rbp)
leaq (%r8,%r8,2), %rax
addq $0x2, %rax
movq %rax, -0x50(%rbp)
movb $0x1, %al
movq $0x0, -0x38(%rbp)
movq %rdi, -0x48(%rbp)
movq %rdi, -0x40(%rbp)
movb %al, -0x29(%rbp)
cmpq $0x10, %r8
je 0x48a4
movq -0x38(%rbp), %rax
leaq (%rax,%rax,4), %rax
leaq (%rax,%rax,2), %rbx
addq -0x48(%rbp), %rbx
movq -0x40(%rbp), %r14
xorl %r11d, %r11d
testq %r8, %r8
je 0x4894
movq (%rsi), %r15
movb -0x1(%r11,%rbx), %r12b
leal (%r8,%r11), %eax
movslq %eax, %r13
addq %rbx, %r13
xorl %edi, %edi
xorl %edx, %edx
xorl %eax, %eax
movb (%r14,%rdi), %r10b
movb (%r15,%rdi), %r9b
cmpb $0x5f, %r10b
jne 0x4821
movl %r9d, %ecx
jmp 0x4829
movl %r10d, %ecx
cmpb %r9b, %r10b
jne 0x482e
incl %eax
movl %ecx, %r9d
cmpb %r9b, %r10b
jne 0x4850
cmpb $0x5f, 0x1(%r14,%rdi)
jne 0x4850
leal 0x2(%rax), %ecx
cmpb $0x5f, -0x1(%r14,%rdi)
sete %r9b
cmovnel %eax, %ecx
orb %r9b, %dl
movl %ecx, %eax
cmpb $0x5f, 0xf(%r14,%rdi)
jne 0x4866
cmpb $0x5f, -0xf(%r14,%rdi)
leal 0x2(%rax), %ecx
cmovnel %eax, %ecx
movl %ecx, %eax
cmpb $0x5f, %r12b
jne 0x487f
leal 0x2(%rax), %ecx
cmpb $0x5f, (%r13)
cmovnel %eax, %ecx
testq %rdi, %rdi
cmovnel %eax, %ecx
movl %ecx, %eax
incq %rdi
cmpq %rdi, %r8
jne 0x480e
cltq
cmpq %rax, -0x50(%rbp)
sete %al
testb %dl, %al
jne 0x48cb
incq %r11
incq %r14
cmpq -0x58(%rbp), %r11
jne 0x47ed
movq -0x38(%rbp), %rax
cmpq $0xe, %rax
leaq 0x1(%rax), %rcx
setb %al
movq -0x40(%rbp), %rdi
addq $0xf, %rdi
movq %rcx, -0x38(%rbp)
cmpq $0xf, %rcx
jne 0x47c5
jmp 0x4910
movl %r11d, %eax
movq -0x40(%rbp), %rdx
addq %rax, %rdx
xorl %eax, %eax
movq (%rsi), %rcx
movb (%rcx,%rax), %cl
movb %cl, (%rdx,%rax)
incq %rax
cmpq %rax, 0x8(%rsi)
ja 0x48d7
movq -0x48(%rbp), %rcx
movslq 0x408(%rcx), %rax
movq -0x38(%rbp), %rdx
movl %edx, 0xe4(%rcx,%rax,8)
movl %r11d, 0xe8(%rcx,%rax,8)
incl 0x408(%rcx)
movb -0x29(%rbp), %al
andb $0x1, %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop