// File: cjlin1[P]liblinear/train.c
// Function: parse_command_line(int, char**, char*, char*)
void parse_command_line(int argc, char **argv, char *input_file_name, char *model_file_name)
{
	int i;
	void (*print_func)(const char*) = NULL;  // default printing to stdout

	// default values
	param.solver_type = L2R_L2LOSS_SVC_DUAL;
	param.C = 1;
	param.p = 0.1;
	param.nu = 0.5;
	param.eps = INF; // see setting below
	param.nr_weight = 0;
	param.regularize_bias = 1;
	param.weight_label = NULL;
	param.weight = NULL;
	param.init_sol = NULL;
	param.w_recalc = false;
	flag_cross_validation = 0;
	flag_C_specified = 0;
	flag_p_specified = 0;
	flag_solver_specified = 0;
	flag_find_parameters = 0;
	bias = -1;

	// parse options
	for(i=1;i<argc;i++)
	{
		if(argv[i][0] != '-') break;
		if(++i>=argc)
			exit_with_help();
		switch(argv[i-1][1])
		{
			case 's':
				param.solver_type = atoi(argv[i]);
				flag_solver_specified = 1;
				break;

			case 'c':
				param.C = atof(argv[i]);
				flag_C_specified = 1;
				break;

			case 'p':
				flag_p_specified = 1;
				param.p = atof(argv[i]);
				break;

			case 'n':
				param.nu = atof(argv[i]);
				break;

			case 'e':
				param.eps = atof(argv[i]);
				break;

			case 'B':
				bias = atof(argv[i]);
				break;

			case 'w':
				++param.nr_weight;
				param.weight_label = (int *) realloc(param.weight_label,sizeof(int)*param.nr_weight);
				param.weight = (double *) realloc(param.weight,sizeof(double)*param.nr_weight);
				param.weight_label[param.nr_weight-1] = atoi(&argv[i-1][2]);
				param.weight[param.nr_weight-1] = atof(argv[i]);
				break;

			case 'v':
				flag_cross_validation = 1;
				nr_fold = atoi(argv[i]);
				if(nr_fold < 2)
				{
					fprintf(stderr,"n-fold cross validation: n must >= 2\n");
					exit_with_help();
				}
				break;

			case 'q':
				print_func = &print_null;
				i--;
				break;

			case 'C':
				flag_find_parameters = 1;
				i--;
				break;

			case 'R':
				param.regularize_bias = 0;
				i--;
				break;

			default:
				fprintf(stderr,"unknown option: -%c\n", argv[i-1][1]);
				exit_with_help();
				break;
		}
	}

	set_print_string_function(print_func);

	// determine filenames
	if(i>=argc)
		exit_with_help();

	strcpy(input_file_name, argv[i]);

	if(i<argc-1)
		strcpy(model_file_name,argv[i+1]);
	else
	{
		char *p = strrchr(argv[i],'/');
		if(p==NULL)
			p = argv[i];
		else
			++p;
		sprintf(model_file_name,"%s.model",p);
	}

	// default solver for parameter selection is L2R_L2LOSS_SVC
	if(flag_find_parameters)
	{
		if(!flag_cross_validation)
			nr_fold = 5;
		if(!flag_solver_specified)
		{
			fprintf(stderr, "Solver not specified. Using -s 2\n");
			param.solver_type = L2R_L2LOSS_SVC;
		}
		else if(param.solver_type != L2R_LR && param.solver_type != L2R_L2LOSS_SVC && param.solver_type != L2R_L2LOSS_SVR)
		{
			fprintf(stderr, "Warm-start parameter search only available for -s 0, -s 2 and -s 11\n");
			exit_with_help();
		}
	}

	if(param.eps == INF)
	{
		switch(param.solver_type)
		{
			case L2R_LR:
			case L2R_L2LOSS_SVC:
				param.eps = 0.01;
				break;
			case L2R_L2LOSS_SVR:
				param.eps = 0.0001;
				break;
			case L2R_L2LOSS_SVC_DUAL:
			case L2R_L1LOSS_SVC_DUAL:
			case MCSVM_CS:
			case L2R_LR_DUAL:
				param.eps = 0.1;
				break;
			case L1R_L2LOSS_SVC:
			case L1R_LR:
				param.eps = 0.01;
				break;
			case L2R_L1LOSS_SVR_DUAL:
			case L2R_L2LOSS_SVR_DUAL:
				param.eps = 0.1;
				break;
			case ONECLASS_SVM:
				param.eps = 0.01;
				break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x1, 0x13caf(%rip)     # 0x16258
movsd 0xfa77(%rip), %xmm0     # 0x12028
movsd %xmm0, 0x13caf(%rip)    # 0x16268
movsd 0xfa5f(%rip), %xmm0     # 0x12020
movsd %xmm0, 0x13cbf(%rip)    # 0x16288
movsd 0xfa47(%rip), %xmm0     # 0x12018
movsd %xmm0, 0x13cb7(%rip)    # 0x16290
movsd 0xfa2f(%rip), %xmm0     # 0x12010
movsd %xmm0, 0x13c77(%rip)    # 0x16260
movl $0x0, 0x13c7d(%rip)     # 0x16270
movl $0x1, 0x13ca3(%rip)     # 0x162a0
movq $0x0, 0x13c70(%rip) # 0x16278
movq $0x0, 0x13c6d(%rip) # 0x16280
movq $0x0, 0x13c7a(%rip) # 0x16298
movb $0x0, 0x13c7f(%rip)     # 0x162a4
movl $0x0, 0x13ca1(%rip)     # 0x162d0
movl $0x0, 0x13c9f(%rip)     # 0x162d8
movl $0x0, 0x13c99(%rip)     # 0x162dc
movl $0x0, 0x13c93(%rip)     # 0x162e0
movl $0x0, 0x13c7d(%rip)     # 0x162d4
movsd 0xf9a9(%rip), %xmm0     # 0x12008
movsd %xmm0, 0x13c81(%rip)    # 0x162e8
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x2926
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x2693
jmp 0x2926
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl -0x4(%rbp), %eax
jl 0x26a6
callq 0x23d0
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
addl $-0x42, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x35, %eax
ja 0x28e4
movq -0x40(%rbp), %rax
leaq 0xf971(%rip), %rcx      # 0x12048
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2200
movl %eax, 0x13b61(%rip)     # 0x16258
movl $0x1, 0x13bdf(%rip)     # 0x162e0
jmp 0x2916
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movsd %xmm0, 0x13b49(%rip)    # 0x16268
movl $0x1, 0x13baf(%rip)     # 0x162d8
jmp 0x2916
movl $0x1, 0x13ba4(%rip)     # 0x162dc
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movsd %xmm0, 0x13b37(%rip)    # 0x16288
jmp 0x2916
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movsd %xmm0, 0x13b21(%rip)    # 0x16290
jmp 0x2916
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movsd %xmm0, 0x13ad3(%rip)    # 0x16260
jmp 0x2916
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movsd %xmm0, 0x13b3d(%rip)    # 0x162e8
jmp 0x2916
movl 0x13aba(%rip), %eax     # 0x16270
addl $0x1, %eax
movl %eax, 0x13ab1(%rip)     # 0x16270
movq 0x13ab2(%rip), %rdi     # 0x16278
movslq 0x13aa3(%rip), %rsi     # 0x16270
shlq $0x2, %rsi
callq 0x2230
movq %rax, 0x13a9b(%rip)     # 0x16278
movq 0x13a9c(%rip), %rdi     # 0x16280
movslq 0x13a85(%rip), %rsi     # 0x16270
shlq $0x3, %rsi
callq 0x2230
movq %rax, 0x13a85(%rip)     # 0x16280
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
addq $0x2, %rdi
callq 0x2200
movl %eax, %edx
movq 0x13a5a(%rip), %rax     # 0x16278
movl 0x13a4c(%rip), %ecx     # 0x16270
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x21a0
movq 0x13a3b(%rip), %rax     # 0x16280
movl 0x13a25(%rip), %ecx     # 0x16270
subl $0x1, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x2916
movl $0x1, 0x13a6b(%rip)     # 0x162d0
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2200
movl %eax, 0x13a68(%rip)     # 0x162e4
cmpl $0x2, 0x13a61(%rip)     # 0x162e4
jge 0x28a2
movq 0x13754(%rip), %rax     # 0x15fe0
movq (%rax), %rdi
leaq 0x1030f(%rip), %rsi     # 0x12ba5
movb $0x0, %al
callq 0x21f0
callq 0x23d0
jmp 0x2916
leaq -0x4eb(%rip), %rax      # 0x23c0
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2916
movl $0x1, 0x13a10(%rip)     # 0x162d4
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2916
movl $0x0, 0x139c7(%rip)     # 0x162a0
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2916
movq 0x136f5(%rip), %rax     # 0x15fe0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %edx
leaq 0x102c1(%rip), %rsi     # 0x12bcb
movb $0x0, %al
callq 0x21f0
callq 0x23d0
jmp 0x2918
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x266e
movq -0x30(%rbp), %rdi
callq 0xc130
movl -0x24(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x293c
callq 0x23d0
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2110
movl -0x24(%rbp), %eax
movl -0x4(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x297a
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x2110
jmp 0x29cf
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movl $0x2f, %esi
callq 0x2140
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x29ad
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
jmp 0x29b9
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x10218(%rip), %rsi     # 0x12be0
movb $0x0, %al
callq 0x2080
cmpl $0x0, 0x138fe(%rip)     # 0x162d4
je 0x2a54
cmpl $0x0, 0x138f1(%rip)     # 0x162d0
jne 0x29eb
movl $0x5, 0x138f9(%rip)     # 0x162e4
cmpl $0x0, 0x138ee(%rip)     # 0x162e0
jne 0x2a18
movq 0x135e5(%rip), %rax     # 0x15fe0
movq (%rax), %rdi
leaq 0x101e4(%rip), %rsi     # 0x12be9
movb $0x0, %al
callq 0x21f0
movl $0x2, 0x13842(%rip)     # 0x16258
jmp 0x2a52
cmpl $0x0, 0x13839(%rip)     # 0x16258
je 0x2a50
cmpl $0x2, 0x13830(%rip)     # 0x16258
je 0x2a50
cmpl $0xb, 0x13827(%rip)     # 0x16258
je 0x2a50
movq 0x135a6(%rip), %rax     # 0x15fe0
movq (%rax), %rdi
leaq 0x101c7(%rip), %rsi     # 0x12c0b
movb $0x0, %al
callq 0x21f0
callq 0x23d0
jmp 0x2a52
jmp 0x2a54
movsd 0x13804(%rip), %xmm0    # 0x16260
movsd 0xf5ac(%rip), %xmm1     # 0x12010
ucomisd %xmm1, %xmm0
jne 0x2b04
jp 0x2b04
movl 0x137de(%rip), %eax     # 0x16258
movq %rax, -0x48(%rbp)
subq $0x15, %rax
ja 0x2b02
movq -0x48(%rbp), %rax
leaq 0xf691(%rip), %rcx      # 0x12120
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0xf590(%rip), %xmm0     # 0x12030
movsd %xmm0, 0x137b8(%rip)    # 0x16260
jmp 0x2b02
movsd 0xf586(%rip), %xmm0     # 0x12038
movsd %xmm0, 0x137a6(%rip)    # 0x16260
jmp 0x2b02
movsd 0xf55c(%rip), %xmm0     # 0x12020
movsd %xmm0, 0x13794(%rip)    # 0x16260
jmp 0x2b02
movsd 0xf55a(%rip), %xmm0     # 0x12030
movsd %xmm0, 0x13782(%rip)    # 0x16260
jmp 0x2b02
movsd 0xf538(%rip), %xmm0     # 0x12020
movsd %xmm0, 0x13770(%rip)    # 0x16260
jmp 0x2b02
movsd 0xf536(%rip), %xmm0     # 0x12030
movsd %xmm0, 0x1375e(%rip)    # 0x16260
jmp 0x2b04
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)