// File: /workspace/github_cpp_makefile_star2_O1/mattcha[P]sgd-svm/sgd_svm.cpp
// Function: load_line(char const*, Instance&, unsigned int&)
int load_line(
        const char* line,
        Instance &instance,
        uint32_t &max_feature)
{
    double label;
    uint32_t fea_idx;
    double fea_val;

    stringstream ss(line);
    string field;
    if (getline(ss, field, ' ')) 
        label = atof(field.c_str());    
    else {
        fprintf(stderr, "read label fail [%s]\n",
                field.c_str());
        return -1;
    }
    instance.y_label = label;
    //cout << label << " ";

    while (true) {
        if (getline(ss, field, ':')) {
            fea_idx = atoi(field.c_str());
            //cout << fea_idx << ":";
        }
        else
            break;

        if (fea_idx > max_feature)
            max_feature = fea_idx;

        if (getline(ss, field, ' ')) {
            fea_val = atof(field.c_str());
            //cout << fea_val << " ";
        }
        else
            break;

        Feature fea;
        fea.idx = fea_idx;
        fea.val = fea_val;
        instance.f_vec.push_back(fea);
    }

    //cout << endl;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdx, -0x50(%rbp)
movq %rsi, %r14
movq %rdi, %rsi
leaq -0x48(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x3426
leaq -0x1f0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
movl $0x18, %edx
callq 0x21b0
leaq -0x38(%rbp), %rbx
movq -0x10(%rbx), %rdi
cmpq %rbx, %rdi
je 0x3270
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
leaq -0x48(%rbp), %rsi
movq %rbx, (%rsi)
movq $0x0, 0x8(%rsi)
movb $0x0, 0x10(%rsi)
leaq -0x1f0(%rbp), %rdi
movl $0x20, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3360
leaq -0x48(%rbp), %r15
movq (%r15), %rdi
callq 0x2150
movsd %xmm0, (%r14)
leaq 0x8(%r14), %rax
movq %rax, -0x68(%rbp)
leaq -0x1f0(%rbp), %r13
xorl %r12d, %r12d
movq %r13, %rdi
movq %r15, %rsi
movl $0x3a, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x336f
movq -0x48(%rbp), %rdi
callq 0x21a0
movl %eax, %ebx
movq -0x50(%rbp), %rax
cmpl (%rax), %ebx
jbe 0x3304
movq -0x50(%rbp), %rax
movl %ebx, (%rax)
movq %r13, %rdi
movq %r15, %rsi
movl $0x20, %edx
callq 0x2200
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x336f
movq -0x48(%rbp), %rdi
callq 0x2150
movl %ebx, -0x60(%rbp)
movsd %xmm0, -0x58(%rbp)
movq 0x10(%r14), %rsi
cmpq 0x18(%r14), %rsi
je 0x334e
movups -0x60(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x10(%r14)
jmp 0x32c9
movq -0x68(%rbp), %rdi
leaq -0x60(%rbp), %rdx
callq 0x34fe
jmp 0x32c9
leaq -0x48(%rbp), %rdi
callq 0x2410
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3388
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
movq 0x2c31(%rip), %rsi      # 0x5fc0
leaq -0x1f0(%rbp), %rdi
callq 0x20b0
leaq -0x170(%rbp), %rdi
callq 0x2050
movl %r12d, %eax
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33e3
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x341e
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
jmp 0x341e
movq %rax, %rbx
jmp 0x341e
jmp 0x33e3
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x33ff
movq -0x38(%rbp), %rsi
incq %rsi
callq 0x2120
movq 0x2bba(%rip), %rsi      # 0x5fc0
leaq -0x1f0(%rbp), %rdi
callq 0x20b0
leaq -0x170(%rbp), %rdi
callq 0x2050
movq %rbx, %rdi
callq 0x21e0