// File: cb92[P]Battleship/Game.cpp
// Function: Game::initializeBoard(Board&)
void Game::initializeBoard(Board &b)
{
	int xEntry, yEntry, horizEntry, attemptCount;
	std::string entryTemp;
	for (int i=0; i<NUM_SHIPS; i++)
	{
		attemptCount=0;
		do // check for valid placement of each ship
		{
			b.printPublicBoard();
			if (attemptCount>0) 
				std::cout<<"INVALID ENTRY for that ship! Please try again. \n";

			std::cout<<"Please enter location [Letter][Number] for the "<<
						"top/left of your "<<SHIP_NAMES[i]<<" which is length "
						<<SHIP_LENGTHS[i]<<": \n";
			entryTemp=getSquare();		
			xEntry=static_cast<int>(entryTemp[0]);
			yEntry=static_cast<int>(entryTemp[1]);

			std::cout<<"Please enter 0 if the ship is oriented vertically, "
						<<"1 if it is oriented horizontally:\n";
			horizEntry=getInt(0,1);

			attemptCount++;
		} while (!b.placeShip(i, xEntry-LETTER_CHAR_OFFSET, 
						yEntry-NUMBER_CHAR_OFFSET, horizEntry));

	}

	std::cout<<"Your starting board: \n";
	b.printPublicBoard();

	return;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x2270
movl $0x0, -0x44(%rbp)
cmpl $0x5, -0x44(%rbp)
jge 0x4b24
movl $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x51d0
jmp 0x4917
cmpl $0x0, -0x20(%rbp)
jle 0x494e
movq 0x86a4(%rip), %rdi      # 0xcfc8
leaq 0x489a(%rip), %rsi      # 0x91c5
callq 0x2180
jmp 0x4932
jmp 0x494e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x20e0
jmp 0x4b56
movq 0x8673(%rip), %rdi      # 0xcfc8
leaq 0x489a(%rip), %rsi      # 0x91f6
callq 0x2180
movq %rax, -0x88(%rbp)
jmp 0x496a
movq -0x88(%rbp), %rdi
leaq 0x48ae(%rip), %rsi      # 0x9226
callq 0x2180
movq %rax, -0x90(%rbp)
jmp 0x4986
movq -0x90(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x5, %rax
leaq 0x88d4(%rip), %rsi      # 0xd270
addq %rax, %rsi
callq 0x2150
movq %rax, -0x98(%rbp)
jmp 0x49ad
movq -0x98(%rbp), %rdi
leaq 0x487d(%rip), %rsi      # 0x9238
callq 0x2180
movq %rax, -0xa0(%rbp)
jmp 0x49c9
movq -0xa0(%rbp), %rdi
movslq -0x44(%rbp), %rcx
leaq 0x49f5(%rip), %rax      # 0x93d0
movl (%rax,%rcx,4), %esi
callq 0x22c0
movq %rax, -0xa8(%rbp)
jmp 0x49ec
movq -0xa8(%rbp), %rdi
leaq 0x47ae(%rip), %rsi      # 0x91a8
callq 0x2180
jmp 0x4a01
movq -0x80(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x4b60
jmp 0x4a10
leaq -0x40(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
leaq -0x78(%rbp), %rsi
movq %rsi, -0xc0(%rbp)
callq 0x2230
movq -0xc0(%rbp), %rdi
callq 0x20e0
movq -0xb8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2310
movq %rax, -0xb0(%rbp)
jmp 0x4a50
movq -0xb0(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x14(%rbp)
leaq -0x40(%rbp), %rdi
movl $0x1, %esi
callq 0x2310
movq %rax, -0xc8(%rbp)
jmp 0x4a74
movq -0xc8(%rbp), %rax
movsbl (%rax), %eax
movl %eax, -0x18(%rbp)
movq 0x8540(%rip), %rdi      # 0xcfc8
leaq 0x47bb(%rip), %rsi      # 0x924a
callq 0x2180
movq %rax, -0xd0(%rbp)
jmp 0x4a9d
movq -0xd0(%rbp), %rdi
leaq 0x47d3(%rip), %rsi      # 0x927e
callq 0x2180
jmp 0x4ab2
xorl %edi, %edi
movl $0x1, %esi
callq 0x7bd0
movl %eax, -0xd4(%rbp)
jmp 0x4ac6
movl -0xd4(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movl -0x44(%rbp), %esi
movl -0x14(%rbp), %edx
addl $-0x41, %edx
movl -0x18(%rbp), %ecx
addl $-0x30, %ecx
movl -0x1c(%rbp), %eax
testl %eax, %eax
setne %al
movzbl %al, %r8d
callq 0x5420
movb %al, -0xd5(%rbp)
jmp 0x4b04
movb -0xd5(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x490c
jmp 0x4b16
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x48fb
movq 0x849d(%rip), %rdi      # 0xcfc8
leaq 0x476f(%rip), %rsi      # 0x92a1
callq 0x2180
jmp 0x4b39
movq -0x10(%rbp), %rdi
callq 0x51d0
jmp 0x4b44
leaq -0x40(%rbp), %rdi
callq 0x20e0
addq $0xe0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x22d0
nop