// File: /workspace/github_cpp_makefile_star2_O1/qmmlib[P]QmmLibrary/train.c
// Function: read_problem(char const*)
void read_problem(const char *filename)
{
	int max_index, inst_max_index, i, max_index_=0;
	long int elements, j;
	FILE *fp = fopen(filename,"r");
	char *endptr;
	char *idx, *val, *label;

	if(fp == NULL)
	{
		fprintf(stderr,"can't open input file %s\n",filename);
		exit(1);
	}

	prob.l = 0;
	elements = 0;
	max_line_len = 1024;
	line = Malloc(char,max_line_len);
	while(readline(fp, 0)!=NULL) 
	{
		char *p = strtok(line," \t"); // label

		// features
		while(1)
		{
			idx = strtok(NULL,":"); 
			p = strtok(NULL," \t");
			if(p == NULL || *p == '\n') // check '\n' as ' ' may be after the last feature
				break;
			if((int) strtol(idx,&endptr,10)>max_index_) 
				max_index_ = (int) strtol(idx,&endptr,10); 
			elements++;
		}
		elements++; // for bias term
		prob.l++;
	}
	param.real_dim = max_index_; 
	rewind(fp);

	prob.bias=bias;

	prob.y = Malloc(double,prob.l);
	prob.x = Malloc(struct feature_node *,prob.l);
	x_space = Malloc(struct feature_node,elements+prob.l);

	max_index = 0;
	j=0;
	for(i=0;i<prob.l;i++)
	{
		inst_max_index = 0; // strtol gives 0 if wrong format
		readline(fp, param.real_dim); //sym
		prob.x[i] = &x_space[j];
		label = strtok(line," \t\n");
		if(label == NULL) // empty line
			exit_input_error(i+1);

		prob.y[i] = strtod(label,&endptr);
		if(endptr == label || *endptr != '\0')
			exit_input_error(i+1);

		while(1)
		{
			idx = strtok(NULL,":");
			val = strtok(NULL," \t");

			if(val == NULL)
				break;

			errno = 0;
			x_space[j].index = (int) strtol(idx,&endptr,10);
			if(endptr == idx || errno != 0 || *endptr != '\0' || x_space[j].index <= inst_max_index)
				exit_input_error(i+1);
			else
				inst_max_index = x_space[j].index;

			errno = 0;
			x_space[j].value = strtod(val,&endptr);
			if(endptr == val || errno != 0 || (*endptr != '\0' && !isspace(*endptr)))
				exit_input_error(i+1);

			++j;
		}

		if(inst_max_index > max_index)
			max_index = inst_max_index;

		if(prob.bias >= 0)
			x_space[j++].value = prob.bias;

		x_space[j++].index = -1;
	}

	if(prob.bias >= 0)
	{
		prob.n=max_index+1;
		for(i=1;i<prob.l;i++)
			(prob.x[i]-2)->index = prob.n; 
		x_space[j-2].index = prob.n;
	}
	else
		prob.n=max_index;

	fclose(fp);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq 0x1202a(%rip), %rsi     # 0x16286
callq 0x3270
testq %rax, %rax
je 0x465b
movq %rax, %r14
movl $0x0, 0x17099(%rip)     # 0x1b310
movl $0x400, 0x170cf(%rip)   # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x32e0
movq %rax, 0x170b6(%rip)     # 0x1b348
movq %r14, 0x18(%rsp)
movq %r14, %rdi
xorl %esi, %esi
callq 0x4a87
testq %rax, %rax
je 0x4338
xorl %r14d, %r14d
leaq 0x11fee(%rip), %r15     # 0x162a2
leaq 0x11fea(%rip), %r12     # 0x162a5
movq %rsp, %r13
xorl %ebp, %ebp
movq 0x17081(%rip), %rdi     # 0x1b348
movq %r15, %rsi
callq 0x3360
xorl %edi, %edi
movq %r12, %rsi
callq 0x3360
movq %rax, %rbx
xorl %edi, %edi
movq %r15, %rsi
callq 0x3360
testq %rax, %rax
je 0x431c
cmpb $0xa, (%rax)
je 0x431c
movq %rbx, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3310
cmpl %eax, %ebp
jge 0x4317
movq %rbx, %rdi
movq %r13, %rsi
movl $0xa, %edx
callq 0x3310
movq %rax, %rbp
incq %r14
jmp 0x42cf
incq %r14
incl 0x16feb(%rip)           # 0x1b310
movq 0x18(%rsp), %rdi
xorl %esi, %esi
callq 0x4a87
testq %rax, %rax
jne 0x42c0
jmp 0x433d
xorl %ebp, %ebp
xorl %r14d, %r14d
movl %ebp, 0x16f7d(%rip)     # 0x1b2c0
movq 0x18(%rsp), %r12
movq %r12, %rdi
callq 0x3070
movsd 0x16fe8(%rip), %xmm0    # 0x1b340
movsd %xmm0, 0x16fc8(%rip)    # 0x1b328
movslq 0x16fa9(%rip), %r15     # 0x1b310
leaq (,%r15,8), %rbx
movq %rbx, %rdi
callq 0x32e0
movq %rax, 0x16f9a(%rip)     # 0x1b318
movq %rbx, %rdi
callq 0x32e0
movq %rax, 0x16f93(%rip)     # 0x1b320
addq %r15, %r14
shlq $0x4, %r14
movq %r14, %rdi
callq 0x32e0
movq %rax, 0x16f65(%rip)     # 0x1b308
movl 0x16f67(%rip), %eax     # 0x1b310
testl %eax, %eax
jle 0x45c2
xorl %r13d, %r13d
xorl %r14d, %r14d
xorl %ebx, %ebx
movl 0x16f01(%rip), %esi     # 0x1b2c0
movq %r12, %rdi
callq 0x4a87
movq %rbx, %rbp
shlq $0x4, %rbp
movq 0x16f33(%rip), %rax     # 0x1b308
addq %rbp, %rax
movq 0x16f41(%rip), %rcx     # 0x1b320
movq %rax, (%rcx,%r13,8)
movq 0x16f5e(%rip), %rdi     # 0x1b348
leaq 0x11eb6(%rip), %rsi     # 0x162a7
callq 0x3360
testq %rax, %rax
je 0x4653
movq %rax, %r12
movq %r14, 0x20(%rsp)
movq %rax, %rdi
movq %rsp, %rsi
callq 0x3160
movq 0x16eff(%rip), %rax     # 0x1b318
movq %r13, 0x8(%rsp)
movsd %xmm0, (%rax,%r13,8)
movq (%rsp), %rax
cmpq %r12, %rax
je 0x4649
cmpb $0x0, (%rax)
jne 0x4649
xorl %r15d, %r15d
xorl %edi, %edi
leaq 0x11e5f(%rip), %rsi     # 0x162a5
callq 0x3360
movq %rax, %r13
xorl %edi, %edi
leaq 0x11e4b(%rip), %rsi     # 0x162a2
callq 0x3360
testq %rax, %rax
je 0x4552
movq %rax, %r14
callq 0x3040
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r13, %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x3310
movq %rax, %r15
movq 0x16e6e(%rip), %rax     # 0x1b308
movl %r15d, (%rax,%rbp)
movq (%rsp), %rax
cmpq %r13, %rax
je 0x4635
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x4635
cmpb $0x0, (%rax)
jne 0x4635
cmpl %r15d, %r12d
jge 0x4635
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r14, %rdi
movq %rsp, %rsi
callq 0x3160
movq 0x16e20(%rip), %rax     # 0x1b308
movsd %xmm0, 0x8(%rax,%rbp)
movq (%rsp), %rax
cmpq %r14, %rax
je 0x463f
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x463f
movsbl (%rax), %edi
testl %edi, %edi
je 0x451d
callq 0x3060
testl %eax, %eax
je 0x463f
incq %rbx
xorl %edi, %edi
leaq 0x11d7c(%rip), %rsi     # 0x162a5
callq 0x3360
movq %rax, %r13
xorl %edi, %edi
leaq 0x11d68(%rip), %rsi     # 0x162a2
callq 0x3360
movq %rax, %r14
addq $0x10, %rbp
movl %r15d, %r12d
testq %rax, %rax
jne 0x4475
movq 0x20(%rsp), %r14
cmpl %r14d, %r15d
cmovgl %r15d, %r14d
movsd 0x16dc2(%rip), %xmm0    # 0x1b328
ucomisd 0x11aa2(%rip), %xmm0    # 0x16010
movq 0x18(%rsp), %r12
jae 0x457a
movq %rbx, %rax
jmp 0x4592
movq 0x16d87(%rip), %rax     # 0x1b308
leaq 0x1(%rbx), %rcx
shlq $0x4, %rbx
movsd %xmm0, 0x8(%rax,%rbx)
movq %rcx, %rax
movq 0x8(%rsp), %r13
movq 0x16d6a(%rip), %rcx     # 0x1b308
leaq 0x1(%rax), %rbx
shlq $0x4, %rax
movl $0xffffffff, (%rcx,%rax) # imm = 0xFFFFFFFF
incq %r13
movslq 0x16d59(%rip), %rax     # 0x1b310
cmpq %rax, %r13
jl 0x43b9
jmp 0x45c7
xorl %ebx, %ebx
xorl %r14d, %r14d
movsd 0x16d59(%rip), %xmm0    # 0x1b328
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x45e2
movl %r14d, 0x16d34(%rip)    # 0x1b314
jmp 0x461f
incl %r14d
movl %r14d, 0x16d28(%rip)    # 0x1b314
cmpl $0x2, %eax
jl 0x460f
movq 0x16d28(%rip), %rcx     # 0x1b320
movl %eax, %eax
movl $0x1, %edx
movq (%rcx,%rdx,8), %rsi
movl %r14d, -0x20(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x45ff
movq 0x16cf2(%rip), %rax     # 0x1b308
shlq $0x4, %rbx
movl %r14d, -0x20(%rax,%rbx)
movq %r12, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31f0
movq 0x8(%rsp), %rdi
callq 0x3540
movq 0x8(%rsp), %rdi
callq 0x351a
movq 0x8(%rsp), %rdi
callq 0x3566
movq %r13, %rdi
callq 0x358c
movq %rbx, %rdi
callq 0x35b2