// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/src/algebra/MatrixOperator.cpp
// Function: abcdl::algebra::Matrix<int>::operator+(abcdl::algebra::Matrix<int> const&) const
Matrix<T> Matrix<T>::operator + (const Matrix<T>& mat) const{
    
	if(get_size() == 0){
        return mat.clone();
    }

    CHECK(equal_shape(mat) 
          || (_cols == mat.cols() && mat.rows() == 1)
          || (_rows == mat.rows() && mat.cols() == 1));

    Matrix<T> new_mat = clone();

    if(equal_shape(mat) || (_cols == mat.cols() && mat.rows() == 1)){
        auto lambda = [](T* a, const T& b){*a += b;};
        _po.parallel_mul2mul_repeat(new_mat.data(), new_mat.get_size(), mat.data(), mat.get_size(), lambda);
    }else{
        for(size_t i = 0; i < _rows; i++){
            T value = mat.get_data(i, 0);
            for(size_t j = 0; j < _cols; j++){
                new_mat.set_data(get_data(i, j) + value, i, j);
            }
        }
    }
    return new_mat;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdx, %r15
movq %rdi, %rbx
movq (%rsi), %rcx
movq 0x8(%rsi), %rax
movq %rax, %rdx
imulq %rcx, %rdx
testq %rdx, %rdx
je 0x1f0da
movq %rsi, %r14
movq (%r15), %rdx
movq 0x8(%r15), %rsi
cmpq %rdx, %rcx
sete %cl
cmpq %rsi, %rax
sete %al
cmpq $0x1, %rdx
sete %dl
orb %cl, %dl
andb %al, %dl
cmpq $0x1, %rsi
sete %al
andb %cl, %al
orb %dl, %al
jne 0x1f044
leaq 0x1dae1(%rip), %rsi     # 0x3caf0
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x51, %edx
movl $0x3, %ecx
callq 0x387b6
leaq 0x1dae2(%rip), %rsi     # 0x3cb0f
movl $0x76, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq %rbx, %rdi
movq %r14, %rsi
callq 0x19326
movq (%r14), %rcx
movq 0x8(%r14), %r8
movq (%r15), %rax
cmpq %rax, %rcx
setne %dl
cmpq $0x1, %rax
setne %sil
testb %sil, %dl
movq %rbx, (%rsp)
jne 0x1f0ed
cmpq 0x8(%r15), %r8
jne 0x1f0ed
addq $0x18, %r14
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
imulq (%rbx), %rdx
movq 0x10(%r15), %rcx
imulq %rax, %r8
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0x958d(%rip), %rax      # 0x2862e
movq %rax, 0x18(%r9)
leaq 0x958a(%rip), %rax      # 0x28636
movq %rax, 0x10(%r9)
movq %r14, %rdi
callq 0xad06
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1f264
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1f264
movq %rbx, %rdi
movq %r15, %rsi
callq 0x19326
movq %rbx, %rax
jmp 0x1f268
testq %rcx, %rcx
je 0x1f264
xorl %ebx, %ebx
leaq 0x1d34e(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %rdx
movq %r15, 0x8(%rsp)
movq 0x8(%r15), %rax
movq %rax, %r13
imulq %rbx, %r13
imulq (%r15), %rax
cmpq %rax, %r13
jae 0x1f221
testq %r8, %r8
je 0x1f20b
movq 0x10(%r15), %rax
movl (%rax,%r13,4), %ebp
xorl %r13d, %r13d
movq %rbx, %r15
imulq %r8, %r15
addq %r13, %r15
imulq (%r14), %r8
cmpq %r8, %r15
jae 0x1f187
movq 0x10(%r14), %rax
movl (%rax,%r15,4), %r15d
addl %ebp, %r15d
movq (%rsp), %rcx
movq 0x8(%rcx), %rax
movq %rbx, %r12
imulq %rax, %r12
addq %r13, %r12
imulq (%rcx), %rax
cmpq %rax, %r12
jae 0x1f1c4
movq 0x10(%rcx), %rax
movl %r15d, (%rax,%r12,4)
incq %r13
movq 0x8(%r14), %r8
cmpq %r8, %r13
jb 0x1f135
jmp 0x1f20e
movq %rdx, %r12
movq %rdx, %rdi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
movl $0x1f, %edx
movq %r12, %rdi
leaq 0x1d375(%rip), %rsi     # 0x3c520
callq 0x93b0
movq %r12, %rdi
callq 0x389de
leaq 0x1d28e(%rip), %rsi     # 0x3c44d
movq %r12, %rdx
jmp 0x1f148
movq %rdx, %rdi
movl $0x50, %edx
movl $0x3, %ecx
callq 0x387b6
movl $0x1f, %edx
leaq 0x10(%rsp), %rdi
leaq 0x1d339(%rip), %rsi     # 0x3c520
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x389de
movq (%rsp), %rcx
leaq 0x1d24c(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %rdx
jmp 0x1f16e
xorl %r8d, %r8d
incq %rbx
cmpq (%r14), %rbx
movq 0x8(%rsp), %r15
jb 0x1f109
jmp 0x1f264
movq %rdx, %rbp
movq %rdx, %rdi
movq %rsi, %r12
movl $0x44, %edx
movl $0x3, %ecx
callq 0x387b6
movl $0x1f, %edx
movq %rbp, %rdi
leaq 0x1d2d8(%rip), %rsi     # 0x3c520
callq 0x93b0
movq %rbp, %rdi
callq 0x389de
movq 0x8(%r14), %r8
movq %r12, %rsi
movq %rbp, %rdx
jmp 0x1f121
movq (%rsp), %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f280
jmp 0x1f28f
jmp 0x1f280
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x389de
jmp 0x1f2c1
movq %rax, %r14
jmp 0x1f2c1
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x389de
jmp 0x1f2ca
jmp 0x1f2d2
movq %rax, %r14
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1f2c1
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq (%rsp), %rdi
callq 0x18494
movq %r14, %rdi
callq 0x95d0
movq %rax, %rdi
callq 0x10f91