// File: /workspace/github_cpp_makefile_star2_O3/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 0x1b326
movq %rbx, %rdi
movl %ebp, %esi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x9986
movq %rbx, %rdi
callq 0x1b448
testb %al, %al
je 0x1078e
movl (%rbx), %ebp
movl 0x10(%rbx), %r14d
movq %rbx, %rdi
callq 0x1b660
testb %al, %al
je 0x1075d
cmpq $0x0, 0x68(%rbx)
movq %rbx, %rax
je 0x10754
movq %rbx, %rcx
movq %rcx, %rax
movq 0x68(%rcx), %rcx
testq %rcx, %rcx
jne 0x10748
movl 0x8(%rax), %eax
cltd
idivl %r14d
movl %edx, %ebp
testl %ebp, %ebp
jle 0x108da
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 0x1077a
jmp 0x108da
movl $0x98, %edi
callq 0x21c0
movabsq $0x100000001, %r14      # imm = 0x100000001
movq %r14, 0x8(%rax)
leaq 0x1b56b(%rip), %r15     # 0x2bd18
movq %r15, (%rax)
leaq 0x10(%rax), %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(%rbx)
movq 0x30(%rbx), %rcx
movq %rax, 0x30(%rbx)
testq %rcx, %rcx
je 0x107fe
movq %rcx, %rdi
callq 0x1b482
movq 0x28(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
leaq 0x4(%rsp), %rsi
movl %eax, (%rsi)
callq 0x9920
movq 0x28(%rbx), %rdi
movl (%rbx), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
callq 0x106fe
movq 0x28(%rbx), %rdi
callq 0x1b70e
movq 0x28(%rbx), %rdx
movq %rbx, %rcx
addl (%rdx), %eax
cmpq $0x0, 0x68(%rbx)
je 0x1084d
movq %rbx, %rdx
movq %rdx, %rcx
movq 0x68(%rdx), %rdx
testq %rdx, %rdx
jne 0x10841
cmpl 0x8(%rcx), %eax
jge 0x108da
movl $0x98, %edi
callq 0x21c0
movq %r14, 0x8(%rax)
movq %r15, (%rax)
leaq 0x10(%rax), %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(%rbx)
movq 0x60(%rbx), %rcx
movq %rax, 0x60(%rbx)
testq %rcx, %rcx
je 0x108b5
movq %rcx, %rdi
callq 0x1b482
movq 0x58(%rbx), %rdi
movq %rbx, 0x68(%rdi)
movl 0x10(%rbx), %eax
movq %rsp, %rsi
movl %eax, (%rsi)
callq 0x9920
movq 0x58(%rbx), %rdi
movl (%rbx), %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl %esi
callq 0x106fe
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop