// File: btbujiangjun[P]abcdl/include/utils/LibsvmHelper.h
// Function: abcdl::utils::LibsvmHelper<float>::read_data(unsigned long, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, abcdl::algebra::Matrix<float>*, abcdl::algebra::Matrix<float>*)
bool LibsvmHelper<T>::read_data(const size_t dim,
                                const size_t label_dim,
                                const std::string& file,
                                abcdl::algebra::Matrix<T>* out_data_mat,
                                abcdl::algebra::Matrix<T>* out_label_mat){

    LOG(INFO) << "Start load Libsvm file:" << file;
    std::vector<libsvm_sample> samples;
    std::string line;
    std::ifstream in_file(file);
    out_data_mat->clear();
    out_label_mat->clear();

    while(std::getline(in_file, line)){
        libsvm_sample sample;
        std::istringstream iss(line);
        iss >> sample.label;
        std::string ss;
        while(iss >> ss){
            std::vector<std::string> kv = string_helper.split(ss, ":");
            if (kv.size() != 2){
                continue;
            }
            sample.data.push_back(std::make_pair<int, T>(string_helper.str2int(kv[0]), string_helper.str2real(kv[1])));
        }
        samples.push_back(sample);
        
        if(samples.size() >= delta_size){
            read_data_append_mat(out_data_mat, out_label_mat, samples, dim, label_dim);
            samples.clear();
        }

    }
        
    read_data_append_mat(out_data_mat, out_label_mat, samples, dim, label_dim);
    samples.clear();

    return true;
}

