// File: /workspace/github_cpp_makefile_star2_O3/cjlin1[P]liblinear/train.c
// Function: read_problem(char const*)
void read_problem(const char *filename)
{
	int max_index, inst_max_index, i;
	size_t 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)!=NULL)
	{
		char *p = strtok(line," \t"); // label

		// features
		while(1)
		{
			p = strtok(NULL," \t");
			if(p == NULL || *p == '\n') // check '\n' as ' ' may be after the last feature
				break;
			elements++;
		}
		elements++; // for bias term
		prob.l++;
	}
	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);
		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 0xb45b(%rip), %rsi      # 0xe31b
callq 0x2190
testq %rax, %rax
je 0x324e
movq %rax, %rbp
movl $0x0, 0x1032d(%rip)     # 0x13208
movl $0x400, 0x10373(%rip)   # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x21f0
movq %rax, 0x1035a(%rip)     # 0x13250
movq %rbp, %rdi
callq 0x34f7
xorl %r13d, %r13d
xorl %ebx, %ebx
testq %rax, %rax
je 0x2f4d
leaq 0xb428(%rip), %r14      # 0xe337
movq 0x1033a(%rip), %rdi     # 0x13250
movq %r14, %rsi
callq 0x2250
xorl %edi, %edi
movq %r14, %rsi
callq 0x2250
testq %rax, %rax
je 0x2f37
cmpb $0xa, (%rax)
je 0x2f37
incq %rbx
jmp 0x2f1e
incq %rbx
incl 0x102c8(%rip)           # 0x13208
movq %rbp, %rdi
callq 0x34f7
testq %rax, %rax
jne 0x2f0f
movq %rbp, %rdi
callq 0x2070
movsd 0x102eb(%rip), %xmm0    # 0x13248
movsd %xmm0, (%rsp)
movsd %xmm0, 0x102b6(%rip)    # 0x13220
movslq 0x10297(%rip), %r15     # 0x13208
leaq (,%r15,8), %r14
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x10288(%rip)     # 0x13210
movq %r14, %rdi
callq 0x21f0
movq %rax, 0x10281(%rip)     # 0x13218
addq %r15, %rbx
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x21f0
movq %rax, 0x10203(%rip)     # 0x131b0
testq %r15, %r15
jle 0x31c0
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
callq 0x34f7
movq %rbx, %rbp
shlq $0x4, %rbp
movq 0x101d7(%rip), %rax     # 0x131b0
addq %rbp, %rax
movq 0x10235(%rip), %rcx     # 0x13218
movq %rax, (%rcx,%r12,8)
movq 0x10262(%rip), %rdi     # 0x13250
leaq 0xb345(%rip), %rsi      # 0xe33a
callq 0x2250
testq %rax, %rax
je 0x3246
movq %rax, %r15
movq %r13, 0x20(%rsp)
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x20d0
movq 0x101f1(%rip), %rax     # 0x13210
movq %r12, 0x10(%rsp)
movsd %xmm0, (%rax,%r12,8)
movq 0x8(%rsp), %rax
cmpq %r15, %rax
je 0x323c
cmpb $0x0, (%rax)
jne 0x323c
xorl %r15d, %r15d
xorl %edi, %edi
leaq 0xb2f1(%rip), %rsi      # 0xe33e
callq 0x2250
movq %rax, %r13
xorl %edi, %edi
leaq 0xb2d9(%rip), %rsi      # 0xe337
callq 0x2250
testq %rax, %rax
je 0x315a
movq %rax, %r14
callq 0x2040
movq %rax, (%rsp)
xorl %r12d, %r12d
movq (%rsp), %rax
movl $0x0, (%rax)
movq %r13, %rdi
leaq 0x8(%rsp), %rsi
movl $0xa, %edx
callq 0x2210
movq %rax, %r15
movq 0x1010f(%rip), %rax     # 0x131b0
movl %r15d, (%rax,%rbp)
movq 0x8(%rsp), %rax
cmpq %r13, %rax
je 0x3228
movq (%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x3228
cmpb $0x0, (%rax)
jne 0x3228
cmpl %r15d, %r12d
jge 0x3228
movq (%rsp), %rax
movl $0x0, (%rax)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x20d0
movq 0x100c0(%rip), %rax     # 0x131b0
movsd %xmm0, 0x8(%rax,%rbp)
movq 0x8(%rsp), %rax
cmpq %r14, %rax
je 0x3232
movq (%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x3232
movsbl (%rax), %edi
testl %edi, %edi
je 0x3125
callq 0x2060
testl %eax, %eax
je 0x3232
incq %rbx
xorl %edi, %edi
leaq 0xb20d(%rip), %rsi      # 0xe33e
callq 0x2250
movq %rax, %r13
xorl %edi, %edi
leaq 0xb1f5(%rip), %rsi      # 0xe337
callq 0x2250
movq %rax, %r14
addq $0x10, %rbp
movl %r15d, %r12d
testq %rax, %rax
jne 0x307b
movq 0x20(%rsp), %r13
cmpl %r13d, %r15d
cmovgl %r15d, %r13d
movsd 0x100b2(%rip), %xmm1    # 0x13220
ucomisd 0xaec2(%rip), %xmm1     # 0xe038
movq 0x10033(%rip), %rax     # 0x131b0
movq 0x18(%rsp), %rbp
jae 0x3189
movq %rbx, %rcx
jmp 0x3197
leaq 0x1(%rbx), %rcx
shlq $0x4, %rbx
movsd %xmm1, 0x8(%rax,%rbx)
leaq 0x1(%rcx), %rbx
shlq $0x4, %rcx
movl $0xffffffff, (%rax,%rcx) # imm = 0xFFFFFFFF
movq 0x10(%rsp), %r12
incq %r12
movslq 0x10053(%rip), %r15     # 0x13208
cmpq %r15, %r12
jl 0x2fc3
jmp 0x31c7
xorl %ebx, %ebx
movsd (%rsp), %xmm1
xorpd %xmm0, %xmm0
ucomisd %xmm0, %xmm1
jae 0x31da
movl %r13d, 0x10034(%rip)    # 0x1320c
jmp 0x3212
incl %r13d
movl %r13d, 0x10028(%rip)    # 0x1320c
cmpl $0x2, %r15d
jl 0x3209
movq 0x10027(%rip), %rcx     # 0x13218
movl %r15d, %edx
movl $0x1, %esi
movq (%rcx,%rsi,8), %rdi
movl %r13d, -0x20(%rdi)
incq %rsi
cmpq %rsi, %rdx
jne 0x31f9
shlq $0x4, %rbx
movl %r13d, -0x20(%rax,%rbx)
movq %rbp, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2140
movq 0x10(%rsp), %rdi
callq 0x243d
movq 0x10(%rsp), %rdi
callq 0x2417
movq 0x10(%rsp), %rdi
callq 0x2463
movq %r12, %rdi
callq 0x2489
movq %rbx, %rdi
callq 0x24af