// File: /workspace/github_cpp_makefile_star2_O3/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 0x5a35
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 0x430c
addl $-0x44, %r15d
je 0x5a26
addq $0x44, %rbx
testq %r12, %r12
je 0x5748
cmpq $0x0, 0x28(%r14)
jne 0x5a53
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r12, %rsi
callq 0x523e
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 0x8656(%rip), %rcx      # 0xdd18
movq %rcx, (%rax)
movq %rax, %rdi
addq $0x10, %rdi
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 %rdi, 0x28(%r14)
movq 0x30(%r14), %rcx
movq %rax, 0x30(%r14)
testq %rcx, %rcx
je 0x5716
movq %rcx, %rdi
callq 0x6b3c
movq 0x28(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x55f6
movq 0x28(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5742
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r12, %rbx
subl %r12d, %r15d
testq %rbp, %rbp
je 0x5823
cmpq $0x0, 0x38(%r14)
jne 0x5a71
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rbp, %rsi
callq 0x523e
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 0x857b(%rip), %rcx      # 0xdd18
movq %rcx, (%rax)
movq %rax, %rdi
addq $0x10, %rdi
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 %rdi, 0x38(%r14)
movq 0x40(%r14), %rcx
movq %rax, 0x40(%r14)
testq %rcx, %rcx
je 0x57f1
movq %rcx, %rdi
callq 0x6b3c
movq 0x38(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %rbp, %rdx
callq 0x55f6
movq 0x38(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x581d
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %rbp, %rbx
subl %ebp, %r15d
testq %r13, %r13
je 0x58fe
cmpq $0x0, 0x48(%r14)
jne 0x5a8f
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r13, %rsi
callq 0x523e
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 0x84a0(%rip), %rcx      # 0xdd18
movq %rcx, (%rax)
movq %rax, %rdi
addq $0x10, %rdi
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 %rdi, 0x48(%r14)
movq 0x50(%r14), %rcx
movq %rax, 0x50(%r14)
testq %rcx, %rcx
je 0x58cc
movq %rcx, %rdi
callq 0x6b3c
movq 0x48(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x55f6
movq 0x48(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x58f8
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r13, %rbx
subl %r13d, %r15d
movq 0x20(%rsp), %r12
testq %r12, %r12
je 0x59de
cmpq $0x0, 0x58(%r14)
jne 0x5aad
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %r12, %rsi
callq 0x523e
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 0x83c0(%rip), %rcx      # 0xdd18
movq %rcx, (%rax)
movq %rax, %rdi
addq $0x10, %rdi
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 %rdi, 0x58(%r14)
movq 0x60(%r14), %rcx
movq %rax, 0x60(%r14)
testq %rcx, %rcx
je 0x59ac
movq %rcx, %rdi
callq 0x6b3c
movq 0x58(%r14), %rdi
movq 0x8(%rsp), %rsi
movq %r12, %rdx
callq 0x55f6
movq 0x58(%r14), %rax
movq %r14, 0x68(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x59d8
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
addq %r12, %rbx
subl %r12d, %r15d
testl %r15d, %r15d
je 0x5a26
movslq %r15d, %rax
movslq (%r14), %rcx
movslq 0x4(%r14), %rsi
imulq %rcx, %rsi
leaq (,%rsi,8), %rcx
cmpq %rax, %rcx
jne 0x5adf
leaq 0x70(%r14), %rdi
callq 0x696e
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 0x5482(%rip), %rsi      # 0xaecb
movq %rax, %rdi
callq 0x2060
jmp 0x5ac9
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x54b4(%rip), %rsi      # 0xaf1b
movq %rax, %rdi
callq 0x2060
jmp 0x5ac9
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x5496(%rip), %rsi      # 0xaf1b
movq %rax, %rdi
callq 0x2060
jmp 0x5ac9
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x5478(%rip), %rsi      # 0xaf1b
movq %rax, %rdi
callq 0x2060
jmp 0x5ac9
movl $0x10, %edi
callq 0x2070
movq %rax, %r14
leaq 0x545a(%rip), %rsi      # 0xaf1b
movq %rax, %rdi
callq 0x2060
movq 0x8520(%rip), %rsi      # 0xdff0
movq 0x84e9(%rip), %rdx      # 0xdfc0
movq %r14, %rdi
callq 0x21a0
leaq 0x5489(%rip), %rdi      # 0xaf6f
leaq 0x4aa0(%rip), %rsi      # 0xa58d
leaq 0x54b1(%rip), %rcx      # 0xafa5
movl $0x5c8, %edx            # imm = 0x5C8
callq 0x20a0
jmp 0x5b3b
jmp 0x5b3b
jmp 0x5b3b
jmp 0x5b3b
jmp 0x5b1a
jmp 0x5b1a
jmp 0x5b36
jmp 0x5b1a
jmp 0x5b1a
jmp 0x5b36
jmp 0x5b1a
jmp 0x5b1a
jmp 0x5b36
jmp 0x5b1a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x5b46
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x2140
jmp 0x5b46
movq %rax, %rbx
jmp 0x5b46
movq %rax, %rbx
movq %r14, %rdi
callq 0x20e0
movq %rbx, %rdi
callq 0x21c0