// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
movq %rdi, %rbx
movq (%rsi), %rcx
movq 0x8(%rsi), %rax
movq %rax, %rdx
imulq %rcx, %rdx
testq %rdx, %rdx
je 0x1f3c7
movq %rsi, %r14
movq (%r13), %rdx
movq 0x8(%r13), %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 0x1f331
leaq 0x1d7f4(%rip), %rsi     # 0x3caf0
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movl $0x51, %edx
movl $0x3, %ecx
callq 0x3894e
leaq 0x1d7f5(%rip), %rsi     # 0x3cb0f
movl $0x76, %edx
movq %r12, %rdi
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x38b76
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1957e
movq (%r13), %rax
cmpq %rax, (%r14)
setne %cl
cmpq $0x1, %rax
setne %dl
testb %dl, %cl
movq %rbx, (%rsp)
jne 0x1f3da
movq 0x8(%r13), %r8
cmpq %r8, 0x8(%r14)
jne 0x1f3da
addq $0x18, %r14
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rsi
imulq (%rbx), %rdx
movq 0x10(%r13), %rcx
imulq %rax, %r8
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %r9
movaps %xmm0, (%r9)
leaq 0x9408(%rip), %rax      # 0x28796
movq %rax, 0x18(%r9)
leaq 0x9405(%rip), %rax      # 0x2879e
movq %rax, 0x10(%r9)
movq %r14, %rdi
callq 0xada2
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1f555
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x1f555
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1957e
movq %rbx, %rax
jmp 0x1f559
cmpq $0x0, (%r14)
je 0x1f555
xorl %ebx, %ebx
leaq 0x1d060(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %rdx
movq %r13, 0x8(%rsp)
movq 0x8(%r13), %rax
movq %rax, %r15
imulq %rbx, %r15
imulq (%r13), %rax
cmpq %rax, %r15
jae 0x1f516
movq 0x8(%r14), %rax
testq %rax, %rax
je 0x1f503
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rcx
movl (%rcx,%r15,4), %ebp
xorl %r13d, %r13d
movq %rbx, %r15
imulq %rax, %r15
addq %r13, %r15
imulq (%r14), %rax
cmpq %rax, %r15
jae 0x1f47f
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 0x1f4bc
movq 0x10(%rcx), %rax
movl %r15d, (%rax,%r12,4)
incq %r13
movq 0x8(%r14), %rax
cmpq %rax, %r13
jb 0x1f42d
jmp 0x1f503
movq %rdx, %r12
movq %rdx, %rdi
movl $0x44, %edx
movl $0x3, %ecx
callq 0x3894e
movl $0x1f, %edx
movq %r12, %rdi
leaq 0x1d07d(%rip), %rsi     # 0x3c520
callq 0x93b0
movq %r12, %rdi
callq 0x38b76
leaq 0x1cf96(%rip), %rsi     # 0x3c44d
movq %r12, %rdx
jmp 0x1f440
movq %rdx, %rdi
movl $0x50, %edx
movl $0x3, %ecx
callq 0x3894e
movl $0x1f, %edx
leaq 0x10(%rsp), %rdi
leaq 0x1d041(%rip), %rsi     # 0x3c520
callq 0x93b0
leaq 0x10(%rsp), %rdi
callq 0x38b76
movq (%rsp), %rcx
leaq 0x1cf54(%rip), %rsi     # 0x3c44d
leaq 0x10(%rsp), %rdx
jmp 0x1f466
incq %rbx
cmpq (%r14), %rbx
movq 0x8(%rsp), %r13
jb 0x1f3f7
jmp 0x1f555
movq %rdx, %rbp
movq %rdx, %rdi
movq %rsi, %r12
movl $0x44, %edx
movl $0x3, %ecx
callq 0x3894e
movl $0x1f, %edx
movq %rbp, %rdi
leaq 0x1cfe3(%rip), %rsi     # 0x3c520
callq 0x93b0
movq %rbp, %rdi
callq 0x38b76
movq %r12, %rsi
movq %rbp, %rdx
jmp 0x1f410
movq (%rsp), %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1f571
jmp 0x1f580
jmp 0x1f571
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x38b76
jmp 0x1f5b2
movq %rax, %r14
jmp 0x1f5b2
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x38b76
jmp 0x1f5bb
jmp 0x1f5c3
movq %rax, %r14
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0x1f5b2
leaq 0x10(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq (%rsp), %rdi
callq 0x186ec
movq %r14, %rdi
callq 0x95d0
movq %rax, %rdi
callq 0x112c8
nop