// File: /workspace/github_cpp_makefile_star2_O1/toxaart[P]hierarchical_block_sparse_lib/source/HierarchicalBlockSparseMatrix.h
// Function: hbsm::HierarchicalBlockSparseMatrix<double>::assign_from_buffer(char const*, unsigned long)
void HierarchicalBlockSparseMatrix<Treal>::assign_from_buffer(const char * dataBuffer, size_t const bufferSize) {

			const char *p = dataBuffer;

			int n_bytes_left_to_read = bufferSize;

			if (bufferSize < 5 * sizeof(int) + 4 * sizeof(size_t))
			  throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::assign_from_buffer(): buffer too small.");


			memcpy(&nRows, p, sizeof(int));
			p += sizeof(int);
			n_bytes_left_to_read -= sizeof(int);

			memcpy(&nCols, p, sizeof(int));
			p += sizeof(int);
			n_bytes_left_to_read -= sizeof(int);

			memcpy(&nRows_orig, p, sizeof(int));
			p += sizeof(int);
			n_bytes_left_to_read -= sizeof(int);

			memcpy(&nCols_orig, p, sizeof(int));
			p += sizeof(int);
			n_bytes_left_to_read -= sizeof(int);

			memcpy(&blocksize, p, sizeof(int));
			p += sizeof(int);
			n_bytes_left_to_read -= sizeof(int);

			memcpy(&frob_norm_squared_internal, p, sizeof(Treal));
			p += sizeof(Treal);
			n_bytes_left_to_read -= sizeof(Treal);

			memcpy(&n_block_multiplies, p, sizeof(size_t));
			p += sizeof(size_t);
			n_bytes_left_to_read -= sizeof(size_t);

			size_t child0_size, child1_size, child2_size, child3_size;

			memcpy(&child0_size, p, sizeof(size_t));
			p += sizeof(size_t);
			n_bytes_left_to_read -= sizeof(size_t);

			memcpy(&child1_size, p, sizeof(size_t));
			p += sizeof(size_t);
			n_bytes_left_to_read -= sizeof(size_t);

			memcpy(&child2_size, p, sizeof(size_t));
			p += sizeof(size_t);
			n_bytes_left_to_read -= sizeof(size_t);

			memcpy(&child3_size, p, sizeof(size_t));
			p += sizeof(size_t);
			n_bytes_left_to_read -= sizeof(size_t);

			this->resize(nRows_orig, nCols_orig);

			//check if buffer ended, if so, that was an empty matrix
			if(n_bytes_left_to_read == 0){
				return;
			}

			if(child0_size > 0){
				if(children[0] != NULL)
					throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::assign_from_buffer(): non-null child exist!");

				std::vector<char> child0_buf(child0_size);
				memcpy(&child0_buf[0], p, child0_size);
				p += child0_size;
				n_bytes_left_to_read -= child0_size;

				children[0] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[0]->assign_from_buffer(&child0_buf[0], child0_size);
				children[0]->parent = this;

			}


			if(child1_size > 0){
				if(children[1] != NULL)
					throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::assign_from_buffer(): non-null child exist!");

				std::vector<char> child1_buf(child1_size);
				memcpy(&child1_buf[0], p, child1_size);
				p += child1_size;
				n_bytes_left_to_read -= child1_size;

				children[1] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[1]->assign_from_buffer(&child1_buf[0], child1_size);
				children[1]->parent = this;

			}


			if(child2_size > 0){
				if(children[2] != NULL)
					throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::assign_from_buffer(): non-null child exist!");

				std::vector<char> child2_buf(child2_size);
				memcpy(&child2_buf[0], p, child2_size);
				p += child2_size;
				n_bytes_left_to_read -= child2_size;

				children[2] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[2]->assign_from_buffer(&child2_buf[0], child2_size);
				children[2]->parent = this;

			}


			if(child3_size > 0){
				if(children[3] != NULL)
					throw std::runtime_error("Error in HierarchicalBlockSparseMatrix::assign_from_buffer(): non-null child exist!");

				std::vector<char> child3_buf(child3_size);
				memcpy(&child3_buf[0], p, child3_size);
				p += child3_size;
				n_bytes_left_to_read -= child3_size;

				children[3] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
				children[3]->assign_from_buffer(&child3_buf[0], child3_size);
				children[3]->parent = this;

			}

			// at this point, if n_bytes_left_to_read is 0, then we are done, if not, then it was a leaf matrix!
			if(n_bytes_left_to_read == 0){
				return;
			}
			else{

				assert(n_bytes_left_to_read == nRows * nCols * sizeof(Treal));
				submatrix.resize(nRows * nCols);

				memcpy(&submatrix[0], p, nRows * nCols * sizeof(Treal));
				p += nRows * nCols * sizeof(Treal);
			}

		}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
