// File: 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
movq %rsp, %rbp
subq $0x5b0, %rsp            # imm = 0x5B0
movq %rsi, -0x508(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x500(%rbp)
movl $0x0, (%rax)
movl $0x0, 0x4(%rax)
movl $0x0, 0x38(%rax)
cmpl $0x0, 0x84(%rsi)
jl 0x5b36
movq -0x508(%rbp), %rdi
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
addq $0x20, %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
movl $0x8, %edx
callq 0x23e0
movq -0x238(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x238(%rbp,%rax), %rdi
callq 0x2110
movb %al, -0x509(%rbp)
jmp 0x5507
movb -0x509(%rbp), %al
testb $0x1, %al
jne 0x5516
jmp 0x55a4
movq 0x9ab3(%rip), %rdi      # 0xefd0
leaq 0x5bdc(%rip), %rsi      # 0xb100
callq 0x2210
movq %rax, -0x518(%rbp)
jmp 0x5532
movq -0x518(%rbp), %rdi
movq -0x508(%rbp), %rsi
addq $0x20, %rsi
callq 0x21f0
movq %rax, -0x520(%rbp)
jmp 0x5552
movq -0x520(%rbp), %rdi
leaq 0x5baf(%rip), %rsi      # 0xb10f
callq 0x2210
movq %rax, -0x528(%rbp)
jmp 0x556e
movq -0x528(%rbp), %rdi
movq 0x9a44(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x5583
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x5b28
leaq -0x268(%rbp), %rdi
callq 0x2300
leaq -0x238(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x2070
movq %rax, -0x530(%rbp)
jmp 0x55cc
movq -0x530(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22d0
movb %al, -0x531(%rbp)
jmp 0x55ea
movb -0x531(%rbp), %al
testb $0x1, %al
jne 0x55f9
jmp 0x5691
movq -0x500(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x540(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x22c0
movq -0x540(%rbp), %rdi
movsd %xmm0, -0x270(%rbp)
leaq -0x270(%rbp), %rsi
callq 0x8f10
jmp 0x563c
movq -0x508(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jle 0x5683
movq -0x508(%rbp), %rcx
movl -0x28(%rbp), %eax
cmpl 0x84(%rcx), %eax
jl 0x5683
jmp 0x5691
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x268(%rbp), %rdi
callq 0x2140
jmp 0x5b28
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x55b0
leaq -0x268(%rbp), %rdi
callq 0x2140
leaq -0x238(%rbp), %rdi
callq 0x2080
jmp 0x56ab
movq -0x18(%rbp), %rsi
leaq -0x478(%rbp), %rdi
movl $0x8, %edx
callq 0x23e0
jmp 0x56c2
movq -0x478(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x478(%rbp,%rax), %rdi
callq 0x2110
movb %al, -0x541(%rbp)
jmp 0x56e2
movb -0x541(%rbp), %al
testb $0x1, %al
jne 0x56f1
jmp 0x577b
movq 0x98d8(%rip), %rdi      # 0xefd0
leaq 0x5a01(%rip), %rsi      # 0xb100
callq 0x2210
movq %rax, -0x550(%rbp)
jmp 0x570d
movq -0x508(%rbp), %rsi
movq -0x550(%rbp), %rdi
callq 0x21f0
movq %rax, -0x558(%rbp)
jmp 0x5729
movq -0x558(%rbp), %rdi
leaq 0x59d8(%rip), %rsi      # 0xb10f
callq 0x2210
movq %rax, -0x560(%rbp)
jmp 0x5745
movq -0x560(%rbp), %rdi
movq 0x986d(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x575a
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x5b1c
leaq -0x498(%rbp), %rdi
callq 0x2300
leaq -0x478(%rbp), %rdi
leaq -0x498(%rbp), %rsi
callq 0x2070
movq %rax, -0x568(%rbp)
jmp 0x57a3
movq -0x568(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22d0
movb %al, -0x569(%rbp)
jmp 0x57c1
movb -0x569(%rbp), %al
testb $0x1, %al
jne 0x57d0
jmp 0x59f4
movl $0x0, -0x2c(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x8ef0
leaq 0x5930(%rip), %rax      # 0xb11a
movq %rax, -0x4b8(%rbp)
leaq -0x498(%rbp), %rdi
callq 0x2160
movq %rax, %rdi
incq %rdi
callq 0x2030
movq %rax, -0x578(%rbp)
jmp 0x5811
movq -0x578(%rbp), %rax
movq %rax, -0x4c0(%rbp)
movq -0x4c0(%rbp), %rax
movq %rax, -0x580(%rbp)
leaq -0x498(%rbp), %rdi
callq 0x20e0
movq -0x580(%rbp), %rdi
movq %rax, %rsi
callq 0x2200
movq -0x4c0(%rbp), %rdi
movq -0x4b8(%rbp), %rsi
callq 0x2350
movq %rax, -0x4c8(%rbp)
movq -0x4c8(%rbp), %rdi
callq 0x22c0
movsd %xmm0, -0x4d0(%rbp)
leaq -0x4b0(%rbp), %rdi
leaq -0x4d0(%rbp), %rsi
callq 0x8f10
jmp 0x588b
movl $0x1, -0x2c(%rbp)
jmp 0x5894
movq -0x4b8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x2350
movq %rax, -0x4c8(%rbp)
cmpq $0x0, -0x4c8(%rbp)
je 0x58c4
movq -0x4c8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x5900
jmp 0x5937
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x5a02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x3c10
jmp 0x5a02
movq -0x4c8(%rbp), %rdi
callq 0x22c0
movsd %xmm0, -0x4d8(%rbp)
leaq -0x4b0(%rbp), %rdi
leaq -0x4d8(%rbp), %rsi
callq 0x8f10
jmp 0x5929
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5892
movq -0x20(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0x8f40
jmp 0x5949
movq -0x500(%rbp), %rax
movl -0x2c(%rbp), %ecx
movl %ecx, 0x4(%rax)
leaq -0x4f0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x4f0(%rbp), %rdi
callq 0x8ef0
leaq -0x4f0(%rbp), %rdi
leaq -0x4b0(%rbp), %rsi
callq 0x8fb0
leaq -0x4f0(%rbp), %rdi
callq 0x3c10
movq -0x508(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jle 0x59c2
movq -0x508(%rbp), %rcx
movl -0x24(%rbp), %eax
cmpl 0x84(%rcx), %eax
jl 0x59c2
movl $0x5, -0x4f4(%rbp)
jmp 0x59d5
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl $0x0, -0x4f4(%rbp)
leaq -0x4b0(%rbp), %rdi
callq 0x3c10
movl -0x4f4(%rbp), %eax
testl %eax, %eax
je 0x59ef
jmp 0x59ed
jmp 0x59f4
jmp 0x5787
leaq -0x498(%rbp), %rdi
callq 0x2140
jmp 0x5a13
leaq -0x498(%rbp), %rdi
callq 0x2140
jmp 0x5b1c
leaq -0x478(%rbp), %rdi
callq 0x2080
jmp 0x5a21
movl -0x24(%rbp), %eax
cmpl -0x28(%rbp), %eax
jne 0x5a3d
movq -0x500(%rbp), %rax
movl -0x24(%rbp), %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x4(%rax)
jmp 0x5a78
movq 0x958c(%rip), %rdi      # 0xefd0
leaq 0x56d2(%rip), %rsi      # 0xb11d
callq 0x2210
movq %rax, -0x588(%rbp)
jmp 0x5a59
movq -0x588(%rbp), %rdi
movq 0x9559(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x5a6e
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq 0x9551(%rip), %rdi      # 0xefd0
leaq 0x56ba(%rip), %rsi      # 0xb140
callq 0x2210
movq %rax, -0x590(%rbp)
jmp 0x5a94
movq -0x590(%rbp), %rdi
movq -0x500(%rbp), %rax
movl (%rax), %esi
callq 0x2380
movq %rax, -0x598(%rbp)
jmp 0x5ab2
movq -0x598(%rbp), %rdi
leaq 0x5693(%rip), %rsi      # 0xb153
callq 0x2210
movq %rax, -0x5a0(%rbp)
jmp 0x5ace
movq -0x5a0(%rbp), %rdi
movq -0x500(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2380
movq %rax, -0x5a8(%rbp)
jmp 0x5aed
movq -0x5a8(%rbp), %rdi
movq 0x94c5(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x5b02
leaq -0x478(%rbp), %rdi
callq 0x2090
leaq -0x238(%rbp), %rdi
callq 0x2090
jmp 0x5b36
leaq -0x478(%rbp), %rdi
callq 0x2090
leaq -0x238(%rbp), %rdi
callq 0x2090
jmp 0x5b3f
addq $0x5b0, %rsp            # imm = 0x5B0
popq %rbp
retq
movq -0x240(%rbp), %rdi
callq 0x23a0
nopl (%rax,%rax)