// File: myudelson[P]hmm-scalable/trainhmmst.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':
				task.tol = atof( strtok(argv[i],",\t\n\r") );
                ch = strtok(NULL,",\t\n\r"); // could be NULL
                if(ch != NULL)
                    task.tol_mode = ch[0];
				if(task.tol<0) {
					fprintf(stderr,"ERROR! Fitting tolerance cannot be negative\n");
					exit_with_help();
				}
                if(task.tol>10) {
                    fprintf(stderr,"ERROR! Fitting tolerance cannot be >10\n");
                    exit_with_help();
                }
                if(task.tol_mode!='p' && task.tol_mode!='l') {
                    fprintf(stderr,"ERROR! Tolerance mode '%c' is not allowed\n",task.tol_mode);
                    exit_with_help();
                }
				break;
			case 't':
				task.sliced = (NPAR)atoi(argv[i]);
				if(task.sliced!=0 && task.sliced!=1) {
					fprintf(stderr,"ERROR! Time parameter should be either 0 (off) or 1(on)\n");
					exit_with_help();
				}
				break;
			case 'i':
				task.maxiter = atoi(argv[i]);
				if(task.maxiter<10) {
					fprintf(stderr,"ERROR! Maximum iterations should be at least 10\n");
					exit_with_help();
				}
				break;
			case 'q':
				task.quiet = (NPAR)atoi(argv[i]);
				if(task.quiet!=0 && task.quiet!=1) {
					fprintf(stderr,"ERROR! Quiet param should be 0 or 1\n");
					exit_with_help();
				}
				break;
			case 'n':
				task.nS = (NPAR)atoi(argv[i]);
				if(task.nS<2) {
					fprintf(stderr,"ERROR! Number of hidden states should be at least 2\n");
					exit_with_help();
				}
                if(task.nS != 2) {
                    task.stat_specd_gt2 = true;
                }
				break;
			case 'S':
				task.is_scaled = (NPAR)atoi(argv[i]);
				if(task.is_scaled < 0 || task.is_scaled > 1) {
					fprintf(stderr,"ERROR! Scaling flag should be either 0 (off) or 1 (in)\n");
					exit_with_help();
				}
				break;
			case 's':
				task.structure = (NPAR)atoi( strtok(argv[i],".\t\n\r") );
                ch = strtok(NULL,".\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL)
                    task.solver = (NPAR)atoi(ch);
                ch = strtok(NULL,"\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL)
                    task.solver_setting = (NPAR)atoi(ch);
                if( task.structure != STRUCTURE_SKILL && // task.structure != STRUCTURE_GROUP &&
                   task.structure != STRUCTURE_PIg   && task.structure != STRUCTURE_PIgk  &&
                   task.structure != STRUCTURE_PIAgk && task.structure != STRUCTURE_Agk &&
                   task.structure != STRUCTURE_PIABgk && task.structure != STRUCTURE_Agki &&
                   task.structure != STRUCTURE_PIgkww && task.structure != STRUCTURE_SKABslc &&
                   task.structure != STRUCTURE_SKAslc && task.structure != STRUCTURE_COMP &&
                   task.structure != STRUCTURE_ELO ) {
                    fprintf(stderr, "Model Structure specified (%d) is out of range of allowed values\n",task.structure);
					exit_with_help();
                }
                if( task.solver != METHOD_BW  && task.solver != METHOD_GD &&
                   task.solver != METHOD_CGD && task.solver != METHOD_GDL &&
                   task.solver != METHOD_GBB) {
                    fprintf(stderr, "Method specified (%d) is out of range of allowed values\n",task.solver);
					exit_with_help();
                }
//                if( (task.structure == STRUCTURE_SKABslc || task.structure == STRUCTURE_SKAslc) && task.solver == METHOD_BW) {
//                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
//                    exit_with_help();
//                }
                if( task.structure == STRUCTURE_COMP && task.solver == METHOD_BW) {
                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
                    exit_with_help();
                }
//                if( task.structure == STRUCTURE_ELO && !(task.solver == METHOD_GD || task.solver == METHOD_CGD) ) {
//                    fprintf(stderr, "Method specified (%d) is not defined for this structure (%d) \n",task.solver,task.structure);
//                    exit_with_help();
//                }
                if( task.solver == METHOD_BW && ( task.solver != STRUCTURE_SKILL /*&& task.solver != STRUCTURE_GROUP*/ ) ) {
                    fprintf(stderr, "Baum-Welch solver does not support model structure specified (%d)\n",task.solver);
					exit_with_help();
                }
                if( task.solver == METHOD_CGD  &&
                   ( task.solver_setting != 1 && task.solver_setting != 2 &&
                    task.solver_setting != 3 && task.solver_setting !=4 )
                   ) {
                    fprintf(stderr, "Conjugate Gradient Descent setting specified (%d) is out of range of allowed values\n",task.solver_setting);
					exit_with_help();
                }
				break;
            case 'f':
                task.single_skill = (NPAR)atoi(argv[i]);
                break;
			case 'm':
                task.metrics = atoi( strtok(argv[i],",\t\n\r"));
                ch = strtok(NULL, "\t\n\r");
                if(ch!=NULL) {
                    task.metrics_target_obs = (NPAR)(atoi(ch)-1);
                }
				if(task.metrics<0 || task.metrics>1) {
					fprintf(stderr,"value for -m should be either 0 or 1.\n");
					exit_with_help();
				}
				if(task.metrics_target_obs<0) {// || task.metrics_target_obs>(task.nO-1)) {
					fprintf(stderr,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
					exit_with_help();
				}
                break;
			case 'b':
                task.binaryinput = atoi( strtok(argv[i],"\t\n\r"));
                break;
			case 'v':
				task.cv_folds   = (NPAR)atoi( strtok(argv[i],",\t\n\r"));
                ch2 = strtok(NULL, ",\t\n\r");
                if(ch2!=NULL)
                    task.cv_strat = ch2[0];
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    task.cv_target_obs = (NPAR)(atoi(ch)-1);
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    strcpy(task.cv_folds_file, ch);
                ch = strtok(NULL, ",\t\n\r");
                if(ch!=NULL)
                    task.cv_inout_flag = ch[0];
                
				if(task.cv_folds<2) {
					fprintf(stderr,"number of cross-validation folds should be at least 2\n");

					exit_with_help();
				}
				if(task.cv_folds>10) {
					fprintf(stderr,"please keep number of cross-validation folds less than or equal to 10\n");
					exit_with_help();
				}
                if(task.cv_strat != CV_GROUP && task.cv_strat != CV_ITEM && task.cv_strat != CV_NSTR){
					fprintf(stderr,"cross-validation stratification parameter '%c' is illegal\n",task.cv_strat);
					exit_with_help();
                }
				if(task.cv_target_obs<0) {// || task.cv_target_obs>(task.nO-1)) {
					fprintf(stderr,"target observation to be cross-validated against cannot be '%d'\n",task.cv_target_obs+1);
					exit_with_help();
				}
                if( task.cv_inout_flag!='i' && task.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",task.cv_inout_flag);
					exit_with_help();
                }
                
				break;
            case  'p':
                task.predictions = atoi(argv[i]);
                if(task.predictions<0 || task.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':
                task.update_known = *strtok(argv[i],",\t\n\r");
                ch = strtok(NULL, ",\t\n\r");
                task.update_unknown = ch[0];
                
                if( (task.update_known!='r' && task.update_known!='g') ||
                   (task.update_unknown!='t' && task.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':
				task.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();
                }
                task.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
                    task.first_iteration_qualify = 0;
                    task.iterations_to_qualify   = (NPAR)n;
                } else {
                    task.first_iteration_qualify = (NPAR)n;
                    task.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();
                }
                task.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();
                    }
                    task.Cslices = (NPAR) tmp_array->getSize() / 4;
                    task.Cw = Calloc(NUMBER, (size_t)task.Cslices);
                    task.Ccenters = Calloc(NUMBER, (size_t)(task.Cslices * 3) );
                    int c1 = 0, c2 = 0, i = 0;
                    for(int l=0; l<(int)tmp_array->getSize() / 4; l++) {
                        task.Cw[c1++] = tmp_array->get((NDAT)i++);
                        for(int j=0; j<3; j++)
                            task.Ccenters[c2++] = tmp_array->get((NDAT)i++);
                    }
                    delete tmp_array;
                }
                break;
                */
            case 'c': // just to keep it a valid option
                break;
            case 'o':
                task.duplicate_console = 1;
                strcpy(console_file_name,argv[i]);
                break;
            case '0':
                task.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;
            case 'k': // 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(task.cv_folds>0 && task.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(task.is_scaled == 1 && task.solver != METHOD_BW) {
        task.is_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(task.nS > 2 && !task.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( (task.sliced==1) != (task.structure == STRUCTURE_SKABslc || task.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 0x4cce
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x421b
jmp 0x4cce
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
cmpl -0x4(%rbp), %eax
jl 0x422e
callq 0x78a0
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 0x4c8c
movq -0x50(%rbp), %rax
leaq 0x19dc9(%rip), %rcx     # 0x1e028
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1b1dd(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movsd %xmm0, 0x230b0(%rip)    # 0x27340
xorl %eax, %eax
movl %eax, %edi
leaq 0x1b1bd(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x42b7
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x23091(%rip)      # 0x27348
xorps %xmm0, %xmm0
ucomisd 0x2307e(%rip), %xmm0    # 0x27340
jbe 0x42e1
movq 0x22d0d(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b188(%rip), %rsi     # 0x1f45d
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsd 0x23057(%rip), %xmm0    # 0x27340
movsd 0x19d27(%rip), %xmm1    # 0x1e018
ucomisd %xmm1, %xmm0
jbe 0x4314
movq 0x22cda(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b182(%rip), %rsi     # 0x1f48a
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x2302d(%rip), %eax     # 0x27348
cmpl $0x70, %eax
je 0x4350
movsbl 0x23021(%rip), %eax     # 0x27348
cmpl $0x6c, %eax
je 0x4350
movq 0x22ca5(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x2300b(%rip), %edx     # 0x27348
leaq 0x1b16e(%rip), %rsi     # 0x1f4b2
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movb %al, 0x22fdf(%rip)      # 0x2734b
movsbl 0x22fd8(%rip), %eax     # 0x2734b
cmpl $0x0, %eax
je 0x43a1
movsbl 0x22fcc(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
je 0x43a1
movq 0x22c4d(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b148(%rip), %rsi     # 0x1f4dd
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movl %eax, 0x22f93(%rip)     # 0x27350
cmpl $0xa, 0x22f8c(%rip)     # 0x27350
jge 0x43e3
movq 0x22c0b(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b13f(%rip), %rsi     # 0x1f516
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movb %al, 0x22f55(%rip)      # 0x27354
movsbl 0x22f4e(%rip), %eax     # 0x27354
cmpl $0x0, %eax
je 0x4434
movsbl 0x22f42(%rip), %eax     # 0x27354
cmpl $0x1, %eax
je 0x4434
movq 0x22bba(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b11f(%rip), %rsi     # 0x1f547
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movb %al, 0x237b8(%rip)      # 0x27c08
movsbl 0x237b1(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
jge 0x4479
movq 0x22b75(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b0ff(%rip), %rsi     # 0x1f56c
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x23788(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
je 0x448c
movb $0x1, 0x237a0(%rip)     # 0x27c2c
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movb %al, 0x22ea1(%rip)      # 0x27349
movsbl 0x22e9a(%rip), %eax     # 0x27349
cmpl $0x0, %eax
jl 0x44c0
movsbl 0x22e8e(%rip), %eax     # 0x27349
cmpl $0x1, %eax
jle 0x44dd
movq 0x22b11(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1b0d0(%rip), %rsi     # 0x1f5a1
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1b0e4(%rip), %rsi     # 0x1f5d9
callq 0x3440
movq %rax, %rdi
callq 0x3430
movb %al, 0x22e4e(%rip)      # 0x27356
xorl %eax, %eax
movl %eax, %edi
leaq 0x1b0c6(%rip), %rsi     # 0x1f5d9
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4532
movq -0x40(%rbp), %rdi
callq 0x3430
movb %al, 0x22e25(%rip)      # 0x27357
xorl %eax, %eax
movl %eax, %edi
leaq 0x1af1c(%rip), %rsi     # 0x1f459
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x455c
movq -0x40(%rbp), %rdi
callq 0x3430
movb %al, 0x22dfc(%rip)      # 0x27358
movsbl 0x22df3(%rip), %eax     # 0x27356
cmpl $0x1, %eax
je 0x4620
movsbl 0x22de3(%rip), %eax     # 0x27356
cmpl $0x3, %eax
je 0x4620
movsbl 0x22dd3(%rip), %eax     # 0x27356
cmpl $0x4, %eax
je 0x4620
movsbl 0x22dc3(%rip), %eax     # 0x27356
cmpl $0x5, %eax
je 0x4620
movsbl 0x22db3(%rip), %eax     # 0x27356
cmpl $0x6, %eax
je 0x4620
movsbl 0x22da7(%rip), %eax     # 0x27356
cmpl $0x7, %eax
je 0x4620
movsbl 0x22d9b(%rip), %eax     # 0x27356
cmpl $0x9, %eax
je 0x4620
movsbl 0x22d8f(%rip), %eax     # 0x27356
cmpl $0xa, %eax
je 0x4620
movsbl 0x22d83(%rip), %eax     # 0x27356
cmpl $0xb, %eax
je 0x4620
movsbl 0x22d77(%rip), %eax     # 0x27356
cmpl $0xc, %eax
je 0x4620
movsbl 0x22d6b(%rip), %eax     # 0x27356
cmpl $0xd, %eax
je 0x4620
movsbl 0x22d5f(%rip), %eax     # 0x27356
cmpl $0xe, %eax
je 0x4620
movq 0x229d5(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22d49(%rip), %edx     # 0x27356
leaq 0x1afca(%rip), %rsi     # 0x1f5de
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22d30(%rip), %eax     # 0x27357
cmpl $0x1, %eax
je 0x4680
movsbl 0x22d24(%rip), %eax     # 0x27357
cmpl $0x2, %eax
je 0x4680
movsbl 0x22d18(%rip), %eax     # 0x27357
cmpl $0x3, %eax
je 0x4680
movsbl 0x22d0c(%rip), %eax     # 0x27357
cmpl $0x4, %eax
je 0x4680
movsbl 0x22d00(%rip), %eax     # 0x27357
cmpl $0x5, %eax
je 0x4680
movq 0x22975(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22cea(%rip), %edx     # 0x27357
leaq 0x1afac(%rip), %rsi     # 0x1f620
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22ccf(%rip), %eax     # 0x27356
cmpl $0xd, %eax
jne 0x46c3
movsbl 0x22cc4(%rip), %eax     # 0x27357
cmpl $0x1, %eax
jne 0x46c3
movq 0x22939(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22cae(%rip), %edx     # 0x27357
movsbl 0x22ca6(%rip), %ecx     # 0x27356
leaq 0x1afa2(%rip), %rsi     # 0x1f659
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22c8d(%rip), %eax     # 0x27357
cmpl $0x1, %eax
jne 0x46ff
movsbl 0x22c81(%rip), %eax     # 0x27357
cmpl $0x1, %eax
je 0x46ff
movq 0x228f6(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22c6b(%rip), %edx     # 0x27357
leaq 0x1afa5(%rip), %rsi     # 0x1f698
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22c51(%rip), %eax     # 0x27357
cmpl $0x3, %eax
jne 0x475f
movsbl 0x22c46(%rip), %eax     # 0x27358
cmpl $0x1, %eax
je 0x475f
movsbl 0x22c3a(%rip), %eax     # 0x27358
cmpl $0x2, %eax
je 0x475f
movsbl 0x22c2e(%rip), %eax     # 0x27358
cmpl $0x3, %eax
je 0x475f
movsbl 0x22c22(%rip), %eax     # 0x27358
cmpl $0x4, %eax
je 0x475f
movq 0x22896(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22c0c(%rip), %edx     # 0x27358
leaq 0x1af88(%rip), %rsi     # 0x1f6db
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movb %al, 0x22bda(%rip)      # 0x27355
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1acc5(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3430
movl %eax, 0x22bca(%rip)     # 0x27370
xorl %eax, %eax
movl %eax, %edi
leaq 0x1aca8(%rip), %rsi     # 0x1f459
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x47d3
movq -0x40(%rbp), %rdi
callq 0x3430
subl $0x1, %eax
movb %al, 0x22ba1(%rip)      # 0x27374
cmpl $0x0, 0x22b96(%rip)     # 0x27370
jl 0x47e5
cmpl $0x1, 0x22b8d(%rip)     # 0x27370
jle 0x4802
movq 0x227ec(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1af3a(%rip), %rsi     # 0x1f730
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22b6b(%rip), %eax     # 0x27374
cmpl $0x0, %eax
jge 0x4835
movq 0x227c3(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22b55(%rip), %edx     # 0x27374
addl $0x1, %edx
leaq 0x1af2e(%rip), %rsi     # 0x1f757
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1ac0c(%rip), %rsi     # 0x1f459
callq 0x3440
movq %rax, %rdi
callq 0x3430
movl %eax, 0x22b20(%rip)     # 0x27380
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1abe0(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3430
movb %al, 0x22ef9(%rip)      # 0x27784
xorl %eax, %eax
movl %eax, %edi
leaq 0x1abc2(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x48b2
movq -0x48(%rbp), %rax
movb (%rax), %al
movb %al, 0x22ed3(%rip)      # 0x27785
xorl %eax, %eax
movl %eax, %edi
leaq 0x1ab9b(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x48df
movq -0x40(%rbp), %rdi
callq 0x3430
subl $0x1, %eax
movb %al, 0x22ea7(%rip)      # 0x27786
xorl %eax, %eax
movl %eax, %edi
leaq 0x1ab6e(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x490a
movq -0x40(%rbp), %rsi
leaq 0x22e82(%rip), %rdi     # 0x27787
callq 0x3270
xorl %eax, %eax
movl %eax, %edi
leaq 0x1ab43(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x4931
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x23256(%rip)      # 0x27b87
movsbl 0x22e4c(%rip), %eax     # 0x27784
cmpl $0x2, %eax
jge 0x495a
movq 0x22694(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ae47(%rip), %rsi     # 0x1f795
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22e23(%rip), %eax     # 0x27784
cmpl $0xa, %eax
jle 0x4983
movq 0x2266b(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ae55(%rip), %rsi     # 0x1f7cc
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22dfb(%rip), %eax     # 0x27785
cmpl $0x67, %eax
je 0x49cb
movsbl 0x22def(%rip), %eax     # 0x27785
cmpl $0x69, %eax
je 0x49cb
movsbl 0x22de3(%rip), %eax     # 0x27785
cmpl $0x6e, %eax
je 0x49cb
movq 0x2262a(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22dcd(%rip), %edx     # 0x27785
leaq 0x1ae54(%rip), %rsi     # 0x1f813
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22db4(%rip), %eax     # 0x27786
cmpl $0x0, %eax
jge 0x49fe
movq 0x225fa(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x22d9e(%rip), %edx     # 0x27786
addl $0x1, %edx
leaq 0x1ae5c(%rip), %rsi     # 0x1f84e
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x23182(%rip), %eax     # 0x27b87
cmpl $0x69, %eax
je 0x4a3a
movsbl 0x23176(%rip), %eax     # 0x27b87
cmpl $0x6f, %eax
je 0x4a3a
movq 0x225bb(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x23160(%rip), %edx     # 0x27b87
leaq 0x1ae61(%rip), %rsi     # 0x1f88f
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movl %eax, 0x22922(%rip)     # 0x27378
cmpl $0x0, 0x2291b(%rip)     # 0x27378
jl 0x4a68
cmpl $0x3, 0x22912(%rip)     # 0x27378
jle 0x4a85
movq 0x22569(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ae78(%rip), %rsi     # 0x1f8f1
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1a9bb(%rip), %rsi     # 0x1f458
callq 0x3440
movb (%rax), %al
movb %al, 0x228d2(%rip)      # 0x2737c
xorl %eax, %eax
movl %eax, %edi
leaq 0x1a9a3(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, 0x228b3(%rip)      # 0x2737d
movsbl 0x228ab(%rip), %eax     # 0x2737c
cmpl $0x72, %eax
je 0x4ae2
movsbl 0x2289f(%rip), %eax     # 0x2737c
cmpl $0x67, %eax
jne 0x4afa
movsbl 0x22894(%rip), %eax     # 0x2737d
cmpl $0x74, %eax
je 0x4b17
movsbl 0x22888(%rip), %eax     # 0x2737d
cmpl $0x67, %eax
je 0x4b17
movq 0x224d7(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ae3e(%rip), %rsi     # 0x1f949
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movb (%rax), %al
movb %al, 0x230f8(%rip)      # 0x27c28
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x4b78
cmpl $0x1, -0x38(%rbp)
je 0x4b78
cmpl $0x2, -0x38(%rbp)
je 0x4b78
movq 0x22476(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ae47(%rip), %rsi     # 0x1f9b3
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movl -0x38(%rbp), %eax
movb %al, 0x227d8(%rip)      # 0x27359
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1a8bf(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3430
movl %eax, -0x38(%rbp)
xorl %eax, %eax
movl %eax, %edi
leaq 0x1a8a4(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x4bd6
movb $0x0, 0x230bd(%rip)     # 0x27c88
movl -0x38(%rbp), %eax
movb %al, 0x230b5(%rip)      # 0x27c89
jmp 0x4bee
movl -0x38(%rbp), %eax
movb %al, 0x230a9(%rip)      # 0x27c88
movq -0x40(%rbp), %rdi
callq 0x3430
movb %al, 0x2309b(%rip)      # 0x27c89
jmp 0x4cbe
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3430
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jg 0x4c2a
movq 0x223c4(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1adc5(%rip), %rsi     # 0x1f9e3
movb $0x0, %al
callq 0x33f0
callq 0x78a0
cmpl $0x0, -0x38(%rbp)
jg 0x4c4d
movq 0x223a1(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ada2(%rip), %rsi     # 0x1f9e3
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movl -0x38(%rbp), %eax
movsbl %al, %eax
movl %eax, 0x23033(%rip)     # 0x27c8c
jmp 0x4cbe
jmp 0x4cbe
movb $0x1, 0x226e8(%rip)     # 0x2734c
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3270
jmp 0x4cbe
movb $0x1, 0x22fa7(%rip)     # 0x27c29
jmp 0x4cbe
jmp 0x4cbe
jmp 0x4cbe
jmp 0x4cbe
jmp 0x4cbe
movq 0x22345(%rip), %rax     # 0x26fd8
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 0x1ad7c(%rip), %rsi     # 0x1fa2e
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x4cc0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x41f6
movsbl 0x22aaf(%rip), %eax     # 0x27784
cmpl $0x0, %eax
jle 0x4d00
cmpl $0x0, 0x2268f(%rip)     # 0x27370
jle 0x4d00
movq 0x222ee(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ad4f(%rip), %rsi     # 0x1fa43
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x22642(%rip), %eax     # 0x27349
cmpl $0x1, %eax
jne 0x4d2d
movsbl 0x22644(%rip), %eax     # 0x27357
cmpl $0x1, %eax
je 0x4d2d
movb $0x0, 0x2262a(%rip)     # 0x27349
leaq 0x1ad4c(%rip), %rdi     # 0x1fa72
movb $0x0, %al
callq 0x3060
movsbl 0x22ed4(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
jle 0x4d5f
testb $0x1, 0x22ee9(%rip)     # 0x27c29
jne 0x4d5f
movq 0x2228f(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ad65(%rip), %rsi     # 0x1fab8
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x225e5(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x58(%rbp)
movsbl 0x225db(%rip), %ecx     # 0x27356
movb $0x1, %al
cmpl $0xb, %ecx
movb %al, -0x51(%rbp)
je 0x4d95
movsbl 0x225ca(%rip), %eax     # 0x27356
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 0x4dc2
movq 0x2222c(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1ad6e(%rip), %rsi     # 0x1fb24
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x4dcf
callq 0x78a0
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 0x3270
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x4e18
movq -0x20(%rbp), %rdi
leaq 0x1ad9e(%rip), %rsi     # 0x1fb9f
callq 0x3270
movq -0x28(%rbp), %rdi
leaq 0x1ad99(%rip), %rsi     # 0x1fbaa
callq 0x3270
jmp 0x4e68
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 0x3270
movl -0x34(%rbp), %eax
cmpl -0x4(%rbp), %eax
jl 0x4e51
movq -0x28(%rbp), %rdi
leaq 0x1ad60(%rip), %rsi     # 0x1fbaa
callq 0x3270
jmp 0x4e66
movq -0x28(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3270
jmp 0x4e68
addq $0x60, %rsp
popq %rbp
retq
nop