// File: poseidon1214[P]logistic-regression-ftrl-mpi/src/load_data.h
// Function: Load_Data::load_data_batch(int, int)
void load_data_batch(int nproc, int rank){
        MPI_Status status;
        fea_matrix.clear();
        //std::cout<<"load batch data start..."<<std::endl;
        while(!fin_.eof()){
            std::getline(fin_, line);
            if(fin_.eof()) break;
            key_val.clear();
            const char *pline = line.c_str();
            if(sscanf(pline, "%d%n", &y, &nchar) >= 1){
                pline += nchar;
                label.push_back(y);
                while(sscanf(pline, "%ld:%d%n", &index, &value, &nchar) >= 2){
                //while(sscanf(pline, "%ld:%lf%n", &index, &value, &nchar) >= 2){
                    pline += nchar;
                    sf.idx = index;
                    if(index+1 > loc_fea_dim) loc_fea_dim = index+1;
                    sf.val = value;
                    key_val.push_back(sf);
                }
            }
            fea_matrix.push_back(key_val);
        }
        if(rank != 0) {
            MPI_Send(&loc_fea_dim, 1, MPI_LONG, 0, 90, MPI_COMM_WORLD);
        }
        else if(rank == 0){ 
            for(int i = 1; i < nproc; i++){
                MPI_Recv(&loc_fea_dim, 1, MPI_LONG, i, 90, MPI_COMM_WORLD, &status);
                if(loc_fea_dim > glo_fea_dim) glo_fea_dim = loc_fea_dim;
            }
        }
        MPI_Bcast(&glo_fea_dim, 1, MPI_LONG, 0, MPI_COMM_WORLD);//must be in all processes code;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
addq $0x208, %rdi            # imm = 0x208
callq 0xebc0
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x8bc0
xorb $-0x1, %al
testb $0x1, %al
jne 0x9ad1
jmp 0x9c53
movq -0x40(%rbp), %rdi
movq %rdi, %rsi
addq $0x260, %rsi            # imm = 0x260
callq 0x80e0
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
addq -0x18(%rax), %rdi
callq 0x8bc0
testb $0x1, %al
jne 0x9afa
jmp 0x9aff
jmp 0x9c53
movq -0x40(%rbp), %rdi
addq $0x220, %rdi            # imm = 0x220
callq 0xebe0
movq -0x40(%rbp), %rdi
addq $0x260, %rdi            # imm = 0x260
callq 0x8210
movq -0x40(%rbp), %rcx
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq %rcx, %rdx
addq $0x280, %rdx            # imm = 0x280
addq $0x284, %rcx            # imm = 0x284
leaq 0x954f(%rip), %rsi      # 0x13092
movb $0x0, %al
callq 0x85d0
cmpl $0x1, %eax
jl 0x9c34
movq -0x40(%rbp), %rsi
movl 0x284(%rsi), %ecx
movq -0x30(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq %rsi, %rdi
addq $0x248, %rdi            # imm = 0x248
addq $0x280, %rsi            # imm = 0x280
callq 0xec00
movq -0x40(%rbp), %r8
movq -0x30(%rbp), %rdi
movq %r8, %rdx
addq $0x290, %rdx            # imm = 0x290
movq %r8, %rcx
addq $0x288, %rcx            # imm = 0x288
addq $0x284, %r8             # imm = 0x284
leaq 0x94e3(%rip), %rsi      # 0x1308e
movb $0x0, %al
callq 0x85d0
cmpl $0x2, %eax
jl 0x9c32
movq -0x40(%rbp), %rcx
movl 0x284(%rcx), %edx
movq -0x30(%rbp), %rax
movslq %edx, %rdx
addq %rdx, %rax
movq %rax, -0x30(%rbp)
movq 0x290(%rcx), %rax
movq %rax, 0x238(%rcx)
movq 0x290(%rcx), %rax
addq $0x1, %rax
cmpq 0x298(%rcx), %rax
jle 0x9c07
movq -0x40(%rbp), %rax
movq 0x290(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x298(%rax)
movq -0x40(%rbp), %rsi
movl 0x288(%rsi), %eax
movl %eax, 0x240(%rsi)
movq %rsi, %rdi
addq $0x220, %rdi            # imm = 0x220
addq $0x238, %rsi            # imm = 0x238
callq 0xec70
jmp 0x9b81
jmp 0x9c34
movq -0x40(%rbp), %rsi
movq %rsi, %rdi
addq $0x208, %rdi            # imm = 0x208
addq $0x220, %rsi            # imm = 0x220
callq 0xece0
jmp 0x9ab6
cmpl $0x0, -0x10(%rbp)
je 0x9c89
movq -0x40(%rbp), %rdi
addq $0x298, %rdi            # imm = 0x298
movl $0x1, %esi
movq 0x11350(%rip), %rdx     # 0x1afc0
xorl %ecx, %ecx
movl $0x5a, %r8d
movq 0x11329(%rip), %r9      # 0x1afa8
callq 0x81e0
jmp 0x9d09
cmpl $0x0, -0x10(%rbp)
jne 0x9d07
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x9d05
movq -0x40(%rbp), %rdi
addq $0x298, %rdi            # imm = 0x298
movl -0x34(%rbp), %ecx
movl $0x1, %esi
movq 0x11308(%rip), %rdx     # 0x1afc0
movl $0x5a, %r8d
movq 0x112e3(%rip), %r9      # 0x1afa8
leaq -0x28(%rbp), %rax
movq %rax, (%rsp)
callq 0x84e0
movq -0x40(%rbp), %rcx
movq 0x298(%rcx), %rax
cmpq 0x2a0(%rcx), %rax
jle 0x9cf8
movq -0x40(%rbp), %rax
movq 0x298(%rax), %rcx
movq %rcx, 0x2a0(%rax)
jmp 0x9cfa
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x9c96
jmp 0x9d07
jmp 0x9d09
movq -0x40(%rbp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
movl $0x1, %esi
movq 0x112a0(%rip), %rdx     # 0x1afc0
xorl %ecx, %ecx
movq 0x1127f(%rip), %r8      # 0x1afa8
callq 0x80d0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop