// File: /workspace/github_cpp_makefile_star2_O2/shuimu[P]logistic-regression/lr.cpp
// Function: load_data()
int load_data() {
    FILE * tfp, * pfp;
    int line = 0, sz = 0; 
    char buffer[LINE_LEN];
    char ** str_array = NULL;
 
    // load train file
    if((tfp = fopen(train_file, "r")) == NULL) {
        fprintf(stderr, "train file is not valid\n");
        return -1;
    }
    M = 0;
    while(fgets(buffer, LINE_LEN, tfp) != NULL) {
        vector<double> tmp;
        str_array = split(buffer, '\t', &sz);
        D = sz - 2;
        train_instances.push_back(str_array[0]);
        for(int i = 1; i < sz-1; i++) {
            tmp.push_back(atof(str_array[i]));
        }
        train_features.push_back(tmp);
        labels.push_back(atof(str_array[sz-1]));
        M++;
    }
    fclose(tfp);

    // load predict data
    if((pfp = fopen(predict_file, "r")) == NULL) {
        fprintf(stderr, "load predict file failed");
        return -1;
    }
    while(fgets(buffer, LINE_LEN, pfp) != NULL) {
        vector<double> tmp;
        str_array = split(buffer, '\t', &sz);
        predict_instances.push_back(str_array[0]);
        for(int i = 1; i < sz; i++) {
            tmp.push_back(atof(str_array[i]));
        }
        predict_features.push_back(tmp);
    }
    fclose(pfp);
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
andl $0x0, -0x2c(%rbp)
movq 0x37a9(%rip), %rdi      # 0x5120
leaq 0x1869(%rip), %rsi      # 0x31e7
callq 0x10f0
movq %rax, -0x48(%rbp)
testq %rax, %rax
je 0x1b5a
andl $0x0, 0x3761(%rip)      # 0x50f8
leaq -0x160(%rbp), %rbx
leaq -0x60(%rbp), %r15
leaq -0x40(%rbp), %r12
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq -0x48(%rbp), %rdx
callq 0x1160
testq %rax, %rax
je 0x1a74
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
movq %rbx, %rdi
pushq $0x9
popq %rsi
leaq -0x2c(%rbp), %rdx
callq 0x189d
movq %rax, %r13
movslq -0x2c(%rbp), %rbx
leal -0x2(%rbx), %eax
movl %eax, 0x3711(%rip)      # 0x50fc
leaq 0x378e(%rip), %rdi      # 0x5180
movq %r13, %rsi
callq 0x1e40
movq %rbx, -0x38(%rbp)
decq %rbx
pushq $0x1
popq %r14
cmpq %rbx, %r14
jge 0x1a29
movq (%r13,%r14,8), %rdi
callq 0x1100
movsd %xmm0, -0x40(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x20f0
incq %r14
jmp 0x1a05
leaq 0x3708(%rip), %rdi      # 0x5138
movq %r15, %rsi
callq 0x1e64
movq -0x38(%rbp), %rax
movq -0x8(%r13,%rax,8), %rdi
callq 0x1100
movsd %xmm0, -0x40(%rbp)
leaq 0x3716(%rip), %rdi      # 0x5168
movq %r12, %rsi
callq 0x20f0
incl 0x3698(%rip)            # 0x50f8
movq %r15, %rdi
callq 0x1f18
leaq -0x160(%rbp), %rbx
jmp 0x19a6
movq -0x48(%rbp), %rdi
callq 0x10b0
movq 0x36a4(%rip), %rdi      # 0x5128
leaq 0x175c(%rip), %rsi      # 0x31e7
callq 0x10f0
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x1b6d
leaq -0x160(%rbp), %rbx
leaq -0x60(%rbp), %r15
leaq -0x40(%rbp), %r12
movq %rbx, %rdi
movl $0x100, %esi            # imm = 0x100
movq -0x38(%rbp), %rdx
callq 0x1160
testq %rax, %rax
je 0x1b3d
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
movq %rbx, %rdi
pushq $0x9
popq %rsi
leaq -0x2c(%rbp), %rdx
callq 0x189d
movq %rax, %r13
leaq 0x36b1(%rip), %rdi      # 0x5198
movq %rax, %rsi
callq 0x1e40
movslq -0x2c(%rbp), %r14
pushq $0x1
popq %rbx
cmpq %r14, %rbx
jge 0x1b1a
movq (%r13,%rbx,8), %rdi
callq 0x1100
movsd %xmm0, -0x40(%rbp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x20f0
incq %rbx
jmp 0x1af6
leaq 0x362f(%rip), %rdi      # 0x5150
movq %r15, %rsi
callq 0x1e64
movq %r15, %rdi
callq 0x1f18
leaq -0x160(%rbp), %rbx
jmp 0x1aac
movq -0x38(%rbp), %rdi
callq 0x10b0
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3477(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x167e(%rip), %rdi      # 0x31e9
jmp 0x1b7e
movq 0x3464(%rip), %rax      # 0x4fd8
movq (%rax), %rcx
leaq 0x1684(%rip), %rdi      # 0x3202
pushq $0x18
popq %rsi
pushq $0x1
popq %rdx
callq 0x11b0
pushq $-0x1
popq %rax
jmp 0x1b48
jmp 0x1b96
jmp 0x1b96
jmp 0x1b96
jmp 0x1b96
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x1f18
movq %rbx, %rdi
callq 0x1190