// File: /workspace/github_cpp_makefile_star2_O3/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 0x36a01(%rip), %rsi     # 0x49d43
leaq 0xe0(%rsp), %r14
movq %r14, %rdi
movl $0x58, %edx
xorl %ecx, %ecx
callq 0x4839e
leaq 0x36a00(%rip), %rsi     # 0x49d60
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 0x485c6
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 0x133e4
callq 0xb570
movq $0x0, 0x10(%r12)
movq %r12, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x13406
callq 0xb570
movq $0x0, 0x10(%r15)
movq %r15, 0x28(%rsp)
leaq 0x98(%rsp), %r15
leaq 0x2e8(%rsp), %r12
leaq 0x40(%rsp), %rbp
leaq 0x88(%rsp), %r13
leaq 0xc8(%rsp), %rbx
movq 0xe0(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0xe0(%rsp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0xb450
movsbl %al, %edx
movq %r14, %rdi
leaq 0xa8(%rsp), %rsi
callq 0xb7d0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x13673
xorps %xmm0, %xmm0
leaq 0x68(%rsp), %rax
movups %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movq %r12, %rdi
leaq 0xa8(%rsp), %rsi
movl $0x8, %edx
callq 0xb710
movq %r12, %rdi
leaq 0x60(%rsp), %rsi
callq 0xb870
leaq 0x50(%rsp), %rax
movq %rax, 0x40(%rsp)
movq $0x0, 0x48(%rsp)
movb $0x0, 0x50(%rsp)
movq %r12, %rdi
movq %rbp, %rsi
callq 0xb550
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x135a4
movq %r15, 0x88(%rsp)
movq %r13, %rdi
leaq 0x38dce(%rip), %rsi     # 0x4c2c0
leaq 0x38dc8(%rip), %rdx     # 0x4c2c1
callq 0x15f3e
movq %rbx, %rdi
movq %rbp, %rdx
movq %r13, %rcx
callq 0xc08c
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x1351e
callq 0xb440
movq 0xc8(%rsp), %r14
movq 0xd0(%rsp), %rax
subq %r14, %rax
cmpq $0x40, %rax
jne 0x13597
movq (%r14), %rdi
callq 0xb680
movl %eax, %r12d
movq 0x20(%r14), %rdi
callq 0xb530
cvtsd2ss %xmm0, %xmm0
movslq %r12d, %rax
movq %rax, 0x88(%rsp)
movss %xmm0, 0x90(%rsp)
movq 0x70(%rsp), %rsi
cmpq 0x78(%rsp), %rsi
je 0x13582
movups 0x88(%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x70(%rsp)
jmp 0x1358f
leaq 0x68(%rsp), %rdi
movq %r13, %rdx
callq 0x243d2
leaq 0x2e8(%rsp), %r12
movq %rbx, %rdi
callq 0x1382a
jmp 0x134c3
movq %rsp, %rdi
leaq 0x60(%rsp), %rsi
callq 0x24080
movq 0x8(%rsp), %rax
subq (%rsp), %rax
sarq $0x5, %rax
movq 0x18(%rsp), %rcx
cmpq (%rcx), %rax
jb 0x13623
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq %rsp, %rcx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x240bc
movq (%rsp), %r14
movq 0x8(%rsp), %r12
cmpq %r14, %r12
je 0x13623
movq %r14, 0x80(%rsp)
movq 0x8(%r14), %rdi
testq %rdi, %rdi
je 0x1360d
callq 0xb440
addq $0x20, %r14
cmpq %r12, %r14
jne 0x135ff
movq 0x80(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x13637
callq 0xb440
leaq 0x2e8(%rsp), %r12
movq %r12, %rdi
movq 0x5a957(%rip), %rsi     # 0x6dfa0
callq 0xb600
leaq 0x360(%rsp), %rdi
callq 0xb130
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x13430
callq 0xb440
jmp 0x13430
movq %rsp, %rcx
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
callq 0x240bc
movq (%rsp), %rbx
movq 0x8(%rsp), %r14
cmpq %rbx, %r14
je 0x136c1
movq %rbx, %r15
movq 0x8(%r15), %rdi
testq %rdi, %rdi
je 0x136b3
callq 0xb440
addq $0x20, %r15
cmpq %r14, %r15
jne 0x136a5
movq %rbx, 0x8(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xb0d0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x136e8
callq 0xb440
movq %rsp, %rdi
callq 0x2438c
movb $0x1, %al
addq $0x468, %rsp            # imm = 0x468
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x1372f
movq %rax, %rbx
jmp 0x137b3
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0x485c6
jmp 0x137d5
movq %rax, %rbx
jmp 0x13776
movq %rax, %rbx
jmp 0x13797
jmp 0x1375f
movq %rax, %rbx
jmp 0x137a6
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x1382a
jmp 0x13762
jmp 0x1375f
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0x13762
callq 0xb440
jmp 0x13762
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x13776
callq 0xb440
movq 0x5a823(%rip), %rsi     # 0x6dfa0
leaq 0x2e8(%rsp), %rdi
callq 0xb600
leaq 0x360(%rsp), %rdi
callq 0xb130
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x137a6
callq 0xb440
leaq 0xe0(%rsp), %rdi
callq 0xb0d0
movq 0xa8(%rsp), %rdi
leaq 0xb8(%rsp), %rax
cmpq %rax, %rdi
je 0x137cd
callq 0xb440
movq %rsp, %rdi
callq 0x2438c
movq %rbx, %rdi
callq 0xb770
nop