// File: 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:
subq $0xf8, %rsp
movq %rdi, 0xf0(%rsp)
movq %rsi, 0xe8(%rsp)
movq %rdx, 0xe0(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x1fa00
movq 0xe0(%rsp), %rdi
callq 0x1fa00
movq 0x18(%rsp), %rcx
movq 0x70(%rcx), %rax
imulq 0x78(%rcx), %rax
movq %rax, 0xd8(%rsp)
cmpq $0x0, 0xd8(%rsp)
jbe 0x39bc9
jmp 0x39be8
leaq 0x1af98(%rip), %rdi     # 0x54b68
leaq 0x1aec5(%rip), %rsi     # 0x54a9c
movl $0x9c, %edx
leaq 0x1af98(%rip), %rcx     # 0x54b7b
callq 0x4170
movq 0x18(%rsp), %rdi
movl (%rdi), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, 0xd4(%rsp)
movl 0x4(%rdi), %eax
imull 0xd4(%rsp), %eax
movl %eax, 0xd0(%rsp)
movl 0xd0(%rsp), %eax
addl 0xd4(%rsp), %eax
cltq
movq %rax, 0x10(%rsp)
addq $0x90, %rdi
callq 0x1f9c0
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
ja 0x39c40
jmp 0x39c5f
leaq 0x1af78(%rip), %rdi     # 0x54bbf
leaq 0x1ae4e(%rip), %rsi     # 0x54a9c
movl $0xa2, %edx
leaq 0x1af21(%rip), %rcx     # 0x54b7b
callq 0x4170
movl $0x0, 0xcc(%rsp)
movl 0xcc(%rsp), %eax
cmpl 0xd4(%rsp), %eax
jge 0x39e4e
leaq 0xb0(%rsp), %rdi
callq 0x3b2e0
movq 0x18(%rsp), %rax
cmpl $0x0, 0xc0(%rax)
jne 0x39d45
movq 0x18(%rsp), %rdi
addq $0x90, %rdi
movl 0xd0(%rsp), %eax
movl 0xcc(%rsp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x1f9e0
movq %rax, %rsi
movq 0xd8(%rsp), %rdx
leaq 0x98(%rsp), %rdi
movl $0x1, %ecx
callq 0x3df60
jmp 0x39ce0
leaq 0xb0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1fa20
jmp 0x39cf7
leaq 0x98(%rsp), %rdi
callq 0x3bb80
jmp 0x39d7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x39e3c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x3bb80
jmp 0x39e3c
movq 0x18(%rsp), %rdi
addq $0x90, %rdi
movl 0xd0(%rsp), %eax
movl 0xcc(%rsp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x1f9e0
movq %rax, %rsi
leaq 0xb0(%rsp), %rdi
callq 0x1fa20
jmp 0x39d7b
jmp 0x39d7d
movq 0xe8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x1fa50
jmp 0x39d94
leaq 0x70(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
callq 0x3b590
jmp 0x39dad
xorl %eax, %eax
movl %eax, %esi
leaq 0x70(%rsp), %rdi
callq 0x3be50
movq %rax, 0x8(%rsp)
jmp 0x39dc2
movq 0x8(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1fd60
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq 0xe0(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x1fa50
jmp 0x39df1
leaq 0x70(%rsp), %rdi
callq 0x3bb80
leaq 0xb0(%rsp), %rdi
callq 0x3bb80
movl 0xcc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xcc(%rsp)
jmp 0x39c6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x3bb80
leaq 0xb0(%rsp), %rdi
callq 0x3bb80
jmp 0x3a01f
movl $0x0, 0x6c(%rsp)
movl 0x6c(%rsp), %eax
cmpl 0xd4(%rsp), %eax
jge 0x3a009
leaq 0x50(%rsp), %rdi
callq 0x3b2e0
movq 0x18(%rsp), %rax
cmpl $0x0, 0xc0(%rax)
jne 0x39f19
movq 0x18(%rsp), %rdi
addq $0xa8, %rdi
movl 0xd0(%rsp), %eax
movl 0x6c(%rsp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x1f9e0
movq %rax, %rsi
movq 0xd8(%rsp), %rdx
leaq 0x38(%rsp), %rdi
movl $0x1, %ecx
callq 0x3df60
jmp 0x39ec0
leaq 0x50(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x1fa20
jmp 0x39ed1
leaq 0x38(%rsp), %rdi
callq 0x3bb80
jmp 0x39f4b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x39ffd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x3bb80
jmp 0x39ffd
movq 0x18(%rsp), %rdi
addq $0xa8, %rdi
movl 0xd0(%rsp), %eax
movl 0x6c(%rsp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x1f9e0
movq %rax, %rsi
leaq 0x50(%rsp), %rdi
callq 0x1fa20
jmp 0x39f49
jmp 0x39f4b
movq 0xe8(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1fa50
jmp 0x39f5f
leaq 0x20(%rsp), %rdi
movl $0x2, %esi
movl $0x1, %edx
xorps %xmm0, %xmm0
callq 0x3b590
jmp 0x39f78
leaq 0x20(%rsp), %rdi
movl $0x1, %esi
callq 0x3be50
movq %rax, (%rsp)
jmp 0x39f8d
movq (%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x1fd60
movabsq $0x3ff0000000000000, %rcx # imm = 0x3FF0000000000000
movq %rcx, (%rax)
movq 0xe0(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0x1fa50
jmp 0x39fbb
leaq 0x20(%rsp), %rdi
callq 0x3bb80
leaq 0x50(%rsp), %rdi
callq 0x3bb80
movl 0x6c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x6c(%rsp)
jmp 0x39e56
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x20(%rsp), %rdi
callq 0x3bb80
leaq 0x50(%rsp), %rdi
callq 0x3bb80
jmp 0x3a01f
movq 0x18(%rsp), %rax
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
addq $0xf8, %rsp
retq
movq 0x90(%rsp), %rdi
callq 0x43f0
nopl (%rax)