// File: /workspace/github_cpp_makefile_star2_O3/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 $0x478, %rsp            # imm = 0x478
movq %rcx, 0x60(%rsp)
movq $0x0, (%rdi)
movl $0x0, 0x38(%rdi)
cmpl $0x0, 0x84(%rsi)
js 0x41c5
movq %rdi, %rbx
movq %rdx, 0x30(%rsp)
movq %rsi, 0x8(%rsp)
movq 0x20(%rsi), %rsi
leaq 0x270(%rsp), %r12
movq %r12, %rdi
movl $0x8, %edx
callq 0x22e0
movq (%r12), %rax
movq -0x18(%rax), %rcx
testb $0x5, 0x290(%rsp,%rcx)
jne 0x41d7
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
leaq 0x20(%rbx), %r13
movl $0x0, 0x4(%rsp)
leaq 0x68(%rsp), %rbp
leaq 0x40(%rsp), %r15
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r12, %rdi
movq %rbp, %rsi
callq 0x22f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
movq 0x68(%rsp), %rdi
jne 0x3ee9
callq 0x2200
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x3ea9
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rbx)
jmp 0x3eb4
movq %r13, %rdi
movq %r15, %rdx
callq 0x653e
movq 0x8(%rsp), %rax
movl 0x84(%rax), %eax
testl %eax, %eax
setle %cl
movl 0x4(%rsp), %edx
cmpl %eax, %edx
setl %al
orb %cl, %al
je 0x3ee4
incl %edx
movl %edx, 0x4(%rsp)
movq 0x270(%rsp), %rax
jmp 0x3e54
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
movq 0x8(%rsp), %r15
je 0x3f00
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x270(%rsp), %rdi
callq 0x2060
leaq 0x68(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl $0x8, %edx
callq 0x22e0
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x88(%rsp,%rax)
jne 0x4229
movq %rbx, 0x30(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %r12d, %r12d
leaq 0x31ef(%rip), %rbp      # 0x714a
leaq 0x10(%rsp), %r13
xorl %r14d, %r14d
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x68(%rsp), %rbx
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x22f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
movq 0x30(%rsp), %rbx
jne 0x4103
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x48(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %r12
movq 0x40(%rsp), %rsi
movq %rax, %rdi
callq 0x2190
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2260
movq %rax, %rdi
callq 0x2200
movsd %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x4007
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4014
movq %r13, %rdi
leaq 0x38(%rsp), %rdx
callq 0x653e
xorl %edi, %edi
movq %rbp, %rsi
callq 0x2260
movl $0x1, %r12d
testq %rax, %rax
je 0x4073
cmpb $0xa, (%rax)
je 0x4073
movq %rax, %rdi
callq 0x2200
movsd %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x4057
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4064
movq %r13, %rdi
leaq 0x38(%rsp), %rdx
callq 0x653e
incl %r12d
xorl %edi, %edi
movq %rbp, %rsi
callq 0x2260
jmp 0x4024
movq 0x60(%rsp), %rdi
movq %r13, %rsi
callq 0x6512
movl %r12d, 0x4(%rbx)
movq 0x10(%rsp), %rdi
movq 0x20(%rsp), %rsi
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
testq %rdi, %rdi
je 0x40e5
subq %rdi, %rsi
callq 0x21c0
movq 0x10(%rsp), %rdi
movl 0x84(%r15), %eax
testl %eax, %eax
setle %cl
cmpl %eax, %r14d
setl %r15b
orb %cl, %r15b
testq %rdi, %rdi
je 0x40d9
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
testb %r15b, %r15b
movq 0x8(%rsp), %r15
jne 0x40fb
jmp 0x4103
movl 0x84(%r15), %eax
testl %eax, %eax
setle %cl
cmpl %eax, %r14d
setl %al
orb %cl, %al
je 0x4103
incl %r14d
jmp 0x3f63
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x411f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x68(%rsp), %rdi
callq 0x2060
movl 0x4(%rsp), %eax
cmpl %r14d, %eax
jne 0x427a
movl %eax, (%rbx)
movl %r12d, 0x4(%rbx)
movq 0x5e95(%rip), %rdi      # 0x9fd8
leaq 0x3026(%rip), %rsi      # 0x7170
movl $0x12, %edx
callq 0x21e0
movl (%rbx), %esi
movq 0x5e7b(%rip), %rdi      # 0x9fd8
callq 0x22a0
movq %rax, %r14
leaq 0x3017(%rip), %rsi      # 0x7183
movl $0x6, %edx
movq %rax, %rdi
callq 0x21e0
movl 0x4(%rbx), %esi
movq %r14, %rdi
callq 0x22a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2040
movq %rax, %rdi
callq 0x2110
leaq 0x68(%rsp), %rdi
callq 0x2070
leaq 0x270(%rsp), %rdi
callq 0x2070
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5dfa(%rip), %rdi      # 0x9fd8
leaq 0x2f4b(%rip), %rsi      # 0x7130
movl $0xe, %edx
callq 0x21e0
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq 0x5dd5(%rip), %rdi      # 0x9fd8
callq 0x21e0
movq %rax, %rbx
leaq 0x2f2d(%rip), %rsi      # 0x713f
movl $0xa, %edx
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x20d0
jmp 0x429e
movq 0x5da8(%rip), %rdi      # 0x9fd8
leaq 0x2ef9(%rip), %rsi      # 0x7130
movl $0xe, %edx
callq 0x21e0
movq 0x8(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq 0x5d84(%rip), %rdi      # 0x9fd8
callq 0x21e0
movq %rax, %rbx
leaq 0x2edc(%rip), %rsi      # 0x713f
movl $0xa, %edx
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x20d0
jmp 0x429e
movq 0x5d57(%rip), %rdi      # 0x9fd8
leaq 0x2ec5(%rip), %rsi      # 0x714d
movl $0x22, %edx
callq 0x21e0
movq 0x5d3f(%rip), %rdi      # 0x9fd8
callq 0x20d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
jmp 0x42aa
movq %rax, %rbx
jmp 0x431d
jmp 0x42dd
jmp 0x42c1
movq %rax, %rbx
jmp 0x4313
jmp 0x42bc
jmp 0x42dd
movq %rax, %rbx
jmp 0x42f7
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x431d
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x431d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x42f7
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x4313
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x68(%rsp), %rdi
callq 0x2070
leaq 0x270(%rsp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22b0