// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x468, %rsp            # imm = 0x468
movq %r9, 0x10(%rsp)
movq %r8, 0x8(%rsp)
movq %rcx, %rbx
movq %rdx, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdi, 0x18(%rsp)
leaq 0x2c5f1(%rip), %rsi     # 0x3ed43
leaq 0xe0(%rsp), %r14
pushq $0x58
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x3d0e4
leaq 0x2c5f2(%rip), %rsi     # 0x3ed60
movq %r14, %rdi
callq 0xb480
leaq 0xe0(%rsp), %rdi
movq %rbx, %rsi
callq 0xb420
leaq 0xe0(%rsp), %rdi
callq 0x3d320
andq $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xe0(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0xb700
movq 0x8(%rsp), %rdi
callq 0x21720
movq 0x10(%rsp), %rdi
callq 0x21720
leaq 0x2e8(%rsp), %r14
leaq 0x60(%rsp), %rbx
leaq 0x2ead0(%rip), %rbp     # 0x412c0
leaq 0xa0(%rsp), %r15
leaq 0x7(%rsp), %r13
leaq 0x48(%rsp), %r12
leaq 0xe0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xb0a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x12997
leaq 0x88(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq %r14, %rdi
leaq 0xc0(%rsp), %rsi
pushq $0x8
popq %rdx
callq 0xb740
movq %r14, %rdi
leaq 0x80(%rsp), %rsi
callq 0xb8a0
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
andq $0x0, 0x68(%rsp)
movb $0x0, 0x70(%rsp)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb580
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1291e
movq %r15, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq 0xb180
movq %r12, %rdi
movq %rbx, %rdx
movq %r15, %rcx
callq 0xbcdc
movq %r15, %rdi
callq 0xb1d0
movq 0x48(%rsp), %r12
movq 0x50(%rsp), %rax
subq %r12, %rax
cmpq $0x40, %rax
jne 0x1290c
movq (%r12), %rdi
callq 0xb6b0
movl %eax, %r15d
addq $0x20, %r12
movq %r12, %rsi
callq 0xbf44
movslq %r15d, %rax
leaq 0xa0(%rsp), %r15
movq %rax, 0xa0(%rsp)
movss %xmm0, 0xa8(%rsp)
leaq 0x88(%rsp), %rdi
movq %r15, %rsi
callq 0x21996
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x12b3e
jmp 0x12874
leaq 0x20(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x21740
movq 0x28(%rsp), %rax
subq 0x20(%rsp), %rax
sarq $0x5, %rax
movq 0x18(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x12975
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x20(%rsp), %rcx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x2176c
leaq 0x20(%rsp), %rdi
callq 0x2196c
movq %rbx, %rdi
callq 0xb1d0
movq %r14, %rdi
callq 0xb1f0
leaq 0x88(%rsp), %rdi
callq 0x21c54
jmp 0x12802
leaq 0x20(%rsp), %rcx
movq 0x18(%rsp), %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
callq 0x2176c
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0x2196c
leaq 0xe0(%rsp), %rdi
callq 0xb0e0
leaq 0xc0(%rsp), %rdi
callq 0xb1d0
movq %rbx, %rdi
callq 0x21974
movb $0x1, %al
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x12a20
movq %rax, %rbx
jmp 0x12a7e
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x3d320
jmp 0x12a95
movq %rax, %rbx
jmp 0x12a57
movq %rax, %rbx
jmp 0x12a64
movq %rax, %rbx
jmp 0x12a71
jmp 0x12a4a
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x12b3e
jmp 0x12a4d
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xb1d0
jmp 0x12a4d
jmp 0x12a4a
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0xb1d0
leaq 0x2e8(%rsp), %rdi
callq 0xb1f0
leaq 0x88(%rsp), %rdi
callq 0x21c54
leaq 0xe0(%rsp), %rdi
callq 0xb0e0
leaq 0xc0(%rsp), %rdi
callq 0xb1d0
leaq 0x20(%rsp), %rdi
callq 0x21974
movq %rbx, %rdi
callq 0xb7b0
nop