// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rcx, %r14
leaq 0x80(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %rdi, %rbx
leaq 0x38(%rdi), %r15
shlq $0x20, %rdx
movl %esi, %eax
orq %rdx, %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsp)
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x60ae
leaq 0x40(%rbx), %rcx
cmpq %rcx, %rax
movq %rbx, 0x8(%rsp)
je 0x589b
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x57e2
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, 0x8(%r14)
je 0x5812
movq %r14, %rdi
xorl %esi, %esi
callq 0x4620
cmpb $0x3d, (%rax)
jne 0x5812
movl $0xb8, %edi
callq 0x4310
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6978
jmp 0x5825
pushq $0x30
popq %rdi
callq 0x4310
movq %rax, %r12
movq %rax, %rdi
callq 0x68ec
movl 0x68(%rbx), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x68(%rbx)
movq %r12, %rdi
callq 0x535a
leaq 0x10(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x5ce6
movq %r12, (%rax)
leaq 0xa8(%rsp), %rdi
movq %r14, %rsi
callq 0x4440
movq (%r12), %rax
leaq 0x10(%rsp), %rdi
leaq 0xa8(%rsp), %rdx
movq %r12, %rsi
callq *0x10(%rax)
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x5e08
movq %r14, %rdi
callq 0x536a
leaq 0xa8(%rsp), %rdi
jmp 0x5950
cmpq $0x0, 0x8(%r14)
je 0x58cb
movq %r14, %rdi
xorl %esi, %esi
callq 0x4620
cmpb $0x3d, (%rax)
jne 0x58cb
movl $0xb8, %edi
callq 0x4310
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6978
jmp 0x58de
pushq $0x30
popq %rdi
callq 0x4310
movq %rax, %r12
movq %rax, %rdi
callq 0x68ec
movl 0x68(%rbx), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x68(%rbx)
movq %r12, %rdi
callq 0x535a
leaq 0x10(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
movq %r12, 0x8(%rsi)
movq %r15, %rdi
callq 0x613e
leaq 0xc8(%rsp), %rdi
movq %r14, %rsi
callq 0x4440
movq (%r12), %rax
leaq 0x10(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
movq %r12, %rsi
callq *0x10(%rax)
leaq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %r14
movq %r14, %rsi
callq 0x5e08
movq %r14, %rdi
callq 0x536a
leaq 0xc8(%rsp), %rdi
callq 0x4150
cmpq $0x0, 0xa0(%rsp)
je 0x5a39
movq 0x90(%rsp), %r12
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %r15
leaq 0x10(%rax), %r13
leaq 0x48(%rsp), %rbx
leaq 0x10(%rsp), %rbp
leaq 0x80(%rsp), %rax
cmpq %rax, %r12
je 0x5a39
leaq 0x20(%r12), %r14
movq %r15, %rdi
movq %r14, %rsi
callq 0x64b0
cmpq %r13, %rax
je 0x59c3
addq $0x28, %rax
movq (%rsp), %rcx
movq %rcx, 0x10(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x6526
jmp 0x5a29
andl $0x0, 0x50(%rsp)
andq $0x0, 0x58(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movq (%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x6526
movq (%r14), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x5eb8
movq %r15, %rdi
movq %rbp, %rsi
callq 0x6672
leaq 0x18(%rsp), %rdi
callq 0x536a
movq %rbx, %rdi
callq 0x536a
movq %r12, %rdi
callq 0x4380
movq %rax, %r12
jmp 0x5983
movq 0x8(%rsp), %rbx
leaq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
callq 0x64b0
movq %rax, %r14
leaq 0x10(%rbx), %rax
cmpq %rax, %r14
je 0x5a8a
movq 0x40(%r14), %r15
addq $0x30, %r14
cmpq %r14, %r15
je 0x5a8a
movl 0x20(%r15), %esi
movl 0x24(%r15), %edx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r15, %rdi
callq 0x4380
movq %rax, %r15
jmp 0x5a67
leaq 0x78(%rsp), %rdi
callq 0x536a
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5aa8
movq %rax, %rbx
movl $0xb8, %esi
jmp 0x5acb
jmp 0x5ac5
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x5ae0
jmp 0x5b17
jmp 0x5b17
movq %rax, %rbx
pushq $0x30
popq %rsi
movq %r12, %rdi
callq 0x4320
jmp 0x5b1a
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x4150
jmp 0x5b1a
jmp 0x5b17
jmp 0x5b17
jmp 0x5b17
jmp 0x5b17
jmp 0x5b17
jmp 0x5b17
jmp 0x5af5
movq %rax, %rbx
jmp 0x5b07
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x536a
leaq 0x48(%rsp), %rdi
callq 0x536a
jmp 0x5b1a
jmp 0x5b17
jmp 0x5b17
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x536a
movq %rbx, %rdi
callq 0x4590