// File: MatthewZMD[P]TetrisDual/cell.cc
// Function: Cell::notify(Subject&)
void Cell::notify(Subject& s) {
    Cell & c = dynamic_cast<Cell&>(s);
    CellInfo & info = dynamic_cast<CellInfo&>(c.getInfo());

	if (c.cellState.cellStatus == CellStatus::Dead) {
		if (info.pos.row == pos.row + 1) {
			c.cellState = CellState{CellStatus::Down};
			notifyObservers();
		}
	}
	else {
		if (info.pos.row == pos.row - 1) {
			blockLevel = info.blockLevel;
			type = info.type;
			squad = info.squad;

			// update squad
			for (auto& cell : squad) {
				for (unsigned i = 0; i < cell->squad.size(); ++i) {
					if (cell->squad.at(i)->pos == c.pos) {
						cell->squad.at(i) = this;
						break;
					}
				}
			}
		} else {
			c.cellState = CellState{CellStatus::Down};
			notifyObservers();
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x333ca(%rip), %rsi     # 0x43140
leaq 0x33623(%rip), %rdx     # 0x433a0
movl $0x8, %ecx
callq 0x63f0
movq %rax, -0x78(%rbp)
cmpq $0x0, %rax
jne 0xfd96
callq 0x6690
movq -0x78(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq %rax, %rdi
leaq 0x33bee(%rip), %rsi     # 0x439a0
leaq 0x33667(%rip), %rdx     # 0x43420
xorl %eax, %eax
movl %eax, %ecx
callq 0x63f0
movq %rax, -0x88(%rbp)
cmpq $0x0, %rax
jne 0xfdd4
callq 0x6690
movq -0x88(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, 0x88(%rax)
jne 0xfe3e
movq -0x80(%rbp), %rcx
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl 0x58(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0xfe39
leaq -0x30(%rbp), %rdi
movl $0x1, %esi
callq 0x10940
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
leaq -0x30(%rbp), %rsi
callq 0x102c0
leaq -0x30(%rbp), %rdi
callq 0x10300
movq -0x80(%rbp), %rdi
addq $0x8, %rdi
callq 0x25430
jmp 0xffaa
movq -0x80(%rbp), %rcx
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl 0x58(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xff70
movq -0x80(%rbp), %rdi
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x60(%rdi)
movq -0x20(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x64(%rdi)
movq -0x20(%rbp), %rsi
addq $0x18, %rsi
addq $0x68, %rdi
callq 0x10070
movq -0x80(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0xd190
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
callq 0xd1c0
movq %rax, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0xd1f0
testb $0x1, %al
jne 0xfebc
jmp 0xff6e
leaq -0x40(%rbp), %rdi
callq 0xd230
movq %rax, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rdi
addq $0x68, %rdi
callq 0xd020
movq %rax, %rcx
movq -0x90(%rbp), %rax
cmpq %rcx, %rax
jae 0xff5e
movq -0x50(%rbp), %rax
movq (%rax), %rdi
addq $0x68, %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
callq 0xd040
movq (%rax), %rdi
addq $0x58, %rdi
movq -0x18(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x5c(%rbp)
movq -0x5c(%rbp), %rsi
callq 0x1a4f0
testb $0x1, %al
jne 0xff30
jmp 0xff4e
movq -0x50(%rbp), %rax
movq (%rax), %rdi
addq $0x68, %rdi
movl -0x54(%rbp), %eax
movl %eax, %esi
callq 0xd040
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
jmp 0xff5e
jmp 0xff50
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0xfed0
jmp 0xff60
leaq -0x40(%rbp), %rdi
callq 0xd2d0
jmp 0xfea6
jmp 0xffa8
leaq -0x70(%rbp), %rdi
movl $0x1, %esi
callq 0x10940
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
leaq -0x70(%rbp), %rsi
callq 0x102c0
leaq -0x70(%rbp), %rdi
callq 0x10300
movq -0x80(%rbp), %rdi
addq $0x8, %rdi
callq 0x25430
jmp 0xffaa
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)