// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdi, 0x18(%rsp)
leaq 0x376db(%rip), %rsi     # 0x4ad43
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movl $0x58, %edx
xorl %ecx, %ecx
callq 0x4854e
leaq 0x376da(%rip), %rsi     # 0x4ad60
movl $0x17, %edx
movq %r14, %rdi
callq 0xb4d0
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
leaq 0xe0(%rsp), %rdi
callq 0xb4d0
leaq 0xe0(%rsp), %rdi
callq 0x48776
xorl %eax, %eax
movq %rax, 0x10(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
leaq 0xb8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
leaq 0xe0(%rsp), %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0xb6d0
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movq 0x10(%r12), %rdi
testq %rdi, %rdi
je 0x1370a
callq 0xb570
movq $0x0, 0x10(%r12)
movq %r12, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x1372c
callq 0xb570
movq $0x0, 0x10(%r15)
movq %r15, 0x28(%rsp)
leaq 0x98(%rsp), %r14
leaq 0x40(%rsp), %rbp
leaq 0x88(%rsp), %r13
leaq 0xc8(%rsp), %rbx
movq 0xe0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xe0(%rsp), %r15
addq %r15, %rdi
movl $0xa, %esi
callq 0xb450
movsbl %al, %edx
movq %r15, %rdi
leaq 0xa8(%rsp), %rsi
callq 0xb7d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x13999
xorps %xmm0, %xmm0
leaq 0x68(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
leaq 0x2e8(%rsp), %r15
movq %r15, %rdi
leaq 0xa8(%rsp), %rsi
movl $0x8, %edx
callq 0xb710
movq %r15, %rdi
leaq 0x60(%rsp), %rsi
callq 0xb870
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movb $0x0, 0x50(%rsp)
movq %r15, %rdi
movq %rbp, %rsi
callq 0xb550
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x138cc
movq %r14, 0x88(%rsp)
movq %r13, %rdi
leaq 0x39aa8(%rip), %rsi     # 0x4d2c0
leaq 0x39aa2(%rip), %rdx     # 0x4d2c1
callq 0x1625a
movq %rbx, %rdi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xc0ac
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x13844
callq 0xb440
movq 0xc8(%rsp), %r12
movq 0xd0(%rsp), %rax
subq %r12, %rax
cmpq $0x40, %rax
jne 0x138bf
movq (%r12), %rdi
callq 0xb680
movl %eax, %r15d
movq 0x20(%r12), %rdi
callq 0xb530
cvtsd2ss %xmm0, %xmm0
movslq %r15d, %rax
movq %rax, 0x88(%rsp)
movss %xmm0, 0x90(%rsp)
movq 0x70(%rsp), %rsi
cmpq 0x78(%rsp), %rsi
je 0x138aa
movups 0x88(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x70(%rsp)
jmp 0x138b7
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x246ae
leaq 0x2e8(%rsp), %r15
movq %rbx, %rdi
callq 0x13b50
jmp 0x137e9
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
callq 0x24362
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x5, %rax
movq 0x18(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x1394c
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rsp, %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x2439e
movq (%rsp), %r12
movq 0x8(%rsp), %r15
cmpq %r12, %r15
je 0x1394c
movq %r12, 0x80(%rsp)
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x13936
callq 0xb440
addq $0x20, %r12
cmpq %r15, %r12
jne 0x13927
movq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x13960
callq 0xb440
leaq 0x2e8(%rsp), %rdi
movq 0x5b631(%rip), %rsi     # 0x6efa0
callq 0xb600
leaq 0x360(%rsp), %rdi
callq 0xb130
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x1374e
callq 0xb440
jmp 0x1374e
movq %rsp, %rcx
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x2439e
movq (%rsp), %rbx
movq 0x8(%rsp), %r14
cmpq %rbx, %r14
je 0x139e7
movq %rbx, %r15
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x139d9
callq 0xb440
addq $0x20, %r15
cmpq %r14, %r15
jne 0x139cb
movq %rbx, 0x8(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xb0d0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x13a0e
callq 0xb440
movq %rsp, %rdi
callq 0x2466e
movb $0x1, %al
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x13a55
movq %rax, %rbx
jmp 0x13ad9
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x48776
jmp 0x13afb
movq %rax, %rbx
jmp 0x13a9c
movq %rax, %rbx
jmp 0x13abd
jmp 0x13a85
movq %rax, %rbx
jmp 0x13acc
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x13b50
jmp 0x13a88
jmp 0x13a85
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r14, %rdi
je 0x13a88
callq 0xb440
jmp 0x13a88
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x13a9c
callq 0xb440
movq 0x5b4fd(%rip), %rsi     # 0x6efa0
leaq 0x2e8(%rsp), %rdi
callq 0xb600
leaq 0x360(%rsp), %rdi
callq 0xb130
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x13acc
callq 0xb440
leaq 0xe0(%rsp), %rdi
callq 0xb0d0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x13af3
callq 0xb440
movq %rsp, %rdi
callq 0x2466e
movq %rbx, %rdi
callq 0xb770
nop