// File: /workspace/github_cpp_makefile_star2_O1/toxaart[P]hierarchical_block_sparse_lib/source/HierarchicalBlockSparseMatrix.h
// Function: hbsm::HierarchicalBlockSparseMatrix<double>::set_to_identity(hbsm::HierarchicalBlockSparseMatrix<double>&, int)
void HierarchicalBlockSparseMatrix<Treal>::set_to_identity(HierarchicalBlockSparseMatrix<Treal> & A, int nRows) {

            // assume params are set

            A.clear();

            A.resize(nRows, nRows);

            if(A.lowest_level()){

                int blocksize = A.blocksize;
								int n = A.nRows;
								if(A.on_bottom_boundary()) n = A.get_n_rows() % blocksize; // fill only necessary elements

                for(int i = 0; i < n; ++i) A.submatrix[i*blocksize + i] = 1.0;

                return;
            }

            int blocksize = A.blocksize;

            A.children[0] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
            A.children[0]->parent = &A;
            A.children[0]->set_params(A.get_params());
            set_to_identity(*A.children[0], A.nRows/2);

            if(A.children[0]->get_first_row_position() + A.children[0]->nRows >= A.get_n_rows() ) return;

            A.children[3] = std::make_shared<HierarchicalBlockSparseMatrix<Treal> >();
            A.children[3]->parent = &A;
            A.children[3]->set_params(A.get_params());
            set_to_identity(*A.children[3], A.nRows/2);

            return;
        }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
callq 0x1adc6
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x99da
movq %rbx, %rdi
callq 0x1aed4
testb %al, %al
je 0x1063e
movl (%rbx), %ebp
movl 0x10(%rbx), %r14d
movq %rbx, %rdi
callq 0x1b0e6
testb %al, %al
je 0x1060d
cmpq $0x0, 0x68(%rbx)
movq %rbx, %rax
je 0x10604
movq %rbx, %rcx
movq %rcx, %rax
movq 0x68(%rcx), %rcx
testq %rcx, %rcx
jne 0x105f8
movl 0x8(%rax), %eax
cltd
idivl %r14d
movl %edx, %ebp
testl %ebp, %ebp
jle 0x10784
incl %r14d
movq 0x70(%rbx), %rax
movl %ebp, %ecx
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movslq %edx, %rdx
movq %rsi, (%rax,%rdx,8)
addl %r14d, %edx
decq %rcx
jne 0x1062a
jmp 0x10784
movl $0x98, %edi
callq 0x21c0
movabsq $0x100000001, %r14      # imm = 0x100000001
movq %r14, 0x8(%rax)
leaq 0x1a683(%rip), %r15     # 0x2ace0
movq %r15, (%rax)
leaq 0x10(%rax), %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(%rbx)
movq 0x30(%rbx), %rdi
movq %rax, 0x30(%rbx)
testq %rdi, %rdi
je 0x106a7
callq 0x1af0e
movq 0x28(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
callq 0x9974
movq 0x28(%rbx), %rdi
movl (%rbx), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
callq 0x105ae
movq 0x28(%rbx), %rdi
callq 0x1b194
movq 0x28(%rbx), %rdx
movq %rbx, %rcx
addl (%rdx), %eax
cmpq $0x0, 0x68(%rbx)
je 0x106fa
movq %rbx, %rdx
movq %rdx, %rcx
movq 0x68(%rdx), %rdx
testq %rdx, %rdx
jne 0x106ee
cmpl 0x8(%rcx), %eax
jge 0x10784
movl $0x98, %edi
callq 0x21c0
movq %r14, 0x8(%rax)
movq %r15, (%rax)
leaq 0x10(%rax), %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(%rbx)
movq 0x60(%rbx), %rdi
movq %rax, 0x60(%rbx)
testq %rdi, %rdi
je 0x1075b
callq 0x1af0e
movq 0x58(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
movq %rsp, %rsi
movl %eax, (%rsi)
callq 0x9974
movq 0x58(%rbx), %rdi
movl (%rbx), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
callq 0x105ae
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop