// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %r14
movl %edi, %ebp
movabsq $0x400000032, %rax      # imm = 0x400000032
movq %rax, 0x1759f(%rip)     # 0x1b258
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x17616(%rip)     # 0x1b2e0
movabsq $0x7ff0000000000000, %rsi # imm = 0x7FF0000000000000
movq %rsi, 0x175fd(%rip)     # 0x1b2d8
movabsq $0x3fb999999999999a, %rsi # imm = 0x3FB999999999999A
movq %rsi, 0x17614(%rip)     # 0x1b300
xorl %edi, %edi
movl %edi, 0x175f4(%rip)     # 0x1b2e8
xorps %xmm0, %xmm0
movups %xmm0, 0x175f2(%rip)    # 0x1b2f0
movl %edi, 0x17634(%rip)     # 0x1b338
movabsq $-0x4010000000000000, %rsi # imm = 0xBFF0000000000000
movq %rsi, 0x1762b(%rip)     # 0x1b340
movq %rax, 0x1755c(%rip)     # 0x1b278
movabsq $0x3fe0000000000000, %rax # imm = 0x3FE0000000000000
movq %rax, 0x17533(%rip)     # 0x1b260
movabsq $0x3f50624dd2f1a9fc, %rax # imm = 0x3F50624DD2F1A9FC
movq %rax, 0x17532(%rip)     # 0x1b270
movl $0x1, 0x17520(%rip)     # 0x1b268
movq $0x0, 0x1752d(%rip) # 0x1b280
movups %xmm0, 0x1753e(%rip)    # 0x1b298
movq %rax, 0x17557(%rip)     # 0x1b2b8
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x17536(%rip)     # 0x1b2a8
movl $0xa, 0x17534(%rip)     # 0x1b2b0
movb $0x0, 0x17541(%rip)     # 0x1b2c4
movups %xmm0, 0x1753e(%rip)    # 0x1b2c8
cmpl $0x2, %ebp
setge %r12b
jl 0x421d
movq %rcx, 0x8(%rsp)
movq 0x8(%r14), %rax
cmpb $0x2d, (%rax)
movq %rdx, 0x10(%rsp)
jne 0x414c
leaq 0x8(%r14), %rbx
movl $0x1, %r13d
xorl %r15d, %r15d
leal 0x1(%r13), %r12d
cmpl %ebp, %r12d
jge 0x4222
movzbl 0x1(%rax), %eax
leal -0x53(%rax), %ecx
cmpl $0x25, %ecx
ja 0x3e5f
leaq 0x12241(%rip), %rdx     # 0x16020
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
leaq -0x2a1(%rip), %rdi      # 0x3b4c
jmpq *%rcx
movslq %r12d, %rbx
movq (%r14,%rbx,8), %r13
movq %r13, %rdi
leaq 0x137cd(%rip), %rsi     # 0x175cd
callq 0x3300
testl %eax, %eax
je 0x40d1
movq %r13, %rdi
leaq 0x12401(%rip), %rsi     # 0x16218
callq 0x3300
testl %eax, %eax
je 0x40d1
movq %r13, %rdi
leaq 0x174a2(%rip), %rsi     # 0x1b2d0
leaq 0x1749f(%rip), %rdx     # 0x1b2d4
callq 0x4846
movq %rax, 0x17487(%rip)     # 0x1b2c8
movb $0x66, 0x1747c(%rip)    # 0x1b2c4
movq (%r14,%rbx,8), %rsi
leaq 0x123f4(%rip), %rdi     # 0x16247
xorl %eax, %eax
callq 0x3050
jmp 0x411e
cmpl $0x42, %eax
jne 0x4238
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x174c4(%rip)    # 0x1b340
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x17423(%rip)    # 0x1b2b8
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x17432(%rip)    # 0x1b2e0
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x173a9(%rip)    # 0x1b270
jmp 0x411e
movl $0x400, %edi            # imm = 0x400
callq 0x32e0
movq %rax, 0x173c3(%rip)     # 0x1b2a0
jmp 0x3f03
movl $0x400, %edi            # imm = 0x400
callq 0x32e0
movq %rax, 0x17390(%rip)     # 0x1b280
jmp 0x3f03
movl $0x400, %edi            # imm = 0x400
callq 0x32e0
movq %rax, 0x17385(%rip)     # 0x1b288
movslq %r12d, %rcx
movq (%r14,%rcx,8), %rsi
movq %rax, %rdi
callq 0x31e0
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x173ad(%rip)    # 0x1b2d8
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x173bc(%rip)    # 0x1b300
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
movl %eax, 0x17301(%rip)     # 0x1b25c
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
movl %eax, 0x17326(%rip)     # 0x1b298
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x1731d(%rip)    # 0x1b2a8
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x172d4(%rip)    # 0x1b278
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
movl %eax, 0x172f5(%rip)     # 0x1b2b0
jmp 0x411e
movl $0x1, 0x1736e(%rip)     # 0x1b338
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
movl %eax, 0x17360(%rip)     # 0x1b33c
movl %r12d, %r13d
movq %r15, %rdi
cmpl $0x1, %eax
jg 0x4124
jmp 0x423f
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
movl %eax, 0x17256(%rip)     # 0x1b258
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x3350
cmpl $0x2, %eax
jg 0x40ed
movl %eax, 0x17246(%rip)     # 0x1b268
movl $0x0, 0x17270(%rip)     # 0x1b29c
jmp 0x411e
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movsd %xmm0, 0x1721b(%rip)    # 0x1b260
jmp 0x411e
movslq 0x17297(%rip), %rax     # 0x1b2e8
leaq 0x1(%rax), %rcx
movl %ecx, 0x1728d(%rip)     # 0x1b2e8
movq 0x1728e(%rip), %rdi     # 0x1b2f0
leaq 0x4(,%rax,4), %rsi
callq 0x33c0
movq %rax, 0x1727a(%rip)     # 0x1b2f0
movq 0x1727b(%rip), %rdi     # 0x1b2f8
movslq 0x17264(%rip), %rsi     # 0x1b2e8
shlq $0x3, %rsi
callq 0x33c0
movq %rax, %r13
movq %rax, 0x17261(%rip)     # 0x1b2f8
movq (%rbx), %rdi
addq $0x2, %rdi
callq 0x3350
movq 0x17246(%rip), %rcx     # 0x1b2f0
movslq 0x17237(%rip), %rdx     # 0x1b2e8
movl %eax, -0x4(%rcx,%rdx,4)
movslq %r12d, %rax
movq (%r14,%rax,8), %rdi
callq 0x32a0
movslq 0x17220(%rip), %rax     # 0x1b2e8
movsd %xmm0, -0x8(%r13,%rax,8)
jmp 0x411e
movsbl (%r13), %esi
movb %sil, 0x171e7(%rip)     # 0x1b2c4
leaq 0x12136(%rip), %rdi     # 0x1621a
xorl %eax, %eax
callq 0x3050
jmp 0x411e
cmpl $0x4, %eax
je 0x410d
cmpl $0x3, %eax
jne 0x411e
movl $0x0, 0x17167(%rip)     # 0x1b268
movl $0x1, 0x17191(%rip)     # 0x1b29c
jmp 0x411e
movl $0x1, %eax
movl %eax, 0x17150(%rip)     # 0x1b268
movl %eax, 0x1717e(%rip)     # 0x1b29c
movl %r12d, %r13d
movq %r15, %rdi
incl %r13d
cmpl %ebp, %r13d
setl %r12b
jge 0x421d
movslq %r13d, %rax
leaq (%r14,%rax,8), %rbx
movq (%rbx), %rax
cmpb $0x2d, (%rax)
movq %rdi, %r15
je 0x3dbb
jmp 0x4154
movl $0x1, %r13d
xorl %edi, %edi
callq 0x1348f
testb %r12b, %r12b
je 0x4222
movslq %r13d, %rbx
movq (%r14,%rbx,8), %rsi
movq 0x10(%rsp), %rdi
callq 0x31e0
decl %ebp
cmpl %ebp, %ebx
jge 0x418a
movq 0x8(%r14,%rbx,8), %rsi
movq 0x8(%rsp), %rdi
callq 0x31e0
jmp 0x41b9
movq (%r14,%rbx,8), %r14
movq %r14, %rdi
movl $0x2f, %esi
callq 0x3230
leaq 0x1(%rax), %rdx
testq %rax, %rax
cmoveq %r14, %rdx
leaq 0x120d0(%rip), %rsi     # 0x1627d
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x3090
movsd 0x17117(%rip), %xmm0    # 0x1b2d8
ucomisd 0x11e3f(%rip), %xmm0    # 0x16008
jb 0x420e
movl 0x17087(%rip), %eax     # 0x1b258
cmpq $0xd, %rax
ja 0x41f5
movl $0x38ff, %ecx           # imm = 0x38FF
btl %eax, %ecx
jae 0x41f5
leaq 0x11ed0(%rip), %rcx     # 0x160b8
movsd (%rcx,%rax,8), %xmm0
movsd %xmm0, 0x170e3(%rip)    # 0x1b2d8
addl $-0x32, %eax
cmpl $0x5, %eax
ja 0x420e
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0x170ca(%rip)     # 0x1b2d8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x1348f
leaq 0x1212d(%rip), %rdi     # 0x16356
callq 0x3340
movl $0x1, %edi
callq 0x3290
movl %eax, %edi
callq 0x34e9
callq 0x34b8