// File: /workspace/github_cpp_makefile_star2_O2/Wheatwizard[P]Waldo/Tile.cpp
// Function: Tile::bond(Reactor&, unsigned int, unsigned int)
void Tile::bond( Reactor& board, unsigned row, unsigned col) {
	if (mat != BONDER) return;
	if (row > 0 && board[row-1][col].mat == BONDER) {
		Bond& bond = atom->getBond(UP);
		if (bond.getAtom()) {
			++bond;
		} else {
			Atom* otherAtom = board[row-1][col].getAtom();
			bond.setAtom(otherAtom);
			if (atom->getPriority() > otherAtom->getPriority()) {
				atom->setPriority(otherAtom->getPriority());
			}
		}
	}
	if (row+1 < board.getNumRows() && board[row+1][col].mat == BONDER) {
		Bond& bond = atom->getBond(DOWN);
		if (bond.getAtom()) {
			++bond;
		} else {
			Atom* otherAtom = board[row+1][col].getAtom();
			bond.setAtom(otherAtom);
			if (atom->getPriority() > otherAtom->getPriority()) {
				atom->setPriority(otherAtom->getPriority());
			}
		}
	}
	if (col > 0 && board[row][col-1].mat == BONDER) {
		Bond& bond = atom->getBond(LEFT);
		if (bond.getAtom()) {
			++bond;
		} else {
			Atom* otherAtom = board[row][col-1].getAtom();
			bond.setAtom(otherAtom);
			if (atom->getPriority() > otherAtom->getPriority()) {
				atom->setPriority(otherAtom->getPriority());
			}
		}
	}
	if (col+1 < board.getNumCols() && board[row][col+1].mat == BONDER) {
		Bond& bond = atom->getBond(RIGHT);
		if (bond.getAtom()) {
			++bond;
		} else {
			Atom* otherAtom = board[row][col+1].getAtom();
			bond.setAtom(otherAtom);
			if (atom->getPriority() > otherAtom->getPriority()) {
				atom->setPriority(otherAtom->getPriority());
			}
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl $0x1, 0x20(%rdi)
jne 0x3ec9
movl %ecx, %r12d
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movl %ecx, %eax
movq %rax, 0x8(%rsp)
testl %edx, %edx
je 0x3da0
leal -0x1(%r14), %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x256c
imulq $0x28, 0x8(%rsp), %r13
cmpl $0x1, 0x20(%rax,%r13)
jne 0x3da0
movq 0x18(%rbx), %rax
leaq 0x28(%rax), %rdi
cmpq $0x0, 0x28(%rax)
je 0x3d75
callq 0x3a5e
jmp 0x3da0
movq %rdi, 0x10(%rsp)
movq %r15, %rdi
movl %ebp, %esi
callq 0x256c
movq 0x18(%rax,%r13), %rcx
movq 0x10(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rbx), %rax
movl 0x4c(%rcx), %ecx
cmpl %ecx, 0x4c(%rax)
jbe 0x3da0
movl %ecx, 0x4c(%rax)
leal 0x1(%r14), %ebp
cmpl 0x4(%r15), %ebp
jae 0x3e03
movq %r15, %rdi
movl %ebp, %esi
callq 0x256c
imulq $0x28, 0x8(%rsp), %r13
cmpl $0x1, 0x20(%rax,%r13)
jne 0x3e03
movq 0x18(%rbx), %rax
leaq 0x48(%rax), %rdi
cmpq $0x0, 0x48(%rax)
je 0x3dd8
callq 0x3a5e
jmp 0x3e03
movq %rdi, 0x8(%rsp)
movq %r15, %rdi
movl %ebp, %esi
callq 0x256c
movq 0x18(%rax,%r13), %rcx
movq 0x8(%rsp), %rax
movq %rcx, (%rax)
movq 0x18(%rbx), %rax
movl 0x4c(%rcx), %ecx
cmpl %ecx, 0x4c(%rax)
jbe 0x3e03
movl %ecx, 0x4c(%rax)
testl %r12d, %r12d
je 0x3e5f
movq %r15, %rdi
movl %r14d, %esi
callq 0x256c
leal -0x1(%r12), %ecx
imulq $0x28, %rcx, %rbp
cmpl $0x1, 0x20(%rax,%rbp)
jne 0x3e5f
movq 0x18(%rbx), %rax
leaq 0x38(%rax), %r13
cmpq $0x0, 0x38(%rax)
je 0x3e3c
movq %r13, %rdi
callq 0x3a5e
jmp 0x3e5f
movq %r15, %rdi
movl %r14d, %esi
callq 0x256c
movq 0x18(%rax,%rbp), %rcx
movq %rcx, (%r13)
movq 0x18(%rbx), %rax
movl 0x4c(%rcx), %ecx
cmpl %ecx, 0x4c(%rax)
jbe 0x3e5f
movl %ecx, 0x4c(%rax)
incl %r12d
cmpl (%r15), %r12d
jae 0x3ec9
movq %r15, %rdi
movl %r14d, %esi
callq 0x256c
movl %r12d, %ecx
imulq $0x28, %rcx, %r13
cmpl $0x1, 0x20(%rax,%r13)
jne 0x3ec9
movq 0x18(%rbx), %rax
leaq 0x18(%rax), %r12
cmpq $0x0, 0x18(%rax)
je 0x3ea6
movq %r12, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3a5e
movq %r15, %rdi
movl %r14d, %esi
callq 0x256c
movq 0x18(%rax,%r13), %rcx
movq %rcx, (%r12)
movq 0x18(%rbx), %rax
movl 0x4c(%rcx), %ecx
cmpl %ecx, 0x4c(%rax)
jbe 0x3ec9
movl %ecx, 0x4c(%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq