// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpl $0x1, 0x20(%rdi)
jne 0x3fc2
movl %ecx, %r14d
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
movl %ecx, %r13d
testl %edx, %edx
je 0x3ec9
leal -0x1(%r12), %eax
cmpl %eax, 0x4(%r15)
jbe 0x3fcc
movq 0x18(%r15), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
leaq (,%r13,4), %rcx
addq %r13, %rcx
cmpl $0x1, 0x20(%rax,%rcx,8)
jne 0x3ec9
movq 0x18(%rbx), %rdi
cmpq $0x0, 0x28(%rdi)
je 0x3eb5
addq $0x28, %rdi
callq 0x3b74
jmp 0x3ec9
movq 0x18(%rax,%rcx,8), %rax
movq %rax, 0x28(%rdi)
movl 0x4c(%rax), %eax
cmpl %eax, 0x4c(%rdi)
jbe 0x3ec9
movl %eax, 0x4c(%rdi)
leal 0x1(%r12), %eax
cmpl 0x4(%r15), %eax
jae 0x3f1a
movq 0x18(%r15), %rcx
movl %eax, %eax
movq (%rcx,%rax,8), %rax
leaq (,%r13,4), %rcx
addq %r13, %rcx
cmpl $0x1, 0x20(%rax,%rcx,8)
jne 0x3f1a
movq 0x18(%rbx), %rdi
cmpq $0x0, 0x48(%rdi)
je 0x3f06
addq $0x48, %rdi
callq 0x3b74
jmp 0x3f1a
movq 0x18(%rax,%rcx,8), %rax
movq %rax, 0x48(%rdi)
movl 0x4c(%rax), %eax
cmpl %eax, 0x4c(%rdi)
jbe 0x3f1a
movl %eax, 0x4c(%rdi)
movl %r12d, %r13d
testl %r14d, %r14d
je 0x3f6d
cmpl %r12d, 0x4(%r15)
jbe 0x3fcc
movq 0x18(%r15), %rax
movq (%rax,%r13,8), %rax
leal -0x1(%r14), %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x1, 0x20(%rax,%rcx,8)
jne 0x3f6d
movq 0x18(%rbx), %rdi
cmpq $0x0, 0x38(%rdi)
je 0x3f59
addq $0x38, %rdi
callq 0x3b74
jmp 0x3f6d
movq 0x18(%rax,%rcx,8), %rax
movq %rax, 0x38(%rdi)
movl 0x4c(%rax), %eax
cmpl %eax, 0x4c(%rdi)
jbe 0x3f6d
movl %eax, 0x4c(%rdi)
incl %r14d
cmpl (%r15), %r14d
jae 0x3fc2
cmpl %r12d, 0x4(%r15)
jbe 0x3fcc
movq 0x18(%r15), %rax
movq (%rax,%r13,8), %rax
movl %r14d, %ecx
leaq (%rcx,%rcx,4), %rcx
cmpl $0x1, 0x20(%rax,%rcx,8)
jne 0x3fc2
movq 0x18(%rbx), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x3fae
addq $0x18, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x3b74
movq 0x18(%rax,%rcx,8), %rax
movq %rax, 0x18(%rdi)
movl 0x4c(%rax), %eax
cmpl %eax, 0x4c(%rdi)
jbe 0x3fc2
movl %eax, 0x4c(%rdi)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0x103a(%rip), %rdi      # 0x500d
leaq 0x1048(%rip), %rsi      # 0x5022
leaq 0x104d(%rip), %rcx      # 0x502e
movl $0x32, %edx
callq 0x20d0
nop