// File: /workspace/github_cpp_makefile_star2_O3/xbai0624[P]dnn/src/DataInterface.cpp
// Function: DataInterface::UpdateBatch(std::vector<Matrix, std::allocator<Matrix>>&, std::vector<Matrix, std::allocator<Matrix>>&)
void DataInterface::UpdateBatch(vector<Matrix> &data, vector<Matrix> &label)
{
    // clear previous batch
    data.clear();
    label.clear();

    size_t total_elements = __dataDimension.first*__dataDimension.second;
    assert( total_elements > 0); // make sure data dimension has been set

    //---------------------------------------------
    // prepare data
    int batch_size = gBatchSize / 2; // because signal + cosmic = gBatchSize
    int offset = gDataIndex * batch_size;
    assert( (size_t)(offset + batch_size) <= test_training_signal.size() ); // to avoid exceed range issue

    for(int i=0;i<batch_size;i++) // signal data
    {
        // data signal
        Matrix M;	
        if(__gLayerDimension == LayerDimension::_1D)
        {
            // if input layer is 1D, then reshape images into a collum vector
            M = test_training_signal[offset+i].Reshape(total_elements, 1);
        }
        else
        {
            M = test_training_signal[offset+i];
        }
        data.push_back(M);

        // label
        Matrix signal_label_m(2, 1, 0); // signal label
        signal_label_m[0][0] = 1;
        label.push_back(signal_label_m);
    }
    for(int i=0;i<batch_size;i++) // cosmic data
    {
        // data cosmic
        Matrix M;
        if(__gLayerDimension == LayerDimension::_1D)
        {
            M = test_training_cosmic[offset+i].Reshape(total_elements, 1);
        }
        else
        {
            M = test_training_cosmic[offset+i];
        }
        data.push_back(M);

        // label
        Matrix cosmic_label_m(2, 1, 0); // cosmic label
        cosmic_label_m[1][0] = 1;
        label.push_back(cosmic_label_m);
    }

    // get ready for next batch
    gDataIndex++;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, (%rsp)
movq %rdi, %r14
movq (%rsi), %rbx
movq %rsi, 0x8(%rsp)
movq 0x8(%rsi), %r15
cmpq %rbx, %r15
je 0x198fd
movq %rbx, %r12
movq %r12, %rdi
callq 0x1abf2
addq $0x18, %r12
cmpq %r15, %r12
jne 0x198e3
movq 0x8(%rsp), %rax
movq %rbx, 0x8(%rax)
movq (%rsp), %rax
movq (%rax), %rbx
movq 0x8(%rax), %r15
cmpq %rbx, %r15
je 0x19929
movq %rbx, %r12
movq %r12, %rdi
callq 0x1abf2
addq $0x18, %r12
cmpq %r15, %r12
jne 0x19910
movq (%rsp), %rax
movq %rbx, 0x8(%rax)
movq 0x78(%r14), %rax
imulq 0x70(%r14), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x19b62
movl (%r14), %edi
movl %edi, %eax
shrl $0x1f, %eax
addl %edi, %eax
sarl %eax
movslq 0x4(%r14), %rcx
movslq %eax, %r8
imulq %rcx, %r8
leal (%r8,%rax), %ecx
movslq %ecx, %rcx
movq 0x98(%r14), %rdx
subq 0x90(%r14), %rdx
sarq $0x3, %rdx
movabsq $-0x5555555555555555, %rsi # imm = 0xAAAAAAAAAAAAAAAB
imulq %rdx, %rsi
cmpq %rcx, %rsi
jb 0x19b81
cmpl $0x2, %edi
jl 0x19b4f
movl %edi, 0x14(%rsp)
movl %eax, %r15d
movq %r8, 0x20(%rsp)
movq %r8, %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
leaq 0x40(%rsp), %r13
leaq 0x28(%rsp), %rbp
movq %r15, %r12
movq %r13, %rdi
callq 0x1a6e2
cmpl $0x0, 0xc0(%r14)
je 0x199da
movq 0x90(%r14), %rsi
addq %rbx, %rsi
movq %r13, %rdi
callq 0x14e2c
jmp 0x19a09
movq 0x90(%r14), %rsi
addq %rbx, %rsi
movl $0x1, %ecx
movq %rbp, %rdi
movq 0x18(%rsp), %rdx
callq 0x1c0d2
movq %r13, %rdi
movq %rbp, %rsi
callq 0x14e2c
movq %rbp, %rdi
callq 0x1abf2
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x138a4
movl $0x2, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
movq %rbp, %rdi
callq 0x1a892
movq %rbp, %rdi
xorl %esi, %esi
callq 0x1adb2
movq (%rax), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0x138a4
movq %rbp, %rdi
callq 0x1abf2
movq %r13, %rdi
callq 0x1abf2
addq $0x18, %rbx
decq %r12
jne 0x199b4
cmpl $0x2, 0x14(%rsp)
movq 0x20(%rsp), %rax
jl 0x19b4f
cltq
shlq $0x3, %rax
leaq (%rax,%rax,2), %rbx
leaq 0x40(%rsp), %r13
leaq 0x28(%rsp), %rbp
movq %r13, %rdi
callq 0x1a6e2
cmpl $0x0, 0xc0(%r14)
je 0x19ab8
movq 0xa8(%r14), %rsi
addq %rbx, %rsi
movq %r13, %rdi
callq 0x14e2c
jmp 0x19ae7
movq 0xa8(%r14), %rsi
addq %rbx, %rsi
movl $0x1, %ecx
movq %rbp, %rdi
movq 0x18(%rsp), %rdx
callq 0x1c0d2
movq %r13, %rdi
movq %rbp, %rsi
callq 0x14e2c
movq %rbp, %rdi
callq 0x1abf2
movq 0x8(%rsp), %rdi
movq %r13, %rsi
callq 0x138a4
movl $0x2, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
movq %rbp, %rdi
callq 0x1a892
movl $0x1, %esi
movq %rbp, %rdi
callq 0x1adb2
movq (%rax), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0x138a4
movq %rbp, %rdi
callq 0x1abf2
movq %r13, %rdi
callq 0x1abf2
addq $0x18, %rbx
decq %r15
jne 0x19a92
incl 0x4(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1012c(%rip), %rdi     # 0x29c95
leaq 0x10059(%rip), %rsi     # 0x29bc9
leaq 0x10131(%rip), %rcx     # 0x29ca8
movl $0x9c, %edx
callq 0x4160
leaq 0x10164(%rip), %rdi     # 0x29cec
leaq 0x1003a(%rip), %rsi     # 0x29bc9
leaq 0x10112(%rip), %rcx     # 0x29ca8
movl $0xa2, %edx
callq 0x4160
jmp 0x19bb5
jmp 0x19bb0
jmp 0x19bb5
jmp 0x19bb0
jmp 0x19bb0
jmp 0x19bb0
jmp 0x19bb5
jmp 0x19bb0
movq %rax, %rbx
jmp 0x19bc2
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x1abf2
leaq 0x40(%rsp), %rdi
callq 0x1abf2
movq %rbx, %rdi
callq 0x43e0