// File: /workspace/github_cpp_makefile_star2_O2/qmmlib[P]QmmLibrary/linear.cpp
// Function: load_model
struct model *load_model(const char *model_file_name)
{
	FILE *fp = fopen(model_file_name,"r");
	if(fp==NULL) return NULL;

	int i;
	int nr_feature;
	int n;
	int nr_class;
	double bias;
	model *model_ = Malloc(model,1);
	parameter& param = model_->param;

	model_->label = NULL;
	
	char *old_locale = strdup(setlocale(LC_ALL, NULL));
	setlocale(LC_ALL, "C");

	char cmd[81];
	while(1)
	{
		fscanf(fp,"%80s",cmd);
		if(strcmp(cmd,"solver_type")==0)
		{
			fscanf(fp,"%80s",cmd);
			int i;
			for(i=0;solver_type_table[i];i++)
			{
				if(strcmp(solver_type_table[i],cmd)==0)
				{
					param.solver_type=i;
					break;
				}
			}
			if(solver_type_table[i] == NULL)
			{
				fprintf(stderr,"unknown solver type.\n");
				
				setlocale(LC_ALL, old_locale);
				free(model_->label);
				free(model_);
				free(old_locale);
				return NULL;
			}
		}
		else if(strcmp(cmd,"nr_class")==0)
		{
			fscanf(fp,"%d",&nr_class);
			model_->nr_class=nr_class;
		}
		else if(strcmp(cmd,"nr_feature")==0)
		{
			fscanf(fp,"%d",&nr_feature);
			model_->nr_feature=nr_feature;
		}
		else if(strcmp(cmd,"bias")==0)
		{
			fscanf(fp,"%lf",&bias);
			model_->bias=bias;
		}
		else if(strcmp(cmd,"w")==0)
		{
			break;
		}
		else if(strcmp(cmd,"label")==0)
		{
			int nr_class = model_->nr_class;
			model_->label = Malloc(int,nr_class);
			for(int i=0;i<nr_class;i++)
				fscanf(fp,"%d",&model_->label[i]);
		}
		else
		{
			fprintf(stderr,"unknown text in model file: [%s]\n",cmd);
			setlocale(LC_ALL, old_locale);
			free(model_->label);
			free(model_);
			free(old_locale);
			return NULL;
		}
	}

	nr_feature=model_->nr_feature;
	if(model_->bias>=0)
		n=nr_feature+1;
	else
		n=nr_feature;
	int w_size = n;
	int nr_w;
	if(nr_class==2 && param.solver_type != MCSVM_CS)
		nr_w = 1;
	else
		nr_w = nr_class;

	model_->w=Malloc(double, w_size*nr_w);
	for(i=0; i<w_size; i++)
	{
		int j;
		for(j=0; j<nr_w; j++)
			fscanf(fp, "%lf ", &model_->w[i*nr_w+j]);
		fscanf(fp, "\n");
	}
	
	setlocale(LC_ALL, old_locale);
	free(old_locale);
	
	if (ferror(fp) != 0 || fclose(fp) != 0) return NULL;

