// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rdi, %r14
movq %rsi, 0x18(%rsp)
movq %rsi, %rdi
callq 0x11394
movq %rbx, 0x10(%rsp)
movq %rbx, %rdi
callq 0x11394
movq 0x78(%r14), %rax
imulq 0x70(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x16deb
movl (%r14), %eax
pushq $0x2
popq %rcx
cltd
idivl %ecx
movl %eax, %r13d
movslq 0x4(%r14), %rdi
cltq
imulq %rax, %rdi
addl %edi, %eax
movslq %eax, %rcx
movq 0x98(%r14), %rax
subq 0x90(%r14), %rax
pushq $0x18
popq %rsi
cqto
idivq %rsi
cmpq %rcx, %rax
jb 0x16e0a
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
movq %rdi, 0x20(%rsp)
imulq $0x18, %rdi, %rbx
leaq 0x40(%rsp), %rbp
leaq 0x28(%rsp), %r12
movq %r13, %r15
subq $0x1, %r15
jb 0x16d09
movq %rbp, %rdi
callq 0x1766c
cmpl $0x0, 0xc0(%r14)
je 0x16c7e
movq 0x90(%r14), %rsi
addq %rbx, %rsi
movq %rbp, %rdi
callq 0x125b4
jmp 0x16cab
movq 0x90(%r14), %rsi
addq %rbx, %rsi
movq %r12, %rdi
movq 0x8(%rsp), %rdx
pushq $0x1
popq %rcx
callq 0x18a0c
movq %rbp, %rdi
movq %r12, %rsi
callq 0x125b4
movq %r12, %rdi
callq 0x17a9a
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x1139c
xorps %xmm0, %xmm0
movq %r12, %rdi
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
callq 0x177ee
movq %r12, %rdi
xorl %esi, %esi
callq 0x17c46
movq (%rax), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x1139c
movq %r12, %rdi
callq 0x17a9a
movq %rbp, %rdi
callq 0x17a9a
addq $0x18, %rbx
jmp 0x16c4e
imulq $0x18, 0x20(%rsp), %r15
leaq 0x40(%rsp), %r12
leaq 0x28(%rsp), %rbp
pushq $0x1
popq %rbx
subq $0x1, %r13
jb 0x16dd8
movq %r12, %rdi
callq 0x1766c
cmpl $0x0, 0xc0(%r14)
je 0x16d4c
movq 0xa8(%r14), %rsi
addq %r15, %rsi
movq %r12, %rdi
callq 0x125b4
jmp 0x16d79
movq 0xa8(%r14), %rsi
addq %r15, %rsi
movq %rbp, %rdi
movq 0x8(%rsp), %rdx
movq %rbx, %rcx
callq 0x18a0c
movq %r12, %rdi
movq %rbp, %rsi
callq 0x125b4
movq %rbp, %rdi
callq 0x17a9a
movq 0x18(%rsp), %rdi
movq %r12, %rsi
callq 0x1139c
xorps %xmm0, %xmm0
movq %rbp, %rdi
pushq $0x2
popq %rsi
movq %rbx, %rdx
callq 0x177ee
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x17c46
movq (%rax), %rax
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x1139c
movq %rbp, %rdi
callq 0x17a9a
movq %r12, %rdi
callq 0x17a9a
addq $0x18, %r15
jmp 0x16d1c
incl 0x4(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xce3b(%rip), %rdi      # 0x23c2d
leaq 0xcd68(%rip), %rsi      # 0x23b61
leaq 0xce40(%rip), %rcx      # 0x23c40
movl $0x9c, %edx
callq 0x4180
leaq 0xce73(%rip), %rdi      # 0x23c84
leaq 0xcd49(%rip), %rsi      # 0x23b61
leaq 0xce21(%rip), %rcx      # 0x23c40
movl $0xa2, %edx
callq 0x4180
jmp 0x16e3e
jmp 0x16e37
jmp 0x16e3e
jmp 0x16e37
jmp 0x16e37
jmp 0x16e37
jmp 0x16e37
movq %rax, %rbx
jmp 0x16e4b
jmp 0x16e3e
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x17a9a
leaq 0x40(%rsp), %rdi
callq 0x17a9a
movq %rbx, %rdi
callq 0x43b0
nop