// File: /workspace/github_cpp_makefile_star2_O2/lipiji[P]PG_DEEP/deep.cpp
// Function: Dataset::Dataset(Conf)
Dataset::Dataset(Conf conf)
{

    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(conf.f_train_x.c_str());
        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;
                }
                X.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 $0x498, %rsp            # imm = 0x498
xorps %xmm0, %xmm0
movups %xmm0, 0x2c(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
cmpl $0x0, 0x84(%rsi)
js 0x3692
movq %rsi, %r12
movq %rdi, %rbx
leaq 0x8(%rdi), %rax
movq %rax, 0x18(%rsp)
leaq 0x20(%rdi), %r15
movq 0x20(%rsi), %rsi
leaq 0x290(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x22e0
movq %rbx, 0x20(%rsp)
movq 0x290(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0x2b0(%rsp,%rax)
jne 0x36a4
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %ebp, %ebp
leaq 0x290(%rsp), %rbx
leaq 0x88(%rsp), %r14
leaq 0x50(%rsp), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3468
movq 0x88(%rsp), %rdi
callq 0x21f0
movsd %xmm0, 0x50(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x5880
movl 0x84(%r12), %eax
testl %eax, %eax
setle %cl
cmpl %eax, %ebp
setl %al
orb %cl, %al
je 0x3468
incl %ebp
jmp 0x3417
leaq 0x88(%rsp), %rdi
callq 0x20d0
leaq 0x290(%rsp), %rdi
callq 0x2060
movq (%r12), %rsi
leaq 0x88(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x22e0
movl %ebp, 0xc(%rsp)
movq %r12, 0x10(%rsp)
movq %r15, (%rsp)
movq 0x88(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xa8(%rsp,%rax)
jne 0x36df
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %ebp, %ebp
leaq 0x2c73(%rip), %rbx      # 0x614a
leaq 0x30(%rsp), %r14
leaq 0x70(%rsp), %r13
xorl %r15d, %r15d
movl %r15d, %eax
movq %rax, 0x28(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2050
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x360a
andq $0x0, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movq 0x58(%rsp), %rdi
incq %rdi
callq 0x2030
movq %rax, %rbp
movq 0x50(%rsp), %rsi
movq %rax, %rdi
callq 0x2190
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x2260
movq %rax, %rdi
callq 0x21f0
movsd %xmm0, 0x70(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x5880
pushq $0x1
popq %rax
movl %eax, %ebp
xorl %edi, %edi
movq %rbx, %rsi
callq 0x2260
testq %rax, %rax
je 0x3595
cmpb $0xa, (%rax)
je 0x3595
movq %rax, %rdi
callq 0x21f0
movsd %xmm0, 0x70(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0x5880
incl %ebp
jmp 0x3564
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x5832
movq 0x20(%rsp), %rax
movl %ebp, 0x4(%rax)
movaps 0x30(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0x40(%rsp)
movq %r13, %rdi
callq 0x2ef2
movq 0x10(%rsp), %rax
movl 0x84(%rax), %eax
testl %eax, %eax
setle %cl
movq 0x28(%rsp), %rdx
cmpl %eax, %edx
setl %r12b
orb %cl, %r12b
leal 0x1(%rdx), %r15d
movq %r14, %rdi
callq 0x2ef2
testb %r12b, %r12b
jne 0x34e4
leaq 0x50(%rsp), %rdi
callq 0x20d0
leaq 0x88(%rsp), %rdi
callq 0x2060
movq 0x20(%rsp), %rbx
movl 0xc(%rsp), %eax
cmpl 0x28(%rsp), %eax
jne 0x3718
movl %eax, (%rbx)
movl %ebp, 0x4(%rbx)
movq 0x5998(%rip), %rdi      # 0x8fd8
leaq 0x2b29(%rip), %rsi      # 0x6170
callq 0x21a0
movl (%rbx), %esi
movq %rax, %rdi
callq 0x22a0
leaq 0x2b26(%rip), %rsi      # 0x6183
movq %rax, %rdi
callq 0x21a0
movl 0x4(%rbx), %esi
movq %rax, %rdi
callq 0x22a0
movq %rax, %rdi
callq 0x20e0
leaq 0x88(%rsp), %rdi
callq 0x2070
leaq 0x290(%rsp), %rdi
callq 0x2070
addq $0x498, %rsp            # imm = 0x498
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x592d(%rip), %rdi      # 0x8fd8
leaq 0x2a7e(%rip), %rsi      # 0x6130
callq 0x21a0
addq $0x20, %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x2180
leaq 0x2a72(%rip), %rsi      # 0x613f
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
jmp 0x3733
movq 0x58f2(%rip), %rdi      # 0x8fd8
leaq 0x2a43(%rip), %rsi      # 0x6130
callq 0x21a0
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x2180
leaq 0x2a39(%rip), %rsi      # 0x613f
movq %rax, %rdi
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
jmp 0x3733
movq 0x58b9(%rip), %rdi      # 0x8fd8
leaq 0x2a27(%rip), %rsi      # 0x614d
callq 0x21a0
movq %rax, %rdi
callq 0x20e0
pushq $-0x1
popq %rdi
callq 0x21e0
jmp 0x3742
movq %rax, %rbx
jmp 0x37a4
movq %rax, %rbx
jmp 0x3797
movq %rax, %rbx
movq (%rsp), %r15
jmp 0x378a
jmp 0x376f
jmp 0x376f
jmp 0x376f
jmp 0x375d
movq %rax, %rbx
jmp 0x377c
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0x20d0
jmp 0x3797
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2ef2
movq (%rsp), %r15
leaq 0x50(%rsp), %rdi
callq 0x20d0
leaq 0x88(%rsp), %rdi
callq 0x2070
leaq 0x290(%rsp), %rdi
callq 0x2070
movq %r15, %rdi
callq 0x2ef2
movq 0x18(%rsp), %rdi
callq 0x2d9a
movq %rbx, %rdi
callq 0x22b0