// File: 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
subq $0x80, %rsp
movq %rsi, -0x40(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x1d(%rbp)
movb $0x0, -0x1e(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0xf, -0x24(%rbp)
jge 0x5aa2
movl $0x0, -0x28(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x28(%rbp), %rax
movq %rax, -0x48(%rbp)
callq 0x2130
movq %rax, %rdx
movq -0x48(%rbp), %rax
movl $0x10, %ecx
subq %rdx, %rcx
cmpq %rcx, %rax
jae 0x5a92
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x2c(%rbp), %rax
movq %rax, -0x50(%rbp)
callq 0x2130
movq %rax, %rcx
movq -0x50(%rbp), %rax
cmpq %rcx, %rax
jae 0x599c
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
je 0x5863
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
callq 0x5ac0
movq -0x40(%rbp), %rdi
movsbl %al, %eax
movl %eax, -0x54(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x22e0
movq %rax, %rcx
movl -0x54(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x586c
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
callq 0x5ac0
movq -0x40(%rbp), %rdi
movsbl %al, %eax
movl %eax, -0x58(%rbp)
movslq -0x2c(%rbp), %rsi
callq 0x22e0
movq %rax, %rcx
movl -0x58(%rbp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x58e7
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
addl $0x1, %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x58e5
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
subl $0x1, %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x58e5
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movb $0x1, -0x1e(%rbp)
jmp 0x58e7
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
addl $0x1, %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x592a
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
subl $0x1, %esi
movl -0x28(%rbp), %edx
addl -0x2c(%rbp), %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x592a
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
subl $0x1, %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x598c
movq -0x40(%rbp), %rdi
movl -0x24(%rbp), %eax
movl %eax, -0x64(%rbp)
movslq -0x28(%rbp), %rax
movq %rax, -0x60(%rbp)
callq 0x2130
movq -0x38(%rbp), %rdi
movl -0x64(%rbp), %esi
movq %rax, %rcx
movq -0x60(%rbp), %rax
addq %rcx, %rax
movl %eax, %edx
callq 0x5ac0
movsbl %al, %eax
cmpl $0x5f, %eax
jne 0x598c
cmpl $0x0, -0x2c(%rbp)
jne 0x598a
movl -0x1c(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x1c(%rbp)
jmp 0x598c
jmp 0x598e
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x57f6
movq -0x40(%rbp), %rdi
movslq -0x1c(%rbp), %rax
movq %rax, -0x70(%rbp)
callq 0x2130
movq %rax, %rcx
movq -0x70(%rbp), %rax
imulq $0x3, %rcx, %rcx
addq $0x2, %rcx
cmpq %rcx, %rax
jne 0x5a79
movb -0x1e(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x5a79
movb -0x1d(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5a79
movl $0x0, -0x30(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x30(%rbp), %rax
movq %rax, -0x78(%rbp)
callq 0x2130
movq %rax, %rcx
movq -0x78(%rbp), %rax
cmpq %rcx, %rax
jae 0x5a3a
movq -0x40(%rbp), %rdi
movslq -0x30(%rbp), %rsi
callq 0x22e0
movq -0x38(%rbp), %rdi
movb (%rax), %al
movl -0x24(%rbp), %edx
movl -0x28(%rbp), %ecx
addl -0x30(%rbp), %ecx
movsbl %al, %esi
callq 0x4e80
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x59ee
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %edx
movslq 0x408(%rax), %rcx
movl %edx, 0xe4(%rax,%rcx,8)
movl -0x28(%rbp), %edx
movslq 0x408(%rax), %rcx
movl %edx, 0xe8(%rax,%rcx,8)
movl 0x408(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x408(%rax)
movb $0x1, -0x1d(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0x5aa6
movl $0x0, -0x1c(%rbp)
movb $0x0, -0x1e(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x57c6
jmp 0x5a94
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x57b5
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)