// File: /workspace/github_cpp_makefile_star2_O1/havluj[P]spreadsheet/src/CEquation.cpp
// Function: CEquation::replaceOtherCells(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
std::string CEquation::replaceOtherCells(std::string exp) {
    // erase all the spaces
    exp.erase(std::remove(exp.begin(), exp.end(), ' '), exp.end());
    m_expression = exp; 
    // replace = with a space
    exp.replace(exp.find("="), 1, " "); 
    // erase all the spaces
    exp.erase(std::remove(exp.begin(), exp.end(), ' '), exp.end());
    

    /* make everything upper case */
    exp = UpperCase(exp);

    /* PARSING CELL FUNCTION */
    std::string phraze = "CELL"; // substring we are looking for
    std::string subExp;
    size_t pos = exp.find(phraze, 0);
    while (pos != std::string::npos) {
	  size_t endingParentheses = exp.find(")", pos);
	  subExp = exp.substr(pos + 4, endingParentheses - pos + 1);
	  std::stringstream stream;
	  stream << subExp;
	  char ch;
	  stream >> ch;
	  if (ch != '(') {
		m_error = true;
		m_errorMsg = "ERR: wrong CELL format";
		return exp;
	  }
	  int row = 0, col = 0;
	  stream >> row;
	  stream >> ch;
	  if (ch != ',') {
		m_error = true;
		m_errorMsg = "ERR: wrong CELL format";
		return exp;
	  }
	  stream >> col;

	  stream >> ch;
	  if (ch != ')') {
		m_error = true;
		m_errorMsg = "ERR: wrong CELL format";
		return exp;
	  }

	  if (col == 0 || row == 0) {
		m_error = true;
		m_errorMsg = "ERR: wrong CELL format";
		return exp;
	  }

	  m_affectedBy.insert(std::make_pair(row, col));

	  //replace the cell
	  double val = 0;
	  CCell* cell = NULL;
	  try {
		cell = m_database->getCell(row, col);
		if (cell->getId() == m_id) {
		    m_error = true;
		    m_errorMsg = "ERR: trying to get value of itself in CELL function";
		    return exp;
		} else {
		    val = cell->getValue();
		}
	  } catch (std::logic_error e) {
		m_error = true;
		m_errorMsg = "ERR: trying to compute with string or empty cell";
		return exp;
	  }

	  exp.replace(pos, endingParentheses - pos + 1, std::to_string(val));

	  pos = exp.find(phraze, pos + 1);
    }


    /* PARSING SUM FUNCTION */
    phraze = "SUM"; // substring we are looking for
    pos = exp.find(phraze, 0);
    while (pos != std::string::npos) {
	  size_t endingParentheses = exp.find(")", pos);
	  subExp = exp.substr(pos + 3, endingParentheses - pos + 1);
	  std::stringstream stream;
	  stream << subExp;
	  char ch;
	  stream >> ch;
	  if (ch != '(') {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }
	  int rowBegin = 0, colBegin = 0, rowEnd = 0, colEnd = 0;
	  stream >> rowBegin;
	  stream >> ch;
	  if (ch != ',') {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }
	  stream >> colBegin;

	  stream >> ch;
	  if (ch != ':') {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }
	  stream >> rowEnd;
	  stream >> ch;
	  if (ch != ',') {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }
	  stream >> colEnd;

	  stream >> ch;
	  if (ch != ')') {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }

	  if (colBegin == 0 || rowBegin == 0 || rowEnd == 0 || colEnd == 0) {
		m_error = true;
		m_errorMsg = "ERR: wrong SUM format";
		return exp;
	  }

	  if (rowBegin > rowEnd) {
		int tmp = rowEnd;
		rowEnd = rowBegin;
		rowBegin = tmp;
	  }

	  if (colBegin > colEnd) {
		int tmp = colEnd;
		colEnd = colBegin;
		colBegin = tmp;
	  }

	  double val = 0;
	  for (int i = rowBegin; i <= rowEnd; i++) {
		for (int j = colBegin; j <= colEnd; j++) {
		    m_affectedBy.insert(std::make_pair(i, j));

		    //replace the cell
		    CCell* cell = NULL;
		    try {
			  cell = m_database->getCell(i, j);
			  if (cell->getId() == m_id) {
				m_error = true;
				m_errorMsg = "ERR: trying to get value of itself in SUM function";
			  } else {
				val += cell->getValue();
			  }
		    } catch (std::logic_error e) {
			  m_error = true;
			  m_errorMsg = "ERR: trying to compute with string or empty cell";
		    }
		}
	  }
	  if (m_error) {
		return exp;
	  }

	  exp.replace(pos, endingParentheses - pos + 1, std::to_string(val));

	  pos = exp.find(phraze, pos + 1);
    }


    /* PARSING SUM FUNCTION */
    phraze = "AVG"; // substring we are looking for
    pos = exp.find(phraze, 0);
    while (pos != std::string::npos) {
	  size_t endingParentheses = exp.find(")", pos);
	  subExp = exp.substr(pos + 3, endingParentheses - pos + 1);
	  std::stringstream stream;
	  stream << subExp;
	  char ch;
	  stream >> ch;
	  if (ch != '(') {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }
	  int rowBegin = 0, colBegin = 0, rowEnd = 0, colEnd = 0;
	  stream >> rowBegin;
	  stream >> ch;
	  if (ch != ',') {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }
	  stream >> colBegin;

	  stream >> ch;
	  if (ch != ':') {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }
	  stream >> rowEnd;
	  stream >> ch;
	  if (ch != ',') {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }
	  stream >> colEnd;

	  stream >> ch;
	  if (ch != ')') {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }

	  if (colBegin == 0 || rowBegin == 0 || rowEnd == 0 || colEnd == 0) {
		m_error = true;
		m_errorMsg = "ERR: wrong AVG format";
		return exp;
	  }

	  if (rowBegin > rowEnd) {
		int tmp = rowEnd;
		rowEnd = rowBegin;
		rowBegin = tmp;
	  }

	  if (colBegin > colEnd) {
		int tmp = colEnd;
		colEnd = colBegin;
		colBegin = tmp;
	  }

	  double val = 0;
	  for (int i = rowBegin; i <= rowEnd; i++) {
		for (int j = colBegin; j <= colEnd; j++) {
		    m_affectedBy.insert(std::make_pair(i, j));

		    //replace the cell
		    CCell* cell = NULL;
		    try {
			  cell = m_database->getCell(i, j);
			  if (cell->getId() == m_id) {
				m_error = true;
				m_errorMsg = "ERR: trying to get value of itself in AVG function";
			  } else {
				val += cell->getValue();
			  }
		    } catch (std::logic_error e) {
			  m_error = true;
			  m_errorMsg = "ERR: trying to compute with string or empty cell";
		    }
		}
	  }
	  if (m_error) {
		return exp;
	  }
	  int rowCnt = rowEnd - rowBegin + 1;
	  int colCnt = colEnd - colBegin + 1;

	  exp.replace(pos, endingParentheses - pos + 1, std::to_string(val / (rowCnt * colCnt)));

	  pos = exp.find(phraze, pos + 1);
    }

    return exp;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x268, %rsp            # imm = 0x268
movq %rdx, %r14
movq %rsi, %r13
movq %rdi, %r12
movq (%rdx), %rdi
movq 0x8(%rdx), %rsi
addq %rdi, %rsi
movb $0x20, %bpl
leaq 0xc0(%rsp), %rbx
movb %bpl, (%rbx)
movq %rbx, %rdx
callq 0x854a
movq %rax, %rcx
subq (%r14), %rcx
movq %rcx, 0x8(%r14)
xorl %r15d, %r15d
movb %r15b, (%rax)
movq %r13, 0x30(%rsp)
leaq 0x8(%r13), %rdi
movq %r14, %rsi
callq 0x4190
leaq 0x7466(%rip), %rsi      # 0xe4b6
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4580
leaq 0x781d(%rip), %rcx      # 0xe883
movl $0x1, %edx
movl $0x1, %r8d
movq %r14, %rdi
movq %rax, %rsi
callq 0x4320
movq (%r14), %rdi
movq 0x8(%r14), %rsi
addq %rdi, %rsi
movb %bpl, (%rbx)
leaq 0xc0(%rsp), %rdx
callq 0x854a
movq %rax, %rcx
subq (%r14), %rcx
movq %rcx, 0x8(%r14)
movb %r15b, (%rax)
movq (%r14), %rsi
leaq 0x258(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x248(%rsp), %rbx
movq %rbx, %rdi
callq 0x5370
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0xa4c2
leaq 0xc0(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4380
movq (%rbx), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x710c
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x248(%rsp), %rdi
cmpq %r15, %rdi
movq 0x30(%rsp), %rbx
je 0x712e
movq 0x258(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %r12, 0x38(%rsp)
leaq 0x80(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x7372(%rip), %rsi      # 0xe4b8
leaq 0x736f(%rip), %rdx      # 0xe4bc
leaq 0x70(%rsp), %rdi
callq 0x84ba
leaq 0xa0(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4580
movq %rax, %r13
leaq 0x60(%rbx), %rax
movq %rax, 0x20(%rsp)
movq 0x38(%rsp), %rax
addq $0x10, %rax
movq %rax, 0x18(%rsp)
leaq 0x10(%r14), %rax
movq %rax, 0x40(%rsp)
leaq 0x88(%rbx), %rax
movq %rax, 0xb0(%rsp)
leaq 0xc0(%rsp), %rbp
cmpq $-0x1, %r13
je 0x7596
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x777f(%rip), %rsi      # 0xe954
movq %r13, %rdx
callq 0x4580
movq %rax, %r12
leaq 0x4(%r13), %rdx
subq %r13, %r12
incq %r12
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x42e0
leaq 0x90(%rsp), %rdi
movq %rbp, %rsi
callq 0x4380
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x722d
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbp, %rdi
callq 0x41f0
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
callq 0x4330
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x43e0
cmpb $0x28, 0x8(%rsp)
jne 0x7307
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movq %rbp, %rdi
leaq 0x10(%rsp), %rsi
callq 0x41b0
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x43e0
cmpb $0x2c, 0x8(%rsp)
jne 0x732f
movq %rbp, %rdi
leaq 0xc(%rsp), %rsi
callq 0x41b0
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x43e0
cmpb $0x29, 0x8(%rsp)
jne 0x7357
movl 0xc(%rsp), %eax
testq %rax, %rax
sete %dl
movl 0x10(%rsp), %ecx
testl %ecx, %ecx
sete %sil
orb %dl, %sil
cmpb $0x1, %sil
jne 0x73ee
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x68(%rax), %rdx
movl $0x16, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x71bd(%rip), %rcx      # 0xe4bd
callq 0x44a0
jmp 0x737d
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x68(%rax), %rdx
movl $0x16, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x7195(%rip), %rcx      # 0xe4bd
callq 0x44a0
jmp 0x737d
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x68(%rax), %rdx
movl $0x16, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x716d(%rip), %rcx      # 0xe4bd
callq 0x44a0
jmp 0x737d
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x68(%rax), %rdx
movl $0x16, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x7145(%rip), %rcx      # 0xe4bd
callq 0x44a0
movq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq %rsi, (%rcx)
movq (%r14), %rax
movq 0x40(%rsp), %rdx
cmpq %rdx, %rax
je 0x73a3
movq %rax, (%rcx)
movq (%rdx), %rax
movq %rax, 0x10(%rcx)
jmp 0x73ab
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rcx)
movq %rdx, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
xorl %ebx, %ebx
movq %rbp, %rdi
movq 0xbbb1(%rip), %rsi      # 0x12f80
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
testb %bl, %bl
jne 0x71bc
jmp 0x8146
movl %ecx, %ecx
shlq $0x20, %rax
orq %rcx, %rax
movq %rax, 0x48(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x65ae
movq 0x30(%rsp), %rax
movq 0x38(%rax), %rdi
movl 0x10(%rsp), %esi
movl 0xc(%rsp), %edx
movq (%rdi), %rax
callq *0x30(%rax)
movq %rax, %rbx
movq %rax, %rdi
callq 0x530c
movq 0x30(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x7460
movb $0x1, 0x58(%rcx)
movq 0x68(%rcx), %rdx
movl $0x33, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x707e(%rip), %rcx      # 0xe4d4
callq 0x44a0
jmp 0x737d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
movl $0x148, %edx            # imm = 0x148
leaq 0x48(%rsp), %rdi
movq 0xbb16(%rip), %rsi      # 0x12f90
leaq 0x7199(%rip), %rcx      # 0xe61a
movb $0x1, %al
callq 0x8409
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4320
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x74bc
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
incq %r13
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x4580
movq %rax, %r13
movb $0x1, %bl
jmp 0x73c5
movq %rax, %rbx
cmpl $0x1, %edx
jne 0x8318
movq %rbx, %rdi
callq 0x43a0
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x45e0
movq %rbx, %rdi
callq 0x4110
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x20(%rsp), %rdi
leaq 0x6fec(%rip), %rsi      # 0xe508
callq 0x4400
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq (%r14), %rax
cmpq 0x40(%rsp), %rax
je 0x754e
movq 0x38(%rsp), %rcx
movq %rax, (%rcx)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x10(%rcx)
jmp 0x7560
movq 0x40(%rsp), %rax
movupd (%rax), %xmm0
movq 0x18(%rsp), %rax
movupd %xmm0, (%rax)
movq 0x8(%r14), %rax
movq 0x38(%rsp), %rcx
movq %rax, 0x8(%rcx)
movq 0x40(%rsp), %rax
movq %rax, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
leaq 0x48(%rsp), %rdi
callq 0x4648
callq 0x4510
jmp 0x73c3
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x6f93(%rip), %rcx      # 0xe539
movl $0x3, %r8d
xorl %esi, %esi
callq 0x44a0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4580
movq %rax, %r13
leaq 0xc0(%rsp), %rbp
cmpq $-0x1, %r13
je 0x7b41
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x7369(%rip), %rsi      # 0xe954
movq %r13, %rdx
callq 0x4580
movq %rax, %r12
leaq 0x3(%r13), %rdx
movq %r13, 0x28(%rsp)
subq %r13, %r12
incq %r12
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x42e0
movq 0x38(%rsp), %rbx
movq %rbp, %rsi
movq 0x30(%rsp), %rbp
movq 0x40(%rsp), %r13
leaq 0x90(%rsp), %rdi
callq 0x4380
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0x7657
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xc0(%rsp), %rdi
callq 0x41f0
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
callq 0x4330
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x28, 0x7(%rsp)
jne 0x77cc
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movl %eax, 0x14(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x2c, 0x7(%rsp)
jne 0x77f2
leaq 0xc0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x3a, 0x7(%rsp)
jne 0x7815
leaq 0xc0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x2c, 0x7(%rsp)
jne 0x7838
leaq 0xc0(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x29, 0x7(%rsp)
jne 0x785b
movl 0xc(%rsp), %eax
testl %eax, %eax
sete %cl
movl 0x10(%rsp), %edx
testl %edx, %edx
sete %dil
orb %cl, %dil
movl 0x8(%rsp), %esi
testl %esi, %esi
sete %r8b
movl 0x14(%rsp), %ecx
testl %ecx, %ecx
sete %r9b
orb %r8b, %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x78f3
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6d7b(%rip), %rcx      # 0xe53d
callq 0x44a0
jmp 0x787c
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6d55(%rip), %rcx      # 0xe53d
callq 0x44a0
jmp 0x787c
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6d2f(%rip), %rcx      # 0xe53d
callq 0x44a0
jmp 0x787c
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6d0c(%rip), %rcx      # 0xe53d
callq 0x44a0
jmp 0x787c
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6ce9(%rip), %rcx      # 0xe53d
callq 0x44a0
jmp 0x787c
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6cc6(%rip), %rcx      # 0xe53d
callq 0x44a0
movq 0x18(%rsp), %rcx
movq %rcx, (%rbx)
movq (%r14), %rax
cmpq %r13, %rax
je 0x7899
movq %rax, (%rbx)
movq (%r13), %rax
movq %rax, 0x10(%rbx)
jmp 0x78a3
movupd (%r13), %xmm0
movupd %xmm0, (%rcx)
leaq 0xc0(%rsp), %rbp
movq 0x8(%r14), %rax
movq %rax, 0x8(%rbx)
movq %r13, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
xorl %ebx, %ebx
movq 0x28(%rsp), %r13
movq %rbp, %rdi
movq 0xb6ac(%rip), %rsi      # 0x12f80
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
testb %bl, %bl
jne 0x75d2
jmp 0x8146
cmpl %esi, %edx
jle 0x78ff
movl %edx, 0x8(%rsp)
movl %esi, 0x10(%rsp)
cmpl %ecx, %eax
jle 0x790b
movl %eax, 0x14(%rsp)
movl %ecx, 0xc(%rsp)
movl 0x10(%rsp), %r13d
xorpd %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
cmpl 0x8(%rsp), %r13d
jle 0x796e
movb 0x58(%rbp), %bl
testb %bl, %bl
je 0x7a8e
movq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq %rsi, (%rcx)
movq (%r14), %rax
movq 0x40(%rsp), %rdx
cmpq %rdx, %rax
leaq 0x80(%rsp), %r15
movq 0x28(%rsp), %r13
leaq 0xc0(%rsp), %rbp
je 0x7b19
movq %rax, (%rcx)
movq (%rdx), %rax
movq %rax, 0x10(%rcx)
jmp 0x7b21
movsd %xmm0, 0x68(%rsp)
movl 0xc(%rsp), %ebx
cmpl 0x14(%rsp), %ebx
jle 0x798e
leal 0x1(%r13), %eax
cmpl 0x8(%rsp), %r13d
movl %eax, %r13d
jl 0x7974
jmp 0x7921
movl %r13d, %r15d
movq %rbx, %rax
shlq $0x20, %rax
orq %r15, %rax
movq %rax, 0x48(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x65ae
movq 0x38(%rbp), %rdi
movq (%rdi), %rax
movl %r13d, %esi
movl %ebx, %edx
callq *0x30(%rax)
movq %rax, %rbp
movq %rax, %rdi
callq 0x530c
movq 0x30(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x79f9
movb $0x1, 0x58(%rcx)
movq 0x68(%rcx), %rdx
movl $0x32, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6b61(%rip), %rcx      # 0xe553
callq 0x44a0
jmp 0x7a13
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x20(%rax)
movsd 0x68(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x68(%rsp)
leal 0x1(%rbx), %eax
cmpl 0x14(%rsp), %ebx
movl %eax, %ebx
movq 0x30(%rsp), %rbp
jl 0x7991
jmp 0x797e
movq %rax, %rbp
cmpl $0x1, %edx
jne 0x819f
movq %rbp, %rdi
callq 0x43a0
movq %rbp, 0xb8(%rsp)
leaq 0x48(%rsp), %rbp
movq %rbp, %rdi
movq %rax, %rsi
callq 0x45e0
movq 0xb8(%rsp), %rdi
callq 0x4110
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x20(%rsp), %rdi
leaq 0x6a8e(%rip), %rsi      # 0xe508
callq 0x4400
movq %rbp, %rdi
callq 0x4648
callq 0x4510
jmp 0x7a13
movl $0x148, %edx            # imm = 0x148
leaq 0x48(%rsp), %rdi
movq 0xb4f1(%rip), %rsi      # 0x12f90
leaq 0x6b74(%rip), %rcx      # 0xe61a
movsd 0x68(%rsp), %xmm0
movb $0x1, %al
leaq 0x80(%rsp), %r15
callq 0x8409
movq 0x28(%rsp), %r13
leaq 0xc0(%rsp), %rbp
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4320
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x7afc
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
incq %r13
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x4580
movq %rax, %r13
jmp 0x7b39
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rcx)
movq %rdx, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
xorb $0x1, %bl
jmp 0x78ca
leaq 0x70(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x6a35(%rip), %rcx      # 0xe586
movl $0x3, %r8d
xorl %esi, %esi
callq 0x44a0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4580
movq %rax, %r13
leaq 0xc0(%rsp), %rbp
cmpq $-0x1, %r13
je 0x8100
movl $0x1, %ecx
movq %r14, %rdi
leaq 0x6dbe(%rip), %rsi      # 0xe954
movq %r13, %rdx
callq 0x4580
movq %rax, %r12
leaq 0x3(%r13), %rdx
movq %r13, 0x28(%rsp)
subq %r13, %r12
incq %r12
movq %rbp, %rdi
movq %r14, %rsi
movq %r12, %rcx
callq 0x42e0
movq 0x38(%rsp), %rbx
movq 0x40(%rsp), %r13
leaq 0x90(%rsp), %rdi
movq %rbp, %rsi
callq 0x4380
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
movq 0x30(%rsp), %rbp
je 0x7c02
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x42d0
leaq 0xc0(%rsp), %rdi
callq 0x41f0
movq 0x90(%rsp), %rsi
movq 0x98(%rsp), %rdx
leaq 0xd0(%rsp), %rdi
callq 0x4330
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x28, 0x7(%rsp)
jne 0x7d77
xorl %eax, %eax
movl %eax, 0x10(%rsp)
movl %eax, 0xc(%rsp)
movl %eax, 0x8(%rsp)
movl %eax, 0x14(%rsp)
leaq 0xc0(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x2c, 0x7(%rsp)
jne 0x7d9d
leaq 0xc0(%rsp), %rdi
leaq 0xc(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x3a, 0x7(%rsp)
jne 0x7dc0
leaq 0xc0(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x2c, 0x7(%rsp)
jne 0x7de3
leaq 0xc0(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x41b0
leaq 0xc0(%rsp), %rdi
leaq 0x7(%rsp), %rsi
callq 0x43e0
cmpb $0x29, 0x7(%rsp)
jne 0x7e06
movl 0xc(%rsp), %eax
testl %eax, %eax
sete %cl
movl 0x10(%rsp), %edx
testl %edx, %edx
sete %dil
orb %cl, %dil
movl 0x8(%rsp), %esi
testl %esi, %esi
sete %r8b
movl 0x14(%rsp), %ecx
testl %ecx, %ecx
sete %r9b
orb %r8b, %r9b
orb %dil, %r9b
cmpb $0x1, %r9b
jne 0x7e9e
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x681d(%rip), %rcx      # 0xe58a
callq 0x44a0
jmp 0x7e27
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x67f7(%rip), %rcx      # 0xe58a
callq 0x44a0
jmp 0x7e27
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x67d1(%rip), %rcx      # 0xe58a
callq 0x44a0
jmp 0x7e27
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x67ae(%rip), %rcx      # 0xe58a
callq 0x44a0
jmp 0x7e27
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x678b(%rip), %rcx      # 0xe58a
callq 0x44a0
jmp 0x7e27
movb $0x1, 0x58(%rbp)
movq 0x68(%rbp), %rdx
movl $0x15, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x6768(%rip), %rcx      # 0xe58a
callq 0x44a0
movq 0x18(%rsp), %rcx
movq %rcx, (%rbx)
movq (%r14), %rax
cmpq %r13, %rax
je 0x7e44
movq %rax, (%rbx)
movq (%r13), %rax
movq %rax, 0x10(%rbx)
jmp 0x7e4e
movupd (%r13), %xmm0
movupd %xmm0, (%rcx)
leaq 0xc0(%rsp), %rbp
movq 0x8(%r14), %rax
movq %rax, 0x8(%rbx)
movq %r13, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
xorl %ebx, %ebx
movq 0x28(%rsp), %r13
movq %rbp, %rdi
movq 0xb101(%rip), %rsi      # 0x12f80
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
testb %bl, %bl
jne 0x7b7d
jmp 0x8146
cmpl %esi, %edx
jle 0x7eaa
movl %edx, 0x8(%rsp)
movl %esi, 0x10(%rsp)
cmpl %ecx, %eax
jle 0x7eb6
movl %eax, 0x14(%rsp)
movl %ecx, 0xc(%rsp)
movl 0x10(%rsp), %r13d
movl 0x8(%rsp), %eax
xorpd %xmm0, %xmm0
movsd %xmm0, 0x68(%rsp)
cmpl %eax, %r13d
jle 0x7f1b
movb 0x58(%rbp), %bl
testb %bl, %bl
je 0x802f
movq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq %rsi, (%rcx)
movq (%r14), %rax
movq 0x40(%rsp), %rdx
cmpq %rdx, %rax
leaq 0x80(%rsp), %r15
movq 0x28(%rsp), %r13
leaq 0xc0(%rsp), %rbp
je 0x80d8
movq %rax, (%rcx)
movq (%rdx), %rax
movq %rax, 0x10(%rcx)
jmp 0x80e0
movsd %xmm0, 0x68(%rsp)
movl 0xc(%rsp), %ebx
cmpl 0x14(%rsp), %ebx
jle 0x7f3d
leal 0x1(%r13), %ecx
movl 0x8(%rsp), %eax
cmpl %eax, %r13d
movl %ecx, %r13d
jl 0x7f21
jmp 0x7ece
movl %r13d, %r15d
movq %rbx, %rax
shlq $0x20, %rax
orq %r15, %rax
movq %rax, 0x48(%rsp)
movq 0xb0(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x65ae
movq 0x38(%rbp), %rdi
movq (%rdi), %rax
movl %r13d, %esi
movl %ebx, %edx
callq *0x30(%rax)
movq %rax, %rbp
movq %rax, %rdi
callq 0x530c
movq 0x30(%rsp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x7fa8
movb $0x1, 0x58(%rcx)
movq 0x68(%rcx), %rdx
movl $0x32, %r8d
movq 0x20(%rsp), %rdi
xorl %esi, %esi
leaq 0x65ff(%rip), %rcx      # 0xe5a0
callq 0x44a0
jmp 0x7fc2
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x20(%rax)
movsd 0x68(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x68(%rsp)
leal 0x1(%rbx), %eax
cmpl 0x14(%rsp), %ebx
movl %eax, %ebx
movq 0x30(%rsp), %rbp
jl 0x7f40
jmp 0x7f2b
movq %rax, %rbp
cmpl $0x1, %edx
jne 0x82db
movq %rbp, %rdi
callq 0x43a0
leaq 0x48(%rsp), %rdi
movq %rax, %rsi
callq 0x45e0
movq %rbp, %rdi
callq 0x4110
movq 0x30(%rsp), %rax
movb $0x1, 0x58(%rax)
movq 0x20(%rsp), %rdi
leaq 0x64ef(%rip), %rsi      # 0xe508
callq 0x4400
leaq 0x48(%rsp), %rdi
callq 0x4648
callq 0x4510
jmp 0x7fc2
subl 0x10(%rsp), %eax
incl %eax
movl 0x14(%rsp), %ecx
subl 0xc(%rsp), %ecx
incl %ecx
imull %eax, %ecx
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
movsd 0x68(%rsp), %xmm0
divsd %xmm1, %xmm0
movl $0x148, %edx            # imm = 0x148
leaq 0x48(%rsp), %rdi
movq 0xaf2c(%rip), %rsi      # 0x12f90
leaq 0x65af(%rip), %rcx      # 0xe61a
movb $0x1, %al
leaq 0x80(%rsp), %r15
callq 0x8409
movq 0x28(%rsp), %r13
leaq 0xc0(%rsp), %rbp
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %r8
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x4320
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x80bb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
incq %r13
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rcx
movq %r14, %rdi
movq %r13, %rdx
callq 0x4580
movq %rax, %r13
jmp 0x80f8
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rcx)
movq %rdx, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
xorb $0x1, %bl
jmp 0x7e75
movq 0x38(%rsp), %rcx
movq 0x18(%rsp), %rsi
movq %rsi, (%rcx)
movq (%r14), %rax
movq 0x40(%rsp), %rdx
cmpq %rdx, %rax
je 0x8126
movq %rax, (%rcx)
movq (%rdx), %rax
movq %rax, 0x10(%rcx)
jmp 0x812e
movupd (%rdx), %xmm0
movupd %xmm0, (%rsi)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rcx)
movq %rdx, (%r14)
movq $0x0, 0x8(%r14)
movb $0x0, 0x10(%r14)
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x816b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
movq 0x38(%rsp), %rbx
je 0x818a
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rax
addq $0x268, %rsp            # imm = 0x268
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, %rbx
jmp 0x833e
jmp 0x8315
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4648
callq 0x4510
jmp 0x8318
jmp 0x82d8
movq %rax, %rbp
leaq 0x48(%rsp), %rdi
callq 0x4648
callq 0x4510
jmp 0x82db
jmp 0x833b
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4648
callq 0x4510
jmp 0x833e
movq %rax, %rdi
callq 0x5314
movq %rax, %rbp
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x82db
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x82db
jmp 0x82d8
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x833e
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x833e
jmp 0x833b
movq %rax, %rbx
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x8318
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42d0
jmp 0x8318
jmp 0x8315
jmp 0x82ce
jmp 0x8315
movq %rax, %rbx
jmp 0x83a6
movq %rax, %rbx
movq 0x248(%rsp), %rdi
cmpq %r15, %rdi
je 0x83a6
movq 0x258(%rsp), %rsi
jmp 0x839e
jmp 0x82ce
jmp 0x82ce
jmp 0x82d8
jmp 0x82d8
jmp 0x82ce
jmp 0x82ce
jmp 0x833b
jmp 0x82d8
jmp 0x833b
jmp 0x82ce
movq %rax, %rbx
jmp 0x8367
jmp 0x8315
movq %rax, %rbp
movq 0xac9e(%rip), %rsi      # 0x12f80
leaq 0xc0(%rsp), %rdi
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
leaq 0x80(%rsp), %r15
leaq 0xa0(%rsp), %rax
movq %rbp, %rbx
jmp 0x836f
jmp 0x833b
jmp 0x8315
movq %rax, %rbx
movq 0xac61(%rip), %rsi      # 0x12f80
leaq 0xc0(%rsp), %rdi
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
jmp 0x8367
movq %rax, %rbx
movq 0xac3b(%rip), %rsi      # 0x12f80
leaq 0xc0(%rsp), %rdi
callq 0x4220
leaq 0x140(%rsp), %rdi
callq 0x40d0
leaq 0x80(%rsp), %r15
leaq 0xa0(%rsp), %rax
movq 0x90(%rsp), %rdi
cmpq %rax, %rdi
je 0x838c
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x42d0
movq 0x70(%rsp), %rdi
cmpq %r15, %rdi
je 0x83a6
movq 0x80(%rsp), %rsi
incq %rsi
callq 0x42d0
movq %rbx, %rdi
callq 0x45a0