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

    CHECK(mat.rows() == _rows);
    CHECK(col_id <= _cols);

    size_t sub_cols = mat.cols();
    size_t new_cols = _cols + sub_cols;
    T* sub_data   = mat.data();

    T* data = new T[_rows * new_cols];
    for(size_t i = 0; i != _rows; i++){
        if(col_id > 0){
            memcpy(&data[i * new_cols], &_data[i * _cols], sizeof(T) * sub_cols);
        }
        memcpy(&data[i * new_cols + sub_cols], &sub_data[i * sub_cols], sizeof(T) * sub_cols);
        if(col_id != _cols){
            memcpy(&data[i * new_cols + col_id + sub_cols], &_data[i * _cols + col_id], sizeof(T) * (_cols - col_id));
        }
    }

    set_shallow_data(data, _rows, new_cols);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %rdx, %r12
movq %rsi, 0x8(%rsp)
movq %rdi, %r13
movq (%rdi), %rcx
movq 0x8(%rdi), %rax
imulq %rcx, %rax
testq %rax, %rax
je 0x19451
cmpq %rcx, (%r12)
jne 0x194c8
movq 0x8(%rsp), %rax
cmpq %rax, 0x8(%r13)
jb 0x19509
movq 0x8(%r12), %r15
movq 0x10(%r12), %r12
movq (%r13), %rbx
movq %r13, 0x28(%rsp)
movq 0x8(%r13), %rax
movq %rax, 0x30(%rsp)
leaq (%rax,%r15), %rdx
movq %rbx, %rax
movq %rdx, 0x18(%rsp)
imulq %rdx, %rax
movq %rax, %rcx
shrq $0x3e, %rcx
shlq $0x2, %rax
xorl %edi, %edi
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x9030
movq %rax, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
testq %rbx, %rbx
je 0x19412
movq 0x28(%rsp), %rax
movq 0x10(%rax), %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0x50(%rsp)
leaq (%rcx,%rax,4), %rcx
movq %rcx, 0x48(%rsp)
movq 0x30(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
shlq $0x2, %rdx
movq %rdx, 0x40(%rsp)
leaq (,%rcx,4), %rcx
movq %rcx, 0x58(%rsp)
leaq (,%rax,4), %rax
leaq (%rax,%r15,4), %rax
movq %rax, 0x38(%rsp)
shlq $0x2, %r15
movq 0x18(%rsp), %rax
leaq (,%rax,4), %rbp
xorl %r14d, %r14d
movq 0x10(%rsp), %r13
movq 0x20(%rsp), %rbx
cmpq $0x0, 0x8(%rsp)
je 0x193cb
movq 0x50(%rsp), %rax
leaq (%rax,%r14), %rsi
movq %r13, %rdi
movq %r15, %rdx
callq 0x92b0
leaq (%r15,%r13), %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x92b0
movq 0x30(%rsp), %rax
cmpq 0x8(%rsp), %rax
je 0x19402
movq 0x38(%rsp), %rax
leaq (%rax,%r13), %rdi
movq 0x48(%rsp), %rax
leaq (%rax,%r14), %rsi
movq 0x40(%rsp), %rdx
callq 0x92b0
addq 0x58(%rsp), %r14
addq %r15, %r12
addq %rbp, %r13
decq %rbx
jne 0x193af
movq 0x28(%rsp), %rbx
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x19425
callq 0x9420
movq 0x10(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x20(%rsp), %rax
movq %rax, (%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbx)
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x10(%r12), %r14
movq (%r12), %rbx
movq 0x8(%r12), %r12
movq %r12, %r15
imulq %rbx, %r15
cmpq %r15, %rax
je 0x1949c
movq 0x10(%r13), %rdi
testq %rdi, %rdi
je 0x19479
callq 0x9420
movq %r15, %rax
shrq $0x3e, %rax
leaq (,%r15,4), %rcx
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %rcx, %rdi
callq 0x9030
movq %rax, 0x10(%r13)
movq %rbx, (%r13)
movq %r12, 0x8(%r13)
movq 0x10(%r13), %rdi
shlq $0x2, %r15
movq %r14, %rsi
movq %r15, %rdx
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x92b0
leaq 0x23071(%rip), %rsi     # 0x3c540
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movl $0xc2, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x2315d(%rip), %rsi     # 0x3c64a
movl $0x21, %edx
movq %r15, %rdi
callq 0x93b0
leaq 0x60(%rsp), %rdi
callq 0x38b76
jmp 0x192da
leaq 0x23030(%rip), %rsi     # 0x3c540
leaq 0x60(%rsp), %r15
movq %r15, %rdi
movl $0xc3, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x23169(%rip), %rsi     # 0x3c697
movl $0x1d, %edx
movq %r15, %rdi
callq 0x93b0
leaq 0x60(%rsp), %rdi
callq 0x38b76
jmp 0x192e9
jmp 0x1954c
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x38b76
movq %rbx, %rdi
callq 0x95d0
nop