// File: /workspace/github_cpp_makefile_star2_O1/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 0x4174
movq %rdi, %rbx
movq %rdx, 0x8(%rsp)
movq %rsi, 0x30(%rsp)
movq 0x20(%rsi), %rsi
leaq 0x270(%rsp), %r12
movq %r12, %rdi
movl $0x8, %edx
callq 0x22e0
movq (%r12), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x290(%rsp,%rax)
jne 0x4186
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 0x270(%rsp), %rax
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)
jne 0x3ea2
movq 0x68(%rsp), %rdi
callq 0x2200
movsd %xmm0, 0x40(%rsp)
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x3e73
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rbx)
jmp 0x3e7e
movq %r13, %rdi
movq %r15, %rdx
callq 0x64b0
movq 0x30(%rsp), %rax
movl 0x84(%rax), %eax
testl %eax, %eax
setle %cl
cmpl %eax, 0x4(%rsp)
setl %al
orb %cl, %al
je 0x3ea2
incl 0x4(%rsp)
jmp 0x3e16
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x3eb9
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x270(%rsp), %rdi
callq 0x2060
leaq 0x68(%rsp), %r15
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movl $0x8, %edx
callq 0x22e0
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x88(%rsp,%rax)
jne 0x41d8
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %r12d, %r12d
leaq 0x3238(%rip), %r13      # 0x714a
leaq 0x10(%rsp), %rbp
movl $0x0, 0x8(%rsp)
movq 0x68(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %edx
movq %r15, %rdi
leaq 0x40(%rsp), %rsi
callq 0x22f0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x40b1
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 %r13, %rsi
callq 0x2260
movq %rax, %rdi
callq 0x2200
movsd %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x3fb9
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x3fc6
movq %rbp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x64b0
xorl %edi, %edi
movq %r13, %rsi
callq 0x2260
movl $0x1, %r12d
testq %rax, %rax
je 0x4025
cmpb $0xa, (%rax)
je 0x4025
movq %rax, %rdi
callq 0x2200
movsd %xmm0, 0x38(%rsp)
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x4009
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x4016
movq %rbp, %rdi
leaq 0x38(%rsp), %rdx
callq 0x64b0
incl %r12d
xorl %edi, %edi
movq %r13, %rsi
callq 0x2260
jmp 0x3fd6
movq 0x60(%rsp), %rdi
movq %rbp, %r14
movq %rbp, %rsi
callq 0x6484
movq %rbx, %rbp
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 0x4064
subq %rdi, %rsi
callq 0x21c0
movq 0x30(%rsp), %rax
movl 0x84(%rax), %eax
testl %eax, %eax
setle %r15b
cmpl %eax, 0x8(%rsp)
setl %bl
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4093
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
orb %bl, %r15b
movzbl %r15b, %eax
addl %eax, 0x8(%rsp)
testb %al, %al
movq %rbp, %rbx
leaq 0x68(%rsp), %r15
movq %r14, %rbp
jne 0x3f1f
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x40cd
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x21c0
leaq 0x68(%rsp), %rdi
callq 0x2060
movl 0x8(%rsp), %eax
cmpl 0x4(%rsp), %eax
jne 0x4229
movl %eax, (%rbx)
movl %r12d, 0x4(%rbx)
movq 0x5ee6(%rip), %rdi      # 0x9fd8
leaq 0x3077(%rip), %rsi      # 0x7170
movl $0x12, %edx
callq 0x21e0
movl (%rbx), %esi
movq 0x5ecc(%rip), %rdi      # 0x9fd8
callq 0x22a0
movq %rax, %r14
leaq 0x3068(%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 0x5e4b(%rip), %rdi      # 0x9fd8
leaq 0x2f9c(%rip), %rsi      # 0x7130
movl $0xe, %edx
callq 0x21e0
movq 0x30(%rsp), %rax
movq 0x20(%rax), %rsi
movq 0x28(%rax), %rdx
movq 0x5e26(%rip), %rdi      # 0x9fd8
callq 0x21e0
movq %rax, %rbx
leaq 0x2f7e(%rip), %rsi      # 0x713f
movl $0xa, %edx
movq %rax, %rdi
callq 0x21e0
movq %rbx, %rdi
callq 0x20d0
jmp 0x424d
movq 0x5df9(%rip), %rdi      # 0x9fd8
leaq 0x2f4a(%rip), %rsi      # 0x7130
movl $0xe, %edx
callq 0x21e0
movq 0x30(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%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 0x424d
movq 0x5da8(%rip), %rdi      # 0x9fd8
leaq 0x2f16(%rip), %rsi      # 0x714d
movl $0x22, %edx
callq 0x21e0
movq 0x5d90(%rip), %rdi      # 0x9fd8
callq 0x20d0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21f0
jmp 0x4259
movq %rax, %rbx
jmp 0x42cc
jmp 0x428c
jmp 0x4270
movq %rax, %rbx
jmp 0x42c2
jmp 0x428c
jmp 0x428c
movq %rax, %rbx
jmp 0x42a6
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0x42cc
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x21c0
jmp 0x42cc
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x42a6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x21c0
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x42c2
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
nop