LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/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 %rax
cmpq %rcx, %r8
jbe 0x1c5bf
cmpq %rsi, %rdx
jbe 0x1c5bf
movl %ecx, %eax
orl %esi, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1c5bf
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
subq %rax, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %r9
cmpq %rdx, %r9
jb 0x1c5bf
movq 0x8(%rax), %rdi
subq (%rax), %rdi
sarq $0x3, %rdi
cmpq %r8, %rdi
jb 0x1c5bf
leaq (%rsi,%rsi,2), %rdi
movq (%rax,%rdi,8), %rdi
movsd (%rdi,%rcx,8), %xmm0
leaq (%rsi,%rsi,2), %rdi
movq (%rax,%rdi,8), %rdi
movq %rcx, %r9
movapd %xmm0, %xmm1
movsd (%rdi,%r9,8), %xmm0
maxsd %xmm1, %xmm0
incq %r9
cmpq %r9, %r8
jne 0x1c59f
incq %rsi
cmpq %rdx, %rsi
jne 0x1c594
popq %rax
retq
movq 0x1aa12(%rip), %rdi     # 0x36fd8
leaq 0xdf28(%rip), %rsi      # 0x2a4f5
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/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:
movq %rsi, %rax
movq (%rdi), %rcx
movq 0x8(%rcx), %rsi
subq (%rcx), %rsi
movq 0x8(%rdi), %rdi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
subq %rcx, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %rsi
cmpq %rsi, %rax
jae 0x1c768
leaq (%rax,%rax,2), %rax
movq (%rcx,%rax,8), %rax
movsd %xmm0, (%rax,%rdx,8)
retq
pushq %rax
movq 0x1a868(%rip), %rdi     # 0x36fd8
leaq 0xda68(%rip), %rsi      # 0x2a1df
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/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:
movq %rsi, %rax
movq (%rdi), %rcx
movq 0x8(%rdi), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
movq 0x8(%rcx), %rdi
subq (%rcx), %rdi
imulq %rdx, %rsi
xorl %edx, %edx
divq %rsi
sarq $0x3, %rdi
cmpq %rdi, %rax
jae 0x1c7ce
leaq (%rdx,%rdx,2), %rdx
movq (%rcx,%rdx,8), %rcx
movsd %xmm0, (%rcx,%rax,8)
retq
pushq %rax
movq 0x1a802(%rip), %rdi     # 0x36fd8
leaq 0xda02(%rip), %rsi      # 0x2a1df
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/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
movq %rsi, (%rsp)
movq %r9, %r13
subq %r8, %r13
jbe 0x1c990
movq %rdx, %r14
movq %rcx, %rbp
subq %rdx, %rbp
jbe 0x1c990
movq %r8, %rbx
movl %ebx, %eax
orl %r14d, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1c990
movq (%rsp), %rdx
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %r15
cmpq %r14, %r15
jbe 0x1c990
movq 0x8(%rax), %r12
subq (%rax), %r12
sarq $0x3, %r12
cmpq %rbx, %r12
jbe 0x1c990
movsd %xmm0, 0x10(%rsp)
cmpb $0x0, 0x50(%rsp)
jne 0x1c900
cmpq %rcx, %r15
jb 0x1c9cc
cmpq %r9, %r12
jb 0x1c9cc
movq %rbp, %rsi
movq %r13, %rdx
movq %rdi, 0x8(%rsp)
callq 0x1a76e
movq 0x8(%rsp), %rax
leaq (,%rbx,8), %r11
xorl %ecx, %ecx
movsd 0x10(%rsp), %xmm1
leaq (%rcx,%r14), %rdx
leaq (%rcx,%rcx,2), %rsi
shlq $0x3, %rsi
addq (%rax), %rsi
leaq (%rdx,%rdx,2), %rdi
shlq $0x3, %rdi
movq (%rsp), %r8
addq (%r8), %rdi
xorl %r8d, %r8d
cmpq %r15, %rdx
jae 0x1c965
leaq (%rbx,%r8), %r10
movq (%rsi), %r9
cmpq %r12, %r10
jae 0x1c968
movq (%rdi), %r10
addq %r11, %r10
movsd (%r10,%r8,8), %xmm0
jmp 0x1c96b
movq (%rsi), %r9
movaps %xmm1, %xmm0
movsd %xmm0, (%r9,%r8,8)
incq %r8
cmpq %r8, %r13
jne 0x1c946
incq %rcx
cmpq %rbp, %rcx
jne 0x1c925
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a641(%rip), %rbx     # 0x36fd8
leaq 0xd867(%rip), %rsi      # 0x2a205
movq %rbx, %rdi
callq 0x4260
movq %rax, %rdi
callq 0x4100
leaq 0xd888(%rip), %rsi      # 0x2a23d
movq %rbx, %rdi
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
movq 0x1a605(%rip), %rdi     # 0x36fd8
leaq 0xd882(%rip), %rsi      # 0x2a25c
jmp 0x1c9b8
// File: /workspace/github_cpp_makefile_star2_O3/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 $0x28, %rsp
movl %r8d, 0x4(%rsp)
movq (%rsi), %r14
movq %rsi, 0x8(%rsp)
movq 0x8(%rsi), %rax
movq %rax, 0x18(%rsp)
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r15
movq %rdx, %rax
subq %r15, %rax
movq %rax, 0x20(%rsp)
jb 0x1cb4f
movq (%r14), %r12
movq 0x8(%r14), %rbx
movq %rbx, %r13
subq %r12, %r13
sarq $0x3, %r13
movq %rcx, %rbp
subq %r13, %rbp
jb 0x1cb4f
movq %rdi, 0x10(%rsp)
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x1a892
cmpb $0x0, 0x4(%rsp)
je 0x1cadf
cmpq %r14, 0x18(%rsp)
movq 0x10(%rsp), %rax
je 0x1cb40
shrq %rbp
movq 0x20(%rsp), %rdx
shrq %rdx
movq 0x8(%rsp), %rcx
movq (%rcx), %r9
leaq (%rdx,%rdx,2), %rcx
shlq $0x3, %rcx
addq (%rax), %rcx
cmpq $0x1, %r13
adcq $0x0, %r13
cmpq $0x1, %r15
adcq $0x0, %r15
xorl %edx, %edx
shlq $0x3, %rbp
cmpq %r12, %rbx
je 0x1cad5
leaq (,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rdi
movq (%r9,%rdi), %rsi
movq (%rcx,%rdi), %rdi
addq %rbp, %rdi
xorl %r8d, %r8d
movsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %r13
jne 0x1cac1
incq %rdx
cmpq %r15, %rdx
jne 0x1caa2
jmp 0x1cb40
cmpq %r14, 0x18(%rsp)
movq 0x10(%rsp), %rax
je 0x1cb40
movq 0x8(%rsp), %rcx
movq (%rcx), %r9
movq (%rax), %rcx
cmpq $0x1, %r13
adcq $0x0, %r13
cmpq $0x1, %r15
adcq $0x0, %r15
xorl %edx, %edx
cmpq %r12, %rbx
je 0x1cb38
leaq (,%rdx,8), %rsi
leaq (%rsi,%rsi,2), %rdi
movq (%r9,%rdi), %rsi
movq (%rcx,%rdi), %rdi
xorl %r8d, %r8d
movsd (%rsi,%r8,8), %xmm0
movsd %xmm0, (%rdi,%r8,8)
incq %r8
cmpq %r8, %r13
jne 0x1cb24
incq %rdx
cmpq %r15, %rdx
jne 0x1cb08
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a482(%rip), %rdi     # 0x36fd8
leaq 0xd72e(%rip), %rsi      # 0x2a28b
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, 0x8(%rsp)
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x1a76e
movq (%r12), %r13
movq 0x8(%r12), %rdx
movq %rdx, %rax
subq %r13, %rax
sarq $0x3, %rax
movq (%r13), %rsi
movq 0x8(%r13), %rcx
movq %rcx, 0x20(%rsp)
movq %rcx, %rdi
subq %rsi, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdi
movq %rdi, %r8
imulq %rdi, %rax
movq (%rsi), %rdi
movq %rsi, 0x28(%rsp)
movq 0x8(%rsi), %r12
movq %r12, 0x38(%rsp)
movq %rdi, 0x40(%rsp)
subq %rdi, %r12
sarq $0x3, %r12
imulq %r14, %rbx
imulq %r12, %rcx
imulq %rax, %rcx
cmpq %rcx, %rbx
jne 0x1ccb0
movq %rbx, 0x10(%rsp)
cmpq %rdx, %r13
je 0x1cc92
cmpq $0x1, %r12
adcq $0x0, %r12
cmpq $0x1, %r8
adcq $0x0, %r8
movq %r8, 0x30(%rsp)
xorl %r14d, %r14d
movq %rdx, 0x18(%rsp)
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x1cc82
xorl %r15d, %r15d
movq 0x38(%rsp), %rax
cmpq 0x40(%rsp), %rax
je 0x1cc78
leaq (%r15,%r15,2), %rbx
xorl %ebp, %ebp
leaq (%r14,%rbp), %rsi
movq (%r13), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%rbp,8), %xmm0
movq 0x8(%rsp), %rdi
callq 0x1c726
incq %rbp
cmpq %rbp, %r12
jne 0x1cc52
addq %rbp, %r14
incq %r15
cmpq 0x30(%rsp), %r15
jne 0x1cc40
addq $0x18, %r13
movq 0x18(%rsp), %rdx
cmpq %rdx, %r13
jne 0x1cc31
jmp 0x1cc95
xorl %r14d, %r14d
cmpq 0x10(%rsp), %r14
jne 0x1ccd6
movq 0x8(%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a321(%rip), %rdi     # 0x36fd8
leaq 0xd60c(%rip), %rsi      # 0x2a2ca
movl $0x2c, %edx
callq 0x4280
movq 0x1a309(%rip), %rdi     # 0x36fd8
callq 0x4100
jmp 0x1ccfa
movq 0x1a2fb(%rip), %rdi     # 0x36fd8
leaq 0xd5e6(%rip), %rsi      # 0x2a2ca
movl $0x2c, %edx
callq 0x4280
movq 0x1a2e3(%rip), %rdi     # 0x36fd8
callq 0x4100
xorl %edi, %edi
callq 0x4290
jmp 0x1cd05
jmp 0x1cd05
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1e8dc
movq %rbx, %rdi
callq 0x14578
movq %r14, %rdi
callq 0x43e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 $0x48, %rsp
movq %rdx, %r8
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq %rdi, (%rsp)
movq $0x0, 0x10(%rdi)
movq (%rsi), %rbx
movq %rsi, 0x40(%rsp)
movq 0x8(%rsi), %r14
movq %r14, %rax
subq %rbx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdx
movq (%rbx), %rax
movq 0x8(%rbx), %rbp
movq %rbp, 0x28(%rsp)
movq %rax, 0x30(%rsp)
subq %rax, %rbp
sarq $0x3, %rbp
movq %rbp, %rax
movq %rdx, %r15
imulq %rdx, %rax
movq %rcx, %r13
imulq %r8, %r13
xorl %edx, %edx
divq %r13
testq %rdx, %rdx
jne 0x1ce89
leaq 0x8(%rsp), %rdi
movq %r8, %rsi
movq %rcx, %rdx
callq 0x1a76e
cmpq %rbx, %r14
je 0x1ce3f
cmpq $0x1, %rbp
adcq $0x0, %rbp
cmpq $0x1, %r15
adcq $0x0, %r15
movq %r15, 0x20(%rsp)
xorl %ecx, %ecx
leaq 0x8(%rsp), %r15
xorl %r12d, %r12d
movq 0x28(%rsp), %rax
cmpq 0x30(%rsp), %rax
movq %rcx, 0x38(%rsp)
je 0x1ce30
leaq (%rcx,%rcx,2), %rbx
xorl %r14d, %r14d
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %rax
movsd (%rax,%r14,8), %xmm0
movq %r15, %rdi
movq %r12, %rsi
callq 0x1c726
incq %r12
cmpq %r13, %r12
jne 0x1ce28
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x138a4
xorl %r12d, %r12d
incq %r14
cmpq %r14, %rbp
jne 0x1cdf4
movq 0x38(%rsp), %rcx
incq %rcx
cmpq 0x20(%rsp), %rcx
jne 0x1cddc
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r14
cmpq %rbx, %r14
je 0x1ce6c
movq %rbx, %r15
movq (%r15), %rdi
testq %rdi, %rdi
je 0x1ce5e
callq 0x4230
addq $0x18, %r15
cmpq %r14, %r15
jne 0x1ce51
movq %rbx, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x14578
movq (%rsp), %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x1a148(%rip), %rdi     # 0x36fd8
leaq 0xd460(%rip), %rsi      # 0x2a2f7
movl $0x2b, %edx
callq 0x4280
movq 0x1a130(%rip), %rdi     # 0x36fd8
callq 0x4100
xorl %edi, %edi
callq 0x4290
jmp 0x1ceb6
movq %rax, %r14
jmp 0x1cef6
movq %rax, %r14
movq 0x8(%rsp), %rbx
movq 0x10(%rsp), %r15
cmpq %rbx, %r15
je 0x1ceec
movq %rbx, %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1cede
callq 0x4230
addq $0x18, %r12
cmpq %r15, %r12
jne 0x1ced0
movq %rbx, 0x10(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x14578
movq (%rsp), %rdi
callq 0x1353a
movq %r14, %rdi
callq 0x43e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/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 %rax
cmpq %rcx, %r8
jbe 0x1d5f4
cmpq %rsi, %rdx
jbe 0x1d5f4
movl %ecx, %eax
orl %esi, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1d5f4
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
subq %rax, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %r10 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %r10
cmpq %rdx, %r10
jb 0x1d5f4
movq 0x8(%rax), %rdi
subq (%rax), %rdi
sarq $0x3, %rdi
cmpq %r8, %rdi
jb 0x1d5f4
leaq (%rsi,%rsi,2), %rdi
movq (%rax,%rdi,8), %rdi
movsd (%rdi,%rcx,8), %xmm0
leaq (%rsi,%rsi,2), %rdi
movq (%rax,%rdi,8), %rdi
movq %rcx, %r10
movsd (%rdi,%r10,8), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x1d5e2
movq %rsi, (%r9)
movq %r10, 0x8(%r9)
movapd %xmm1, %xmm0
incq %r10
cmpq %r10, %r8
jne 0x1d5cb
incq %rsi
cmpq %rdx, %rsi
jne 0x1d5c0
popq %rax
retq
movq 0x199dd(%rip), %rdi     # 0x36fd8
leaq 0xcef3(%rip), %rsi      # 0x2a4f5
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
// File: /workspace/github_cpp_makefile_star2_O3/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 %rax
cmpq %rcx, %r8
jbe 0x1d7e2
cmpq %rsi, %rdx
jbe 0x1d7e2
movl %ecx, %eax
orl %esi, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1d7e2
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
subq %rax, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %r9
cmpq %rdx, %r9
jb 0x1d7e2
movq 0x8(%rax), %rdi
subq (%rax), %rdi
sarq $0x3, %rdi
cmpq %r8, %rdi
jb 0x1d7e2
xorpd %xmm0, %xmm0
leaq (%rsi,%rsi,2), %rdi
movq (%rax,%rdi,8), %rdi
movq %rcx, %r9
addsd (%rdi,%r9,8), %xmm0
incq %r9
cmpq %r9, %r8
jne 0x1d7ca
incq %rsi
cmpq %rdx, %rsi
jne 0x1d7bf
popq %rax
retq
movq 0x197ef(%rip), %rdi     # 0x36fd8
leaq 0xce2b(%rip), %rsi      # 0x2a61b
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
// File: /workspace/github_cpp_makefile_star2_O3/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 %rbp
pushq %rbx
pushq %rax
testl %esi, %esi
js 0x1d8a3
cmpq %rsi, %rdx
jbe 0x1d8a3
testl %ecx, %ecx
js 0x1d8c2
cmpq %rcx, %r8
jbe 0x1d8c2
movq (%rdi), %rax
movq 0x8(%rdi), %r10
subq %rax, %r10
sarq $0x3, %r10
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
movq 0x8(%rax), %r9
subq (%rax), %r9
imulq %r10, %rdi
sarq $0x3, %r9
xorpd %xmm0, %xmm0
xorl %r10d, %r10d
leaq (%rsi,%rsi,2), %r11
leaq (%rax,%r11,8), %r11
movq %rcx, %rbx
testl %esi, %esi
js 0x1d886
cmpq %rsi, %rdi
jbe 0x1d886
movl %ebx, %ebp
andl $0x80000000, %ebp       # imm = 0x80000000
jne 0x1d886
cmpq %rbx, %r9
jbe 0x1d886
movq (%r11), %r10
addsd (%r10,%rbx,8), %xmm0
movb $0x1, %r10b
incq %rbx
cmpq %rbx, %r8
jne 0x1d862
incq %rsi
cmpq %rdx, %rsi
jne 0x1d857
testb $0x1, %r10b
je 0x1d8e1
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
leaq 0xcce8(%rip), %rdi      # 0x2a592
leaq 0xc746(%rip), %rsi      # 0x29ff7
leaq 0xcd91(%rip), %rcx      # 0x2a649
movl $0x49a, %edx            # imm = 0x49A
callq 0x4160
leaq 0xccee(%rip), %rdi      # 0x2a5b7
leaq 0xc727(%rip), %rsi      # 0x29ff7
leaq 0xcd72(%rip), %rcx      # 0x2a649
movl $0x49b, %edx            # imm = 0x49B
callq 0x4160
movq 0x196f0(%rip), %rdi     # 0x36fd8
leaq 0xcda1(%rip), %rsi      # 0x2a690
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::AverageInSection(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::AverageInSection(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find element average 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 =  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];
        }
    }

    res = res /(int)(i_end-i_start)/(int)(j_end - j_start); 
    return res;
}