cmpq $0x33, %rdx
jbe 0x5a69
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl (%rsi), %eax
movl %eax, (%rdi)
movl 0x4(%rsi), %eax
movl %eax, 0x4(%rdi)
movl 0x8(%rsi), %esi
movl %esi, 0x8(%rdi)
movl 0xc(%rbx), %edx
movl %edx, 0xc(%rdi)
movl 0x10(%rbx), %eax
movl %eax, 0x10(%rdi)
movq 0x14(%rbx), %rax
movq %rax, 0x18(%rdi)
movq 0x1c(%rbx), %rax
movq %rax, 0x20(%rdi)
movq 0x24(%rbx), %r12
movq 0x2c(%rbx), %rbp
movq 0x34(%rbx), %r13
movq 0x3c(%rbx), %rax
movq %rax, 0x20(%rsp)
xorl %ecx, %ecx
callq 0x436c
addl $-0x44, %r15d
je 0x5a5a
addq $0x44, %rbx
testq %r12, %r12
je 0x5785
cmpq $0x0, 0x28(%r14)
jne 0x5a87
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r12, %rsi
callq 0x5284
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2100
movl $0x98, %edi
callq 0x2130
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x85de(%rip), %rcx      # 0xdce0
movq %rcx, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
movups %xmm0, 0x68(%rax)
movups %xmm0, 0x78(%rax)
movups %xmm0, 0x88(%rax)
movq %rcx, 0x28(%r14)
movq 0x30(%r14), %rdi
movq %rax, 0x30(%r14)
testq %rdi, %rdi
je 0x574f
callq 0x6b64
movq 0x28(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x5636
movq 0x28(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x577f
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r12, %rbx
subl %r12d, %r15d
testq %rbp, %rbp
je 0x585d
cmpq $0x0, 0x38(%r14)
jne 0x5aa5
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rbp, %rsi
callq 0x5284
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x2100
movl $0x98, %edi
callq 0x2130
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x8506(%rip), %rcx      # 0xdce0
movq %rcx, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
movups %xmm0, 0x68(%rax)
movups %xmm0, 0x78(%rax)
movups %xmm0, 0x88(%rax)
movq %rcx, 0x38(%r14)
movq 0x40(%r14), %rdi
movq %rax, 0x40(%r14)
testq %rdi, %rdi
je 0x5827
callq 0x6b64
movq 0x38(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x5636
movq 0x38(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5857
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %rbp, %rbx
subl %ebp, %r15d
testq %r13, %r13
je 0x5935
cmpq $0x0, 0x48(%r14)
jne 0x5ac3
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r13, %rsi
callq 0x5284
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x2100
movl $0x98, %edi
callq 0x2130
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x842e(%rip), %rcx      # 0xdce0
movq %rcx, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
movups %xmm0, 0x68(%rax)
movups %xmm0, 0x78(%rax)
movups %xmm0, 0x88(%rax)
movq %rcx, 0x48(%r14)
movq 0x50(%r14), %rdi
movq %rax, 0x50(%r14)
testq %rdi, %rdi
je 0x58ff
callq 0x6b64
movq 0x48(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x5636
movq 0x48(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x592f
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r13, %rbx
subl %r13d, %r15d
movq 0x20(%rsp), %r12
testq %r12, %r12
je 0x5a12
cmpq $0x0, 0x58(%r14)
jne 0x5ae1
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r12, %rsi
callq 0x5284
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x2100
movl $0x98, %edi
callq 0x2130
movabsq $0x100000001, %rcx      # imm = 0x100000001
movq %rcx, 0x8(%rax)
leaq 0x8351(%rip), %rcx      # 0xdce0
movq %rcx, (%rax)
movq %rax, %rcx
addq $0x10, %rcx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movl $0xffffffff, 0x20(%rax) # imm = 0xFFFFFFFF
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
movups %xmm0, 0x68(%rax)
movups %xmm0, 0x78(%rax)
movups %xmm0, 0x88(%rax)
movq %rcx, 0x58(%r14)
movq 0x60(%r14), %rdi
movq %rax, 0x60(%r14)
testq %rdi, %rdi
je 0x59dc
callq 0x6b64
movq 0x58(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x5636
movq 0x58(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5a0c
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r12, %rbx
subl %r12d, %r15d
testl %r15d, %r15d
je 0x5a5a
movslq %r15d, %rax
movslq (%r14), %rcx
movslq 0x4(%r14), %rsi
imulq %rcx, %rsi
leaq (,%rsi,8), %rcx
cmpq %rax, %rcx
jne 0x5b13
leaq 0x70(%r14), %rdi
callq 0x699c
movq 0x70(%r14), %rdi
movslq (%r14), %rax
movslq 0x4(%r14), %rdx
imulq %rax, %rdx
shlq $0x3, %rdx
movq %rbx, %rsi
callq 0x2100
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x5436(%rip), %rsi      # 0xaeb3
movq %rax, %rdi
callq 0x2060
jmp 0x5afd
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x5468(%rip), %rsi      # 0xaf03
movq %rax, %rdi
callq 0x2060
jmp 0x5afd
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x544a(%rip), %rsi      # 0xaf03
movq %rax, %rdi
callq 0x2060
jmp 0x5afd
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x542c(%rip), %rsi      # 0xaf03
movq %rax, %rdi
callq 0x2060
jmp 0x5afd
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x540e(%rip), %rsi      # 0xaf03
movq %rax, %rdi
callq 0x2060
movq 0x84ec(%rip), %rsi      # 0xdff0
movq 0x84b5(%rip), %rdx      # 0xdfc0
movq %r14, %rdi
callq 0x21a0
leaq 0x543d(%rip), %rdi      # 0xaf57
leaq 0x4a54(%rip), %rsi      # 0xa575
leaq 0x5465(%rip), %rcx      # 0xaf8d
movl $0x5c8, %edx            # imm = 0x5C8
callq 0x20a0
jmp 0x5b6f
jmp 0x5b6f
jmp 0x5b6f
jmp 0x5b6f
jmp 0x5b4e
jmp 0x5b4e
jmp 0x5b6a
jmp 0x5b4e
jmp 0x5b4e
jmp 0x5b6a
jmp 0x5b4e
jmp 0x5b4e
jmp 0x5b6a
jmp 0x5b4e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5b7a
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x5b7a
movq %rax, %rbx
jmp 0x5b7a
movq %rax, %rbx
movq %r14, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x21c0