// File: 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
movq %rsp, %rbp
subq $0x5b0, %rsp            # imm = 0x5B0
movq %rsi, -0x4f0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x4f8(%rbp)
addq $0x8, %rdi
movq %rdi, -0x508(%rbp)
callq 0x8ed0
movq -0x4f8(%rbp), %rdi
addq $0x20, %rdi
movq %rdi, -0x500(%rbp)
callq 0x8ef0
movq -0x4f8(%rbp), %rax
movq -0x4f0(%rbp), %rsi
movl $0x0, (%rax)
movl $0x0, 0x4(%rax)
movl $0x0, 0x38(%rax)
cmpl $0x0, 0x84(%rsi)
jl 0x542e
movq -0x4f0(%rbp), %rdi
movl $0x0, -0x14(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
addq $0x20, %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x23e0
jmp 0x4db6
movq -0x228(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x228(%rbp,%rax), %rdi
callq 0x2110
movb %al, -0x509(%rbp)
jmp 0x4dd6
movb -0x509(%rbp), %al
testb $0x1, %al
jne 0x4de5
jmp 0x4e8a
movq 0xa1e4(%rip), %rdi      # 0xefd0
leaq 0x630d(%rip), %rsi      # 0xb100
callq 0x2210
movq %rax, -0x518(%rbp)
jmp 0x4e01
movq -0x518(%rbp), %rdi
movq -0x4f0(%rbp), %rsi
addq $0x20, %rsi
callq 0x21f0
movq %rax, -0x520(%rbp)
jmp 0x4e21
movq -0x520(%rbp), %rdi
leaq 0x62e0(%rip), %rsi      # 0xb10f
callq 0x2210
movq %rax, -0x528(%rbp)
jmp 0x4e3d
movq -0x528(%rbp), %rdi
movq 0xa175(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x4e52
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5437
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5420
leaq -0x258(%rbp), %rdi
callq 0x2300
leaq -0x228(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x2070
movq %rax, -0x530(%rbp)
jmp 0x4eb2
movq -0x530(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22d0
movb %al, -0x531(%rbp)
jmp 0x4ed0
movb -0x531(%rbp), %al
testb $0x1, %al
jne 0x4edf
jmp 0x4f77
movq -0x4f8(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x540(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x20e0
movq %rax, %rdi
callq 0x22c0
movq -0x540(%rbp), %rdi
movsd %xmm0, -0x260(%rbp)
leaq -0x260(%rbp), %rsi
callq 0x8f10
jmp 0x4f22
movq -0x4f0(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jle 0x4f69
movq -0x4f0(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x84(%rcx), %eax
jl 0x4f69
jmp 0x4f77
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x2140
jmp 0x5420
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x4e96
leaq -0x258(%rbp), %rdi
callq 0x2140
leaq -0x228(%rbp), %rdi
callq 0x2080
jmp 0x4f91
movq -0x4f0(%rbp), %rdi
callq 0x20e0
movq %rax, %rsi
leaq -0x468(%rbp), %rdi
movl $0x8, %edx
callq 0x23e0
jmp 0x4fb3
movq -0x468(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x468(%rbp,%rax), %rdi
callq 0x2110
movb %al, -0x541(%rbp)
jmp 0x4fd3
movb -0x541(%rbp), %al
testb $0x1, %al
jne 0x4fe2
jmp 0x506c
movq 0x9fe7(%rip), %rdi      # 0xefd0
leaq 0x6110(%rip), %rsi      # 0xb100
callq 0x2210
movq %rax, -0x550(%rbp)
jmp 0x4ffe
movq -0x4f0(%rbp), %rsi
movq -0x550(%rbp), %rdi
callq 0x21f0
movq %rax, -0x558(%rbp)
jmp 0x501a
movq -0x558(%rbp), %rdi
leaq 0x60e7(%rip), %rsi      # 0xb10f
callq 0x2210
movq %rax, -0x560(%rbp)
jmp 0x5036
movq -0x560(%rbp), %rdi
movq 0x9f7c(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x504b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5414
leaq -0x488(%rbp), %rdi
callq 0x2300
leaq -0x468(%rbp), %rdi
leaq -0x488(%rbp), %rsi
callq 0x2070
movq %rax, -0x568(%rbp)
jmp 0x5094
movq -0x568(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22d0
movb %al, -0x569(%rbp)
jmp 0x50b2
movb -0x569(%rbp), %al
testb $0x1, %al
jne 0x50c1
jmp 0x52ec
movl $0x0, -0x1c(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x8ef0
leaq 0x603f(%rip), %rax      # 0xb11a
movq %rax, -0x4a8(%rbp)
leaq -0x488(%rbp), %rdi
callq 0x2160
movq %rax, %rdi
incq %rdi
callq 0x2030
movq %rax, -0x578(%rbp)
jmp 0x5102
movq -0x578(%rbp), %rax
movq %rax, -0x4b0(%rbp)
movq -0x4b0(%rbp), %rax
movq %rax, -0x580(%rbp)
leaq -0x488(%rbp), %rdi
callq 0x20e0
movq -0x580(%rbp), %rdi
movq %rax, %rsi
callq 0x2200
movq -0x4b0(%rbp), %rdi
movq -0x4a8(%rbp), %rsi
callq 0x2350
movq %rax, -0x4b8(%rbp)
movq -0x4b8(%rbp), %rdi
callq 0x22c0
movsd %xmm0, -0x4c0(%rbp)
leaq -0x4a0(%rbp), %rdi
leaq -0x4c0(%rbp), %rsi
callq 0x8f10
jmp 0x517c
movl $0x1, -0x1c(%rbp)
jmp 0x5185
movq -0x4a8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x2350
movq %rax, -0x4b8(%rbp)
cmpq $0x0, -0x4b8(%rbp)
je 0x51b5
movq -0x4b8(%rbp), %rax
movsbl (%rax), %eax
cmpl $0xa, %eax
jne 0x51f1
jmp 0x5228
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x52fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x3c10
jmp 0x52fa
movq -0x4b8(%rbp), %rdi
callq 0x22c0
movsd %xmm0, -0x4c8(%rbp)
leaq -0x4a0(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
callq 0x8f10
jmp 0x521a
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5183
movq -0x4f8(%rbp), %rdi
addq $0x8, %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x8f40
jmp 0x5241
movq -0x4f8(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, 0x4(%rax)
leaq -0x4e0(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x2130
leaq -0x4e0(%rbp), %rdi
callq 0x8ef0
leaq -0x4e0(%rbp), %rdi
leaq -0x4a0(%rbp), %rsi
callq 0x8fb0
leaq -0x4e0(%rbp), %rdi
callq 0x3c10
movq -0x4f0(%rbp), %rax
cmpl $0x0, 0x84(%rax)
jle 0x52ba
movq -0x4f0(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x84(%rcx), %eax
jl 0x52ba
movl $0x5, -0x4e4(%rbp)
jmp 0x52cd
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x4e4(%rbp)
leaq -0x4a0(%rbp), %rdi
callq 0x3c10
movl -0x4e4(%rbp), %eax
testl %eax, %eax
je 0x52e7
jmp 0x52e5
jmp 0x52ec
jmp 0x5078
leaq -0x488(%rbp), %rdi
callq 0x2140
jmp 0x530b
leaq -0x488(%rbp), %rdi
callq 0x2140
jmp 0x5414
leaq -0x468(%rbp), %rdi
callq 0x2080
jmp 0x5319
movl -0x14(%rbp), %eax
cmpl -0x18(%rbp), %eax
jne 0x5335
movq -0x4f8(%rbp), %rax
movl -0x14(%rbp), %ecx
movl %ecx, (%rax)
movl -0x1c(%rbp), %ecx
movl %ecx, 0x4(%rax)
jmp 0x5370
movq 0x9c94(%rip), %rdi      # 0xefd0
leaq 0x5dda(%rip), %rsi      # 0xb11d
callq 0x2210
movq %rax, -0x588(%rbp)
jmp 0x5351
movq -0x588(%rbp), %rdi
movq 0x9c61(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x5366
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22a0
movq 0x9c59(%rip), %rdi      # 0xefd0
leaq 0x5dc2(%rip), %rsi      # 0xb140
callq 0x2210
movq %rax, -0x590(%rbp)
jmp 0x538c
movq -0x590(%rbp), %rdi
movq -0x4f8(%rbp), %rax
movl (%rax), %esi
callq 0x2380
movq %rax, -0x598(%rbp)
jmp 0x53aa
movq -0x598(%rbp), %rdi
leaq 0x5d9b(%rip), %rsi      # 0xb153
callq 0x2210
movq %rax, -0x5a0(%rbp)
jmp 0x53c6
movq -0x5a0(%rbp), %rdi
movq -0x4f8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x2380
movq %rax, -0x5a8(%rbp)
jmp 0x53e5
movq -0x5a8(%rbp), %rdi
movq 0x9bcd(%rip), %rsi      # 0xefc0
callq 0x2240
jmp 0x53fa
leaq -0x468(%rbp), %rdi
callq 0x2090
leaq -0x228(%rbp), %rdi
callq 0x2090
jmp 0x542e
leaq -0x468(%rbp), %rdi
callq 0x2090
leaq -0x228(%rbp), %rdi
callq 0x2090
jmp 0x5437
addq $0x5b0, %rsp            # imm = 0x5B0
popq %rbp
retq
movq -0x500(%rbp), %rdi
callq 0x3c10
movq -0x508(%rbp), %rdi
callq 0x3500
movq -0x230(%rbp), %rdi
callq 0x23a0
nopl (%rax,%rax)