// File: Wheatwizard[P]Waldo/Reactor.cpp
// Function: Reactor::split()
void Reactor::split() {
	for (unsigned r = 0; r < getNumRows(); ++r) {
		for (unsigned c = 1; c < getNumCols(); ++c) {
			if (board[r][c].getMat() == FISSOR) {
				if (board[r][c-1].getMat() == TARGET) {
					//Fuse the Atom to the right
					if (board[r][c].getAtom()) {
						Atom* substrate = board[r][c].getAtom();
						unsigned total = substrate->getValue();
						if (total == 1) return;
						if (total%2) {
							//The Atom is not evenly divisible
							substrate->setValue(total/2+1);
						} else {
							//The Atom is evenly divisible
							substrate->setValue(total/2);
						}
						board[r][c-1].addAtom(new Atom(substrate->getVariety(), total/2));
					}
				} else {
					throw 16;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x38(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
callq 0x2970
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jae 0x5ebb
movl $0x1, -0x10(%rbp)
movq -0x38(%rbp), %rdi
movl -0x10(%rbp), %eax
movl %eax, -0x40(%rbp)
callq 0x6700
movl %eax, %ecx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
jae 0x5eab
movq -0x38(%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 $0x4, %eax
jne 0x5e9b
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rdi
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
imulq $0x28, %rax, %rax
addq %rax, %rdi
callq 0x6fb0
cmpl $0x5, %eax
jne 0x5e76
movq -0x38(%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 0x5e74
movq -0x38(%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, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6710
movl %eax, -0x1c(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x5dce
jmp 0x5ebb
movl -0x1c(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x5dec
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
shrl %esi
addl $0x1, %esi
callq 0x6730
jmp 0x5dfa
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
shrl %esi
callq 0x6730
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movl -0xc(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movl -0x10(%rbp), %ecx
decl %ecx
leaq (%rcx,%rcx,4), %rcx
leaq (%rax,%rcx,8), %rax
movq %rax, -0x58(%rbp)
movl $0x50, %edi
callq 0x21a0
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rdi
callq 0x6750
movl %eax, -0x44(%rbp)
jmp 0x5e36
movl -0x44(%rbp), %esi
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %edx
shrl %edx
callq 0x28f0
jmp 0x5e49
movq -0x50(%rbp), %rsi
movq -0x58(%rbp), %rdi
callq 0x7100
jmp 0x5e74
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x50, %esi
callq 0x21b0
jmp 0x5ec1
jmp 0x5e99
movl $0x4, %edi
callq 0x20d0
movq %rax, %rdi
movl $0x10, (%rdi)
movq 0xb110(%rip), %rsi      # 0x10fa0
xorl %eax, %eax
movl %eax, %edx
callq 0x2280
jmp 0x5e9b
jmp 0x5e9d
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5cfe
jmp 0x5ead
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x5cdb
addq $0x60, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x2290
nopw (%rax,%rax)