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

    CHECK(equal_shape(mat) 
          || (_cols == mat.cols() && mat.rows() == 1)
          || (_rows == mat.rows() && mat.cols() == 1));
    
    if(equal_shape(mat) || (_cols == mat.cols() && mat.rows() == 1)){
        auto lambda = [](T* a, const T& b){*a += b;};
        _po.parallel_mul2mul_repeat(_data, 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++){
                set_data(get_data(i, j) + value, i, j);
            }
        }
    }
    return *this;
}

// Assembly:
subq $0x258, %rsp            # imm = 0x258
movq %rdi, 0x248(%rsp)
movq %rsi, 0x240(%rsp)
movq 0x248(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x317f0
cmpq $0x0, %rax
jne 0x3fa23
movq 0x60(%rsp), %rdi
movq 0x240(%rsp), %rsi
callq 0x31f80
movq 0x60(%rsp), %rax
movq %rax, 0x250(%rsp)
jmp 0x3fd35
movq 0x60(%rsp), %rdi
movq 0x240(%rsp), %rsi
callq 0x339c0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, 0x5f(%rsp)
jne 0x3fad7
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x240(%rsp), %rdi
callq 0x31a20
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
jne 0x3fa8a
movq 0x240(%rsp), %rdi
callq 0x31a10
movq %rax, %rcx
movb $0x1, %al
cmpq $0x1, %rcx
movb %al, 0x5f(%rsp)
je 0x3fad7
movq 0x60(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x240(%rsp), %rdi
callq 0x31a10
movq 0x40(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x4f(%rsp)
jne 0x3facf
movq 0x240(%rsp), %rdi
callq 0x31a20
cmpq $0x1, %rax
sete %al
movb %al, 0x4f(%rsp)
movb 0x4f(%rsp), %al
movb %al, 0x5f(%rsp)
movb 0x5f(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x3fae3
jmp 0x3fb4e
leaq 0x51466(%rip), %rsi     # 0x90f50
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
movl $0x72, %edx
movl $0x3, %ecx
callq 0x89860
movq 0x38(%rsp), %rdi
leaq 0x5145d(%rip), %rsi     # 0x90f6f
callq 0x3f7d0
jmp 0x3fb19
leaq 0xb8(%rsp), %rdi
callq 0x89c20
jmp 0x3fb4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x89c20
jmp 0x3fd45
movq 0x60(%rsp), %rdi
movq 0x240(%rsp), %rsi
callq 0x339c0
testb $0x1, %al
jne 0x3fba7
movq 0x60(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x30(%rsp)
movq 0x240(%rsp), %rdi
callq 0x31a20
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jne 0x3fc64
movq 0x240(%rsp), %rdi
callq 0x31a10
cmpq $0x1, %rax
jne 0x3fc64
movq 0x60(%rsp), %rdi
movq %rdi, %rax
addq $0x18, %rax
movq %rax, (%rsp)
movq 0x10(%rdi), %rax
movq %rax, 0x8(%rsp)
callq 0x317f0
movq %rax, 0x10(%rsp)
movq 0x240(%rsp), %rdi
callq 0x31a30
movq %rax, 0x18(%rsp)
movq 0x240(%rsp), %rdi
callq 0x317f0
movq %rax, 0x20(%rsp)
leaq 0x88(%rsp), %rdi
movq %rdi, 0x28(%rsp)
leaq 0xab(%rsp), %rsi
callq 0x3fd60
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %r8
movq 0x28(%rsp), %r9
callq 0xbb40
jmp 0x3fc2c
leaq 0x88(%rsp), %rdi
callq 0x318a0
jmp 0x3fd28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xb0(%rsp)
movl %eax, 0xac(%rsp)
leaq 0x88(%rsp), %rdi
callq 0x318a0
jmp 0x3fd45
movq $0x0, 0x80(%rsp)
movq 0x60(%rsp), %rcx
movq 0x80(%rsp), %rax
cmpq (%rcx), %rax
jae 0x3fd26
movq 0x240(%rsp), %rdi
movq 0x80(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x31bc0
movl (%rax), %eax
movl %eax, 0x7c(%rsp)
movq $0x0, 0x70(%rsp)
movq 0x60(%rsp), %rcx
movq 0x70(%rsp), %rax
cmpq 0x8(%rcx), %rax
jae 0x3fd0b
movq 0x60(%rsp), %rdi
movq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdx
callq 0x31bc0
movq 0x60(%rsp), %rdi
movl (%rax), %eax
addl 0x7c(%rsp), %eax
movl %eax, 0x6c(%rsp)
movq 0x80(%rsp), %rdx
movq 0x70(%rsp), %rcx
leaq 0x6c(%rsp), %rsi
callq 0x31da0
movq 0x70(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x70(%rsp)
jmp 0x3fcae
jmp 0x3fd0d
movq 0x80(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x80(%rsp)
jmp 0x3fc70
jmp 0x3fd28
movq 0x60(%rsp), %rax
movq %rax, 0x250(%rsp)
movq 0x250(%rsp), %rax
addq $0x258, %rsp            # imm = 0x258
retq
movq 0xb0(%rsp), %rdi
callq 0x9700
nopw %cs:(%rax,%rax)
nopl (%rax)