// File: havluj[P]spreadsheet/src/CTable.cpp
// Function: CTable::updateElement(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void CTable::updateElement(int row, int col, std::string value) {
    std::set<std::pair<int, int>> affectedBy;

    auto it = m_database.find(std::make_pair(row, col));
    if (it == m_database.end()) {
	  CCell* newCell;
	  if (value.length() > 0 && value.at(0) == '=') {
		newCell = new CEquation(this);
	  } else {
		newCell = new CText();
	  }
	  newCell->setId(m_idCounter++);
	  m_database.insert(std::make_pair(std::make_pair(row, col), newCell));
	  affectedBy = newCell->update(value);
    } else {
	  delete it->second;

	  CCell* newCell;
	  if (value.length() > 0 && value.at(0) == '=') {
		newCell = new CEquation(this);
	  } else {
		newCell = new CText();
	  }
	  newCell->setId(m_idCounter++);
	  m_database[std::make_pair(row, col)] = newCell;
	  affectedBy = newCell->update(value);
    }

    // create the affecting relationships
    if (affectedBy.size() > 0) {
	  for (auto i = affectedBy.begin(); i != affectedBy.end(); ++i) {
		auto relIt = m_relationships.find(*i);
		if (relIt == m_relationships.end()) {
		    /* create new entry */
		    std::set<std::pair<int, int>> tmp;
		    tmp.insert(std::make_pair(row, col));
		    m_relationships.insert(std::make_pair(std::make_pair(i->first, i->second), tmp));
		} else {
		    /* expand the set */
		    relIt->second.insert(std::make_pair(row, col));
		}
	  }
    }

    auto recalcIt = m_relationships.find(std::make_pair(row, col));
    if (recalcIt != m_relationships.end()) {
	  for (auto i = recalcIt->second.begin(); i != recalcIt->second.end(); ++i) {
		reCompute((*i).first, (*i).second);
	  }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3b0, %rsp            # imm = 0x3B0
movq %rcx, -0x268(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x260(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7960
movq -0x260(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x258(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x250(%rbp)
jmp 0x83dc
movq -0x258(%rbp), %rdi
movq -0x250(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x91d0
movq %rax, -0x270(%rbp)
jmp 0x8400
movq -0x260(%rbp), %rdi
movq -0x270(%rbp), %rax
movq %rax, -0x50(%rbp)
addq $0x38, %rdi
callq 0x9110
movq %rax, -0x70(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x9230
testb $0x1, %al
jne 0x8435
jmp 0x867f
movq -0x268(%rbp), %rdi
callq 0x5620
cmpq $0x0, %rax
jbe 0x84de
movq -0x268(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5800
movq %rax, -0x278(%rbp)
jmp 0x8464
movq -0x278(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x84de
movl $0xb8, %edi
callq 0x5420
movq %rax, -0x280(%rbp)
jmp 0x8486
movq -0x260(%rbp), %rsi
movq -0x280(%rbp), %rdi
callq 0xd1b0
jmp 0x849b
movq -0x280(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x852e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x8cca
movq -0x280(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xb8, %esi
callq 0x5430
jmp 0x8cca
movl $0x30, %edi
callq 0x5420
movq %rax, -0x288(%rbp)
jmp 0x84f1
movq -0x288(%rbp), %rdi
callq 0xd040
jmp 0x84ff
movq -0x288(%rbp), %rax
movq %rax, -0x78(%rbp)
jmp 0x852e
movq -0x288(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x30, %esi
callq 0x5430
jmp 0x8cca
movq -0x260(%rbp), %rax
movq -0x78(%rbp), %rdi
movl 0x68(%rax), %esi
movl %esi, %ecx
incl %ecx
movl %ecx, 0x68(%rax)
callq 0x7940
jmp 0x854a
movq -0x260(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x298(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x290(%rbp)
jmp 0x8572
movq -0x290(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x90(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x92a0
movq %rdx, -0x2a8(%rbp)
movq %rax, -0x2a0(%rbp)
jmp 0x85a0
movq -0x298(%rbp), %rdi
movq -0x2a8(%rbp), %rax
movq -0x2a0(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq %rax, -0x80(%rbp)
leaq -0x88(%rbp), %rsi
callq 0x9260
movb %dl, -0x2b1(%rbp)
movq %rax, -0x2b0(%rbp)
jmp 0x85db
movq -0x268(%rbp), %rsi
movb -0x2b1(%rbp), %al
movq -0x2b0(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
movb %al, -0x98(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x51b0
jmp 0x8615
movq -0x2c0(%rbp), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0xd0(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq *%rax
jmp 0x8635
leaq -0x48(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x92d0
leaq -0xd0(%rbp), %rdi
callq 0x7980
leaq -0xf0(%rbp), %rdi
callq 0x52a0
jmp 0x88ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x52a0
jmp 0x8cca
leaq -0x50(%rbp), %rdi
callq 0x9140
movq 0x8(%rax), %rax
movq %rax, -0x2c8(%rbp)
cmpq $0x0, %rax
je 0x86a6
movq -0x2c8(%rbp), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x268(%rbp), %rdi
callq 0x5620
cmpq $0x0, %rax
jbe 0x873e
movq -0x268(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5800
movq %rax, -0x2d0(%rbp)
jmp 0x86d5
movq -0x2d0(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3d, %eax
jne 0x873e
movl $0xb8, %edi
callq 0x5420
movq %rax, -0x2d8(%rbp)
jmp 0x86f7
movq -0x260(%rbp), %rsi
movq -0x2d8(%rbp), %rdi
callq 0xd1b0
jmp 0x870c
movq -0x2d8(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x8791
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0xb8, %esi
callq 0x5430
jmp 0x8cca
movl $0x30, %edi
callq 0x5420
movq %rax, -0x2e0(%rbp)
jmp 0x8751
movq -0x2e0(%rbp), %rdi
callq 0xd040
jmp 0x875f
movq -0x2e0(%rbp), %rax
movq %rax, -0xf8(%rbp)
jmp 0x8791
movq -0x2e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
movl $0x30, %esi
callq 0x5430
jmp 0x8cca
movq -0x260(%rbp), %rax
movq -0xf8(%rbp), %rdi
movl 0x68(%rax), %esi
movl %esi, %ecx
incl %ecx
movl %ecx, 0x68(%rax)
callq 0x7940
jmp 0x87b0
movq -0x260(%rbp), %rax
movq -0xf8(%rbp), %rcx
movq %rcx, -0x2f8(%rbp)
addq $0x38, %rax
movq %rax, -0x2f0(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x2e8(%rbp)
jmp 0x87e6
movq -0x2f0(%rbp), %rdi
movq -0x2e8(%rbp), %rax
movq %rax, -0x100(%rbp)
leaq -0x100(%rbp), %rsi
callq 0x9300
movq %rax, -0x300(%rbp)
jmp 0x8810
movq -0x268(%rbp), %rsi
movq -0x300(%rbp), %rax
movq -0x2f8(%rbp), %rcx
movq %rcx, (%rax)
movq -0xf8(%rbp), %rax
movq %rax, -0x308(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x51b0
jmp 0x8844
movq -0x308(%rbp), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rdx
callq *%rax
jmp 0x8864
leaq -0x48(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x92d0
leaq -0x130(%rbp), %rdi
callq 0x7980
leaq -0x150(%rbp), %rdi
callq 0x52a0
jmp 0x88ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x52a0
jmp 0x8cca
leaq -0x48(%rbp), %rdi
callq 0x93e0
cmpq $0x0, %rax
jbe 0x8b77
leaq -0x48(%rbp), %rdi
callq 0x9400
movq %rax, -0x158(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x9460
movq %rax, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x9430
testb $0x1, %al
jne 0x88fa
jmp 0x8b75
movq -0x260(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x318(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x94c0
movq -0x318(%rbp), %rdi
movq %rax, %rsi
callq 0x9490
movq %rax, -0x310(%rbp)
jmp 0x8930
movq -0x260(%rbp), %rdi
movq -0x310(%rbp), %rax
movq %rax, -0x168(%rbp)
addq $0x8, %rdi
callq 0x9520
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x94f0
testb $0x1, %al
jne 0x8971
jmp 0x8aeb
leaq -0x1a0(%rbp), %rdi
callq 0x7960
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x320(%rbp)
jmp 0x8993
movq -0x320(%rbp), %rax
movq %rax, -0x1a8(%rbp)
leaq -0x1a0(%rbp), %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x9550
movb %dl, -0x329(%rbp)
movq %rax, -0x328(%rbp)
jmp 0x89c3
movq -0x260(%rbp), %rax
movb -0x329(%rbp), %cl
movq -0x328(%rbp), %rdx
movq %rdx, -0x1b8(%rbp)
movb %cl, -0x1b0(%rbp)
addq $0x8, %rax
movq %rax, -0x350(%rbp)
leaq -0x158(%rbp), %rdi
movq %rdi, -0x348(%rbp)
callq 0x9650
movq -0x348(%rbp), %rdi
movq %rax, -0x340(%rbp)
callq 0x9650
movq -0x340(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
callq 0x9620
movq %rax, -0x338(%rbp)
jmp 0x8a31
movq -0x338(%rbp), %rax
movq %rax, -0x1f8(%rbp)
leaq -0x1f0(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
leaq -0x1a0(%rbp), %rdx
callq 0x95e0
jmp 0x8a5b
movq -0x350(%rbp), %rdi
leaq -0x1f0(%rbp), %rsi
callq 0x95a0
movb %dl, -0x359(%rbp)
movq %rax, -0x358(%rbp)
jmp 0x8a7d
movb -0x359(%rbp), %al
movq -0x358(%rbp), %rcx
movq %rcx, -0x208(%rbp)
movb %al, -0x200(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x9670
leaq -0x1a0(%rbp), %rdi
callq 0x7980
jmp 0x8b62
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x8ada
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x9670
leaq -0x1a0(%rbp), %rdi
callq 0x7980
jmp 0x8cca
leaq -0x168(%rbp), %rdi
callq 0x9690
addq $0x8, %rax
movq %rax, -0x370(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x368(%rbp)
jmp 0x8b18
movq -0x370(%rbp), %rdi
movq -0x368(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x210(%rbp), %rsi
callq 0x9550
movb %dl, -0x379(%rbp)
movq %rax, -0x378(%rbp)
jmp 0x8b48
movb -0x379(%rbp), %al
movq -0x378(%rbp), %rcx
movq %rcx, -0x220(%rbp)
movb %al, -0x218(%rbp)
jmp 0x8b64
leaq -0x158(%rbp), %rdi
callq 0x96b0
jmp 0x88ce
jmp 0x8b77
movq -0x260(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x390(%rbp)
leaq -0xc(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x9200
movq %rax, -0x388(%rbp)
jmp 0x8b9f
movq -0x390(%rbp), %rdi
movq -0x388(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x230(%rbp), %rsi
callq 0x9490
movq %rax, -0x398(%rbp)
jmp 0x8bc9
movq -0x260(%rbp), %rdi
movq -0x398(%rbp), %rax
movq %rax, -0x228(%rbp)
addq $0x8, %rdi
callq 0x9520
movq %rax, -0x238(%rbp)
leaq -0x228(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x96e0
testb $0x1, %al
jne 0x8c0a
jmp 0x8cb8
leaq -0x228(%rbp), %rdi
callq 0x9690
movq %rax, %rdi
addq $0x8, %rdi
callq 0x9400
movq %rax, -0x240(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x9690
movq %rax, %rdi
addq $0x8, %rdi
callq 0x9460
movq %rax, -0x248(%rbp)
leaq -0x240(%rbp), %rdi
leaq -0x248(%rbp), %rsi
callq 0x9430
testb $0x1, %al
jne 0x8c61
jmp 0x8cb6
leaq -0x240(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x94c0
movq -0x3a8(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x39c(%rbp)
callq 0x94c0
movq -0x260(%rbp), %rdi
movl -0x39c(%rbp), %esi
movl 0x4(%rax), %edx
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0x8ca3
jmp 0x8ca5
leaq -0x240(%rbp), %rdi
callq 0x96b0
jmp 0x8c29
jmp 0x8cb8
leaq -0x48(%rbp), %rdi
callq 0x7980
addq $0x3b0, %rsp            # imm = 0x3B0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x7980
movq -0x60(%rbp), %rdi
callq 0x5730
nopl (%rax)