// File: /workspace/github_cpp_makefile_star2_O3/qmmlib[P]QmmLibrary/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 = MMCD;
	param.C = 1;
	param.eps = INF; // see setting below
	param.p = 0.1;
	param.nr_weight = 0;
	param.weight_label = NULL;
	param.weight = NULL;
	flag_cross_validation = 0;
	bias = -1;
	param.reg_param   = 1; // L2 regularizer
	param.loss_param  = 0.5; // tau for HU1, HU2
	param.curv_param  = 1e-3; // epsilon for minimum curvature value for NC
	param.loss_type   = HU2; // Huberized-hinge loss
	param.curv_type   = OC; // optimal curv
	param.turn_to_nc  = 0;
	param.save_each_iter = 0;
	param.init_model_file = NULL;
	param.chat_level = 0; // minimal talk
	param.cg_tol = 0.001;
	param.cd_tol = 0.01;
	param.cd_reset = 10;
	param.structured_w = 0;
	param.transform_matrix = 0;
	param.tmx_c = 0;
	param.tmx_r = 0;
	
	// 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]);
				break;

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

			case 'p':
				param.p = 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 'l':
				param.loss_type = (loss_var) atoi(argv[i]);
				break;

			case 'u':
				if(atoi(argv[i]) < 3)
				{
					param.curv_type = (curv_var) atoi(argv[i]);
					param.turn_to_nc = 0;
				}
				else if(atoi(argv[i]) == 3)
				{
					param.curv_type = (curv_var) 0;
					param.turn_to_nc = 1;
				}
				else if(atoi(argv[i]) == 4)
				{
					param.curv_type = (curv_var) 1;
					param.turn_to_nc = 1;
				}		
				break;
				
			case 'r':
				param.reg_param = atof(argv[i]);
				break;

			case 'd':
				param.cd_tol = atof(argv[i]);
				break;

			case 'f':
				param.cd_reset = atoi(argv[i]);
				break;

			case 'g':
				param.cg_tol = atof(argv[i]);
				break;

			case 'x':
				param.test_file = Malloc(char,1024);
				strcpy(param.test_file, argv[i]);
				break;

			case 't':
				param.loss_param = atof(argv[i]);
				break;

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

			case 'i':
				param.init_model_file = Malloc(char,1024);
				strcpy(param.init_model_file, argv[i]);
				break;

			case 'h':
				param.chat_level = atoi(argv[i]);
				break;

			case 'S': 
				if(strcmp(argv[i],"s")==0 || strcmp(argv[i],"a")==0)
				{
					param.structured_w = argv[i][0];
					printf("\nUsing symmetric or asymmetric matrix as %c\n",param.structured_w);
				}
				else
				{
					param.transform_matrix = read_transform_matrix(argv[i],param.tmx_r,param.tmx_c);
					param.structured_w = 'f';
					printf("\nUsing free transform matrix %s\n",argv[i]);
				}
				break;

			case 'X':
				param.save_each_iter = Malloc(char,1024);
				strcpy(param.save_each_iter, argv[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);
	}

	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.001;
				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;
		}
		
		if(param.solver_type == MMCD ||param.solver_type == MMCD_SM || param.solver_type == MMCD_SG || param.solver_type == MMCD_SIMPLE || param.solver_type == MMGCD || param.solver_type == MMCG )
			param.eps = 0.01;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebp
movabsq $0x400000032, %rax      # imm = 0x400000032
movq %rax, 0x1a59a(%rip)     # 0x1e260
movaps 0x14343(%rip), %xmm0    # 0x18010
movups %xmm0, 0x1a60c(%rip)    # 0x1e2e0
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0x1a623(%rip)     # 0x1e308
xorl %edi, %edi
movl %edi, 0x1a603(%rip)     # 0x1e2f0
xorps %xmm0, %xmm0
movups %xmm0, 0x1a601(%rip)    # 0x1e2f8
movl %edi, 0x1a643(%rip)     # 0x1e340
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x1a63a(%rip)     # 0x1e348
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x1a549(%rip)     # 0x1e268
movaps 0x142fa(%rip), %xmm1    # 0x18020
movups %xmm1, 0x1a54b(%rip)    # 0x1e278
movl $0x1, 0x1a539(%rip)     # 0x1e270
movq $0x0, 0x1a546(%rip) # 0x1e288
movups %xmm0, 0x1a557(%rip)    # 0x1e2a0
movabsq $0x3f50624dd2f1a9fc, %rax # imm = 0x3F50624DD2F1A9FC
movq %rax, 0x1a566(%rip)     # 0x1e2c0
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x1a545(%rip)     # 0x1e2b0
movl $0xa, 0x1a543(%rip)     # 0x1e2b8
movb $0x0, 0x1a550(%rip)     # 0x1e2cc
movups %xmm0, 0x1a54d(%rip)    # 0x1e2d0
cmpl $0x2, %ebp
jl 0x410b
movq %rsi, %r14
movq %rdx, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
leaq -0x244(%rip), %r13      # 0x3b5c
xorl %r12d, %r12d
movl $0x1, %ecx
movslq %ecx, %r15
movq (%r14,%r15,8), %rax
cmpb $0x2d, (%rax)
jne 0x4126
leal 0x1(%rcx), %ebx
cmpl %ebp, %ebx
jge 0x4110
movzbl 0x1(%rax), %eax
leal -0x53(%rax), %edx
cmpl $0x25, %edx
ja 0x3e38
leaq 0x1427a(%rip), %rsi     # 0x18050
movslq (%rsi,%rdx,4), %rdx
addq %rsi, %rdx
movq %r13, %rdi
jmpq *%rdx
movslq %ebx, %r15
movq (%r14,%r15,8), %rdi
movzbl (%rdi), %esi
cmpl $0x61, %esi
je 0x3df6
cmpl $0x73, %esi
jne 0x3e00
cmpb $0x0, 0x1(%rdi)
je 0x40d1
leaq 0x1a4d1(%rip), %rsi     # 0x1e2d8
leaq 0x1a4ce(%rip), %rdx     # 0x1e2dc
callq 0x47c2
movq %rax, 0x1a4b6(%rip)     # 0x1e2d0
movb $0x66, 0x1a4ab(%rip)    # 0x1e2cc
movq (%r14,%r15,8), %rsi
leaq 0x14449(%rip), %rdi     # 0x18275
xorl %eax, %eax
callq 0x3050
jmp 0x40f9
cmpl $0x42, %eax
jne 0x41e0
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a4f3(%rip)    # 0x1e348
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a452(%rip)    # 0x1e2c0
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a461(%rip)    # 0x1e2e8
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a3d8(%rip)    # 0x1e278
jmp 0x40f9
movl $0x400, %edi            # imm = 0x400
callq 0x32f0
movq %rax, 0x1a3f2(%rip)     # 0x1e2a8
jmp 0x3edc
movl $0x400, %edi            # imm = 0x400
callq 0x32f0
movq %rax, 0x1a3bf(%rip)     # 0x1e288
jmp 0x3edc
movl $0x400, %edi            # imm = 0x400
callq 0x32f0
movq %rax, 0x1a3b4(%rip)     # 0x1e290
movslq %ebx, %rcx
movq (%r14,%rcx,8), %rsi
movq %rax, %rdi
callq 0x31f0
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a3dc(%rip)    # 0x1e2e0
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a3eb(%rip)    # 0x1e308
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
movl %eax, 0x1a330(%rip)     # 0x1e264
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
movl %eax, 0x1a355(%rip)     # 0x1e2a0
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a34c(%rip)    # 0x1e2b0
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a303(%rip)    # 0x1e280
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
movl %eax, 0x1a324(%rip)     # 0x1e2b8
jmp 0x40f9
movl $0x1, 0x1a39d(%rip)     # 0x1e340
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
movl %eax, 0x1a38f(%rip)     # 0x1e344
movl %ebx, %ecx
movq %r12, %rdi
cmpl $0x1, %eax
jg 0x40fe
jmp 0x41e7
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
movl %eax, 0x1a286(%rip)     # 0x1e260
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x3360
cmpl $0x2, %eax
jg 0x40b1
movl %eax, 0x1a276(%rip)     # 0x1e270
movl $0x0, 0x1a2a0(%rip)     # 0x1e2a4
jmp 0x40f9
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movsd %xmm0, 0x1a24b(%rip)    # 0x1e268
jmp 0x40f9
movslq 0x1a2c7(%rip), %rax     # 0x1e2f0
leaq 0x1(%rax), %rcx
movl %ecx, 0x1a2bd(%rip)     # 0x1e2f0
movq 0x1a2be(%rip), %rdi     # 0x1e2f8
leaq 0x4(,%rax,4), %rsi
callq 0x33d0
movq %rax, 0x1a2aa(%rip)     # 0x1e2f8
movq 0x1a2ab(%rip), %rdi     # 0x1e300
movslq 0x1a294(%rip), %rsi     # 0x1e2f0
shlq $0x3, %rsi
callq 0x33d0
movq %rax, %r13
movq %rax, 0x1a291(%rip)     # 0x1e300
movq (%r14,%r15,8), %rdi
addq $0x2, %rdi
callq 0x3360
movq 0x1a275(%rip), %rcx     # 0x1e2f8
movslq 0x1a266(%rip), %rdx     # 0x1e2f0
movl %eax, -0x4(%rcx,%rdx,4)
movslq %ebx, %rax
movq (%r14,%rax,8), %rdi
callq 0x32b0
movslq 0x1a24f(%rip), %rax     # 0x1e2f0
movsd %xmm0, -0x8(%r13,%rax,8)
leaq -0x553(%rip), %r13      # 0x3b5c
jmp 0x40f9
cmpl $0x4, %eax
je 0x40e8
cmpl $0x3, %eax
jne 0x40f9
movl $0x0, 0x1a1ab(%rip)     # 0x1e270
movl $0x1, 0x1a1d5(%rip)     # 0x1e2a4
jmp 0x40f9
movb %sil, 0x1a1f4(%rip)     # 0x1e2cc
leaq 0x14169(%rip), %rdi     # 0x18248
xorl %eax, %eax
callq 0x3050
jmp 0x40f9
movl $0x1, %eax
movl %eax, 0x1a17d(%rip)     # 0x1e270
movl %eax, 0x1a1ab(%rip)     # 0x1e2a4
movl %ebx, %ecx
movq %r12, %rdi
incl %ecx
movq %rdi, %r12
cmpl %ebp, %ecx
jl 0x3da8
callq 0x150d8
leaq 0x1426d(%rip), %rdi     # 0x18384
callq 0x3350
movl $0x1, %edi
callq 0x32a0
movq %r12, %rdi
callq 0x150d8
movq (%r14,%r15,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x31f0
decl %ebp
cmpl %ebp, %r15d
jge 0x4154
movq 0x8(%r14,%r15,8), %rsi
movq 0x8(%rsp), %rdi
callq 0x31f0
jmp 0x4183
movq (%r14,%r15,8), %r14
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3240
leaq 0x1(%rax), %rdx
testq %rax, %rax
cmoveq %r14, %rdx
leaq 0x14134(%rip), %rsi     # 0x182ab
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3090
movsd 0x1a155(%rip), %xmm0    # 0x1e2e0
ucomisd 0x13e9d(%rip), %xmm0    # 0x18030
jb 0x41d1
movl 0x1a0c5(%rip), %eax     # 0x1e260
cmpq $0xe, %rax
jae 0x41b9
movl $0x38ff, %ecx           # imm = 0x38FF
btl %eax, %ecx
jae 0x41b9
leaq 0x13f36(%rip), %rcx     # 0x180e8
movsd (%rcx,%rax,8), %xmm0
jmp 0x41c9
addl $-0x32, %eax
cmpl $0x6, %eax
jae 0x41d1
movsd 0x13e6f(%rip), %xmm0    # 0x18038
movsd %xmm0, 0x1a10f(%rip)    # 0x1e2e0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x34f9
callq 0x34c8