// File: myudelson[P]hmm-scalable/trainhmm.cpp
// Function: parse_arguments_step1(int, char**, char*, char*, char*, char*)
void parse_arguments_step1(int argc, char **argv, char *input_file_name, char *output_file_name, char *predict_file_name, char *console_file_name) {
	// parse command line options, starting from 1 (0 is path to executable)
	// go in pairs, looking at whether first in pair starts with '-', if not, stop parsing arguments
    
    // at this time we do not know nO (the number of observations) yet
	int i;
    int n;
    char *ch, *ch2;
	for(i=1;i<argc;i++)
	{
		if(argv[i][0] != '-') break; // end of options stop parsing
		if(++i>=argc)
			exit_with_help();
		switch(argv[i-1][1])
		{
			case 'e':
				param.tol = atof( strtok(argv[i],",\t\n\r") );
                ch = strtok(NULL,",\t\n\r"); // could be NULL
                if(ch != NULL)
                    param.tol_mode = ch[0];
				if(param.tol<0) {
					fprintf(stderr,"ERROR! Fitting tolerance cannot be negative\n");
					exit_with_help();
				}
                if(param.tol>10) {
                    fprintf(stderr,"ERROR! Fitting tolerance cannot be >10\n");
                    exit_with_help();
                }
                if(param.tol_mode!='p' && param.tol_mode!='l') {
                    fprintf(stderr,"ERROR! Tolerance mode '%c' is not allowed\n",param.tol_mode);
                    exit_with_help();
                }
				break;
			case 't':
				param.sliced = (NPAR)atoi(argv[i]);
				if(param.sliced!=0 && param.sliced!=1) {
					fprintf(stderr,"ERROR! Time parameter should be either 0 (off) or 1(on)\n");
					exit_with_help();
				}
				break;
			case 'i':
				param.maxiter = atoi(argv[i]);
				if(param.maxiter<10) {
					fprintf(stderr,"ERROR! Maximum iterations should be at least 10\n");
					exit_with_help();
				}
				break;
			case 'q':
				param.quiet = (NPAR)atoi(argv[i]);
				if(param.quiet!=0 && param.quiet!=1) {
					fprintf(stderr,"ERROR! Quiet param should be 0 or 1\n");
					exit_with_help();
				}
				break;
			case 'n':
				param.nS = (NPAR)atoi(argv[i]);
				if(param.nS<2) {
					fprintf(stderr,"ERROR! Number of hidden states should be at least 2\n");
					exit_with_help();
				}
                if(param.nS != 2) {
                    param.stat_specd_gt2 = true;
                }
				break;
			case 'S':
				param.scaled = (NPAR)atoi(argv[i]);
				if(param.scaled < 0 || param.scaled > 1) {
					fprintf(stderr,"ERROR! Scaling flag should be either 0 (off) or 1 (in)\n");
					exit_with_help();
				}
				break;
			case 's':
				param.structure = (NPAR)atoi( strtok(argv[i],".\t\n\r") );
                ch = strtok(NULL,".\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL)
                    param.solver = (NPAR)atoi(ch);
                ch = strtok(NULL,"\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL)
                    param.solver_setting = (NPAR)atoi(ch);
                if( param.structure != STRUCTURE_SKILL && // param.structure != STRUCTURE_GROUP &&
                   param.structure != STRUCTURE_PIg   && param.structure != STRUCTURE_PIgk  &&
                   param.structure != STRUCTURE_PIAgk && param.structure != STRUCTURE_Agk &&
                   param.structure != STRUCTURE_PIABgk && param.structure != STRUCTURE_Agki &&
                   param.structure != STRUCTURE_PIgkww && param.structure != STRUCTURE_SKABslc &&
                   param.structure != STRUCTURE_SKAslc && param.structure != STRUCTURE_COMP &&
                   param.structure != STRUCTURE_ELOK ) {
                    fprintf(stderr, "Model Structure specified (%d) is out of range of allowed values\n",param.structure);
					exit_with_help();
                }
                if( param.solver != METHOD_BW  && param.solver != METHOD_GD &&
                   param.solver != METHOD_CGD && param.solver != METHOD_GDL &&
                   param.solver != METHOD_GBB) {
                    fprintf(stderr, "Method specified (%d) is out of range of allowed values\n",param.solver);
					exit_with_help();
                }
//                if( (param.structure == STRUCTURE_SKABslc || param.structure == STRUCTURE_SKAslc) && param.solver == METHOD_BW) {
//                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",param.solver,param.structure);
//                    exit_with_help();
//                }
                if( param.structure == STRUCTURE_COMP && param.solver == METHOD_BW) {
                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",param.solver,param.structure);
                    exit_with_help();
                }
                if( param.structure == STRUCTURE_ELOK && !(param.solver == METHOD_GD || param.solver == METHOD_CGD) ) {
                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",param.solver,param.structure);
                    exit_with_help();
                }
                if( param.solver == METHOD_BW && ( param.solver != STRUCTURE_SKILL /*&& param.solver != STRUCTURE_GROUP*/ ) ) {
                    fprintf(stderr, "Baum-Welch solver does not support model structure specified (%d)\n",param.solver);
					exit_with_help();
                }
                if( param.solver == METHOD_CGD  &&
                   ( param.solver_setting != 1 && param.solver_setting != 2 &&
                    param.solver_setting != 3 && param.solver_setting !=4 )
                   ) {
                    fprintf(stderr, "Conjugate Gradient Descent setting specified (%d) is out of range of allowed values\n",param.solver_setting);
					exit_with_help();
                }
				break;
            case 'f':
                param.single_skill = (NPAR)atoi(argv[i]);
                break;
			case 'm':
                param.metrics = atoi( strtok(argv[i],",\t\n\r"));
                ch = strtok(NULL, "\t\n\r");
                if(ch!=NULL) {
                    param.metrics_target_obs = (NPAR)(atoi(ch)-1);
                }
				if(param.metrics<0 || param.metrics>1) {
					fprintf(stderr,"value for -m should be either 0 or 1.\n");
					exit_with_help();
				}
				if(param.metrics_target_obs<0) {// || param.metrics_target_obs>(param.nO-1)) {
					fprintf(stderr,"target observation to compute metrics against cannot be '%d'\n",param.metrics_target_obs+1);
					exit_with_help();
				}
                break;
			case 'b':
                param.binaryinput = atoi( strtok(argv[i],"\t\n\r"));
                break;
			case 'v':
				param.cv_folds   = (NPAR)atoi( strtok(argv[i],",\t\n\r"));
                ch2 = strtok(NULL, ",\t\n\r");
                if(ch2!=NULL)
                    param.cv_strat = ch2[0];
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    param.cv_target_obs = (NPAR)(atoi(ch)-1);
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    strcpy(param.cv_folds_file, ch);
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    param.cv_inout_flag = ch[0];
                
				if(param.cv_folds<2) {
					fprintf(stderr,"number of cross-validation folds should be at least 2\n");

					exit_with_help();
				}
				if(param.cv_folds>10) {
					fprintf(stderr,"please keep number of cross-validation folds less than or equal to 10\n");
					exit_with_help();
				}
                if(param.cv_strat != CV_GROUP && param.cv_strat != CV_ITEM && param.cv_strat != CV_NSTR){
					fprintf(stderr,"cross-validation stratification parameter '%c' is illegal\n",param.cv_strat);
					exit_with_help();
                }
				if(param.cv_target_obs<0) {// || param.cv_target_obs>(param.nO-1)) {
					fprintf(stderr,"target observation to be cross-validated against cannot be '%d'\n",param.cv_target_obs+1);
					exit_with_help();
				}
                if( param.cv_inout_flag!='i' && param.cv_inout_flag!='o') {
					fprintf(stderr,"cross-validation folds input/output flag should be ither 'o' (out) or 'i' (in), while it is '%c'\n",param.cv_inout_flag);
					exit_with_help();
                }
                
				break;
            case  'p':
                param.predictions = atoi(argv[i]);
                if(param.predictions<0 || param.predictions>3) {
                    fprintf(stderr,"a flag of whether to report predictions for training data (-p) should be 0, 1, 2, or 3\n");
                    exit_with_help();
                }
                break;
            case  'U':
                param.update_known = *strtok(argv[i],",\t\n\r");
                ch = strtok(NULL, ",\t\n\r");
                param.update_unknown = ch[0];
                
                if( (param.update_known!='r' && param.update_known!='g') ||
                   (param.update_unknown!='t' && param.update_unknown!='g') ) {
                    fprintf(stderr,"specification of how probabilities of states should be updated (-U) is incorrect, it sould be r|g[,t|g] \n");
                    exit_with_help();
                }
                break;
            case  'd':
				param.multiskill = argv[i][0]; // just grab first character (later, maybe several)
                break;
            case  'P':
				n = atoi(argv[i]);
                if(n!=0 && n!=1 && n!=2) {
					fprintf(stderr,"parallel processing flag (-P) should be 0 or 1\n");
					exit_with_help();
                }
                param.parallel = (NPAR)n;
                break;
            case 'r': // coordinate descend parameters
                // if two first_iteration_qualify,iterations_to_qualify
                // if one iterations_to_qualify (first_iteration_qualify==0)
                n = atoi( strtok(argv[i],",\t\n\r") );
                ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
                if(ch==NULL) {// one parameter
                    param.first_iteration_qualify = 0;
                    param.iterations_to_qualify   = (NPAR)n;
                } else {
                    param.first_iteration_qualify = (NPAR)n;
                    param.iterations_to_qualify   = (NPAR)atoi(ch);
                }
                break;
            case 'R': // coordinate descend parameter for hard iterations limit of skill/group/other fitting
                n = atoi(argv[i]);
                if(n<=0) {
                    fprintf(stderr,"skill/group gradient descent iteration limit (-R) should be an integer >0\n");
                    exit_with_help();
                }
                if(n<=0) {
                    fprintf(stderr,"skill/group gradient descent iteration limit (-R) should be an integer >0\n");
                    exit_with_help();
                }
                param.iterations_limit = (NPAR)n;
                break;
            /*
            case 'c': {
                    // this version is with single center of gravity per Pi, A, and B
                    StripedArray<NUMBER> * tmp_array = new StripedArray<NUMBER>();
                    ch = strtok(argv[i],",\t\n\r");
                    while( ch != NULL ) {
                        tmp_array->add( atof(ch) );
                        ch = strtok(NULL,",\t\n\r");
                    }
                    if( (tmp_array->getSize() % 4) != 0 ) {
                        fprintf(stderr,"The number of regularization parameters should be a multiple of 4 and it is %d\n",tmp_array->getSize());
                        exit_with_help();
                    }
                    param.Cslices = (NPAR) tmp_array->getSize() / 4;
                    param.Cw = Calloc(NUMBER, (size_t)param.Cslices);
                    param.Ccenters = Calloc(NUMBER, (size_t)(param.Cslices * 3) );
                    int c1 = 0, c2 = 0, i = 0;
                    for(int l=0; l<(int)tmp_array->getSize() / 4; l++) {
                        param.Cw[c1++] = tmp_array->get((NDAT)i++);
                        for(int j=0; j<3; j++)
                            param.Ccenters[c2++] = tmp_array->get((NDAT)i++);
                    }
                    delete tmp_array;
                }
                break;
                */
            case 'c': // just to keep it a valid option
                break;
            case 'o':
                param.duplicate_console = 1;
                strcpy(console_file_name,argv[i]);
                break;
            case '0':
                param.init_reset = true;
                break;
            case 'l': // just to keep it a valid option
                break;
            case 'u': // just to keep it a valid option
                break;
            case 'B': // just to keep it a valid option
                break;
			default:
				fprintf(stderr,"unknown option: -%c\n", argv[i-1][1]);
				exit_with_help();
				break;
		}
	}
    // post-process checks
    // -v and -m collision
    if(param.cv_folds>0 && param.metrics>0) { // correct for 0-start coding
        fprintf(stderr,"values for -v and -m cannot be both non-zeros\n");
        exit_with_help();
    }
    // scaling
    if(param.scaled == 1 && param.solver != METHOD_BW) {
        param.scaled = 0;
        printf("Scaling can only be enabled for Baum-Welch method. Setting it to off\n");
    }
    // specifying >2 states via -n and mandatory specification of -0 (initial parameters)
    if(param.nS > 2 && !param.init_reset) {
        fprintf(stderr,"when >2 latent states specified via '-n', initial values of parameters have to be explicitly set via '-0'!\n");
        exit_with_help();
    }
    // STRUCTURE_SKABslc solver and -t 1 should be set together
    if( (param.sliced==1) != (param.structure == STRUCTURE_SKABslc || param.structure == STRUCTURE_SKAslc) ) {
        fprintf(stderr,"Error! sliced parameter ('-t 1') and STRUCTURE_SKABslc or STRUCTURE_SKAslc structure should be either both set on or off.\n");
        exit_with_help();
    }
    
	// next argument should be input file name
	if(i>=argc) // if not
		exit_with_help(); // leave
	
	strcpy(input_file_name, argv[i++]); // copy and advance
	
	if(i>=argc) { // no output file name specified
		strcpy(output_file_name,"output.hmm");
		strcpy(predict_file_name,"predict_hmm.txt"); // the predict file too
	}
	else {
		strcpy(output_file_name,argv[i++]); // copy and advance
		if(i>=argc) // no prediction file name specified
			strcpy(predict_file_name,"predict_hmm.txt"); // the predict file too
		else
			strcpy(predict_file_name,argv[i]);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x73eb
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x68eb
jmp 0x73eb
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl -0x4(%rbp), %eax
jl 0x68fe
callq 0xb500
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
addl $-0x30, %eax
movl %eax, %ecx
movq %rcx, -0x50(%rbp)
subl $0x46, %eax
ja 0x73a9
movq -0x50(%rbp), %rax
leaq 0x4d72d(%rip), %rcx     # 0x5405c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4ebc1(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, %rdi
callq 0x53f0
movsd %xmm0, 0x5aa20(%rip)    # 0x61380
xorl %eax, %eax
movl %eax, %edi
leaq 0x4eba1(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6987
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x5aa01(%rip)      # 0x61388
xorps %xmm0, %xmm0
ucomisd 0x5a9ee(%rip), %xmm0    # 0x61380
jbe 0x69b1
movq 0x5a63d(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eb6c(%rip), %rsi     # 0x55511
movb $0x0, %al
callq 0x5470
callq 0xb500
movsd 0x5a9c7(%rip), %xmm0    # 0x61380
movsd 0x4d657(%rip), %xmm1    # 0x54018
ucomisd %xmm1, %xmm0
jbe 0x69e4
movq 0x5a60a(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eb66(%rip), %rsi     # 0x5553e
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a99d(%rip), %eax     # 0x61388
cmpl $0x70, %eax
je 0x6a20
movsbl 0x5a991(%rip), %eax     # 0x61388
cmpl $0x6c, %eax
je 0x6a20
movq 0x5a5d5(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a97b(%rip), %edx     # 0x61388
leaq 0x4eb52(%rip), %rsi     # 0x55566
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movb %al, 0x5a94f(%rip)      # 0x6138b
movsbl 0x5a948(%rip), %eax     # 0x6138b
cmpl $0x0, %eax
je 0x6a71
movsbl 0x5a93c(%rip), %eax     # 0x6138b
cmpl $0x1, %eax
je 0x6a71
movq 0x5a57d(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eb2c(%rip), %rsi     # 0x55591
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movl %eax, 0x5a903(%rip)     # 0x61390
cmpl $0xa, 0x5a8fc(%rip)     # 0x61390
jge 0x6ab3
movq 0x5a53b(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eb23(%rip), %rsi     # 0x555ca
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movb %al, 0x5a8c5(%rip)      # 0x61394
movsbl 0x5a8be(%rip), %eax     # 0x61394
cmpl $0x0, %eax
je 0x6b04
movsbl 0x5a8b2(%rip), %eax     # 0x61394
cmpl $0x1, %eax
je 0x6b04
movq 0x5a4ea(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eb03(%rip), %rsi     # 0x555fb
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movb %al, 0x5b0f0(%rip)      # 0x61c10
movsbl 0x5b0e9(%rip), %eax     # 0x61c10
cmpl $0x2, %eax
jge 0x6b49
movq 0x5a4a5(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eae3(%rip), %rsi     # 0x55620
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5b0c0(%rip), %eax     # 0x61c10
cmpl $0x2, %eax
je 0x6b5c
movb $0x1, 0x5b118(%rip)     # 0x61c74
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movb %al, 0x5a811(%rip)      # 0x61389
movsbl 0x5a80a(%rip), %eax     # 0x61389
cmpl $0x0, %eax
jl 0x6b90
movsbl 0x5a7fe(%rip), %eax     # 0x61389
cmpl $0x1, %eax
jle 0x6bad
movq 0x5a441(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4eab4(%rip), %rsi     # 0x55655
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4eac8(%rip), %rsi     # 0x5568d
callq 0x54d0
movq %rax, %rdi
callq 0x54c0
movb %al, 0x5a7be(%rip)      # 0x61396
xorl %eax, %eax
movl %eax, %edi
leaq 0x4eaaa(%rip), %rsi     # 0x5568d
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6c02
movq -0x40(%rbp), %rdi
callq 0x54c0
movb %al, 0x5a795(%rip)      # 0x61397
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e900(%rip), %rsi     # 0x5550d
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6c2c
movq -0x40(%rbp), %rdi
callq 0x54c0
movb %al, 0x5a76c(%rip)      # 0x61398
movsbl 0x5a763(%rip), %eax     # 0x61396
cmpl $0x1, %eax
je 0x6cf0
movsbl 0x5a753(%rip), %eax     # 0x61396
cmpl $0x3, %eax
je 0x6cf0
movsbl 0x5a743(%rip), %eax     # 0x61396
cmpl $0x4, %eax
je 0x6cf0
movsbl 0x5a733(%rip), %eax     # 0x61396
cmpl $0x5, %eax
je 0x6cf0
movsbl 0x5a723(%rip), %eax     # 0x61396
cmpl $0x6, %eax
je 0x6cf0
movsbl 0x5a717(%rip), %eax     # 0x61396
cmpl $0x7, %eax
je 0x6cf0
movsbl 0x5a70b(%rip), %eax     # 0x61396
cmpl $0x9, %eax
je 0x6cf0
movsbl 0x5a6ff(%rip), %eax     # 0x61396
cmpl $0xa, %eax
je 0x6cf0
movsbl 0x5a6f3(%rip), %eax     # 0x61396
cmpl $0xb, %eax
je 0x6cf0
movsbl 0x5a6e7(%rip), %eax     # 0x61396
cmpl $0xc, %eax
je 0x6cf0
movsbl 0x5a6db(%rip), %eax     # 0x61396
cmpl $0xd, %eax
je 0x6cf0
movsbl 0x5a6cf(%rip), %eax     # 0x61396
cmpl $0xe, %eax
je 0x6cf0
movq 0x5a305(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a6b9(%rip), %edx     # 0x61396
leaq 0x4e9ae(%rip), %rsi     # 0x55692
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a6a0(%rip), %eax     # 0x61397
cmpl $0x1, %eax
je 0x6d50
movsbl 0x5a694(%rip), %eax     # 0x61397
cmpl $0x2, %eax
je 0x6d50
movsbl 0x5a688(%rip), %eax     # 0x61397
cmpl $0x3, %eax
je 0x6d50
movsbl 0x5a67c(%rip), %eax     # 0x61397
cmpl $0x4, %eax
je 0x6d50
movsbl 0x5a670(%rip), %eax     # 0x61397
cmpl $0x5, %eax
je 0x6d50
movq 0x5a2a5(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a65a(%rip), %edx     # 0x61397
leaq 0x4e990(%rip), %rsi     # 0x556d4
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a63f(%rip), %eax     # 0x61396
cmpl $0xd, %eax
jne 0x6d93
movsbl 0x5a634(%rip), %eax     # 0x61397
cmpl $0x1, %eax
jne 0x6d93
movq 0x5a269(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a61e(%rip), %edx     # 0x61397
movsbl 0x5a616(%rip), %ecx     # 0x61396
leaq 0x4e986(%rip), %rsi     # 0x5570d
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a5fc(%rip), %eax     # 0x61396
cmpl $0xe, %eax
jne 0x6de2
movsbl 0x5a5f1(%rip), %eax     # 0x61397
cmpl $0x2, %eax
je 0x6de2
movsbl 0x5a5e5(%rip), %eax     # 0x61397
cmpl $0x3, %eax
je 0x6de2
movq 0x5a21a(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a5cf(%rip), %edx     # 0x61397
movsbl 0x5a5c7(%rip), %ecx     # 0x61396
leaq 0x4e937(%rip), %rsi     # 0x5570d
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a5ae(%rip), %eax     # 0x61397
cmpl $0x1, %eax
jne 0x6e1e
movsbl 0x5a5a2(%rip), %eax     # 0x61397
cmpl $0x1, %eax
je 0x6e1e
movq 0x5a1d7(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a58c(%rip), %edx     # 0x61397
leaq 0x4e93a(%rip), %rsi     # 0x5574c
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a572(%rip), %eax     # 0x61397
cmpl $0x3, %eax
jne 0x6e7e
movsbl 0x5a567(%rip), %eax     # 0x61398
cmpl $0x1, %eax
je 0x6e7e
movsbl 0x5a55b(%rip), %eax     # 0x61398
cmpl $0x2, %eax
je 0x6e7e
movsbl 0x5a54f(%rip), %eax     # 0x61398
cmpl $0x3, %eax
je 0x6e7e
movsbl 0x5a543(%rip), %eax     # 0x61398
cmpl $0x4, %eax
je 0x6e7e
movq 0x5a177(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a52d(%rip), %edx     # 0x61398
leaq 0x4e91d(%rip), %rsi     # 0x5578f
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movb %al, 0x5a4fb(%rip)      # 0x61395
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e65a(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, %rdi
callq 0x54c0
movl %eax, 0x5a4eb(%rip)     # 0x613b0
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e63d(%rip), %rsi     # 0x5550d
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6ef2
movq -0x40(%rbp), %rdi
callq 0x54c0
subl $0x1, %eax
movb %al, 0x5a4c2(%rip)      # 0x613b4
cmpl $0x0, 0x5a4b7(%rip)     # 0x613b0
jl 0x6f04
cmpl $0x1, 0x5a4ae(%rip)     # 0x613b0
jle 0x6f21
movq 0x5a0cd(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e8cf(%rip), %rsi     # 0x557e4
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a48c(%rip), %eax     # 0x613b4
cmpl $0x0, %eax
jge 0x6f54
movq 0x5a0a4(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a476(%rip), %edx     # 0x613b4
addl $0x1, %edx
leaq 0x4e8c3(%rip), %rsi     # 0x5580b
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e5a1(%rip), %rsi     # 0x5550d
callq 0x54d0
movq %rax, %rdi
callq 0x54c0
movl %eax, 0x5a441(%rip)     # 0x613c0
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e575(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, %rdi
callq 0x54c0
movb %al, 0x5a81a(%rip)      # 0x617c4
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e557(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x6fd1
movq -0x48(%rbp), %rax
movb (%rax), %al
movb %al, 0x5a7f4(%rip)      # 0x617c5
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e530(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x6ffe
movq -0x40(%rbp), %rdi
callq 0x54c0
subl $0x1, %eax
movb %al, 0x5a7c8(%rip)      # 0x617c6
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e503(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x7029
movq -0x40(%rbp), %rsi
leaq 0x5a7a3(%rip), %rdi     # 0x617c7
callq 0x52b0
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e4d8(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x7050
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x5ab77(%rip)      # 0x61bc7
movsbl 0x5a76d(%rip), %eax     # 0x617c4
cmpl $0x2, %eax
jge 0x7079
movq 0x59f75(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e7dc(%rip), %rsi     # 0x55849
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a744(%rip), %eax     # 0x617c4
cmpl $0xa, %eax
jle 0x70a2
movq 0x59f4c(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e7ea(%rip), %rsi     # 0x55880
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a71c(%rip), %eax     # 0x617c5
cmpl $0x67, %eax
je 0x70ea
movsbl 0x5a710(%rip), %eax     # 0x617c5
cmpl $0x69, %eax
je 0x70ea
movsbl 0x5a704(%rip), %eax     # 0x617c5
cmpl $0x6e, %eax
je 0x70ea
movq 0x59f0b(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a6ee(%rip), %edx     # 0x617c5
leaq 0x4e7e9(%rip), %rsi     # 0x558c7
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5a6d5(%rip), %eax     # 0x617c6
cmpl $0x0, %eax
jge 0x711d
movq 0x59edb(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5a6bf(%rip), %edx     # 0x617c6
addl $0x1, %edx
leaq 0x4e7f1(%rip), %rsi     # 0x55902
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x5aaa3(%rip), %eax     # 0x61bc7
cmpl $0x69, %eax
je 0x7159
movsbl 0x5aa97(%rip), %eax     # 0x61bc7
cmpl $0x6f, %eax
je 0x7159
movq 0x59e9c(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movsbl 0x5aa81(%rip), %edx     # 0x61bc7
leaq 0x4e7f6(%rip), %rsi     # 0x55943
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movl %eax, 0x5a243(%rip)     # 0x613b8
cmpl $0x0, 0x5a23c(%rip)     # 0x613b8
jl 0x7187
cmpl $0x3, 0x5a233(%rip)     # 0x613b8
jle 0x71a4
movq 0x59e4a(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e80d(%rip), %rsi     # 0x559a5
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e350(%rip), %rsi     # 0x5550c
callq 0x54d0
movb (%rax), %al
movb %al, 0x5a1f3(%rip)      # 0x613bc
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e338(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x5a1d4(%rip)      # 0x613bd
movsbl 0x5a1cc(%rip), %eax     # 0x613bc
cmpl $0x72, %eax
je 0x7201
movsbl 0x5a1c0(%rip), %eax     # 0x613bc
cmpl $0x67, %eax
jne 0x7219
movsbl 0x5a1b5(%rip), %eax     # 0x613bd
cmpl $0x74, %eax
je 0x7236
movsbl 0x5a1a9(%rip), %eax     # 0x613bd
cmpl $0x67, %eax
je 0x7236
movq 0x59db8(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e7d3(%rip), %rsi     # 0x559fd
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movb (%rax), %al
movb %al, 0x5aa21(%rip)      # 0x61c70
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x7297
cmpl $0x1, -0x38(%rbp)
je 0x7297
cmpl $0x2, -0x38(%rbp)
je 0x7297
movq 0x59d57(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e7dc(%rip), %rsi     # 0x55a67
movb $0x0, %al
callq 0x5470
callq 0xb500
movl -0x38(%rbp), %eax
movb %al, 0x5a0f9(%rip)      # 0x61399
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x4e254(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, %rdi
callq 0x54c0
movl %eax, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x4e239(%rip), %rsi     # 0x5550c
callq 0x54d0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x72f5
movb $0x0, 0x5a9e6(%rip)     # 0x61cd0
movl -0x38(%rbp), %eax
movb %al, 0x5a9de(%rip)      # 0x61cd1
jmp 0x730d
movl -0x38(%rbp), %eax
movb %al, 0x5a9d2(%rip)      # 0x61cd0
movq -0x40(%rbp), %rdi
callq 0x54c0
movb %al, 0x5a9c4(%rip)      # 0x61cd1
jmp 0x73db
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x54c0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x7349
movq 0x59ca5(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e75a(%rip), %rsi     # 0x55a97
movb $0x0, %al
callq 0x5470
callq 0xb500
cmpl $0x0, -0x38(%rbp)
jg 0x736c
movq 0x59c82(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e737(%rip), %rsi     # 0x55a97
movb $0x0, %al
callq 0x5470
callq 0xb500
movl -0x38(%rbp), %eax
movsbl %al, %eax
movl %eax, 0x5a95c(%rip)     # 0x61cd4
jmp 0x73db
jmp 0x73db
movb $0x1, 0x5a009(%rip)     # 0x6138c
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x52b0
jmp 0x73db
movb $0x1, 0x5a8d0(%rip)     # 0x61c71
jmp 0x73db
jmp 0x73db
jmp 0x73db
jmp 0x73db
movq 0x59c28(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %edx
leaq 0x4e713(%rip), %rsi     # 0x55ae2
movb $0x0, %al
callq 0x5470
callq 0xb500
jmp 0x73dd
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x68c6
movsbl 0x5a3d2(%rip), %eax     # 0x617c4
cmpl $0x0, %eax
jle 0x741d
cmpl $0x0, 0x59fb2(%rip)     # 0x613b0
jle 0x741d
movq 0x59bd1(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e6e6(%rip), %rsi     # 0x55af7
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x59f65(%rip), %eax     # 0x61389
cmpl $0x1, %eax
jne 0x744a
movsbl 0x59f67(%rip), %eax     # 0x61397
cmpl $0x1, %eax
je 0x744a
movb $0x0, 0x59f4d(%rip)     # 0x61389
leaq 0x4e6e3(%rip), %rdi     # 0x55b26
movb $0x0, %al
callq 0x5060
movsbl 0x5a7bf(%rip), %eax     # 0x61c10
cmpl $0x2, %eax
jle 0x747c
testb $0x1, 0x5a814(%rip)     # 0x61c71
jne 0x747c
movq 0x59b72(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e6fc(%rip), %rsi     # 0x55b6c
movb $0x0, %al
callq 0x5470
callq 0xb500
movsbl 0x59f08(%rip), %eax     # 0x6138b
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
movsbl 0x59efe(%rip), %ecx     # 0x61396
movb $0x1, %al
cmpl $0xb, %ecx
movb %al, -0x51(%rbp)
je 0x74b2
movsbl 0x59eed(%rip), %eax     # 0x61396
cmpl $0xc, %eax
sete %al
movb %al, -0x51(%rbp)
movl -0x58(%rbp), %eax
movb -0x51(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
je 0x74df
movq 0x59b0f(%rip), %rax     # 0x60fd8
movq (%rax), %rdi
leaq 0x4e705(%rip), %rsi     # 0x55bd8
movb $0x0, %al
callq 0x5470
callq 0xb500
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x74ec
callq 0xb500
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x52b0
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x7535
movq -0x20(%rbp), %rdi
leaq 0x4e735(%rip), %rsi     # 0x55c53
callq 0x52b0
movq -0x28(%rbp), %rdi
leaq 0x4e730(%rip), %rsi     # 0x55c5e
callq 0x52b0
jmp 0x7585
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x52b0
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x756e
movq -0x28(%rbp), %rdi
leaq 0x4e6f7(%rip), %rsi     # 0x55c5e
callq 0x52b0
jmp 0x7583
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x52b0
jmp 0x7585
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)