// File: /workspace/github_cpp_makefile_star2_O1/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 0xa411(%rip), %rsi      # 0xd2f3
callq 0x2190
testq %rax, %rax
je 0x327e
movq %rax, %rbp
movl $0x0, 0xf30b(%rip)      # 0x12208
movl $0x400, 0xf351(%rip)    # imm = 0x400
movl $0x400, %edi            # imm = 0x400
callq 0x21f0
movq %rax, 0xf338(%rip)      # 0x12250
movq %rbp, %rdi
callq 0x354e
xorl %r13d, %r13d
xorl %ebx, %ebx
testq %rax, %rax
je 0x2f6f
leaq 0xa3de(%rip), %r14      # 0xd30f
movq 0xf318(%rip), %rdi      # 0x12250
movq %r14, %rsi
callq 0x2250
xorl %edi, %edi
movq %r14, %rsi
callq 0x2250
testq %rax, %rax
je 0x2f59
cmpb $0xa, (%rax)
je 0x2f59
incq %rbx
jmp 0x2f40
incq %rbx
incl 0xf2a6(%rip)            # 0x12208
movq %rbp, %rdi
callq 0x354e
testq %rax, %rax
jne 0x2f31
movq %rbp, %rdi
callq 0x2070
movsd 0xf2c9(%rip), %xmm0     # 0x12248
movsd %xmm0, 0xf299(%rip)     # 0x12220
movslq 0xf27a(%rip), %r15      # 0x12208
leaq (,%r15,8), %r14
movq %r14, %rdi
callq 0x21f0
movq %rax, 0xf26b(%rip)      # 0x12210
movq %r14, %rdi
callq 0x21f0
movq %rax, 0xf264(%rip)      # 0x12218
addq %r15, %rbx
shlq $0x4, %rbx
movq %rbx, %rdi
callq 0x21f0
movq %rax, 0xf1e6(%rip)      # 0x121b0
movl 0xf238(%rip), %eax      # 0x12208
testl %eax, %eax
jle 0x31e8
xorl %r12d, %r12d
xorl %r13d, %r13d
xorl %ebx, %ebx
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
callq 0x354e
movq %rbx, %rbp
shlq $0x4, %rbp
movq 0xf1b5(%rip), %rax      # 0x121b0
addq %rbp, %rax
movq 0xf213(%rip), %rcx      # 0x12218
movq %rax, (%rcx,%r12,8)
movq 0xf240(%rip), %rdi      # 0x12250
leaq 0xa2fb(%rip), %rsi      # 0xd312
callq 0x2250
testq %rax, %rax
je 0x3276
movq %rax, %r15
movq %r13, 0x20(%rsp)
movq %rax, %rdi
movq %rsp, %rsi
callq 0x20d0
movq 0xf1d1(%rip), %rax      # 0x12210
movq %r12, 0x8(%rsp)
movsd %xmm0, (%rax,%r12,8)
movq (%rsp), %rax
cmpq %r15, %rax
je 0x326c
cmpb $0x0, (%rax)
jne 0x326c
xorl %r15d, %r15d
xorl %edi, %edi
leaq 0xa2aa(%rip), %rsi      # 0xd316
callq 0x2250
movq %rax, %r13
xorl %edi, %edi
leaq 0xa292(%rip), %rsi      # 0xd30f
callq 0x2250
testq %rax, %rax
je 0x3178
movq %rax, %r14
callq 0x2040
movq %rax, 0x10(%rsp)
xorl %r12d, %r12d
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r13, %rdi
movq %rsp, %rsi
movl $0xa, %edx
callq 0x2210
movq %rax, %r15
movq 0xf0f0(%rip), %rax      # 0x121b0
movl %r15d, (%rax,%rbp)
movq (%rsp), %rax
cmpq %r13, %rax
je 0x3258
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x3258
cmpb $0x0, (%rax)
jne 0x3258
cmpl %r15d, %r12d
jge 0x3258
movq 0x10(%rsp), %rax
movl $0x0, (%rax)
movq %r14, %rdi
movq %rsp, %rsi
callq 0x20d0
movq 0xf0a2(%rip), %rax      # 0x121b0
movsd %xmm0, 0x8(%rax,%rbp)
movq (%rsp), %rax
cmpq %r14, %rax
je 0x3262
movq 0x10(%rsp), %rcx
cmpl $0x0, (%rcx)
jne 0x3262
movsbl (%rax), %edi
testl %edi, %edi
je 0x3143
callq 0x2060
testl %eax, %eax
je 0x3262
incq %rbx
xorl %edi, %edi
leaq 0xa1c7(%rip), %rsi      # 0xd316
callq 0x2250
movq %rax, %r13
xorl %edi, %edi
leaq 0xa1af(%rip), %rsi      # 0xd30f
callq 0x2250
movq %rax, %r14
addq $0x10, %rbp
movl %r15d, %r12d
testq %rax, %rax
jne 0x309b
movq 0x20(%rsp), %r13
cmpl %r13d, %r15d
cmovgl %r15d, %r13d
movsd 0xf094(%rip), %xmm0     # 0x12220
ucomisd 0x9e7c(%rip), %xmm0     # 0xd010
movq 0x18(%rsp), %rbp
jae 0x31a0
movq %rbx, %rax
jmp 0x31b8
movq 0xf009(%rip), %rax      # 0x121b0
leaq 0x1(%rbx), %rcx
shlq $0x4, %rbx
movsd %xmm0, 0x8(%rax,%rbx)
movq %rcx, %rax
movq 0xeff1(%rip), %rcx      # 0x121b0
leaq 0x1(%rax), %rbx
shlq $0x4, %rax
movl $0xffffffff, (%rcx,%rax) # imm = 0xFFFFFFFF
movq 0x8(%rsp), %r12
incq %r12
movslq 0xf02b(%rip), %rax      # 0x12208
cmpq %rax, %r12
jl 0x2fe5
jmp 0x31ea
xorl %ebx, %ebx
movsd 0xf02e(%rip), %xmm0     # 0x12220
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jae 0x3205
movl %r13d, 0xf009(%rip)     # 0x1220c
jmp 0x3242
incl %r13d
movl %r13d, 0xeffd(%rip)     # 0x1220c
cmpl $0x2, %eax
jl 0x3232
movq 0xeffd(%rip), %rcx      # 0x12218
movl %eax, %eax
movl $0x1, %edx
movq (%rcx,%rdx,8), %rsi
movl %r13d, -0x20(%rsi)
incq %rdx
cmpq %rdx, %rax
jne 0x3222
movq 0xef77(%rip), %rax      # 0x121b0
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 0x8(%rsp), %rdi
callq 0x243d
movq 0x8(%rsp), %rdi
callq 0x2417
movq 0x8(%rsp), %rdi
callq 0x2463
movq %r12, %rdi
callq 0x2489
movq %rbx, %rdi
callq 0x24af