// File: Wheatwizard[P]Waldo/Reactor.cpp
// Function: Reactor::fuse()
void Reactor::fuse() {
	for (unsigned r = 0; r < getNumRows(); ++r) {
		for (unsigned c = 0; c < getNumCols()-1; ++c) {
			if (board[r][c].getMat() == FUSOR) {
				if (board[r][c+1].getMat() == TARGET) {
					//Fuse the Atom to the right
					if (board[r][c].getAtom()) {
						board[r][c].getAtom()->unbond();
						Atom newAtom = *board[r][c+1].getAtom() + *board[r][c].getAtom();
						delete board[r][c].getAtom();
						delete board[r][c+1].getAtom();
						board[r][c+1].addAtom(NULL);
						board[r][c+1].addAtom(&newAtom);
					}
				} else {
					throw 16;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x68(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x6c(%rbp)
callq 0x2970
movl %eax, %ecx
movl -0x6c(%rbp), %eax
cmpl %ecx, %eax
jae 0x5cb5
movl $0x0, -0x10(%rbp)
movq -0x68(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x70(%rbp)
callq 0x6700
movl %eax, %ecx
movl -0x70(%rbp), %eax
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x5ca5
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6fb0
cmpl $0x3, %eax
jne 0x5c95
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6fb0
cmpl $0x5, %eax
jne 0x5c70
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
cmpq $0x0, %rax
je 0x5c6e
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
movq %rax, %rdi
callq 0x2eb0
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
movq %rax, %rcx
movq -0x68(%rbp), %rax
movq %rcx, -0x80(%rbp)
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
movq -0x80(%rbp), %rsi
movq %rax, %rdx
leaq -0x60(%rbp), %rdi
callq 0x2c30
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
je 0x5bdf
movq -0x78(%rbp), %rdi
movl $0x50, %esi
callq 0x21b0
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6f90
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
je 0x5c20
movq -0x88(%rbp), %rdi
movl $0x50, %esi
callq 0x21b0
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x7100
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0x7100
jmp 0x5c93
movl $0x4, %edi
callq 0x20d0
movq %rax, %rdi
movl $0x10, (%rdi)
movq 0xb316(%rip), %rsi      # 0x10fa0
xorl %eax, %eax
movl %eax, %edx
callq 0x2280
jmp 0x5c95
jmp 0x5c97
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5a91
jmp 0x5ca7
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5a6e
addq $0x90, %rsp
popq %rbp
retq
nop