// File: /workspace/github_cpp_makefile_star2_O2/lipiji[P]PG_DEEP/deep.cpp
// Function: Dataset::reloadx(Conf, char*, std::vector<std::vector<double, std::allocator<double>>, std::allocator<std::vector<double, std::allocator<double>>>>&)
void Dataset::reloadx(Conf conf, char* xl, vector<vector<double> >& xlayer)
{

    N = 0;
    n_f = 0;
    batch_index = 0;

    if(conf.batch_size >= 0)
    {
        int Nx = 0;
        int Ny = 0;
        int Nf = 0; // dim of x

        //read the label file
        ifstream fin_y(conf.f_train_y.c_str());
        if(!fin_y) 
        {   
            cout << "Error opening " << conf.f_train_y << " for input" << endl;
            exit(-1);
        }
        else
        {
            string s;
            while(getline(fin_y, s))
            {	
                Y.push_back(atof(s.c_str()));
                if(conf.batch_size > 0 && Ny >= conf.batch_size)
                    break;
                ++Ny;
            }
        }
        fin_y.close();

        // read the x file
        ifstream fin_x(xl);
        if(!fin_x) 
        {   
            cout << "Error opening " << conf.f_train_x << " for input" << endl;
            exit(-1);
        }
        else
        {
            string s;
            while(getline(fin_x, s))
            {	
                Nf = 0;
                vector<double> x;
                const char *split = " \t";

                char *line=new char[s.size()+1];
                strcpy(line, s.c_str());
                char *p = strtok(line, split);
                x.push_back(atof(p));

                Nf = 1;
                while(1)
                {
                    p = strtok(NULL, split);
                    if(p == NULL || *p == '\n')
                        break;
                    x.push_back(atof(p));
                    ++Nf;
                }
                xlayer.push_back(x);
                n_f = Nf;

                vector<double>().swap(x);
                if(conf.batch_size > 0 && Nx >= conf.batch_size)
                    break;
                ++Nx;
            }
        }
        fin_x.close();

        if(Nx == Ny)
        {
            N = Nx;
            n_f = Nf;
        }
        else
        {
            cout << "Dataset error: size(x) != size(y)." << endl;
            exit(-1);
        }

        cout << "Data loaded: size=" << N <<", dim=" << n_f << endl;
    }

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x488, %rsp            # imm = 0x488
andq $0x0, (%rdi)
movq %rcx, 0x38(%rsp)
movq %rdi, 0x8(%rsp)
andl $0x0, 0x38(%rdi)
cmpl $0x0, 0x84(%rsi)
js 0x3ac1
movq %rsi, %rbx
movq %rdx, 0x10(%rsp)
movq 0x20(%rsi), %rsi
leaq 0x280(%rsp), %r15
pushq $0x8
popq %rdx
movq %r15, %rdi
callq 0x22e0
movq (%r15), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x2a0(%rsp,%rax)
jne 0x3ad3
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x8(%rsp), %rax
leaq 0x20(%rax), %r13
xorl %r14d, %r14d
leaq 0x280(%rsp), %rbp
leaq 0x78(%rsp), %r12
leaq 0x40(%rsp), %r15
movq %rbp, %rdi
movq %r12, %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x38a2
movq 0x78(%rsp), %rdi
callq 0x21f0
movsd %xmm0, 0x40(%rsp)
movq %r13, %rdi
movq %r15, %rsi
callq 0x5880
movl 0x84(%rbx), %eax
testl %eax, %eax
setle %cl
cmpl %eax, %r14d
setl %al
orb %cl, %al
je 0x38a2
incl %r14d
jmp 0x3854
leaq 0x78(%rsp), %rdi
callq 0x20d0
leaq 0x280(%rsp), %rdi
callq 0x2060
leaq 0x78(%rsp), %rdi
pushq $0x8
popq %rdx
movq 0x10(%rsp), %rsi
callq 0x22e0
movq %rbx, 0x18(%rsp)
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x98(%rsp,%rax)
jne 0x3b0e
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %r15d, %r15d
leaq 0x20(%rsp), %r12
leaq 0x60(%rsp), %r13
xorl %ebx, %ebx
movl %ebx, %eax
movq %rax, 0x10(%rsp)
leaq 0x78(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3a36
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq 0x48(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %r15
movq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x2190
movq %r15, %rdi
leaq 0x27e6(%rip), %rsi      # 0x614a
callq 0x2260
movq %rax, %rdi
callq 0x21f0
movsd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x5880
movq 0x18(%rsp), %rbx
pushq $0x1
popq %rax
movl %eax, %r15d
xorl %edi, %edi
leaq 0x27b4(%rip), %rsi      # 0x614a
callq 0x2260
testq %rax, %rax
je 0x39c3
cmpb $0xa, (%rax)
je 0x39c3
movq %rax, %rdi
callq 0x21f0
movsd %xmm0, 0x60(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x5880
incl %r15d
jmp 0x398d
movl %r14d, %ebp
movq 0x38(%rsp), %rdi
movq %r12, %rsi
callq 0x5832
movq 0x8(%rsp), %rax
movl %r15d, 0x4(%rax)
movaps 0x20(%rsp), %xmm0
movaps %xmm0, 0x60(%rsp)
movq 0x30(%rsp), %rax
movq %rax, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x30(%rsp)
movq %r13, %rdi
callq 0x2ef2
movl 0x84(%rbx), %eax
testl %eax, %eax
setle %cl
movq 0x10(%rsp), %rdx
cmpl %eax, %edx
setl %r14b
orb %cl, %r14b
leal 0x1(%rdx), %ebx
movq %r12, %rdi
callq 0x2ef2
testb %r14b, %r14b
movl %ebp, %r14d
jne 0x3907
leaq 0x40(%rsp), %rdi
callq 0x20d0
leaq 0x78(%rsp), %rdi
callq 0x2060
cmpl 0x10(%rsp), %r14d
jne 0x3b47
movq 0x8(%rsp), %rax
movl %r14d, (%rax)
movl %r15d, 0x4(%rax)
movq 0x5570(%rip), %rdi      # 0x8fd8
leaq 0x2701(%rip), %rsi      # 0x6170
callq 0x21a0
movq 0x8(%rsp), %rcx
movl (%rcx), %esi
movq %rax, %rdi
callq 0x22a0
leaq 0x26f9(%rip), %rsi      # 0x6183
movq %rax, %rdi
callq 0x21a0
movq 0x8(%rsp), %rcx
movl 0x4(%rcx), %esi
movq %rax, %rdi
callq 0x22a0
movq %rax, %rdi
callq 0x20e0
leaq 0x78(%rsp), %rdi
callq 0x2070
leaq 0x280(%rsp), %rdi
callq 0x2070
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x54fe(%rip), %rdi      # 0x8fd8
leaq 0x264f(%rip), %rsi      # 0x6130
callq 0x21a0
addq $0x20, %rbx
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2180
leaq 0x2643(%rip), %rsi      # 0x613f
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
jmp 0x3b62
movq 0x54c3(%rip), %rdi      # 0x8fd8
leaq 0x2614(%rip), %rsi      # 0x6130
callq 0x21a0
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x2180
leaq 0x260a(%rip), %rsi      # 0x613f
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
jmp 0x3b62
movq 0x548a(%rip), %rdi      # 0x8fd8
leaq 0x25f8(%rip), %rsi      # 0x614d
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
pushq $-0x1
popq %rdi
callq 0x21e0
jmp 0x3b6c
movq %rax, %rbx
jmp 0x3bb3
movq %rax, %rbx
jmp 0x3ba9
jmp 0x3b92
jmp 0x3b92
jmp 0x3b92
jmp 0x3b83
movq %rax, %rbx
jmp 0x3b9f
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x20d0
jmp 0x3bb3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2ef2
leaq 0x40(%rsp), %rdi
callq 0x20d0
leaq 0x78(%rsp), %rdi
callq 0x2070
leaq 0x280(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22b0