// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rdi, %rbx
leaq 0x10(%rsp), %rcx
movl $0x0, (%rcx)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x38(%rdi), %r15
shlq $0x20, %rdx
movl %esi, %eax
orq %rdx, %rax
leaq 0x40(%rsp), %rsi
movq %rax, (%rsp)
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x61b4
leaq 0x40(%rbx), %rcx
cmpq %rcx, %rax
movq %rbx, 0x38(%rsp)
je 0x597c
movq 0x28(%rax), %rdi
testq %rdi, %rdi
je 0x586c
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, 0x8(%r14)
je 0x5895
movq (%r14), %rax
cmpb $0x3d, (%rax)
jne 0x5895
movl $0xb8, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x69b0
jmp 0x58aa
movl $0x30, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
callq 0x6924
movl 0x68(%rbx), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x68(%rbx)
movq %r12, %rdi
callq 0x5310
leaq 0x40(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
movq %r15, %rdi
callq 0x5ebc
movq %r12, (%rax)
leaq 0x88(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x5370
movq (%r12), %rax
leaq 0x40(%rsp), %rdi
leaq 0x78(%rsp), %rdx
movq %r12, %rsi
callq *0x10(%rax)
leaq 0x8(%rsp), %rdi
callq 0x5fee
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x5957
leaq 0x48(%rsp), %rcx
movl (%rcx), %edx
movl %edx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movups 0x10(%rcx), %xmm0
movups %xmm0, 0x20(%rsp)
leaq 0x10(%rsp), %rdx
movq %rdx, 0x8(%rax)
movq 0x20(%rcx), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x40(%rsp), %rdi
callq 0x5320
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x5a95
movq 0x88(%rsp), %rsi
jmp 0x5a8d
cmpq $0x0, 0x8(%r14)
je 0x59a5
movq (%r14), %rax
cmpb $0x3d, (%rax)
jne 0x59a5
movl $0xb8, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
callq 0x69b0
jmp 0x59ba
movl $0x30, %edi
callq 0x42c0
movq %rax, %r12
movq %rax, %rdi
callq 0x6924
movl 0x68(%rbx), %esi
leal 0x1(%rsi), %eax
movl %eax, 0x68(%rbx)
movq %r12, %rdi
callq 0x5310
leaq 0x40(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
movq %r12, 0x8(%rsi)
movq %r15, %rdi
callq 0x6212
leaq 0xa8(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x98(%rsp), %rdi
callq 0x5370
movq (%r12), %rax
leaq 0x40(%rsp), %rdi
leaq 0x98(%rsp), %rdx
movq %r12, %rsi
callq *0x10(%rax)
leaq 0x8(%rsp), %rdi
callq 0x5fee
movq 0x50(%rsp), %rax
testq %rax, %rax
je 0x5a6e
leaq 0x48(%rsp), %rcx
movl (%rcx), %edx
movl %edx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movups 0x10(%rcx), %xmm0
movups %xmm0, 0x20(%rsp)
leaq 0x10(%rsp), %rdx
movq %rdx, 0x8(%rax)
movq 0x20(%rcx), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
leaq 0x40(%rsp), %rdi
callq 0x5320
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x5a95
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x42d0
cmpq $0x0, 0x30(%rsp)
je 0x5b90
movq 0x20(%rsp), %r15
leaq 0x10(%rsp), %rax
cmpq %rax, %r15
je 0x5b90
movq 0x38(%rsp), %rax
leaq 0x8(%rax), %r12
leaq 0x10(%rax), %rbx
leaq 0xb8(%rsp), %r13
leaq 0x40(%rsp), %rbp
leaq 0x20(%r15), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x652e
cmpq %rbx, %rax
je 0x5afc
addq $0x28, %rax
movq (%rsp), %rcx
movq %rcx, 0x40(%rsp)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x658c
jmp 0x5b77
movl $0x0, 0xc0(%rsp)
xorl %ecx, %ecx
movq %rcx, 0xc8(%rsp)
leaq 0xc0(%rsp), %rax
movq %rax, 0xd0(%rsp)
movq %rax, 0xd8(%rsp)
movq %rcx, 0xe0(%rsp)
movq (%rsp), %rax
movq %rax, 0x40(%rsp)
movq %r13, %rdi
movq %rbp, %rsi
callq 0x658c
movq (%r14), %rax
movq %rax, 0x40(%rsp)
leaq 0x48(%rsp), %rdi
movq %r13, %rsi
callq 0x601c
movq %r12, %rdi
movq %rbp, %rsi
callq 0x66cc
leaq 0x48(%rsp), %rdi
callq 0x5320
movq %r13, %rdi
callq 0x5320
movq %r15, %rdi
callq 0x4350
movq %rax, %r15
leaq 0x10(%rsp), %rax
cmpq %rax, %r15
jne 0x5ace
movq 0x38(%rsp), %rbx
leaq 0x8(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq (%rsp), %rax
movq %rax, (%rsi)
callq 0x652e
movq %rax, %r14
leaq 0x10(%rbx), %rax
cmpq %rax, %r14
je 0x5be4
movq 0x40(%r14), %r15
addq $0x30, %r14
cmpq %r14, %r15
je 0x5be4
movl 0x20(%r15), %esi
movl 0x24(%r15), %edx
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r15, %rdi
callq 0x4350
movq %rax, %r15
cmpq %r14, %rax
jne 0x5bc3
leaq 0x8(%rsp), %rdi
callq 0x5320
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5c02
movq %rax, %rbx
movl $0xb8, %esi
jmp 0x5c34
jmp 0x5c2c
movq %rax, %rbx
movq 0x98(%rsp), %rdi
cmpq %r15, %rdi
je 0x5c8e
movq 0xa8(%rsp), %rsi
jmp 0x5c4e
jmp 0x5c8b
jmp 0x5c8b
movq %rax, %rbx
movl $0x30, %esi
movq %r12, %rdi
jmp 0x5c51
movq %rax, %rbx
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x5c8e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x5c8e
jmp 0x5c8b
jmp 0x5c8b
jmp 0x5c8b
jmp 0x5c8b
jmp 0x5c8b
jmp 0x5c8b
jmp 0x5c75
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x5320
jmp 0x5c78
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x5320
jmp 0x5c8e
jmp 0x5c8b
jmp 0x5c8b
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5320
movq %rbx, %rdi
callq 0x45a0