// Assembly:
pushq %rax
cmpq %rcx, %r8
jbe 0x1d992
cmpq %rsi, %rdx
jbe 0x1d992
movl %ecx, %eax
orl %esi, %eax
andl $0x80000000, %eax       # imm = 0x80000000
jne 0x1d992
movq (%rdi), %rax
movq 0x8(%rdi), %rdi
subq %rax, %rdi
sarq $0x3, %rdi
movabsq $-0x5555555555555555, %r9 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdi, %r9
cmpq %rdx, %r9
jb 0x1d992
movq 0x8(%rax), %rdi
subq (%rax), %rdi
sarq $0x3, %rdi
cmpq %r8, %rdi
jb 0x1d992
xorpd %xmm0, %xmm0
movq %rsi, %rdi
leaq (%rdi,%rdi,2), %r9
movq (%rax,%r9,8), %r9
movq %rcx, %r10
addsd (%r9,%r10,8), %xmm0
incq %r10
cmpq %r10, %r8
jne 0x1d961
incq %rdi
cmpq %rdx, %rdi
jne 0x1d956
subl %esi, %edx
cvtsi2sd %edx, %xmm1
divsd %xmm1, %xmm0
subl %ecx, %r8d
xorps %xmm1, %xmm1
cvtsi2sd %r8d, %xmm1
divsd %xmm1, %xmm0
popq %rax
retq
movq 0x1963f(%rip), %rdi     # 0x36fd8
leaq 0xcb55(%rip), %rsi      # 0x2a4f5
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::AverageInSectionWithPadding(unsigned long, unsigned long, unsigned long, unsigned long)
double Matrix::AverageInSectionWithPadding(size_t i_start, size_t i_end, size_t j_start, size_t j_end)
{
    // find element average 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;
    };

    size_t x_range = i_end < dim.first ? i_end : dim.first;
    size_t y_range = j_end < dim.second? j_end : dim.second;

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

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

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


    res = res / (int)(x_range-i_start)/(int)(y_range - j_start); 
    return res;
}

