LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::_mul_ComputeSection(Matrix&, Matrix&, unsigned long, unsigned long, unsigned long, unsigned long)
void Matrix::_mul_ComputeSection(Matrix &B, Matrix &C, size_t r1, size_t r2, size_t c1, size_t c2)
{
    // compute a section of C
    if(r1 >= r2 || c1 >= c2) {
        return;
    }
    if( (int)r1<0 || r2>this->size() || (int)c1<0 || c2>B[0].size()) {
        std::cout<<"Error: matrix out of range."<<std::endl;
        exit(0);
    }
    if(C.size() != this->size() || C[0].size() != B[0].size() ) {
        std::cout<<"Error: matrix not match."<<std::endl;
        exit(0);
    }

    for(size_t i=r1; i<r2;i++){
        for(size_t j=c1;j<c2;j++){
            C[i][j] = _mul_ComputeElement(B, i, j);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rcx, %r15
movq %rdx, %rcx
movq 0x50(%rsp), %rbx
movq %r8, 0x8(%rsp)
cmpq %r8, %r15
setae %al
movq %r9, (%rsp)
cmpq %rbx, %r9
setae %dl
orb %al, %dl
jne 0x18496
testl %r15d, %r15d
js 0x184a5
movq %rsi, %r12
movq %rdi, %r13
movq 0x8(%rdi), %rsi
subq (%rdi), %rsi
pushq $0x18
popq %rdi
movq %rsi, %rax
cqto
idivq %rdi
cmpl $0x0, (%rsp)
js 0x184a5
cmpq 0x8(%rsp), %rax
jb 0x184a5
movq (%r12), %rdx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbx, %rdx
jb 0x184a5
movq (%rcx), %rdx
movq 0x8(%rcx), %rcx
subq %rdx, %rcx
cmpq %rsi, %rcx
jne 0x184b5
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
cmpq %rax, %rcx
jne 0x184b5
movq %rdx, 0x10(%rsp)
cmpq 0x8(%rsp), %r15
jae 0x18496
imulq $0x18, %r15, %r14
addq %rdx, %r14
movq (%rsp), %rbp
cmpq %rbx, %rbp
jae 0x1848c
movq %r13, %rdi
movq %r12, %rsi
movq %r15, %rdx
movq %rbp, %rcx
callq 0x184d8
movq (%r14), %rax
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
jmp 0x18469
incq %r15
movq 0x10(%rsp), %rdx
jmp 0x18457
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1ab2c(%rip), %rdi     # 0x32fd8
leaq 0xbc71(%rip), %rsi      # 0x24124
jmp 0x184c3
movq 0x1ab1c(%rip), %rdi     # 0x32fd8
leaq 0xbc7d(%rip), %rsi      # 0x24140
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::_mul_ComputeElement(Matrix&, unsigned long, unsigned long)
double Matrix::_mul_ComputeElement(Matrix &B, size_t r, size_t c)
{
    // compute an element in the result matrix, 
    // B is multiplied to this matrix: AxB = C
    double s = 0;
    for(size_t i=0;i<(*this)[0].size();i++){
        s += (*this)[r][i] * B[i][c];
    }
    return s;
}

// Assembly:
movq (%rdi), %rdi
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x3, %rax
imulq $0x18, %rdx, %rdx
addq %rdi, %rdx
movq (%rsi), %rsi
xorpd %xmm0, %xmm0
xorl %edi, %edi
cmpq %rdi, %rax
je 0x1851a
movq (%rdx), %r8
movsd (%r8,%rdi,8), %xmm1
movq (%rsi), %r8
mulsd (%r8,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rdi
addq $0x18, %rsi
jmp 0x184f6
retq
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: operator<<(std::ostream&, Matrix&)
std::ostream& operator<<(std::ostream &os, Matrix& A)
{
    // overload cout for Matrix
    for(size_t i=0;i<A.size();i++){
        os<<A[i];
    }
    return os;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
xorl %r15d, %r15d
pushq $0x18
popq %r12
xorl %r13d, %r13d
movq (%r14), %rsi
movq 0x8(%r14), %rax
subq %rsi, %rax
cqto
idivq %r12
cmpq %rax, %r13
jae 0x18592
addq %r15, %rsi
movq %rbx, %rdi
callq 0x1859f
incq %r13
addq $0x18, %r15
jmp 0x1856a
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: operator<<(std::ostream&, std::vector<double, std::allocator<double>>&)
std::ostream& operator<<(std::ostream &os, std::vector<double>& A)
{
    // overload cout for vector
    for(size_t i=0;i<A.size();i++){
        os<<std::setfill(' ')<<std::setw(18)<<std::setprecision(6)<<A[i];
    }
    os<<std::endl;
    return os;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %r15d, %r15d
pushq $0x20
popq %rbp
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x3, %rax
movq %rbx, %rdi
cmpq %rax, %r15
jae 0x185ff
movl %ebp, %esi
callq 0x4300
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0x12, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rcx
movq $0x6, 0x8(%rax,%rcx)
movq (%r14), %rcx
movsd (%rcx,%r15,8), %xmm0
movq %rax, %rdi
callq 0x4320
incq %r15
jmp 0x185b2
callq 0x4130
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Random()
void Matrix::Random()
{
    // fill with random numbers
    // uniform (0,1) distribution
    //std::cout<<"Filling matrix using flat (0, 1) distribution"<<std::endl;
    std::random_device rd;
    std::mt19937 mt(rd());
    //unsigned int SEED = seed;
    //std::mt19937 mt(SEED);
    //seed = seed + 1;
    std::uniform_real_distribution<double> dist(0, 1.);

    for(size_t i=0;i<__M.size();i++){
        for(size_t j=0;j<__M[0].size();j++){
            __M[i][j] = dist(mt);
        }
    }
    //std::cout<<"Fill finished."<<std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2728, %rsp           # imm = 0x2728
movq %rdi, %rbx
leaq 0x18(%rsp), %r14
movq %r14, %rdi
callq 0x11a0a
movq %r14, %rdi
callq 0x42b0
movl %eax, %esi
leaq 0x13a0(%rsp), %rdi
callq 0x131a2
xorps %xmm0, %xmm0
movhps 0x8ebc(%rip), %xmm0     # xmm0 = xmm0[0,1],mem[0,1]
movq %rsp, %r14
movaps %xmm0, (%r14)
movq (%rbx), %rcx
xorl %r12d, %r12d
leaq 0x13a0(%rsp), %r15
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %r12
jae 0x186b6
imulq $0x18, %r12, %rbp
xorl %r13d, %r13d
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
cmpq %rax, %r13
jae 0x186b1
movq %r14, %rdi
movq %r15, %rsi
callq 0x1a922
movq (%rbx), %rcx
movq (%rcx,%rbp), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
jmp 0x18684
incq %r12
jmp 0x18669
leaq 0x18(%rsp), %rdi
callq 0x11a8e
addq $0x2728, %rsp           # imm = 0x2728
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x186d4
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x11a8e
movq %rbx, %rdi
callq 0x43b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Random(double, double)
void Matrix::Random(double min, double max)
{
    // fill with random numbers
    // uniform (0,1) distribution
    //std::cout<<"Filling matrix using flat (0, 1) distribution"<<std::endl;
    std::random_device rd;
    std::mt19937 mt(rd());
    //unsigned int SEED = seed;
    //std::mt19937 mt(SEED);
    //seed = seed+1;
    std::uniform_real_distribution<double> dist(min, max);

    for(size_t i=0;i<__M.size();i++){
        for(size_t j=0;j<__M[0].size();j++){
            __M[i][j] = dist(mt);
        }
    }
    //std::cout<<"Fill finished."<<std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2738, %rsp           # imm = 0x2738
movsd %xmm1, 0x10(%rsp)
movsd %xmm0, 0x8(%rsp)
movq %rdi, %rbx
leaq 0x28(%rsp), %r14
movq %r14, %rdi
callq 0x11a0a
movq %r14, %rdi
callq 0x42b0
movl %eax, %esi
leaq 0x13b0(%rsp), %rdi
callq 0x131a2
leaq 0x18(%rsp), %r14
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%r14)
movsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x8(%r14)
movq (%rbx), %rcx
xorl %r12d, %r12d
leaq 0x13b0(%rsp), %r15
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %r12
jae 0x187a5
imulq $0x18, %r12, %rbp
xorl %r13d, %r13d
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
cmpq %rax, %r13
jae 0x187a0
movq %r14, %rdi
movq %r15, %rsi
callq 0x1a922
movq (%rbx), %rcx
movq (%rcx,%rbp), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
jmp 0x18773
incq %r12
jmp 0x18758
leaq 0x28(%rsp), %rdi
callq 0x11a8e
addq $0x2738, %rsp           # imm = 0x2738
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x187c3
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x11a8e
movq %rbx, %rdi
callq 0x43b0
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::RandomGaus(double, double)
void Matrix::RandomGaus(double mu, double sigma)
{
    // fill with random numbers
    // uniform (0,1) distribution
    //std::cout<<"Filling matrix using flat (0, 1) distribution"<<std::endl;
    //std::random_device rd;
    //std::mt19937 mt(rd());

    unsigned int SEED = seed;
    std::mt19937 mt(SEED);
    seed = seed + 1;

    std::normal_distribution<double> dist(mu, sigma);
    for(size_t i=0;i<__M.size();i++){
        for(size_t j=0;j<__M[0].size();j++){
            __M[i][j] = dist(mt);
        }
    }
    //std::cout<<"Fill finished."<<std::endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x13b8, %rsp           # imm = 0x13B8
movsd %xmm1, 0x8(%rsp)
movsd %xmm0, (%rsp)
movq %rdi, %rbx
movl 0x1aa13(%rip), %esi     # 0x33210
leaq 0x30(%rsp), %r14
movq %r14, %rdi
callq 0x131a2
movl 0x1aa00(%rip), %eax     # 0x33210
incl %eax
xchgl %eax, 0x1a9f8(%rip)     # 0x33210
leaq 0x10(%rsp), %r15
movsd (%rsp), %xmm0
movsd %xmm0, (%r15)
movsd 0x8(%rsp), %xmm0
movsd %xmm0, 0x8(%r15)
andq $0x0, 0x10(%r15)
movb $0x0, 0x18(%r15)
movq (%rbx), %rcx
xorl %r12d, %r12d
movq 0x8(%rbx), %rax
subq %rcx, %rax
cqto
pushq $0x18
popq %rsi
idivq %rsi
cmpq %rax, %r12
jae 0x18890
imulq $0x18, %r12, %rbp
xorl %r13d, %r13d
movq 0x8(%rcx), %rax
subq (%rcx), %rax
sarq $0x3, %rax
cmpq %rax, %r13
jae 0x1888b
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a92a
movq (%rbx), %rcx
movq (%rcx,%rbp), %rax
movsd %xmm0, (%rax,%r13,8)
incq %r13
jmp 0x1885e
incq %r12
jmp 0x18843
addq $0x13b8, %rsp           # imm = 0x13B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::operator()(double (*)(double), unsigned long, unsigned long, unsigned long, unsigned long)
void Matrix::operator()(double(*functor)(double), size_t r1, size_t r2, size_t c1, size_t c2)
{
    // pass a functor, apply to a region of the matrix
    if( (int)r1<0 || r2>(*this).size() || r2 <= r1 || c2 <= c1
            || (int)c1<0 || c2 > (*this)[0].size()
      ) 
        return;

    for(size_t i=r1;i<r2;i++){
        for(size_t j=c1;j<c2;j++){
            (*this)[i][j] = (*functor)( (*this)[i][j] );
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, 0x8(%rsp)
movq %rdx, %r12
testl %r12d, %r12d
js 0x18932
movq %rsi, %r13
movq %rdi, %rbp
movq (%rdi), %rdi
movq 0x8(%rbp), %rax
subq %rdi, %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
cmpq %r12, %rcx
jbe 0x18932
cmpq %rcx, %rax
jb 0x18932
movq %r9, %rbx
movq 0x8(%rsp), %rdx
cmpq %rdx, %r9
setbe %al
testl %edx, %edx
sets %dl
orb %al, %dl
jne 0x18932
movq 0x8(%rdi), %rax
subq (%rdi), %rax
sarq $0x3, %rax
cmpq %rbx, %rax
jae 0x18941
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, 0x10(%rsp)
cmpq %rcx, %r12
jae 0x18932
imulq $0x18, %r12, %r14
movq 0x8(%rsp), %r15
cmpq %rbx, %r15
jae 0x18979
movq (%rdi,%r14), %rax
movsd (%rax,%r15,8), %xmm0
callq *%r13
movq (%rbp), %rdi
movq (%rdi,%r14), %rax
movsd %xmm0, (%rax,%r15,8)
incq %r15
jmp 0x18954
incq %r12
movq 0x10(%rsp), %rcx
jmp 0x18946
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::operator==(Matrix&)
bool Matrix::operator==(Matrix &m)
{
    auto dim = m.Dimension();
    if(Dimension() != dim) return false;

    for(size_t i=0;i<dim.first;i++)
        for(size_t j=0;j<dim.second;j++)
        {
            //if(m[i][j] != (*this)[i][j]) return false;
            if(abs(m[i][j] - (*this)[i][j]) > 1.e-6) return false;
        }

    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r15
movq %rsi, %rdi
callq 0x17a6a
movq %rax, %rbx
movq %rdx, %r14
movq %r15, %rdi
callq 0x17a6a
xorq %rbx, %rax
xorq %r14, %rdx
orq %rax, %rdx
je 0x189c1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r12), %rax
movq (%r15), %rcx
xorl %edx, %edx
cmpq %rbx, %rdx
je 0x18a08
imulq $0x18, %rdx, %rsi
leaq (%rax,%rsi), %rdi
addq %rcx, %rsi
xorl %r8d, %r8d
cmpq %r8, %r14
je 0x18a03
movq (%rdi), %r9
movsd (%r9,%r8,8), %xmm0
movq (%rsi), %r9
subsd (%r9,%r8,8), %xmm0
cvttsd2si %xmm0, %r9d
incq %r8
testl %r9d, %r9d
je 0x189dd
jmp 0x189b3
incq %rdx
jmp 0x189ca
movb $0x1, %al
jmp 0x189b5
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Reshape(unsigned long, unsigned long) const
Matrix Matrix::Reshape(size_t m, size_t n) const
{
    // reshape matrix from original (p, q) to (m, n)
    size_t p = this->size();
    size_t q = (*(const_cast<Matrix*>(this)))[0].size();
    size_t T = p*q; // total # of elements

    if(m==0 || n==0 || p==0 || q==0 || T != m*n) {
        std::cout<<"Error: Reshape matrix dimension not match"<<std::endl;
        exit(0);
    }

    Matrix res(m, n);
    for(size_t i=0;i<T;i++){
        size_t new_x = i/n, new_y = i%n;
        size_t old_x = i/q, old_y = i%q;

        res[new_x][new_y] = (*(const_cast<Matrix*>(this)))[old_x][old_y];
    }

    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rcx, %rbx
movq %rdx, %rcx
movq %rsi, %r12
movq %rdi, %r14
movq (%rsi), %rsi
movq 0x8(%r12), %rdi
movq %rdi, %rax
subq %rsi, %rax
pushq $0x18
popq %r8
cqto
idivq %r8
testq %rcx, %rcx
je 0x18ad7
testq %rbx, %rbx
je 0x18ad7
cmpq %rsi, %rdi
je 0x18ad7
movq %rax, %r15
movq (%rsi), %rax
movq 0x8(%rsi), %r13
cmpq %rax, %r13
je 0x18ad7
subq %rax, %r13
sarq $0x3, %r13
imulq %r13, %r15
movq %rbx, %rax
imulq %rcx, %rax
cmpq %rax, %r15
jne 0x18ad7
movq %r14, %rdi
movq %rcx, %rsi
movq %rbx, %rdx
callq 0x176e6
movq (%r12), %r8
movq (%r14), %r9
xorl %ecx, %ecx
cmpq %rcx, %r15
je 0x18aca
movq %rcx, %rax
xorl %edx, %edx
divq %rbx
movq %rdx, %rsi
movq %rax, %rdi
movq %rcx, %rax
xorl %edx, %edx
divq %r13
imulq $0x18, %rax, %rax
movq (%r8,%rax), %rax
movsd (%rax,%rdx,8), %xmm0
imulq $0x18, %rdi, %rax
movq (%r9,%rax), %rax
movsd %xmm0, (%rax,%rsi,8)
incq %rcx
jmp 0x18a90
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x1a4fa(%rip), %rdi     # 0x32fd8
leaq 0xb674(%rip), %rsi      # 0x24159
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::MinInSection(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::MinInSection(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find max element in section [i_start, i_end), and [j_start, j_end)
    // in this code, we all follow the rule: close front and open end
    // and all counters start from 0
    auto dim = Dimension();
    if((int)i_start < 0 || (int)j_start < 0 || i_end <= i_start || j_end <= j_start || i_end > dim.first || j_end > dim.second){
        std::cout<<"Error: Min in matrix section: exceeded range."<<std::endl;
        exit(0);
    }
    double res = __M[i_start][j_start];
    for(size_t i=i_start;i<i_end;i++){
        for(size_t j=j_start;j<j_end;j++){
            if(res > __M[i][j])
                res = __M[i][j];
        }
    }
    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
callq 0x17a6a
cmpq %r14, %rbx
jbe 0x18d53
cmpq %r12, %r15
jbe 0x18d53
movl %r14d, %ecx
orl %r12d, %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
jne 0x18d53
cmpq %r15, %rax
jb 0x18d53
cmpq %rbx, %rdx
jb 0x18d53
movq (%r13), %rax
imulq $0x18, %r12, %rcx
movq (%rax,%rcx), %rcx
movsd (%rcx,%r14,8), %xmm0
cmpq %r15, %r12
jae 0x18d49
imulq $0x18, %r12, %rcx
addq %rax, %rcx
movq %r14, %rdx
cmpq %rbx, %rdx
jae 0x18d44
movq (%rcx), %rsi
movsd (%rsi,%rdx,8), %xmm1
minsd %xmm0, %xmm1
incq %rdx
movapd %xmm1, %xmm0
jmp 0x18d2a
incq %r12
jmp 0x18d1b
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x1a27e(%rip), %rdi     # 0x32fd8
leaq 0xb70a(%rip), %rsi      # 0x2446b
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::MaxInSection(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::MaxInSection(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find max element in section [i_start, i_end), and [j_start, j_end)
    // in this code, we all follow the rule: close front and open end
    // and all counters start from 0
    auto dim = Dimension();
    if((int)i_start < 0 || (int)j_start < 0 || i_end <= i_start || j_end <= j_start || i_end > dim.first || j_end > dim.second){
        std::cout<<"Error: Max in matrix section: exceeded range."<<std::endl;
        exit(0);
    }
    double res = __M[i_start][j_start];
    for(size_t i=i_start;i<i_end;i++){
        for(size_t j=j_start;j<j_end;j++){
            if(res < __M[i][j])
                res = __M[i][j];
        }
    }
    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
callq 0x17a6a
cmpq %r14, %rbx
jbe 0x18dff
cmpq %r12, %r15
jbe 0x18dff
movl %r14d, %ecx
orl %r12d, %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
jne 0x18dff
cmpq %r15, %rax
jb 0x18dff
cmpq %rbx, %rdx
jb 0x18dff
movq (%r13), %rax
imulq $0x18, %r12, %rcx
movq (%rax,%rcx), %rcx
movsd (%rcx,%r14,8), %xmm0
cmpq %r15, %r12
jae 0x18df5
imulq $0x18, %r12, %rcx
addq %rax, %rcx
movq %r14, %rdx
cmpq %rbx, %rdx
jae 0x18df0
movq (%rcx), %rsi
movsd (%rsi,%rdx,8), %xmm1
maxsd %xmm0, %xmm1
incq %rdx
movapd %xmm1, %xmm0
jmp 0x18dd6
incq %r12
jmp 0x18dc7
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x1a1d2(%rip), %rdi     # 0x32fd8
leaq 0xb68c(%rip), %rsi      # 0x24499
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Transpose()
Matrix Matrix::Transpose()
{
    // transpose current matrix
    auto d = Dimension();
    Matrix _m(d.second, d.first);
    for(size_t i=0;i<d.first;i++){
        for(size_t j=0;j<d.second;j++){
            _m[j][i] = __M[i][j];
        }
    }
    return _m;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x17a6a
movq %rax, %r15
movq %rdx, %r12
movq %rbx, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x176e6
xorl %eax, %eax
cmpq %r15, %rax
je 0x18e82
imulq $0x18, %rax, %rcx
addq (%r14), %rcx
movq (%rbx), %rdx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x18e7d
movq (%rcx), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%rdx), %rdi
movsd %xmm0, (%rdi,%rax,8)
incq %rsi
addq $0x18, %rdx
jmp 0x18e5f
incq %rax
jmp 0x18e4e
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::FillElementByRow(unsigned long, double)
void Matrix::FillElementByRow(size_t index, double v)
{
    // fill an element to this matrix, row first
    auto dim = Dimension();
    size_t i = index/dim.second;
    size_t j = index%dim.second;
    if(i >= dim.first || j>= dim.second) {
        std::cout<<"Error: filling matrix exceeded range."<<std::endl;
        exit(0);
    }
    __M[i][j] = v;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rsi, %r14
movq %rdi, %rbx
callq 0x17a6a
movq %rax, %rcx
movq %rdx, %rsi
movq %r14, %rax
xorl %edx, %edx
divq %rsi
cmpq %rcx, %rax
jae 0x18f4c
movq (%rbx), %rcx
imulq $0x18, %rax, %rax
movq (%rcx,%rax), %rax
movsd (%rsp), %xmm0
movsd %xmm0, (%rax,%rdx,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x1a085(%rip), %rdi     # 0x32fd8
leaq 0xb229(%rip), %rsi      # 0x24183
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::FillElementByCollum(unsigned long, double)
void Matrix::FillElementByCollum(size_t index, double v)
{
    // fill an element to this matrix, collum first
    auto dim = Dimension();
    size_t i = index%dim.first;
    size_t j = index/dim.first;
    if(i >= dim.first || j>= dim.second) {
        std::cout<<"Error: filling matrix exceeded range."<<std::endl;
        exit(0);
    }
    __M[i][j] = v;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movsd %xmm0, (%rsp)
movq %rsi, %r14
movq %rdi, %rbx
callq 0x17a6a
movq %rax, %rcx
movq %rdx, %rsi
movq %r14, %rax
xorl %edx, %edx
divq %rcx
cmpq %rsi, %rax
jae 0x18fb2
movq (%rbx), %rcx
imulq $0x18, %rdx, %rdx
movq (%rcx,%rdx), %rcx
movsd (%rsp), %xmm0
movsd %xmm0, (%rcx,%rax,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x1a01f(%rip), %rdi     # 0x32fd8
leaq 0xb1c3(%rip), %rsi      # 0x24183
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::ElementSum()
double Matrix::ElementSum()
{
    // sum all elements together
    double res = 0;
    auto dim = Dimension();
    for(size_t i=0;i<dim.first;i++){
        for(size_t j=0;j<dim.second;j++){
            res += __M[i][j];
        }
    }
    return res;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x17a6a
movq (%rbx), %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
cmpq %rax, %rsi
je 0x1900d
imulq $0x18, %rsi, %rdi
addq %rcx, %rdi
xorl %r8d, %r8d
cmpq %r8, %rdx
je 0x19008
movq (%rdi), %r9
addsd (%r9,%r8,8), %xmm0
incq %r8
jmp 0x18ff5
incq %rsi
jmp 0x18fe6
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::GetSection(unsigned long, unsigned long, unsigned long, unsigned long, bool, double)
Matrix Matrix::GetSection(size_t r_s, size_t r_e, size_t c_s, size_t c_e, 
        bool padding, double padding_value)
{
    // get a section of this matrix
    auto dim = Dimension();

    if( c_e <= c_s || r_e <= r_s || (int)c_s<0 || (int)r_s<0 || r_s>=dim.first || c_s>=dim.second ) 
    {
        std::cout<<"Error: wrong index provided in fetching matrix section."<<std::endl;
        std::cout<<"       front close, back open."<<std::endl;
        exit(0);
    }

    if(!padding) {
        if(r_e > dim.first || c_e > dim.second) {
            std::cout<<"Error: matrix fetching section exceeded range."<<std::endl;
            exit(0);
        }
    }

    Matrix _m(r_e - r_s, c_e - c_s);
    for(size_t i=0;i<(r_e-r_s);i++)
    {
        for(size_t j=0;j<(c_e-c_s);j++){
            if( (r_s + i) < dim.first && (c_s + j) < dim.second ){
                _m[i][j] = __M[r_s+i][c_s+j];
            } else {
                _m[i][j] = padding_value;
            }
        }
    }
    return _m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movsd %xmm0, 0x8(%rsp)
movq %r9, %r15
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r14
movq %rdi, (%rsp)
movq %rsi, 0x10(%rsp)
movq %rsi, %rdi
callq 0x17a6a
movq %rdx, %rbp
movq %r12, %rdx
movq %r15, %r12
subq %rbx, %r12
jbe 0x1912b
movq %r15, %rcx
movq %rdx, %r15
subq %r14, %r15
jbe 0x1912b
movq %rax, %r13
movl %ebx, %eax
orl %r14d, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1912b
cmpq %r14, %r13
jbe 0x1912b
cmpq %rbx, %rbp
jbe 0x1912b
cmpb $0x0, 0x50(%rsp)
jne 0x190a0
cmpq %rdx, %r13
jb 0x19167
cmpq %rcx, %rbp
jb 0x19167
movq (%rsp), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x176e6
movq (%rsp), %rax
leaq (,%rbx,8), %r11
xorl %ecx, %ecx
movsd 0x8(%rsp), %xmm1
cmpq %r15, %rcx
je 0x1911c
leaq (%rcx,%r14), %rdx
imulq $0x18, %rcx, %rsi
addq (%rax), %rsi
imulq $0x18, %rdx, %rdi
movq 0x10(%rsp), %r8
addq (%r8), %rdi
xorl %r8d, %r8d
cmpq %r8, %r12
je 0x19117
cmpq %r13, %rdx
jae 0x19106
leaq (%rbx,%r8), %r10
movq (%rsi), %r9
cmpq %rbp, %r10
jae 0x19109
movq (%rdi), %r10
addq %r11, %r10
movsd (%r10,%r8,8), %xmm0
jmp 0x1910c
movq (%rsi), %r9
movaps %xmm1, %xmm0
movsd %xmm0, (%r9,%r8,8)
incq %r8
jmp 0x190e2
incq %rcx
jmp 0x190c3
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19ea6(%rip), %rbx     # 0x32fd8
leaq 0xb070(%rip), %rsi      # 0x241a9
movq %rbx, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
leaq 0xb091(%rip), %rsi      # 0x241e1
movq %rbx, %rdi
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
movq 0x19e6a(%rip), %rdi     # 0x32fd8
leaq 0xb08b(%rip), %rsi      # 0x24200
jmp 0x19153
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Padding(unsigned long, unsigned long, bool, double)
Matrix Matrix::Padding(size_t ROW, size_t COL, bool pad_front, double padding_value)
{
    // matrix padding, only two modes supported: 1) only pad back, 2) pad back and front
    // only pad front not supported, b/c it's not useful reallistically
    auto dim = Dimension();
    if(ROW < dim.first || COL < dim.second) {
        std::cout<<"Error: trying pad matrix to a smaller size, no padding needed."<<std::endl;
        exit(0);
    }

    Matrix _m(ROW, COL, padding_value);
    if( ! pad_front){ // only pad back
        for(size_t i=0;i<dim.first;i++){
            for(size_t j=0;j<dim.second;j++){
                _m[i][j] = __M[i][j];
            }
        }
    } else { // pad back and front
        size_t extra_row = ROW - dim.first, extra_col = COL - dim.second;
        size_t extra_front_row = extra_row/2, extra_front_col = extra_col/2;
        for(size_t i=0;i<dim.first;i++){
            for(size_t j=0;j<dim.second;j++){
                _m[extra_front_row+i][extra_front_col+j] = __M[i][j];
            }
        }
    }

    return _m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movsd %xmm0, 0x10(%rsp)
movl %r8d, 0xc(%rsp)
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x17a6a
movq %r13, %rbp
subq %rax, %rbp
jb 0x19277
movq %r15, %rcx
movq %rdx, %r12
movq %r13, %rsi
movq %r15, %r13
subq %rdx, %r13
jb 0x19277
movq %rax, %r15
movq %rbx, %rdi
movq %rcx, %rdx
movsd 0x10(%rsp), %xmm0
callq 0x177ee
cmpb $0x0, 0xc(%rsp)
je 0x19230
shrq %rbp
shlq $0x2, %r13
andq $-0x8, %r13
xorl %eax, %eax
imulq $0x18, %rbp, %rcx
cmpq %r15, %rax
je 0x19265
imulq $0x18, %rax, %rdi
movq (%r14), %rdx
addq %rdi, %rdx
movq (%rbx), %rsi
addq %rcx, %rsi
addq %rdi, %rsi
xorl %edi, %edi
cmpq %rdi, %r12
je 0x1922b
movq (%rdx), %r8
movsd (%r8,%rdi,8), %xmm0
movq (%rsi), %r8
addq %r13, %r8
movsd %xmm0, (%r8,%rdi,8)
incq %rdi
jmp 0x1920c
incq %rax
jmp 0x191f2
xorl %eax, %eax
cmpq %r15, %rax
je 0x19265
imulq $0x18, %rax, %rcx
movq (%r14), %rdx
addq %rcx, %rdx
addq (%rbx), %rcx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x19260
movq (%rdx), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%rcx), %rdi
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
jmp 0x19246
incq %rax
jmp 0x19232
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19d5a(%rip), %rdi     # 0x32fd8
leaq 0xafaa(%rip), %rsi      # 0x2422f
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::CombineMatrix(std::vector<Matrix, std::allocator<Matrix>>&, unsigned long, unsigned long)
Matrix Matrix::CombineMatrix(std::vector<Matrix> &vec, size_t R, size_t C)
{
    // combine a vector of matrix'es to one big matrix,
    // the big matrix dimension is R, C
    Matrix _m(R, C);
    size_t N = vec.size();
    auto dim = vec[0].Dimension();
    if(R*C != N * dim.first * dim.second ) {
        std::cout<<"Error: combining matrix dimension not match."<<std::endl;
        exit(0);
    }

    size_t index = 0;
    for(auto &m: vec){
        for(size_t i=0;i<dim.first;i++){
            for(size_t j=0;j<dim.second;j++){
                _m.FillElementByRow(index, m[i][j]);
                index++;
            }
        }
    }

    if(index != R*C) {
        std::cout<<"Error: combining matrix dimension not match."<<std::endl;
        exit(0);
    }

    return _m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r14
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, %rbx
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x176e6
movq (%r12), %r15
movq 0x8(%r12), %rax
movq %rax, 0x10(%rsp)
subq %r15, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %r12
movq %r15, %rdi
callq 0x17a6a
imulq %rbp, %r14
movq %rdx, %rcx
movq %rax, 0x18(%rsp)
imulq %rax, %rcx
imulq %r12, %rcx
movq %r14, 0x8(%rsp)
cmpq %rcx, %r14
jne 0x19371
movq %rdx, %r13
xorl %ebp, %ebp
cmpq 0x10(%rsp), %r15
je 0x19358
xorl %eax, %eax
cmpq 0x18(%rsp), %rax
je 0x19352
movq %rax, 0x20(%rsp)
imulq $0x18, %rax, %r12
xorl %r14d, %r14d
leaq (%r14,%rbp), %rsi
cmpq %r14, %r13
je 0x19345
movq (%r15), %rax
movq (%rax,%r12), %rax
movsd (%rax,%r14,8), %xmm0
movq %rbx, %rdi
callq 0x18f08
incq %r14
jmp 0x19322
movq 0x20(%rsp), %rax
incq %rax
movq %rsi, %rbp
jmp 0x1930f
addq $0x18, %r15
jmp 0x19306
cmpq 0x8(%rsp), %rbp
jne 0x1938e
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19c60(%rip), %rdi     # 0x32fd8
leaq 0xaeef(%rip), %rsi      # 0x2426e
callq 0x4240
movq %rax, %rdi
callq 0x4130
jmp 0x193a9
movq 0x19c43(%rip), %rdi     # 0x32fd8
leaq 0xaed2(%rip), %rsi      # 0x2426e
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
jmp 0x193b4
jmp 0x193b4
movq %rax, %r14
movq %rbx, %rdi
callq 0x17a9a
movq %r14, %rdi
callq 0x43b0
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::DispatchMatrix(Matrix&, unsigned long, unsigned long)
std::vector<Matrix> Matrix::DispatchMatrix(Matrix & M, size_t R, size_t C)
{
    // dispatch one big matrix to multiple small matrix'es, 
    // return in vector form
    // small matrix dimension R, C
    std::vector<Matrix> res;
    auto dim = M.Dimension();
    if( (dim.first*dim.second) % (R*C) != 0) {
        std::cout<<"Error: dispatch matrix dimension not match."<<std::endl;
        exit(0);
    }

    size_t index = 0;
    Matrix tmp(R, C);

    for(size_t i=0;i<dim.first;i++)
    {
        for(size_t j=0;j<dim.second;j++){
            tmp.FillElementByRow(index, M[i][j]);
            index++;
            if(index == R*C) {
                res.push_back(tmp);
                index = 0;
            }
        }
    }
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r15
movq %rdx, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, (%rsp)
andq $0x0, 0x10(%rdi)
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
callq 0x17a6a
movq %rdx, %r12
movq %rax, 0x8(%rsp)
imulq %rdx, %rax
movq %r15, %r13
imulq %rbp, %r13
xorl %edx, %edx
divq %r13
testq %rdx, %rdx
jne 0x194a9
leaq 0x20(%rsp), %rdi
movq %rbp, %rsi
movq %r15, %rdx
callq 0x176e6
xorl %ebp, %ebp
leaq 0x20(%rsp), %r15
xorl %eax, %eax
cmpq 0x8(%rsp), %rax
je 0x1948c
movq %rax, 0x10(%rsp)
imulq $0x18, %rax, %rbx
xorl %r14d, %r14d
cmpq %r14, %r12
je 0x19482
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
movq %rbp, %rsi
callq 0x18f08
incq %rbp
cmpq %r13, %rbp
jne 0x1947d
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x1139c
xorl %ebp, %ebp
incq %r14
jmp 0x19445
movq 0x10(%rsp), %rax
incq %rax
jmp 0x19432
leaq 0x20(%rsp), %rdi
callq 0x17a9a
movq (%rsp), %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19b28(%rip), %rdi     # 0x32fd8
leaq 0xade4(%rip), %rsi      # 0x2429b
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
jmp 0x194cd
movq %rax, %r14
jmp 0x194df
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x17a9a
movq (%rsp), %rdi
callq 0x110e4
movq %r14, %rdi
callq 0x43b0
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::ConcatenateMatrixByI(Matrix&, Matrix&)
Matrix Matrix::ConcatenateMatrixByI(Matrix &A, Matrix &B)
{
    // vertially place two matrix together, 
    auto dimA = A.Dimension();
    auto dimB = B.Dimension();
    if(dimA.second != dimB.second){
        std::cout<<"Error: place two matrix together vertically, dimension not match."<<std::endl;
        exit(0);
    }

    Matrix C(dimA.first + dimB.first, dimA.second);
    for(size_t i=0;i<dimA.first;i++){
        for(size_t j=0;j<dimA.second;j++){
            C[i][j] = A[i][j];
        }
    }
    for(size_t i=dimA.first;i<dimA.first+dimB.first;i++){
        for(size_t j=0;j<dimB.second;j++){
            C[i][j] = B[i-dimA.first][j];
        }
    }
    return C;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r14
movq %rsi, %rdi
callq 0x17a6a
movq %rax, %r15
movq %rdx, %r12
movq %rbx, %rdi
callq 0x17a6a
cmpq %rdx, %r12
jne 0x195bc
movq %rax, %r13
addq %r15, %r13
movq %r14, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq 0x176e6
xorl %eax, %eax
cmpq %r15, %rax
je 0x1956d
imulq $0x18, %rax, %rcx
movq (%rbp), %rdx
addq %rcx, %rdx
addq (%r14), %rcx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x19568
movq (%rdx), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%rcx), %rdi
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
jmp 0x1954e
incq %rax
jmp 0x19539
movq %r15, %rax
cmpq %r13, %rax
jae 0x195aa
movq %rax, %rcx
subq %r15, %rcx
imulq $0x18, %rcx, %rcx
addq (%rbx), %rcx
imulq $0x18, %rax, %rdx
addq (%r14), %rdx
xorl %esi, %esi
cmpq %rsi, %r12
je 0x195a5
movq (%rcx), %rdi
movsd (%rdi,%rsi,8), %xmm0
movq (%rdx), %rdi
movsd %xmm0, (%rdi,%rsi,8)
incq %rsi
jmp 0x1958b
incq %rax
jmp 0x19570
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19a15(%rip), %rdi     # 0x32fd8
leaq 0xacfd(%rip), %rsi      # 0x242c7
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::ConcatenateMatrixByI(std::vector<Matrix, std::allocator<Matrix>>&)
Matrix Matrix::ConcatenateMatrixByI(std::vector<Matrix> &A)
{
    // vertically place a vector of matrix together, 

    // method 1: seems pretty slow
    //Matrix C = A[0];

    //for(size_t i=1;i<A.size();i++)
    //{
    //    auto dimAI = A[i].Dimension();
    //    for(size_t ii=0;ii<dimAI.first;ii++)
    //    {
    //        auto dimC = C.Dimension();
    //        assert(dimC.second == dimAI.second);
    //        C.InsertRow(dimC.first, &A[i][ii]);
    //    }
    //}

    // method 2
    auto dim = A[0].Dimension();
    size_t length = A.size();

    Matrix C(dim.first*length, dim.second, 0);

    for(size_t i=0;i<length;i++)
    {
        assert(dim.second == A[i].Dimension().second);
        assert(dim.first == A[i].Dimension().first);

        for(size_t ii=0;ii<dim.first;ii++)
            for(size_t jj=0;jj<dim.second;jj++)
                C[i*dim.first + ii][jj] = (A[i])[ii][jj];
    }

    return C;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r13
movq %rdi, %rbx
movq (%rsi), %r12
movq %r12, %rdi
callq 0x17a6a
movq %rax, %r14
movq %rdx, %r15
movq 0x8(%r13), %rax
subq %r12, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, (%rsp)
movq %rax, %rsi
imulq %r14, %rsi
xorps %xmm0, %xmm0
movq %rbx, %rdi
movq %r15, %rdx
callq 0x177ee
movq (%r13), %rbp
xorl %r12d, %r12d
cmpq (%rsp), %r12
je 0x1969e
imulq $0x18, %r12, %r13
addq %rbp, %r13
movq %r13, %rdi
callq 0x17a6a
cmpq %rdx, %r15
jne 0x196cf
cmpq %rax, %r14
jne 0x196b0
movq %r12, %rax
imulq %r14, %rax
imulq $0x18, %rax, %rax
xorl %ecx, %ecx
cmpq %r14, %rcx
je 0x19699
movq (%rbx), %rdx
addq %rax, %rdx
imulq $0x18, %rcx, %rsi
addq %rsi, %rdx
xorl %edi, %edi
cmpq %rdi, %r15
je 0x19694
movq (%r13), %r8
movq (%r8,%rsi), %r8
movsd (%r8,%rdi,8), %xmm0
movq (%rdx), %r8
movsd %xmm0, (%r8,%rdi,8)
incq %rdi
jmp 0x19673
incq %rcx
jmp 0x1965f
incq %r12
jmp 0x1962f
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xacba(%rip), %rdi      # 0x24371
leaq 0xa8dd(%rip), %rsi      # 0x23f9b
leaq 0xac6a(%rip), %rcx      # 0x2432f
movl $0x3c7, %edx            # imm = 0x3C7
callq 0x4180
leaq 0xac33(%rip), %rdi      # 0x24309
leaq 0xa8be(%rip), %rsi      # 0x23f9b
leaq 0xac4b(%rip), %rcx      # 0x2432f
movl $0x3c6, %edx            # imm = 0x3C6
callq 0x4180
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::ConcatenateMatrixByI(std::vector<Matrix, std::allocator<Matrix>>*)
Matrix Matrix::ConcatenateMatrixByI(std::vector<Matrix> *A)
{
    // vertically place a vector of matrix together, 
    // method 2
    auto dim = (*A)[0].Dimension();
    size_t length = A->size();

    Matrix C(dim.first*length, dim.second, 0);

    for(size_t i=0;i<length;i++)
    {
        assert(dim.second == (*A)[i].Dimension().second);
        assert(dim.first == (*A)[i].Dimension().first);

        for(size_t ii=0;ii<dim.first;ii++)
            for(size_t jj=0;jj<dim.second;jj++)
                C[i*dim.first + ii][jj] = ((*A)[i])[ii][jj];
    }

    return C;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %r13
movq %r13, %rdi
callq 0x17a6a
movq %rax, %r15
movq %rdx, %r12
movq %r14, (%rsp)
movq 0x8(%r14), %rax
subq %r13, %rax
pushq $0x18
popq %rcx
cqto
idivq %rcx
movq %rax, %r13
movq %rax, %rsi
imulq %r15, %rsi
xorps %xmm0, %xmm0
movq %rbx, %rdi
movq %r12, %rdx
callq 0x177ee
xorl %r14d, %r14d
cmpq %r13, %r14
je 0x197b0
imulq $0x18, %r14, %rbp
movq (%rsp), %rax
addq (%rax), %rbp
movq %rbp, %rdi
callq 0x17a6a
cmpq %rdx, %r12
jne 0x197e1
cmpq %rax, %r15
jne 0x197c2
movq %r14, %rax
imulq %r15, %rax
imulq $0x18, %rax, %rax
xorl %ecx, %ecx
cmpq %r15, %rcx
je 0x197ab
movq (%rbx), %rdx
addq %rax, %rdx
imulq $0x18, %rcx, %rsi
addq %rsi, %rdx
xorl %edi, %edi
cmpq %rdi, %r12
je 0x197a6
movq (%rbp), %r8
movq (%r8,%rsi), %r8
movsd (%r8,%rdi,8), %xmm0
movq (%rdx), %r8
movsd %xmm0, (%r8,%rdi,8)
incq %rdi
jmp 0x19785
incq %rcx
jmp 0x19771
incq %r14
jmp 0x1973e
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xac37(%rip), %rdi      # 0x24400
leaq 0xa7cb(%rip), %rsi      # 0x23f9b
leaq 0xabe7(%rip), %rcx      # 0x243be
movl $0x3dd, %edx            # imm = 0x3DD
callq 0x4180
leaq 0xabad(%rip), %rdi      # 0x24395
leaq 0xa7ac(%rip), %rsi      # 0x23f9b
leaq 0xabc8(%rip), %rcx      # 0x243be
movl $0x3dc, %edx            # imm = 0x3DC
callq 0x4180
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::ConcatenateMatrixByJ(Matrix&, Matrix&)
Matrix Matrix::ConcatenateMatrixByJ(Matrix &A, Matrix &B)
{
    // horizontally place two matrix together, 
    auto dimA = A.Dimension();
    auto dimB = B.Dimension();
    if(dimA.first != dimB.first){
        std::cout<<"Error: place two matrix together horizontally, dimension not match."<<std::endl;
        exit(0);
    }

    Matrix C(dimA.first, dimA.second + dimB.second);
    for(size_t j=0;j<dimA.second;j++){
        for(size_t i=0;i<dimA.first;i++){
            C[i][j] = A[i][j];
        }
    }
    for(size_t j=dimA.second;j<dimA.second+dimB.second;j++){
        for(size_t i=0;i<dimB.first;i++){
            C[i][j] = B[i][j-dimA.second];
        }
    }
    return C;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r14
movq %rsi, %rdi
callq 0x17a6a
movq %rax, %r15
movq %rdx, %r12
movq %rbx, %rdi
callq 0x17a6a
cmpq %rax, %r15
jne 0x198cf
movq %rdx, %r13
addq %r12, %r13
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x176e6
xorl %eax, %eax
cmpq %r12, %rax
je 0x1987f
movq (%rbp), %rcx
movq (%r14), %rdx
xorl %esi, %esi
movq %r15, %rdi
subq $0x1, %rdi
jb 0x1987a
movq (%rcx,%rsi), %r8
movsd (%r8,%rax,8), %xmm0
movq (%rdx,%rsi), %r8
movsd %xmm0, (%r8,%rax,8)
addq $0x18, %rsi
jmp 0x1985a
incq %rax
jmp 0x19849
movq %r12, %rax
cmpq %r13, %rax
jae 0x198bd
movq (%rbx), %rcx
movq %rax, %rdx
subq %r12, %rdx
movq (%r14), %rsi
xorl %edi, %edi
movq %r15, %r8
subq $0x1, %r8
jb 0x198b8
movq (%rcx,%rdi), %r9
movsd (%r9,%rdx,8), %xmm0
movq (%rsi,%rdi), %r9
movsd %xmm0, (%r9,%rax,8)
addq $0x18, %rdi
jmp 0x19898
incq %rax
jmp 0x19882
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19702(%rip), %rdi     # 0x32fd8
leaq 0xab4a(%rip), %rsi      # 0x24427
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::MaxInSection(unsigned long, unsigned long, unsigned long, unsigned long, std::pair<unsigned long, unsigned long>&)
double Matrix::MaxInSection(size_t i_start, size_t i_end, size_t j_start, size_t j_end, std::pair<size_t, size_t> &coord)
{
    // find max element in section [i_start, i_end), and [j_start, j_end)
    // in this code, we all follow the rule: close front and open end
    // and all counters start from 0
    auto dim = Dimension();
    if((int)i_start < 0 || (int)j_start < 0 || i_end <= i_start || j_end <= j_start || i_end > dim.first || j_end > dim.second){
        std::cout<<"Error: Max in matrix section: exceeded range."<<std::endl;
        exit(0);
    }
    double res = __M[i_start][j_start];
    for(size_t i=i_start;i<i_end;i++){
        for(size_t j=j_start;j<j_end;j++)
        {
            if(res < __M[i][j]){
                res = __M[i][j];
                coord.first = i;
                coord.second = j;
            }
        }
    }
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbp
callq 0x17a6a
cmpq %r15, %r14
jbe 0x199a0
cmpq %r13, %r12
jbe 0x199a0
movl %r15d, %ecx
orl %r13d, %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
jne 0x199a0
cmpq %r12, %rax
jb 0x199a0
cmpq %r14, %rdx
jb 0x199a0
movq (%rbp), %rax
imulq $0x18, %r13, %rcx
movq (%rax,%rcx), %rcx
movsd (%rcx,%r15,8), %xmm0
cmpq %r12, %r13
jae 0x19991
imulq $0x18, %r13, %rcx
addq %rax, %rcx
movq %r15, %rdx
cmpq %r14, %rdx
jae 0x1998c
movq (%rcx), %rsi
movsd (%rsi,%rdx,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x19987
movq %r13, (%rbx)
movq %rdx, 0x8(%rbx)
movapd %xmm1, %xmm0
incq %rdx
jmp 0x19969
incq %r13
jmp 0x1995a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x19631(%rip), %rdi     # 0x32fd8
leaq 0xaaeb(%rip), %rsi      # 0x24499
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::SumInSection(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::SumInSection(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find element sum in section [i_start, i_end), and [j_start, j_end)
    // in this code, we all follow the rule: close front and open end
    // and all counters start from 0
    auto dim = Dimension();
    if((int)i_start < 0 || (int)j_start < 0 || i_end <= i_start || j_end <= j_start || i_end > dim.first || j_end > dim.second){
        std::cout<<"Error: Sum in matrix section: exceeded range."<<std::endl;
        exit(0);
    }
    double res =  0;
    for(size_t i=i_start;i<i_end;i++){
        for(size_t j=j_start;j<j_end;j++){
            res += __M[i][j];
        }
    }

    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
callq 0x17a6a
cmpq %r14, %rbx
jbe 0x19c07
cmpq %r12, %r15
jbe 0x19c07
movl %r14d, %ecx
orl %r12d, %ecx
andl $0x80000000, %ecx       # imm = 0x80000000
jne 0x19c07
cmpq %r15, %rax
jb 0x19c07
cmpq %rbx, %rdx
jb 0x19c07
movq (%r13), %rax
xorpd %xmm0, %xmm0
cmpq %r15, %r12
jae 0x19bfd
imulq $0x18, %r12, %rcx
addq %rax, %rcx
movq %r14, %rdx
cmpq %rbx, %rdx
jae 0x19bf8
movq (%rcx), %rsi
addsd (%rsi,%rdx,8), %xmm0
incq %rdx
jmp 0x19be6
incq %r12
jmp 0x19bd7
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x193ca(%rip), %rdi     # 0x32fd8
leaq 0xa9aa(%rip), %rsi      # 0x245bf
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop
// File: /workspace/github_cpp_makefile_star2_O2/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::SumInSectionWithPadding(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::SumInSectionWithPadding(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find element sum in section [i_start, i_end), and [j_start, j_end)
    // in this code, we all follow the rule: close front and open end
    // and all counters start from 0
    auto dim = Dimension();
    bool one_hit = false;

    assert((int)i_start >= 0 && i_end > i_start);
    assert((int)j_start >= 0 && j_end > j_start);

    auto in_range = [&](size_t ii, size_t jj) -> bool
    {
        if((int)ii>=0 && ii<dim.first && (int)jj>=0 && jj<dim.second)
            return true;
        return false;
    };

    double res =  0;
    for(size_t i=i_start;i<i_end;i++){
        for(size_t j=j_start;j<j_end;j++)
        {
            if(! in_range(i, j)) continue;
            one_hit = true;

            res += __M[i][j];
        }
    }

    if(!one_hit)
    {
        std::cout<<"Error: Sum in matrix section with padding: all elements exceeded range."<<std::endl;
        exit(0);
    }

    return res;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %r13
callq 0x17a6a
testl %r12d, %r12d
js 0x19cd1
cmpq %r12, %r15
jbe 0x19cd1
testl %r14d, %r14d
js 0x19cf0
cmpq %r14, %rbx
jbe 0x19cf0
movq (%r13), %rcx
xorpd %xmm0, %xmm0
xorl %esi, %esi
cmpq %r15, %r12
jae 0x19cc1
imulq $0x18, %r12, %rdi
addq %rcx, %rdi
movq %r14, %r8
cmpq %rbx, %r8
jae 0x19cbc
testl %r12d, %r12d
js 0x19cb7
cmpq %r12, %rax
seta %r9b
testl %r8d, %r8d
setns %r10b
cmpq %r8, %rdx
seta %r11b
andb %r9b, %r11b
andb %r10b, %r11b
cmpb $0x1, %r11b
jne 0x19cb7
movq (%rdi), %rsi
addsd (%rsi,%r8,8), %xmm0
movb $0x1, %sil
incq %r8
jmp 0x19c80
incq %r12
jmp 0x19c71
testb $0x1, %sil
je 0x19d0f
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
leaq 0xa85e(%rip), %rdi      # 0x24536
leaq 0xa2bc(%rip), %rsi      # 0x23f9b
leaq 0xa907(%rip), %rcx      # 0x245ed
movl $0x49a, %edx            # imm = 0x49A
callq 0x4180
leaq 0xa864(%rip), %rdi      # 0x2455b
leaq 0xa29d(%rip), %rsi      # 0x23f9b
leaq 0xa8e8(%rip), %rcx      # 0x245ed
movl $0x49b, %edx            # imm = 0x49B
callq 0x4180
movq 0x192c2(%rip), %rdi     # 0x32fd8
leaq 0xa917(%rip), %rsi      # 0x24634
callq 0x4240
movq %rax, %rdi
callq 0x4130
xorl %edi, %edi
callq 0x4260
nop