// File: btbujiangjun[P]abcdl/src/algebra/MatrixBase.cpp
// Function: abcdl::algebra::Matrix<int>::insert_row(unsigned long, abcdl::algebra::Matrix<int> const&)
void Matrix<T>::insert_row(const size_t row_id, const Matrix<T>& mat){  
    if(get_size() == 0){
        set_data(mat.data(), mat.rows(), mat.cols());
        return;
    }

    CHECK(_cols == mat.cols());

    T* data = new T[(_rows + mat.rows()) * _cols];

    if(row_id > 0){
        memcpy(data, _data, sizeof(T) * row_id * _cols);
    }
    memcpy(&data[row_id * _cols], mat.data(), sizeof(T) * mat.get_size());
    if(row_id < _rows){
        memcpy(&data[(row_id + mat.rows()) * _cols], &_data[row_id * _cols], sizeof(T) * (_rows - row_id) * _cols);
    }
    set_shallow_data(data, _rows + mat.rows(), _cols);
}

// Assembly:
subq $0x218, %rsp            # imm = 0x218
movq %rdi, 0x210(%rsp)
movq %rsi, 0x208(%rsp)
movq %rdx, 0x200(%rsp)
movq 0x210(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x317f0
cmpq $0x0, %rax
jne 0x32534
movq 0x200(%rsp), %rdi
callq 0x31a30
movq %rax, 0x48(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a10
movq %rax, 0x50(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a20
movq 0x58(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
movq %rax, %rcx
callq 0x31ea0
jmp 0x32762
movq 0x58(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a20
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x32565
jmp 0x325c1
leaq 0x5dfcc(%rip), %rsi     # 0x90538
leaq 0x78(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl $0x77, %edx
movl $0x3, %ecx
callq 0x89860
movq 0x38(%rsp), %rdi
leaq 0x5dfeb(%rip), %rsi     # 0x9057c
callq 0x310b0
jmp 0x32598
leaq 0x78(%rsp), %rdi
callq 0x89c20
jmp 0x325c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x89c20
jmp 0x3276a
movq 0x58(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a10
movq 0x58(%rsp), %rcx
movq %rax, %rdx
movq 0x30(%rsp), %rax
addq %rdx, %rax
imulq 0x8(%rcx), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x9030
movq %rax, 0x60(%rsp)
cmpq $0x0, 0x208(%rsp)
jbe 0x32645
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rdi
movq 0x10(%rax), %rsi
movq 0x208(%rsp), %rdx
shlq $0x2, %rdx
imulq 0x8(%rax), %rdx
callq 0x9370
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rax
movq 0x208(%rsp), %rcx
imulq 0x8(%rdx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movq %rax, 0x20(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a30
movq %rax, 0x28(%rsp)
movq 0x200(%rsp), %rdi
callq 0x317f0
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq %rax, %rdx
shlq $0x2, %rdx
callq 0x9370
movq 0x58(%rsp), %rcx
movq 0x208(%rsp), %rax
cmpq (%rcx), %rax
jae 0x32725
movq 0x60(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x208(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a10
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rdi
movq %rax, %rdx
movq 0x58(%rsp), %rax
addq %rdx, %rcx
imulq 0x8(%rax), %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq 0x10(%rax), %rsi
movq 0x208(%rsp), %rcx
imulq 0x8(%rax), %rcx
shlq $0x2, %rcx
addq %rcx, %rsi
movq (%rax), %rdx
subq 0x208(%rsp), %rdx
shlq $0x2, %rdx
imulq 0x8(%rax), %rdx
callq 0x9370
movq 0x58(%rsp), %rax
movq 0x60(%rsp), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rax
movq %rax, (%rsp)
movq 0x200(%rsp), %rdi
callq 0x31a10
movq (%rsp), %rdx
movq 0x58(%rsp), %rdi
movq 0x8(%rsp), %rsi
addq %rax, %rdx
movq 0x8(%rdi), %rcx
callq 0x31fe0
addq $0x218, %rsp            # imm = 0x218
retq
movq 0x70(%rsp), %rdi
callq 0x9700
nopw %cs:(%rax,%rax)
nop