// Assembly:
pushq %rbx
testl %esi, %esi
js 0x1da8f
cmpq %rsi, %rdx
jbe 0x1da8f
testl %ecx, %ecx
js 0x1daae
cmpq %rcx, %r8
jbe 0x1daae
movq (%rdi), %r9
movq 0x8(%rdi), %rax
subq %r9, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rdi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rdi
movq 0x8(%r9), %rax
subq (%r9), %rax
sarq $0x3, %rax
cmpq %rdx, %rdi
cmovaeq %rdx, %rdi
cmpq %r8, %rax
cmovaeq %r8, %rax
cmpq %rsi, %rdi
jbe 0x1da6d
xorpd %xmm0, %xmm0
xorl %r8d, %r8d
movq %rsi, %rdx
cmpq %rcx, %rax
jbe 0x1da46
leaq (%rdx,%rdx,2), %r10
leaq (%r9,%r10,8), %r10
movq %rcx, %r11
movl %edx, %ebx
orl %r11d, %ebx
js 0x1da3e
movq (%r10), %r8
addsd (%r8,%r11,8), %xmm0
movb $0x1, %r8b
incq %r11
cmpq %r11, %rax
jne 0x1da2b
incq %rdx
cmpq %rdi, %rdx
jne 0x1da1b
testb $0x1, %r8b
je 0x1da6d
subl %esi, %edi
cvtsi2sd %edi, %xmm1
divsd %xmm1, %xmm0
subl %ecx, %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
popq %rbx
retq
movq 0x19564(%rip), %rdi     # 0x36fd8
leaq 0xcca8(%rip), %rsi      # 0x2a723
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
leaq 0xcafc(%rip), %rdi      # 0x2a592
leaq 0xc55a(%rip), %rsi      # 0x29ff7
leaq 0xcc34(%rip), %rcx      # 0x2a6d8
movl $0x4d7, %edx            # imm = 0x4D7
callq 0x4160
leaq 0xcb02(%rip), %rdi      # 0x2a5b7
leaq 0xc53b(%rip), %rsi      # 0x29ff7
leaq 0xcc15(%rip), %rcx      # 0x2a6d8
movl $0x4d8, %edx            # imm = 0x4D8
callq 0x4160
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Rot_180()
Matrix Matrix::Rot_180()
{
    // rotate matrix by 180 degree
    auto dim = this->Dimension();
    Matrix _m(dim);

    for(size_t i=0;i<dim.first;i++){
        for(size_t j=0;j<dim.second;j++){
            _m[i][j] = (*this)[dim.first - i -1][dim.second - j-1];
        }
    }

    return _m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq (%rsi), %rcx
movq %rsi, (%rsp)
movq 0x8(%rsi), %r13
movq %r13, %rax
movq %rcx, 0x10(%rsp)
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %r14 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %r14
movq (%rcx), %rbp
movq 0x8(%rcx), %rbx
movq %rbx, %r12
subq %rbp, %r12
movq %r12, %r15
sarq $0x3, %r15
movq %r14, %rsi
movq %r15, %rdx
callq 0x1a800
movq 0x8(%rsp), %rax
subq 0x10(%rsp), %r13
je 0x1db92
movq (%rsp), %rcx
addq (%rcx), %r13
movq (%rax), %r8
cmpq $0x1, %r15
adcq $0x0, %r15
cmpq $0x1, %r14
adcq $0x0, %r14
addq $-0x8, %r12
xorl %ecx, %ecx
cmpq %rbp, %rbx
je 0x1db8a
movq %rcx, %rdx
notq %rdx
leaq (%rdx,%rdx,2), %rsi
leaq (%rcx,%rcx,2), %rdx
movq (%r8,%rdx,8), %rdx
movq (%r13,%rsi,8), %rsi
addq %r12, %rsi
xorl %edi, %edi
movsd (%rsi), %xmm0
movsd %xmm0, (%rdx,%rdi,8)
incq %rdi
addq $-0x8, %rsi
cmpq %rdi, %r15
jne 0x1db75
incq %rcx
cmpq %r14, %rcx
jne 0x1db54
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::Convolution(Matrix&, unsigned long, bool, double)
Matrix Matrix::Convolution(Matrix &T, size_t stride, bool pad_front, double padding_value)
{
    // matrix convolution
    // convolution is correlation with T rotated 180 degree
    Matrix _T = T.Rot_180();
    Matrix r = Correlation(_T, stride, pad_front, padding_value);
    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movsd %xmm0, 0x18(%rsp)
movl %r8d, %ebp
movq %rcx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rsp, %r12
movq %r12, %rdi
movq %rdx, %rsi
callq 0x1dace
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
movq %r14, %rcx
movl %ebp, %r8d
movsd 0x18(%rsp), %xmm0
callq 0x1dba2
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r14, %r15
je 0x1e0a5
movq %r14, %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e097
callq 0x4230
addq $0x18, %r12
cmpq %r15, %r12
jne 0x1e089
movq %r14, 0x8(%rsp)
movq %rsp, %rdi
callq 0x14578
movq %rbx, %rax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq (%rsp), %r14
movq 0x8(%rsp), %r15
cmpq %r14, %r15
je 0x1e0ed
movq %r14, %r12
movq (%r12), %rdi
testq %rdi, %rdi
je 0x1e0df
callq 0x4230
addq $0x18, %r12
cmpq %r15, %r12
jne 0x1e0d1
movq %r14, 0x8(%rsp)
movq %rsp, %rdi
callq 0x14578
movq %rbx, %rdi
callq 0x43e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::DeleteRow(unsigned long)
void Matrix::DeleteRow(size_t i)
{
    // delete a row
    auto dim = Dimension();
    if(i>= dim.first || (int)i<0) {
        std::cout<<"Warning: deleting matrix row, index out of range."<<std::endl;
        return;
    }

    __M.erase(__M.begin() + i);
}

// Assembly:
testl %esi, %esi
js 0x1e5ae
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rdx
cmpq %rsi, %rdx
jbe 0x1e5ae
leaq (%rsi,%rsi,2), %rcx
leaq (%rax,%rcx,8), %rsi
jmp 0x1f268
pushq %rbx
movq 0x18a22(%rip), %rbx     # 0x36fd8
leaq 0xc23b(%rip), %rsi      # 0x2a7f8
movl $0x31, %edx
movq %rbx, %rdi
callq 0x4280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
popq %rbx
jmp 0x4190
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::DeleteCollum(unsigned long)
void Matrix::DeleteCollum(size_t i)
{
    // delete a collum
    auto dim = Dimension();
    if((int)i<0 || i>= dim.second){
        std::cout<<"Warning: deleting matrix collum, index out of range."<<std::endl;
        return;
    }
    for(size_t j=0;j<dim.first;j++){
        __M[j].erase(__M[j].begin()+i);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %rbx
testl %ebx, %ebx
js 0x1e68f
movq %rdi, %r14
movq (%rdi), %rax
movq 0x8(%rax), %rcx
subq (%rax), %rcx
sarq $0x3, %rcx
cmpq %rbx, %rcx
jbe 0x1e68f
movq 0x8(%r14), %rcx
cmpq %rax, %rcx
je 0x1e685
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %r15
cmpq $0x1, %r15
adcq $0x0, %r15
movl $0x8, %r12d
movq (%r14), %r13
movq -0x8(%r13,%r12), %rax
movq (%r13,%r12), %rdx
leaq (%rax,%rbx,8), %rsi
addq $0x8, %rsi
cmpq %rdx, %rsi
je 0x1e673
leaq (%rax,%rbx,8), %rdi
subq %rsi, %rdx
callq 0x4350
movq (%r13,%r12), %rdx
addq $-0x8, %rdx
movq %rdx, (%r13,%r12)
addq $0x18, %r12
decq %r15
jne 0x1e648
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq 0x18942(%rip), %rbx     # 0x36fd8
leaq 0xc18d(%rip), %rsi      # 0x2a82a
movl $0x34, %edx
movq %rbx, %rdi
callq 0x4280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x4190
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::InsertRow(unsigned long, std::vector<double, std::allocator<double>>*)
void Matrix::InsertRow(size_t i, std::vector<double>* vec)
{
    // insert vec to matrix at position i
    auto dim = Dimension();
    if(vec!=nullptr && vec->size() != dim.second){
        std::cout<<"Error: inserting row to matrix, dimension not match."<<std::endl;
        exit(0);
    }
    if((int)i<0 || i>dim.first){
        std::cout<<"Error: insert row to matrix, wrong position."<<std::endl;
        exit(0);
    }
    if(vec == nullptr){
        std::vector<double> v(dim.second, 0);
        __M.insert(__M.begin()+i, v);
    } else {
        __M.insert(__M.begin()+i, (*vec));
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rax
movq 0x8(%rdi), %rsi
subq %rax, %rsi
sarq $0x3, %rsi
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rsi, %rcx
movq 0x8(%rax), %rsi
subq (%rax), %rsi
testq %rdx, %rdx
je 0x1e744
movq 0x8(%rdx), %rdi
subq (%rdx), %rdi
cmpq %rsi, %rdi
jne 0x1e7af
testl %r14d, %r14d
js 0x1e79f
cmpq %r14, %rcx
jb 0x1e79f
leaq (%r14,%r14,2), %rcx
leaq (%rax,%rcx,8), %rsi
movq %rbx, %rdi
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x1eac4
testl %r14d, %r14d
js 0x1e79f
cmpq %r14, %rcx
jb 0x1e79f
sarq $0x3, %rsi
leaq 0x10(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x18(%rsp), %r15
leaq 0xf(%rsp), %rcx
movq %r15, %rdi
callq 0x1e9a2
leaq (%r14,%r14,2), %rsi
shlq $0x3, %rsi
addq (%rbx), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0x1eac4
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1e795
callq 0x4230
addq $0x30, %rsp
popq %rbx
popq %r14
popq %r15
retq
movq 0x18832(%rip), %rdi     # 0x36fd8
leaq 0xc0e7(%rip), %rsi      # 0x2a894
jmp 0x1e7bd
movq 0x18822(%rip), %rdi     # 0x36fd8
leaq 0xc0a2(%rip), %rsi      # 0x2a85f
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1e7e3
callq 0x4230
movq %rbx, %rdi
callq 0x43e0
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Matrix.cpp
// Function: Matrix::InsertCollum(unsigned long, std::vector<double, std::allocator<double>>*)
void Matrix::InsertCollum(size_t i, std::vector<double>* vec)
{
    // insert vec to matrix at position i
    auto dim=Dimension();
    if(vec!=nullptr && vec->size() != dim.first){
        std::cout<<"Error: inserting col to matrix, dimension not match."<<std::endl;
        exit(0);
    }
    if((int)i<0 || i>dim.second){
        std::cout<<"Error: insert col to matrix, wrong position."<<std::endl;
        exit(0);
    }
    for(size_t ii=0;ii<dim.first;ii++){
        if(vec == nullptr){
            __M[ii].insert(__M[ii].begin() + i, 0);
        } else {
            __M[ii].insert(__M[ii].begin() + i, (*vec)[ii]);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %r13 # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %r13
movq 0x8(%rax), %rdx
subq (%rax), %rdx
testq %rbx, %rbx
je 0x1e83b
movq 0x8(%rbx), %rsi
subq (%rbx), %rsi
sarq $0x3, %rsi
cmpq %r13, %rsi
jne 0x1e8ba
testl %r14d, %r14d
js 0x1e8aa
sarq $0x3, %rdx
cmpq %r14, %rdx
jb 0x1e8aa
cmpq %rax, %rcx
je 0x1e89b
cmpq $0x1, %r13
adcq $0x0, %r13
xorl %ebp, %ebp
shlq $0x3, %r14
xorl %r12d, %r12d
movq (%r15), %rdi
movq (%rdi,%r12), %rsi
addq %r14, %rsi
addq %r12, %rdi
testq %rbx, %rbx
je 0x1e87e
movq (%rbx), %rdx
addq %rbp, %rdx
callq 0x1eb6a
jmp 0x1e88e
movq $0x0, (%rsp)
movq %rsp, %rdx
callq 0x1f394
addq $0x18, %r12
addq $0x8, %rbp
decq %r13
jne 0x1e85f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18727(%rip), %rdi     # 0x36fd8
leaq 0xc03e(%rip), %rsi      # 0x2a8f6
jmp 0x1e8c8
movq 0x18717(%rip), %rdi     # 0x36fd8
leaq 0xbff9(%rip), %rsi      # 0x2a8c1
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Network.cpp
// Function: Network::UpdateEpoch()
void Network::UpdateEpoch()
{
    int numberofBatches = __dataInterface -> GetNumberOfBatches();
    cout<<"......Info: "<<numberofBatches<<" batches in this epoch"<<endl;
    numberofBatches = 1; // test QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQqq

    __dataInterface->Reset();
    __dataInterface->Shuffle();

    // initializations for epoch
    for(auto &i: __middleAndOutputLayers)
    {
        i->EpochInit();
    }

    for(int i=0;i<numberofBatches;i++)
    {
        cout<<"......... training for batch: "<<i<<"/"<<numberofBatches<<endl;
        UpdateBatch();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
callq 0x1984e
movl %eax, %ebp
movq 0x1753c(%rip), %r14     # 0x36fd8
leaq 0xafcc(%rip), %rsi      # 0x2aa6f
movl $0xc, %edx
movq %r14, %rdi
callq 0x4280
movq %r14, %rdi
movl %ebp, %esi
callq 0x43c0
movq %rax, %r14
leaq 0xafb8(%rip), %rsi      # 0x2aa7c
movl $0x16, %edx
movq %rax, %rdi
callq 0x4280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x28(%rbx), %rdi
callq 0x19d98
movq 0x28(%rbx), %rdi
callq 0x19da2
movq (%rbx), %r14
movq 0x8(%rbx), %r15
cmpq %r15, %r14
je 0x1fb25
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
addq $0x8, %r14
jmp 0x1fb11
movq 0x174ac(%rip), %r14     # 0x36fd8
leaq 0xaf60(%rip), %rsi      # 0x2aa93
movl $0x1e, %edx
movq %r14, %rdi
callq 0x4280
movq %r14, %rdi
xorl %esi, %esi
callq 0x43c0
movq %rax, %r14
leaq 0xaf09(%rip), %rsi      # 0x2aa5d
movl $0x1, %edx
movq %rax, %rdi
callq 0x4280
movq %r14, %rdi
movl $0x1, %esi
callq 0x43c0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1fbaa
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Network.cpp
// Function: Network::UpdateBatch()
void Network::UpdateBatch()
{
    // initializations for batch
    for(auto &i: __middleAndOutputLayers)
        i->BatchInit();

    auto t1 = std::chrono::high_resolution_clock::now();
    ForwardPropagateForBatch();
    //auto t2 = std::chrono::high_resolution_clock::now();
    //auto dt1 = std::chrono::duration_cast<std::chrono::milliseconds>(t2-t1);
    //std::cout<<"forward propagation cost: "<<dt1.count()<<" milliseconds"<<endl;

    BackwardPropagateForBatch();
    //auto t3 = std::chrono::high_resolution_clock::now();
    //auto dt2 = std::chrono::duration_cast<std::chrono::milliseconds>(t3-t2);
    //std::cout<<"backward propagation cost: "<<dt2.count()<<" milliseconds"<<endl;

    UpdateWeightsAndBiasForBatch();
    auto t4 = std::chrono::high_resolution_clock::now();
    auto dt3 = std::chrono::duration_cast<std::chrono::milliseconds>(t4-t1);
    std::cout<<"        batch training cost: "<<dt3.count()<<" milliseconds"<<endl;

    // save training accuracy for batch
    __outputLayer -> SaveAccuracyAndCostForBatch();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
movq 0x8(%rdi), %r15
cmpq %r15, %r14
je 0x1fbd4
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
addq $0x8, %r14
jmp 0x1fbbd
callq 0x4050
movq %rax, %r14
movq %rbx, %rdi
callq 0x1fcd4
movq (%rbx), %r15
movq 0x8(%rbx), %r12
movq %r12, %r13
subq %r15, %r13
shrq $0x3, %r13
testl %r13d, %r13d
jle 0x1fc31
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
incq %r13
movq (%rbx), %rax
movq -0x10(%rax,%r13,8), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
decq %r13
cmpq $0x1, %r13
ja 0x1fc04
movq (%rbx), %r15
movq 0x8(%rbx), %r12
jmp 0x1fc31
movq (%r15), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
addq $0x8, %r15
cmpq %r12, %r15
jne 0x1fc24
callq 0x4050
subq %r14, %rax
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
imulq %rcx
movq %rdx, %r14
shrq $0x3f, %r14
sarq $0x12, %rdx
addq %rdx, %r14
movq 0x17378(%rip), %r15     # 0x36fd8
leaq 0xae4b(%rip), %rsi      # 0x2aab2
movl $0x1d, %edx
movq %r15, %rdi
callq 0x4280
movq %r15, %rdi
movq %r14, %rsi
callq 0x4240
movq %rax, %r14
leaq 0xae47(%rip), %rsi      # 0x2aad0
movl $0xd, %edx
movq %rax, %rdi
callq 0x4280
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x20(%rbx), %rdi
movq (%rdi), %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmpq *0x2d0(%rax)
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Network.cpp
// Function: Network::ForwardPropagateForBatch()
void Network::ForwardPropagateForBatch()
{
    // prepare new batch data and label in Datainterface class
    __dataInterface->GetNewBatchData();
    __dataInterface->GetNewBatchLabel();

    // fill data to input layer
    __inputLayer->FillBatchDataToInputLayerA();

    // forward propagation
    for(auto &i: __middleAndOutputLayers)
    {
        i->ForwardPropagateForBatch();
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
callq 0x198a4
movq 0x28(%rbx), %rdi
callq 0x19bd4
movq 0x18(%rbx), %rdi
movq (%rdi), %rax
callq *0x180(%rax)
movq (%rbx), %r14
movq 0x8(%rbx), %rbx
cmpq %rbx, %r14
je 0x1fd15
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
addq $0x8, %r14
jmp 0x1fd01
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Neuron.cpp
// Function: Neuron::UpdateZ(int)
void Neuron::UpdateZ(int sample_index)
{
    // update z for current layer
    if(__layer->GetType() == LayerType::fullyConnected || __layer->GetType() == LayerType::output)
    {
        //std::cout<<__func__<<" fully connected layer update z"<<std::endl;
        UpdateZFC(sample_index);
    } 
    else if(__layer->GetType() == LayerType::cnn)
    {
        //std::cout<<__func__<<" cnn layer update z"<<std::endl;
        UpdateZCNN(sample_index);
    } 
    else if(__layer->GetType() == LayerType::pooling)
    {
        //std::cout<<__func__<<" pooling layer update z"<<std::endl;
        UpdateZPooling(sample_index);
    } 
    else 
    {
        std::cout<<"Error: unsupported layer type."<<std::endl;
        exit(0);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x78(%rdi), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
testl %eax, %eax
je 0x20214
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x4, %eax
jne 0x20225
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20966
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x1, %eax
jne 0x20248
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20b94
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x2, %eax
jne 0x2026b
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20d82
movq 0x16d66(%rip), %rdi     # 0x36fd8
leaq 0xa966(%rip), %rsi      # 0x2abdf
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Neuron.cpp
// Function: Neuron::UpdateA(int)
void Neuron::UpdateA(int sample_index)
{
    // update a for current training sample
    double v = __z[sample_index];
    //cout<<"debug: sample_id: "<<sample_index<<": z = "<<v<<endl;
    double a = -100.; // theorectially, a>=-1
    if(__funcType == ActuationFuncType::Sigmoid)
    {
        a = __sigmoid(v);
        //cout<<"sigmoid"<<endl;
    }
    else if(__funcType == ActuationFuncType::SoftMax)
    {
        auto & images  = __layer->GetImagesActiveZ();
        assert(images[sample_index].OutputImageFromKernel.size() == 1); // make sure it is 1D layer
        Matrix & m_z = images[sample_index].OutputImageFromKernel[0];

        a = __softmax(m_z);
    }
    else if(__funcType == ActuationFuncType::Tanh)
    {
        a = __tanh(v);
        //cout<<"tanh"<<endl;
    }
    else if(__funcType == ActuationFuncType::Relu)
    {
        a = __relu(v);
        //cout<<"relu"<<endl;
    }
    else
        std::cout<<"Error: unsupported actuation function type."<<std::endl;

    if(a < -1) 
    {
        std::cout<<"Error: Neuron::UpdateA(int sample_index), a<-1? something wrong."
            <<endl;
        exit(0);
    }
    //cout<<"debug: sample_id: "<<sample_index<<": a = "<<a<<endl;
    //getchar();
    //__a.push_back(a);
    __a[sample_index] = a;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl 0x84(%rdi), %eax
cmpq $0x3, %rax
ja 0x2036a
movq %rdi, %rbx
movslq %esi, %r14
movq 0x48(%rdi), %rcx
movsd (%rcx,%r14,8), %xmm0
leaq 0xa847(%rip), %rcx      # 0x2ab00
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorpd 0x6dc6(%rip), %xmm0     # 0x27090
callq 0x43f0
movapd %xmm0, %xmm1
movsd 0x72a5(%rip), %xmm0     # 0x27580
addsd %xmm0, %xmm1
jmp 0x20302
addsd %xmm0, %xmm0
callq 0x43f0
movapd %xmm0, %xmm1
movsd 0x72b2(%rip), %xmm0     # 0x275a8
addsd %xmm1, %xmm0
addsd 0x727e(%rip), %xmm1     # 0x27580
divsd %xmm1, %xmm0
jmp 0x20346
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
jbe 0x20346
jmp 0x20358
movq 0x78(%rbx), %rdi
movq (%rdi), %rax
callq *0xd8(%rax)
movq (%rax), %rax
leaq (%r14,%r14,2), %rcx
movq (%rax,%rcx,8), %rsi
movq 0x8(%rax,%rcx,8), %rax
subq %rsi, %rax
cmpq $0x18, %rax
jne 0x203ce
movq %rbx, %rdi
callq 0x2071e
movsd 0x725a(%rip), %xmm1     # 0x275a8
ucomisd %xmm0, %xmm1
movapd %xmm0, %xmm1
ja 0x203ac
movq 0x18(%rbx), %rax
movsd %xmm1, (%rax,%r14,8)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x16c67(%rip), %rbx     # 0x36fd8
leaq 0xaa48(%rip), %rsi      # 0x2adc0
movl $0x2b, %edx
movq %rbx, %rdi
callq 0x4280
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4250
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4190
movq 0x16c25(%rip), %rdi     # 0x36fd8
leaq 0xaa32(%rip), %rsi      # 0x2adec
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290
leaq 0xa99a(%rip), %rdi      # 0x2ad6f
leaq 0xa77a(%rip), %rsi      # 0x2ab56
leaq 0xa9c3(%rip), %rcx      # 0x2ada6
movl $0x167, %edx            # imm = 0x167
callq 0x4160
nop
// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/Neuron.cpp
// Function: Neuron::UpdateDelta(int)
void Neuron::UpdateDelta(int sample_index)
{
    // update delta for current layer
    if(__layer->GetType() == LayerType::output)
    {
        UpdateDeltaOutputLayer(sample_index);
    } 
    else if(__layer->GetType() == LayerType::fullyConnected)
    {
        UpdateDeltaFC(sample_index);
    } 
    else if(__layer->GetType() == LayerType::cnn)
    {
        UpdateDeltaCNN(sample_index);
    } 
    else if(__layer->GetType() == LayerType::pooling)
    {
        UpdateDeltaPooling(sample_index);
    } 
    else 
    {
        std::cout<<"Error: unsupported layer type."<<std::endl;
        exit(0);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x78(%rdi), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x4, %eax
jne 0x20670
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x20eb8
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
testl %eax, %eax
je 0x206a4
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x1, %eax
jne 0x206b5
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x2125e
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x21098
movq 0x78(%r14), %rdi
movq (%rdi), %rax
callq *0x250(%rax)
cmpl $0x2, %eax
jne 0x206d8
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x218d2
movq 0x168f9(%rip), %rdi     # 0x36fd8
leaq 0xa4f9(%rip), %rsi      # 0x2abdf
callq 0x4260
movq %rax, %rdi
callq 0x4100
xorl %edi, %edi
callq 0x4290