	return model_;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
leaq 0x34ec(%rip), %rsi      # 0x152b4
callq 0x32a0
xorl %r14d, %r14d
testq %rax, %rax
je 0x12111
movq %rax, %r15
movl $0xd0, %edi
callq 0x3320
movq %rax, (%rsp)
andq $0x0, 0xc0(%rax)
pushq $0x6
popq %rbp
movl %ebp, %edi
xorl %esi, %esi
callq 0x31e0
movq %rax, %rdi
callq 0x3460
movq %rax, 0x20(%rsp)
leaq 0x4a9f(%rip), %rsi      # 0x168b1
movl %ebp, %edi
callq 0x31e0
leaq 0x40(%rsp), %rbp
leaq 0x47bd(%rip), %r14      # 0x165e2
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
movslq %ecx, %rax
leaq (,%rax,4), %rdx
movq %rdx, 0x28(%rsp)
testl %eax, %eax
movl $0x0, %r13d
movl %ecx, 0x8(%rsp)
cmovgl %ecx, %r13d
shlq $0x2, %r13
movq %r15, %rdi
leaq 0x47af(%rip), %rsi      # 0x1660a
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3470
movq %rbp, %rdi
leaq 0x47a0(%rip), %rsi      # 0x1660f
pushq $0xc
popq %rdx
callq 0x3250
testl %eax, %eax
je 0x11f39
movq %rbp, %rdi
leaq 0x47a8(%rip), %rsi      # 0x16631
pushq $0x9
popq %rdx
callq 0x3250
testl %eax, %eax
je 0x11f79
movq %rbp, %rdi
leaq 0x4797(%rip), %rsi      # 0x1663a
pushq $0xb
popq %rdx
callq 0x3250
testl %eax, %eax
je 0x11fad
movq %rbp, %rdi
leaq 0x4788(%rip), %rsi      # 0x16645
pushq $0x5
popq %rdx
callq 0x3250
testl %eax, %eax
je 0x11fdb
cmpw $0x77, 0x40(%rsp)
je 0x12012
movq %rbp, %rdi
leaq 0x46f8(%rip), %rsi      # 0x165db
pushq $0x6
popq %rdx
callq 0x3250
testl %eax, %eax
jne 0x1216d
movq %rbx, %rbp
movq 0x28(%rsp), %rdi
callq 0x3320
movq %rax, %r12
movq (%rsp), %rax
movq %r12, 0xc0(%rax)
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x11f2c
leaq (%r12,%rbx), %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x3470
addq $0x4, %rbx
jmp 0x11f10
movq %rbp, %rbx
leaq 0x40(%rsp), %rbp
jmp 0x11e51
movq %r15, %rdi
leaq 0x46c7(%rip), %rsi      # 0x1660a
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3470
leaq 0x7c3c(%rip), %r13      # 0x19b90
xorl %ebx, %ebx
cmpq $0x38, %rbx
je 0x12126
movq (%r13), %rdi
movq %rbp, %rsi
callq 0x3350
testl %eax, %eax
je 0x11f9e
incq %rbx
addq $0x8, %r13
jmp 0x11f56
movq %r15, %rdi
movq %r14, %rsi
leaq 0x10(%rsp), %rdx
xorl %eax, %eax
callq 0x3470
movl 0x10(%rsp), %ecx
movq (%rsp), %rax
movl %ecx, 0xb0(%rax)
jmp 0x11e2d
movq (%rsp), %rax
movl %ebx, (%rax)
movl 0x8(%rsp), %ecx
jmp 0x11e2d
movq %r15, %rdi
movq %r14, %rsi
leaq 0x14(%rsp), %rdx
xorl %eax, %eax
callq 0x3470
movl 0x14(%rsp), %ecx
movq (%rsp), %rax
movq %rcx, 0x18(%rsp)
movl %ecx, 0xb4(%rax)
movl 0x8(%rsp), %ecx
jmp 0x11e2d
movq %r15, %rdi
leaq 0x4665(%rip), %rsi      # 0x1664a
leaq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x3470
movsd 0x38(%rsp), %xmm0
movq (%rsp), %rax
movsd %xmm0, 0x30(%rsp)
movsd %xmm0, 0xc8(%rax)
movl 0x8(%rsp), %ecx
jmp 0x11e2d
xorpd %xmm0, %xmm0
movsd 0x30(%rsp), %xmm1
ucomisd %xmm0, %xmm1
movq 0x18(%rsp), %r12
movl %r12d, 0x14(%rsp)
sbbl $-0x1, %r12d
movl 0x10(%rsp), %eax
cmpl $0x4, %ebx
pushq $0x1
popq %rbx
cmovel %eax, %ebx
cmpl $0x2, %eax
cmovnel %eax, %ebx
movl %ebx, %eax
imull %r12d, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x3320
movq %rax, %r14
movq (%rsp), %rax
movq %r14, 0xb8(%rax)
xorl %eax, %eax
testl %ebx, %ebx
movl $0x0, %ecx
cmovgl %ebx, %ecx
movq %rcx, 0x28(%rsp)
movslq %ebx, %rcx
testl %r12d, %r12d
cmovlel %eax, %r12d
movq %r12, 0x18(%rsp)
shlq $0x3, %rcx
movq %rcx, 0x8(%rsp)
leaq 0x45df(%rip), %r13      # 0x16670
xorl %ebx, %ebx
cmpq 0x18(%rsp), %rbx
je 0x120d6
movq 0x28(%rsp), %r12
movq %r14, %rbp
movq %r15, %rdi
subq $0x1, %r12
jb 0x120be
movq %r13, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x3470
addq $0x8, %rbp
jmp 0x120a2
leaq 0x3212(%rip), %rsi      # 0x152d7
xorl %eax, %eax
callq 0x3470
incq %rbx
addq 0x8(%rsp), %r14
jmp 0x12093
pushq $0x6
popq %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x31e0
movq %rbx, %rdi
callq 0x32b0
movq %r15, %rdi
callq 0x3480
testl %eax, %eax
je 0x120ff
xorl %r14d, %r14d
jmp 0x12111
movq %r15, %rdi
callq 0x3220
xorl %r14d, %r14d
testl %eax, %eax
cmoveq (%rsp), %r14
movq %r14, %rax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7eab(%rip), %rax      # 0x19fd8
movq (%rax), %rcx
leaq 0x44e4(%rip), %rdi      # 0x1661b
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x34a0
pushq $0x6
popq %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x31e0
movq %r12, %rdi
callq 0x32b0
movq (%rsp), %rdi
callq 0x32b0
movq %rbx, %rdi
callq 0x32b0
jmp 0x120fa
movq 0x7e64(%rip), %rax      # 0x19fd8
movq (%rax), %rdi
leaq 0x44d0(%rip), %rsi      # 0x1664e
xorl %r14d, %r14d
leaq 0x40(%rsp), %rdx
xorl %eax, %eax
callq 0x3370
pushq $0x6
popq %rdi
movq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x31e0
movq %r12, %rdi
callq 0x32b0
movq (%rsp), %rdi
callq 0x32b0
movq %rbx, %rdi
callq 0x32b0
jmp 0x12111