// File: 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{
    CHECK(equal_shape(mat) 
          || (_cols == mat.cols() && mat.rows() == 1)
          || (_rows == mat.rows() && mat.cols() == 1));
    
    auto 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:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x70(%rsp)
movq %rdi, %rax
movq %rax, 0x78(%rsp)
movq %rdi, 0x270(%rsp)
movq %rsi, 0x268(%rsp)
movq %rdx, 0x260(%rsp)
movq 0x268(%rsp), %rdi
movq %rdi, 0x80(%rsp)
movq 0x260(%rsp), %rsi
callq 0x339c0
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, 0x8b(%rsp)
jne 0x4008a
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x260(%rsp), %rdi
callq 0x31a20
movq %rax, %rcx
movq 0x68(%rsp), %rax
cmpq %rcx, %rax
jne 0x40037
movq 0x260(%rsp), %rdi
callq 0x31a10
movq %rax, %rcx
movb $0x1, %al
cmpq $0x1, %rcx
movb %al, 0x8b(%rsp)
je 0x4008a
movq 0x80(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x260(%rsp), %rdi
callq 0x31a10
movq 0x58(%rsp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, 0x67(%rsp)
jne 0x4007f
movq 0x260(%rsp), %rdi
callq 0x31a20
cmpq $0x1, %rax
sete %al
movb %al, 0x67(%rsp)
movb 0x67(%rsp), %al
movb %al, 0x8b(%rsp)
movb 0x8b(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x40099
jmp 0x40104
leaq 0x50eb0(%rip), %rsi     # 0x90f50
leaq 0xd8(%rsp), %rdi
movq %rdi, 0x50(%rsp)
movl $0x8e, %edx
movl $0x3, %ecx
callq 0x89860
movq 0x50(%rsp), %rdi
leaq 0x50ea7(%rip), %rsi     # 0x90f6f
callq 0x3f7d0
jmp 0x400cf
leaq 0xd8(%rsp), %rdi
callq 0x89c20
jmp 0x40104
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x89c20
jmp 0x403a9
movq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdi
movb $0x0, 0xcb(%rsp)
callq 0x331e0
movq 0x80(%rsp), %rdi
movq 0x260(%rsp), %rsi
callq 0x339c0
movb %al, 0x4f(%rsp)
jmp 0x40139
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x40189
jmp 0x40143
movq 0x80(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x260(%rsp), %rdi
callq 0x31a20
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jne 0x4026c
movq 0x260(%rsp), %rdi
callq 0x31a10
cmpq $0x1, %rax
jne 0x4026c
movq 0x70(%rsp), %rdi
movq 0x80(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x10(%rsp)
callq 0x31a30
movq 0x70(%rsp), %rdi
movq %rax, 0x18(%rsp)
callq 0x317f0
movq %rax, 0x20(%rsp)
movq 0x260(%rsp), %rdi
callq 0x31a30
movq %rax, 0x28(%rsp)
movq 0x260(%rsp), %rdi
callq 0x317f0
movq %rax, 0x30(%rsp)
leaq 0xa8(%rsp), %rdi
movq %rdi, 0x38(%rsp)
leaq 0xca(%rsp), %rsi
callq 0x403c0
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0xbb40
jmp 0x4021b
leaq 0xa8(%rsp), %rdi
callq 0x318a0
jmp 0x40376
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
jmp 0x4039f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xd0(%rsp)
movl %eax, 0xcc(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x318a0
jmp 0x4039f
movq $0x0, 0xa0(%rsp)
movq 0x80(%rsp), %rcx
movq 0xa0(%rsp), %rax
cmpq (%rcx), %rax
jae 0x40374
movq 0x260(%rsp), %rdi
movq 0xa0(%rsp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x31bc0
movq %rax, 0x8(%rsp)
jmp 0x402b1
movq 0x8(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x9c(%rsp)
movq $0x0, 0x90(%rsp)
movq 0x80(%rsp), %rcx
movq 0x90(%rsp), %rax
cmpq 0x8(%rcx), %rax
jae 0x40359
movq 0x80(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x90(%rsp), %rdx
callq 0x31bc0
movq %rax, (%rsp)
jmp 0x40304
movq 0x70(%rsp), %rdi
movq (%rsp), %rax
movl (%rax), %eax
movl 0x9c(%rsp), %ecx
subl %ecx, %eax
movl %eax, 0x8c(%rsp)
movq 0xa0(%rsp), %rdx
movq 0x90(%rsp), %rcx
leaq 0x8c(%rsp), %rsi
callq 0x31da0
jmp 0x4033e
jmp 0x40340
movq 0x90(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x90(%rsp)
jmp 0x402cb
jmp 0x4035b
movq 0xa0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xa0(%rsp)
jmp 0x40278
jmp 0x40376
movb $0x1, 0xcb(%rsp)
testb $0x1, 0xcb(%rsp)
jne 0x40392
movq 0x70(%rsp), %rdi
callq 0x31a40
movq 0x78(%rsp), %rax
addq $0x278, %rsp            # imm = 0x278
retq
movq 0x70(%rsp), %rdi
callq 0x31a40
movq 0xd0(%rsp), %rdi
callq 0x9700
nopw %cs:(%rax,%rax)