// File: /workspace/github_cpp_makefile_star2_O3/cjlin1[P]liblinear/linear.cpp
// Function: save_model
int save_model(const char *model_file_name, const struct model *model_)
{
	int i;
	int nr_feature=model_->nr_feature;
	int n;
	const parameter& param = model_->param;

	if(model_->bias>=0)
		n=nr_feature+1;
	else
		n=nr_feature;
	int w_size = n;
	FILE *fp = fopen(model_file_name,"w");
	if(fp==NULL) return -1;

	char *old_locale = setlocale(LC_ALL, NULL);
	if (old_locale)
	{
		old_locale = strdup(old_locale);
	}
	setlocale(LC_ALL, "C");

	int nr_w;
	if(model_->nr_class==2 && model_->param.solver_type != MCSVM_CS)
		nr_w=1;
	else
		nr_w=model_->nr_class;

	fprintf(fp, "solver_type %s\n", solver_type_table[param.solver_type]);
	fprintf(fp, "nr_class %d\n", model_->nr_class);

	if(model_->label)
	{
		fprintf(fp, "label");
		for(i=0; i<model_->nr_class; i++)
			fprintf(fp, " %d", model_->label[i]);
		fprintf(fp, "\n");
	}

	fprintf(fp, "nr_feature %d\n", nr_feature);

	fprintf(fp, "bias %.17g\n", model_->bias);

	if(check_oneclass_model(model_))
		fprintf(fp, "rho %.17g\n", model_->rho);

	fprintf(fp, "w\n");
	for(i=0; i<w_size; i++)
	{
		int j;
		for(j=0; j<nr_w; j++)
			fprintf(fp, "%.17g ", model_->w[i*nr_w+j]);
		fprintf(fp, "\n");
	}

	setlocale(LC_ALL, old_locale);
	free(old_locale);

	if (ferror(fp) != 0 || fclose(fp) != 0) return -1;
	else return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movsd 0x68(%rsi), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movl 0x54(%rsi), %ebx
movl %ebx, %ebp
sbbl $-0x1, %ebp
leaq 0x3d60(%rip), %rsi      # 0xf0ad
callq 0x2190
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testq %rax, %rax
je 0xb57b
movq %rax, %r12
xorl %r14d, %r14d
movl $0x6, %edi
xorl %esi, %esi
callq 0x2120
testq %rax, %rax
je 0xb382
movq %rax, %rdi
callq 0x22b0
movq %rax, %r14
movq %r14, 0x10(%rsp)
leaq 0x4350(%rip), %rsi      # 0xf6de
movl $0x6, %edi
callq 0x2120
movl 0x50(%r15), %eax
movslq (%r15), %rcx
cmpq $0x4, %rcx
movl $0x1, %edx
cmovel %eax, %edx
cmpl $0x2, %eax
cmovnel %eax, %edx
movl %edx, 0x4(%rsp)
leaq 0x78e4(%rip), %rax      # 0x12ca0
movq (%rax,%rcx,8), %rdx
leaq 0x3ce8(%rip), %rsi      # 0xf0af
movq %r12, %rdi
xorl %eax, %eax
callq 0x2220
movl 0x50(%r15), %edx
leaq 0x3ce3(%rip), %rsi      # 0xf0bf
movq %r12, %rdi
xorl %eax, %eax
callq 0x2220
cmpq $0x0, 0x60(%r15)
je 0xb445
leaq 0x3cd8(%rip), %rdi      # 0xf0cc
movl $0x5, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x22f0
cmpl $0x0, 0x50(%r15)
jle 0xb438
leaq 0x3cbe(%rip), %r13      # 0xf0d2
xorl %r14d, %r14d
movq 0x60(%r15), %rax
movl (%rax,%r14,4), %edx
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0x2220
incq %r14
movslq 0x50(%r15), %rax
cmpq %rax, %r14
jl 0xb417
movl $0xa, %edi
movq %r12, %rsi
callq 0x21d0
leaq 0x3c8a(%rip), %rsi      # 0xf0d6
movq %r12, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x2220
movsd 0x68(%r15), %xmm0
leaq 0x3c80(%rip), %rsi      # 0xf0e5
movq %r12, %rdi
movb $0x1, %al
callq 0x2220
cmpl $0x15, (%r15)
jne 0xb48c
movsd 0x70(%r15), %xmm0
leaq 0x3c6f(%rip), %rsi      # 0xf0f1
movq %r12, %rdi
movb $0x1, %al
callq 0x2220
movq %r15, 0x30(%rsp)
leaq 0x3c64(%rip), %rdi      # 0xf0fc
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rcx
callq 0x22f0
testl %ebp, %ebp
jle 0xb542
movl 0x4(%rsp), %eax
movl %ebp, %ecx
movq %rcx, 0x28(%rsp)
movq %rax, 0x18(%rsp)
leaq (,%rax,8), %rax
movq %rax, 0x20(%rsp)
movq $0x0, 0x8(%rsp)
leaq 0x3c20(%rip), %r13      # 0xf0ff
xorl %ebp, %ebp
movq 0x30(%rsp), %r14
cmpl $0x0, 0x4(%rsp)
movq %r12, %r15
jle 0xb519
movq 0x18(%rsp), %r12
movq 0x8(%rsp), %rbx
movq 0x58(%r14), %rax
movsd (%rax,%rbx), %xmm0
movq %r15, %rdi
movq %r13, %rsi
movb $0x1, %al
callq 0x2220
addq $0x8, %rbx
decq %r12
jne 0xb4fa
movl $0xa, %edi
movq %r15, %rsi
callq 0x21d0
incq %rbp
movq 0x8(%rsp), %rax
addq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq 0x28(%rsp), %rbp
movq %r15, %r12
jne 0xb4e6
movl $0x6, %edi
movq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0x2120
movq %rbx, %rdi
callq 0x21a0
movq %r12, %rdi
callq 0x22d0
testl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
jne 0xb57b
movq %r12, %rdi
callq 0x2140
xorl %ecx, %ecx
negl %eax
sbbl %ecx, %ecx
movl %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq