// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rcx, 0x8(%rsp)
movq %rdx, 0x10(%rsp)
movl %edi, %ebp
movabsq $0x400000032, %rax      # imm = 0x400000032
movq %rax, 0x16b0b(%rip)     # 0x1a280
movaps 0x11894(%rip), %xmm0    # 0x15010
movups %xmm0, 0x16b7d(%rip)    # 0x1a300
movabsq $0x3fb999999999999a, %rax # imm = 0x3FB999999999999A
movq %rax, 0x16b94(%rip)     # 0x1a328
andl $0x0, 0x16b75(%rip)     # 0x1a310
xorps %xmm0, %xmm0
andl $0x0, 0x16bbb(%rip)     # 0x1a360
movups %xmm0, 0x16b6c(%rip)    # 0x1a318
movabsq $-0x4010000000000000, %rax # imm = 0xBFF0000000000000
movq %rax, 0x16bab(%rip)     # 0x1a368
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x16aba(%rip)     # 0x1a288
movaps 0x1184b(%rip), %xmm1    # 0x15020
movups %xmm1, 0x16abc(%rip)    # 0x1a298
movl $0x1, 0x16aaa(%rip)     # 0x1a290
andq $0x0, 0x16aba(%rip)     # 0x1a2a8
movups %xmm0, 0x16acb(%rip)    # 0x1a2c0
movabsq $0x3f50624dd2f1a9fc, %rax # imm = 0x3F50624DD2F1A9FC
movq %rax, 0x16ada(%rip)     # 0x1a2e0
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x16ab9(%rip)     # 0x1a2d0
movl $0xa, 0x16ab7(%rip)     # 0x1a2d8
movb $0x0, 0x16ac4(%rip)     # 0x1a2ec
movups %xmm0, 0x16ac1(%rip)    # 0x1a2f0
pushq $0x1
popq %rax
movl %eax, %r13d
xorl %r12d, %r12d
movq %rsi, (%rsp)
cmpl %ebp, %r13d
jge 0x3c87
movslq %r13d, %r14
movq (%rsi,%r14,8), %rax
cmpb $0x2d, (%rax)
jne 0x3bcc
leal 0x1(%r13), %ebx
cmpl %ebp, %ebx
jge 0x3c8f
movzbl 0x1(%rax), %eax
leal -0x53(%rax), %ecx
movslq %ebx, %r15
cmpl $0x25, %ecx
ja 0x38e1
leaq 0x117d9(%rip), %rdi     # 0x15050
movslq (%rdi,%rcx,4), %rdx
addq %rdi, %rdx
leaq -0x2a9(%rip), %rcx      # 0x35dc
jmpq *%rdx
movq (%rsi,%r15,8), %rdi
movzbl (%rdi), %esi
cmpl $0x61, %esi
je 0x3898
cmpl $0x73, %esi
jne 0x38a2
cmpb $0x0, 0x1(%rdi)
je 0x3b9a
leaq 0x16a4f(%rip), %rsi     # 0x1a2f8
leaq 0x16a4c(%rip), %rdx     # 0x1a2fc
callq 0x4218
movq %rax, 0x16a34(%rip)     # 0x1a2f0
movb $0x66, 0x16a29(%rip)    # 0x1a2ec
movq (%rsp), %r14
movq (%r14,%r15,8), %rsi
leaq 0x119a3(%rip), %rdi     # 0x15275
xorl %eax, %eax
callq 0x3050
movq %r14, %rsi
jmp 0x3b68
cmpl $0x42, %eax
jne 0x3c94
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x16a69(%rip)    # 0x1a368
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x169c7(%rip)    # 0x1a2e0
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x169d5(%rip)    # 0x1a308
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x1694b(%rip)    # 0x1a298
jmp 0x3b68
movl $0x400, %edi            # imm = 0x400
callq 0x3320
movq %rax, 0x16965(%rip)     # 0x1a2c8
jmp 0x3989
movl $0x400, %edi            # imm = 0x400
callq 0x3320
movq %rax, 0x16932(%rip)     # 0x1a2a8
jmp 0x3989
movl $0x400, %edi            # imm = 0x400
callq 0x3320
movq %rax, 0x16927(%rip)     # 0x1a2b0
movq (%rsp), %rcx
movq (%rcx,%r15,8), %rsi
movq %rax, %rdi
callq 0x3200
movq (%rsp), %rsi
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x16949(%rip)    # 0x1a300
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x16957(%rip)    # 0x1a328
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x33a0
movq (%rsp), %rsi
movl %eax, 0x1689b(%rip)     # 0x1a284
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x33a0
movq (%rsp), %rsi
movl %eax, 0x168bf(%rip)     # 0x1a2c0
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x168b5(%rip)    # 0x1a2d0
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x1686b(%rip)    # 0x1a2a0
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x33a0
movq (%rsp), %rsi
movl %eax, 0x1688b(%rip)     # 0x1a2d8
jmp 0x3b68
movl $0x1, 0x16904(%rip)     # 0x1a360
movq (%rsi,%r15,8), %rdi
callq 0x33a0
movq (%rsp), %rsi
movl %eax, 0x168f5(%rip)     # 0x1a364
movl %ebx, %r13d
movq %r12, %rcx
cmpl $0x1, %eax
jg 0x3b6e
jmp 0x3cb4
movq (%rsi,%r15,8), %rdi
callq 0x33a0
movq (%rsp), %rsi
movl %eax, 0x167ea(%rip)     # 0x1a280
jmp 0x3b68
movq (%rsi,%r15,8), %rdi
callq 0x33a0
cmpl $0x2, %eax
jg 0x3b79
movl %eax, 0x167dd(%rip)     # 0x1a290
andl $0x0, 0x1680a(%rip)     # 0x1a2c4
jmp 0x3bc0
movq (%rsi,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movsd %xmm0, 0x167b4(%rip)    # 0x1a288
jmp 0x3b68
movslq 0x16830(%rip), %rax     # 0x1a310
leaq 0x1(%rax), %rcx
movl %ecx, 0x16826(%rip)     # 0x1a310
movq 0x16827(%rip), %rdi     # 0x1a318
leaq 0x4(,%rax,4), %rsi
callq 0x3410
movq %rax, 0x16813(%rip)     # 0x1a318
movq 0x16814(%rip), %rdi     # 0x1a320
movslq 0x167fd(%rip), %rsi     # 0x1a310
shlq $0x3, %rsi
callq 0x3410
movq %rax, %r13
movq %rax, 0x167fa(%rip)     # 0x1a320
movq (%rsp), %rax
movq (%rax,%r14,8), %rdi
addq $0x2, %rdi
callq 0x33a0
movq 0x167da(%rip), %rcx     # 0x1a318
movslq 0x167cb(%rip), %rdx     # 0x1a310
movl %eax, -0x4(%rcx,%rdx,4)
movq (%rsp), %rax
movq (%rax,%r15,8), %rdi
callq 0x32d0
movq (%rsp), %rsi
movslq 0x167af(%rip), %rax     # 0x1a310
movsd %xmm0, -0x8(%r13,%rax,8)
movl %ebx, %r13d
movq %r12, %rcx
incl %r13d
movq %rcx, %r12
jmp 0x383c
cmpl $0x4, %eax
je 0x3bb1
cmpl $0x3, %eax
movq (%rsp), %rsi
jne 0x3b68
andl $0x0, 0x16702(%rip)     # 0x1a290
movl $0x1, 0x1672c(%rip)     # 0x1a2c4
jmp 0x3b68
movb %sil, 0x1674b(%rip)     # 0x1a2ec
leaq 0x116a0(%rip), %rdi     # 0x15248
xorl %eax, %eax
callq 0x3050
jmp 0x3bc0
pushq $0x1
popq %rax
movl %eax, 0x166d6(%rip)     # 0x1a290
movl %eax, 0x16704(%rip)     # 0x1a2c4
movl %ebx, %r13d
movq %r12, %rcx
movq (%rsp), %rsi
jmp 0x3b6e
movq %r12, %rdi
movq %rsi, %rbx
callq 0x12285
movq (%rbx,%r14,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x3200
decl %ebp
cmpl %ebp, %r13d
jge 0x3bfd
movq 0x8(%rbx,%r14,8), %rsi
movq 0x8(%rsp), %rdi
callq 0x3200
jmp 0x3c2a
movq (%rbx,%r14,8), %r14
pushq $0x2f
popq %rsi
movq %r14, %rdi
callq 0x3270
leaq 0x1(%rax), %rdx
testq %rax, %rax
cmoveq %r14, %rdx
leaq 0x1168d(%rip), %rsi     # 0x152ab
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3090
movsd 0x166ce(%rip), %xmm0    # 0x1a300
ucomisd 0x113f6(%rip), %xmm0    # 0x15030
jb 0x3c78
movl 0x1663e(%rip), %eax     # 0x1a280
cmpq $0xe, %rax
jae 0x3c60
movl $0x38ff, %ecx           # imm = 0x38FF
btl %eax, %ecx
jae 0x3c60
leaq 0x1148f(%rip), %rcx     # 0x150e8
movsd (%rcx,%rax,8), %xmm0
jmp 0x3c70
addl $-0x32, %eax
cmpl $0x6, %eax
jae 0x3c78
movsd 0x113c8(%rip), %xmm0    # 0x15038
movsd %xmm0, 0x16688(%rip)    # 0x1a300
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, %rdi
callq 0x12285
callq 0x35dd
movsbl %al, %edx
movq 0x1633a(%rip), %rax     # 0x19fd8
movq (%rax), %rdi
leaq 0x115ee(%rip), %rsi     # 0x15296
xorl %eax, %eax
callq 0x3370
callq 0x35dd
movq 0x1631d(%rip), %rax     # 0x19fd8
movq (%rax), %rcx
leaq 0x1155d(%rip), %rdi     # 0x15222
pushq $0x25
popq %rsi
pushq $0x1
popq %rdx
callq 0x34a0
callq 0x35dd