// Assembly:
subq $0x698, %rsp            # imm = 0x698
movq %rdi, 0x690(%rsp)
movq %rsi, 0x688(%rsp)
movq %rdx, 0x680(%rsp)
movq %rcx, 0x678(%rsp)
movq %r8, 0x670(%rsp)
movq %r9, 0x668(%rsp)
movq 0x690(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0xa3b2c(%rip), %rsi     # 0xbddb7
leaq 0x4e0(%rsp), %rdi
movq %rdi, 0x60(%rsp)
movl $0x58, %edx
xorl %ecx, %ecx
callq 0xb8d70
movq 0x60(%rsp), %rdi
leaq 0xa3b24(%rip), %rsi     # 0xbddd4
callq 0x55040
movq %rax, 0x68(%rsp)
jmp 0x1a2bc
movq 0x68(%rsp), %rdi
movq 0x678(%rsp), %rsi
callq 0x55010
jmp 0x1a2d0
leaq 0x4e0(%rsp), %rdi
callq 0xb9130
leaq 0x4b8(%rsp), %rdi
callq 0x55070
leaq 0x498(%rsp), %rdi
callq 0xc790
movq 0x678(%rsp), %rsi
leaq 0x290(%rsp), %rdi
movl $0x8, %edx
callq 0xc880
jmp 0x1a313
movq 0x670(%rsp), %rdi
callq 0x55080
jmp 0x1a322
movq 0x668(%rsp), %rdi
callq 0x55080
jmp 0x1a331
jmp 0x1a333
leaq 0x290(%rsp), %rdi
leaq 0x498(%rsp), %rsi
callq 0xc0d0
movq %rax, 0x50(%rsp)
jmp 0x1a34f
movq 0x50(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xc6e0
movb %al, 0x4f(%rsp)
jmp 0x1a369
movb 0x4f(%rsp), %al
testb $0x1, %al
jne 0x1a376
jmp 0x1a757
leaq 0x270(%rsp), %rdi
callq 0x550e0
leaq 0xf0(%rsp), %rdi
leaq 0x498(%rsp), %rsi
movl $0x8, %edx
callq 0xc8f0
jmp 0x1a39f
leaq 0xf0(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0xc0f0
jmp 0x1a3b6
leaq 0xd0(%rsp), %rdi
callq 0xc790
leaq 0xf0(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xc700
movq %rax, 0x40(%rsp)
jmp 0x1a3df
movq 0x40(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xc6e0
movb %al, 0x3f(%rsp)
jmp 0x1a3f9
movb 0x3f(%rsp), %al
testb $0x1, %al
jne 0x1a406
jmp 0x1a693
movq 0x58(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x28(%rsp)
leaq 0x97(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xc990
movq 0x30(%rsp), %rdx
leaq 0xa5f0e(%rip), %rsi     # 0xc0340
leaq 0x98(%rsp), %rdi
callq 0xc770
jmp 0x1a441
movq 0x28(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
leaq 0x98(%rsp), %rcx
callq 0xd1d0
jmp 0x1a465
leaq 0x98(%rsp), %rdi
callq 0xc340
leaq 0x97(%rsp), %rdi
callq 0xc600
leaq 0xb8(%rsp), %rdi
callq 0x3bcb0
cmpq $0x2, %rax
je 0x1a592
movl $0x4, 0x90(%rsp)
jmp 0x1a649
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x4e0(%rsp), %rdi
callq 0xb9130
jmp 0x1a7fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a7e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a7d6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a748
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a73b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a72e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
jmp 0x1a580
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0x98(%rsp), %rdi
callq 0xc340
leaq 0x97(%rsp), %rdi
callq 0xc600
jmp 0x1a72e
movq 0x58(%rsp), %rax
leaq 0x278(%rsp), %rcx
movq %rcx, 0x8(%rsp)
addq $0x8, %rax
movq %rax, 0x18(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0xb8(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x55160
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0xd5a0
movq 0x10(%rsp), %rdi
movl %eax, 0x74(%rsp)
movl $0x1, %esi
callq 0x55160
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0xd5d0
movss %xmm0, 0x70(%rsp)
leaq 0x74(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x55130
movq %rax, 0x20(%rsp)
jmp 0x1a60c
movq 0x20(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x55180
jmp 0x1a62a
movq 0x8(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x55100
jmp 0x1a63e
movl $0x0, 0x90(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x1aa20
movl 0x90(%rsp), %eax
testl %eax, %eax
je 0x1a668
jmp 0x1a663
jmp 0x1a3c3
jmp 0x1a3c3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x4d8(%rsp)
movl %eax, 0x4d4(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x1aa20
jmp 0x1a72e
leaq 0x4b8(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x551b0
jmp 0x1a6aa
leaq 0x4b8(%rsp), %rdi
callq 0x55220
movq 0x58(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x1a702
movq 0x58(%rsp), %rdi
movq 0x670(%rsp), %rsi
movq 0x668(%rsp), %rdx
movq 0x688(%rsp), %r8
movq 0x680(%rsp), %r9
leaq 0x4b8(%rsp), %rcx
callq 0x55240
jmp 0x1a6f5
leaq 0x4b8(%rsp), %rdi
callq 0x55610
leaq 0xd0(%rsp), %rdi
callq 0xc340
leaq 0xf0(%rsp), %rdi
callq 0xc260
leaq 0x270(%rsp), %rdi
callq 0x55630
jmp 0x1a333
leaq 0xd0(%rsp), %rdi
callq 0xc340
leaq 0xf0(%rsp), %rdi
callq 0xc260
leaq 0x270(%rsp), %rdi
callq 0x55630
jmp 0x1a7d6
movq 0x58(%rsp), %rdi
movq 0x670(%rsp), %rsi
movq 0x668(%rsp), %rdx
movq 0x688(%rsp), %r8
movq 0x680(%rsp), %r9
leaq 0x4b8(%rsp), %rcx
callq 0x55240
jmp 0x1a78b
leaq 0x4b8(%rsp), %rdi
callq 0x55610
movl $0x1, 0x90(%rsp)
leaq 0x290(%rsp), %rdi
callq 0xc140
leaq 0x498(%rsp), %rdi
callq 0xc340
leaq 0x4b8(%rsp), %rdi
callq 0x55650
movb $0x1, %al
andb $0x1, %al
addq $0x698, %rsp            # imm = 0x698
retq
leaq 0x290(%rsp), %rdi
callq 0xc140
leaq 0x498(%rsp), %rdi
callq 0xc340
leaq 0x4b8(%rsp), %rdi
callq 0x55650
movq 0x4d8(%rsp), %rdi
callq 0xc980
nopw (%rax,%rax)