// File: myudelson[P]hmm-scalable/trainhmmst.cpp
// Function: parse_arguments_step2(int, char**, _IO_FILE*)
void parse_arguments_step2(int argc, char **argv, FILE *fid_console) {
	// 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 know nO (the number of observations)
	int i;
    int n, expected_n;
    char *ch;
	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 '0': // init_params
				int len;
				len = (int)strlen( argv[i] );
				// count delimiters
				n = 1; // start with 1
				for(int j=0;j<len;j++) {
					n += (argv[i][j]==',')?1:0;
                    if( (argv[i][j] >= 'a' && argv[i][j] <= 'z') || (argv[i][j] >= 'A' && argv[i][j] <= 'Z') ) {
                        strcpy(task.initfile, argv[i]);
                        break;
                    }
                }
                // init parameters
                if(task.init_param_values!=NULL) free(task.init_param_values);
                task.init_param_values = Calloc(NUMBER, (size_t)n);
                task.init_param_values_n = (NPAR)n;
                // read params and write to params
                task.init_param_values[0] = atof( strtok(argv[i],",\t\n\r") );
                for(int j=1; j<n; j++) {
                    task.init_param_values[j] = atof( strtok(NULL,",\t\n\r") );
                }
				break;
			case 'l': // lower boundaries
				len = (int)strlen( argv[i] );
				// count delimiters
				n = 1; // start with 1
				for(int j=0;j<len;j++)
					n += (NPAR)((argv[i][j]==',')?1:0);
				// init params
				if(task.param_values_lb!=NULL) free(task.param_values_lb);
				task.param_values_lb = Calloc(NUMBER, (size_t)n);
				// read params and write to params
				task.param_values_lb[0] = atof( strtok(argv[i],",\t\n\r") );
                for(int j=1; j<n; j++) {
					task.param_values_lb[j] = atof( strtok(NULL,",\t\n\r") );
//                    if(task.param_lo[j] >0) {
//                        int a = 0;
//                    }
                }
                // check if the number of lower boundaries corresponds
                expected_n = task.nS +
                    ((task.sliced==1 && (task.structure==STRUCTURE_SKAslc || task.structure==STRUCTURE_SKABslc) )?task.nZ:1)*task.nS*task.nS +
                    ((task.sliced==1 && task.structure==STRUCTURE_SKABslc )?task.nZ:1)*task.nS*task.nO;
                if( n != expected_n ) {
//                    fprintf(stderr,"Structure=%d, nS=%d, nO=%d, nZ=%d, The expected n=%d specified=%d\n",task.structure,task.nS,task.nO,task.nZ,expected_n,n);
                    fprintf(stderr,"The expected number of lower parameter boundaries is %d and it is %d\n",expected_n,n);
                    exit_with_help();
                }
                task.lb_specd = true;
				break;
			case 'u': // upper boundaries
				len = (int)strlen( argv[i] );
				// count delimiters
				n = 1; // start with 1
				for(int j=0;j<len;j++)
					n += (argv[i][j]==',')?1:0;
				// init params
				if(task.param_values_ub!=NULL) free(task.param_values_ub);
				task.param_values_ub = Calloc(NUMBER, (size_t)n);
				// read params and write to params
				task.param_values_ub[0] = atof( strtok(argv[i],",\t\n\r") );
                for(int j=1; j<n; j++) {
					task.param_values_ub[j] = atof( strtok(NULL,",\t\n\r") );
//                    if(task.param_hi[j] < 1) {
//                        int a = 0;
//                    }
                }
                // check if the number of upper boundaries corresponds
                expected_n = task.nS +
                    ((task.sliced==1 && (task.structure==STRUCTURE_SKAslc || task.structure==STRUCTURE_SKABslc) )?task.nZ:1)*task.nS*task.nS +
                    ((task.sliced==1 && task.structure==STRUCTURE_SKABslc )?task.nZ:1)*task.nS*task.nO;
                if( n != expected_n ) {
                    fprintf(stderr,"The expected number of upper parameter boundaries is %d and it is %d\n",expected_n,n);
                    exit_with_help();
                }
                task.ub_specd = true;
				break;
			case 'B': // block fitting
                // first
				task.block_fitting[0] = (NPAR)atoi( strtok(argv[i],",\t\n\r") );
                if(task.block_fitting[0]!=0 && task.block_fitting[0]!=1) {
                    fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                    if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                    exit_with_help();
                }
                // second
                ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL) {
                    task.block_fitting[1] = (NPAR)atoi(ch);
                    if(task.block_fitting[1]!=0 && task.block_fitting[1]!=1) {
                        fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                        if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                        exit_with_help();
                    }
                }
                else {
                    fprintf(stderr,"There should be 3 blockig the fitting flags specified.\n");
                    if(task.duplicate_console==1) fprintf(fid_console,"There should be 3 blockig the fitting flags specified.\n");
                    exit_with_help();
                }
                // third
                ch = strtok(NULL,",\t\n\r"); // could be NULL (default GD solver)
                if(ch != NULL) {
                    task.block_fitting[2] = (NPAR)atoi(ch);
                    if(task.block_fitting[2]!=0 && task.block_fitting[2]!=1) {
                        fprintf(stderr,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                        if(task.duplicate_console==1) fprintf(fid_console,"Values of blocking the fitting flags shuld only be 0 or 1.\n");
                        exit_with_help();
                    }
                }
                else {
                    fprintf(stderr,"There should be 3 blockig the fitting flags specified.\n");
                    if(task.duplicate_console==1) fprintf(fid_console,"There should be 3 blockig the fitting flags specified.\n");
                    exit_with_help();
                }
				break;
			case 'c': {
                    // this version with per-parameter center of gravity in Pi, A, and B
                    NPAR nS = task.nS;
                    NPAR nO = task.nO;
                    int nPerSlice = 1 + nS + nS*nS + nS*nO; // parameters per slice
                    int nCenters = nS + nS*nS + nS*nO; // centers per slice
                    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() % nPerSlice) != 0 ) {
                        fprintf(stderr,"The number of regularization parameters should be a multiple of %d and it is %d\n",nPerSlice,tmp_array->getSize());
                        exit_with_help();
                    }
                    task.Cslices = (NPAR) ( tmp_array->getSize() / nPerSlice );
                    task.Cw = Calloc(NUMBER, (size_t)task.Cslices);
                    task.Ccenters = Calloc(NUMBER, (size_t)(task.Cslices * nCenters) );
                    int c1 = 0/*counter for weights*/, c2 = 0/*counter for centers*/, i = 0/*counter for tmp_array*/;
                    for(int l=0; l<(int)tmp_array->getSize() / nPerSlice; l++) {
                        task.Cw[c1++] = tmp_array->get((NDAT)i++);
                        for(int j=0; j<nCenters; j++)
                            task.Ccenters[c2++] = tmp_array->get((NDAT)i++);
                    }
                    delete tmp_array;
                }
                break;
            case 'k':
                // ELO parameters specified as a comma-delimited list of values, first is an integer, the rest are real
                len = (int)strlen( argv[i] );
                // count delimiters
                n = 1; // start with 1
                for(int j=0;j<len;j++)
                    n += (NPAR)((argv[i][j]==',')?1:0);
                if( n < 3 ) {
                    fprintf(stderr,"To use Elo, one needs at lest three parameters; %d were specified\n",n);
                    exit_with_help();
                }
                // init params
                task.elo_param_values_n = (NPAR)(n-2); // first parameter is Elo type
                if(task.elo_param_values!=NULL) free(task.elo_param_values);
                task.elo_param_values = Calloc(NUMBER, (size_t)(n-2));
                // read params and write to params
                task.elo_type = (NPAR)atoi( strtok(argv[i],",\t\n\r") );
                task.elo_scope = (NCAT)atof( strtok(NULL,",\t\n\r") );
                for(int j=2; j<n; j++) {
                    task.elo_param_values[j-2] = atof( strtok(NULL,",\t\n\r") );
                }
                break;
                
        } // end switch
    }// end for
    
    // post parse actions
    
    // post-argument checks
    if( 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);
        if(task.duplicate_console==1) fprintf(fid_console,"target observation to be cross-validated against cannot be '%d'\n",task.cv_target_obs+1);
        exit_with_help();
    }
    if(task.metrics_target_obs>(task.nO-1)) {
        fprintf(stderr,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
        if(task.duplicate_console==1) fprintf(fid_console,"target observation to compute metrics against cannot be '%d'\n",task.metrics_target_obs+1);
        exit_with_help();
    }
    
    if( !( (task.elo_param_values_n==0 && task.elo_type==0 && task.structure != STRUCTURE_ELO) || // not an Elo
           (task.elo_param_values_n==1 && task.elo_type==1 && task.structure == STRUCTURE_ELO) || // Simple Elo
           (task.elo_param_values_n==1 && task.elo_type==2 && task.structure == STRUCTURE_ELO) || // relation Uncertainty \frac{1}{1+b*n} Elo
           (task.elo_param_values_n==1 && task.elo_type==3 && task.structure == STRUCTURE_ELO) || // relation Uncertainty \frac{1}{1+b*e^{0.01*n}} Elo
           (task.elo_param_values_n==1 && task.elo_type==4 && task.structure == STRUCTURE_ELO)    // linear trend from 1 to 0 in b steps
          ) ) {
        fprintf(stderr,"Elo type specified (%d) does not match the number of Elo parameters (%d)\n",task.elo_type,task.elo_param_values_n);
        exit_with_help();
    }
    
    if( task.structure == STRUCTURE_ELO && task.nS != 2) {
        fprintf(stderr,"Elo solvers only work with number of states equal to 2, while %d were specified!",task.nS);
        exit_with_help();
    }
    
    // upper and lower bounds
    if( (task.sliced==1) && (task.structure == STRUCTURE_SKABslc || task.structure == STRUCTURE_SKAslc) &&
       !(task.lb_specd && task.ub_specd)) {
        fprintf(stderr,"Error! when parameter slicing is enabled, lower and upper boundaries for all parameters have to be set explicitly.\n");
        exit_with_help();
    }
    if(!task.lb_specd && (task.nS!=2 || task.nO!=2) ) { // if not specified, and it's not 2-state 2-obs case, set to 0
        if(task.param_values_lb!=NULL) free(task.param_values_lb);
        task.param_values_lb = Calloc(NUMBER, (size_t)( task.nS*(1+task.nS+task.nO) ) );
    }
 
    if(!task.ub_specd && (task.nS!=2 || task.nO!=2) ) {  // if not specified, and it's not 2-state 2-obs case, set to 1
        if(task.param_values_ub!=NULL) free(task.param_values_ub);  // if not specified, set to 1
        task.param_values_ub = Calloc(NUMBER, (size_t)( task.nS*(1+task.nS+task.nO) ) );
        for(int j=0; j<( task.nS*(1+task.nS+task.nO) ); j++)
            task.param_values_ub[j] = (NUMBER)1.0;
    }

    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x1, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x5bb9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x4fb2
jmp 0x5bb9
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl -0x4(%rbp), %eax
jl 0x4fc5
callq 0x78a0
movq -0x10(%rbp), %rax
movl -0x1c(%rbp), %ecx
decl %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
movl %eax, -0x90(%rbp)
subl $0x30, %eax
je 0x503e
jmp 0x4fe6
movl -0x90(%rbp), %eax
subl $0x42, %eax
je 0x55bc
jmp 0x4ff7
movl -0x90(%rbp), %eax
subl $0x63, %eax
je 0x57ae
jmp 0x5008
movl -0x90(%rbp), %eax
subl $0x6b, %eax
je 0x5a39
jmp 0x5019
movl -0x90(%rbp), %eax
subl $0x6c, %eax
je 0x51c7
jmp 0x502a
movl -0x90(%rbp), %eax
subl $0x75, %eax
je 0x53c3
jmp 0x5ba9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3130
movl %eax, -0x34(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x5121
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2c, %edx
cmovel %ecx, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x61, %eax
jl 0x50c5
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x7a, %eax
jle 0x50f7
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x41, %eax
jl 0x5111
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x38(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5a, %eax
jg 0x5111
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0x2227a(%rip), %rdi     # 0x27384
callq 0x3270
jmp 0x5121
jmp 0x5113
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x5060
cmpq $0x0, 0x221df(%rip)     # 0x27308
je 0x5137
movq 0x221d6(%rip), %rdi     # 0x27308
callq 0x3350
movslq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x221bc(%rip)     # 0x27308
movl -0x20(%rbp), %eax
movb %al, 0x221bb(%rip)      # 0x27310
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1a2f0(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x2218c(%rip), %rax     # 0x27308
movsd %xmm0, (%rax)
movl $0x1, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x51c2
xorl %eax, %eax
movl %eax, %edi
leaq 0x1a2be(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x2215a(%rip), %rax     # 0x27308
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x5187
jmp 0x5ba9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3130
movl %eax, -0x34(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x5226
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2c, %edx
cmovel %ecx, %eax
movsbl %al, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x51e9
cmpq $0x0, 0x220ea(%rip)     # 0x27318
je 0x523c
movq 0x220e1(%rip), %rdi     # 0x27318
callq 0x3350
movslq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x220c7(%rip)     # 0x27318
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1a1f4(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x220a0(%rip), %rax     # 0x27318
movsd %xmm0, (%rax)
movl $0x1, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x52be
xorl %eax, %eax
movl %eax, %edi
leaq 0x1a1c2(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x2206e(%rip), %rax     # 0x27318
movslq -0x44(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x5283
movsbl 0x22943(%rip), %eax     # 0x27c08
movl %eax, -0x94(%rbp)
movsbl 0x22079(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
jne 0x52fe
movsbl 0x22078(%rip), %eax     # 0x27356
cmpl $0xc, %eax
je 0x52ef
movsbl 0x2206c(%rip), %eax     # 0x27356
cmpl $0xb, %eax
jne 0x52fe
movsbl 0x22922(%rip), %eax     # 0x27c18
movl %eax, -0x98(%rbp)
jmp 0x530b
movl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x530b
movl -0x94(%rbp), %eax
movl -0x98(%rbp), %ecx
movsbl 0x228ea(%rip), %edx     # 0x27c08
imull %edx, %ecx
movsbl 0x228e0(%rip), %edx     # 0x27c08
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x9c(%rbp)
movsbl 0x22011(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
jne 0x535a
movsbl 0x22010(%rip), %eax     # 0x27356
cmpl $0xb, %eax
jne 0x535a
movsbl 0x228c6(%rip), %eax     # 0x27c18
movl %eax, -0xa0(%rbp)
jmp 0x5367
movl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x5367
movl -0x9c(%rbp), %eax
movl -0xa0(%rbp), %ecx
movsbl 0x2288e(%rip), %edx     # 0x27c08
imull %edx, %ecx
movsbl 0x22885(%rip), %edx     # 0x27c09
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x53b7
movq 0x21c3d(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movl -0x24(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x1a80f(%rip), %rsi     # 0x1fbba
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movb $0x1, 0x2286c(%rip)     # 0x27c2a
jmp 0x5ba9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3130
movl %eax, -0x34(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x541f
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2c, %edx
cmovel %ecx, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x53e5
cmpq $0x0, 0x21ef9(%rip)     # 0x27320
je 0x5435
movq 0x21ef0(%rip), %rdi     # 0x27320
callq 0x3350
movslq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x21ed6(%rip)     # 0x27320
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x19ffb(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x21eaf(%rip), %rax     # 0x27320
movsd %xmm0, (%rax)
movl $0x1, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x54b7
xorl %eax, %eax
movl %eax, %edi
leaq 0x19fc9(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x21e7d(%rip), %rax     # 0x27320
movslq -0x4c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x547c
movsbl 0x2274a(%rip), %eax     # 0x27c08
movl %eax, -0xa4(%rbp)
movsbl 0x21e80(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
jne 0x54f7
movsbl 0x21e7f(%rip), %eax     # 0x27356
cmpl $0xc, %eax
je 0x54e8
movsbl 0x21e73(%rip), %eax     # 0x27356
cmpl $0xb, %eax
jne 0x54f7
movsbl 0x22729(%rip), %eax     # 0x27c18
movl %eax, -0xa8(%rbp)
jmp 0x5504
movl $0x1, %eax
movl %eax, -0xa8(%rbp)
jmp 0x5504
movl -0xa4(%rbp), %eax
movl -0xa8(%rbp), %ecx
movsbl 0x226f1(%rip), %edx     # 0x27c08
imull %edx, %ecx
movsbl 0x226e7(%rip), %edx     # 0x27c08
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0xac(%rbp)
movsbl 0x21e18(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
jne 0x5553
movsbl 0x21e17(%rip), %eax     # 0x27356
cmpl $0xb, %eax
jne 0x5553
movsbl 0x226cd(%rip), %eax     # 0x27c18
movl %eax, -0xb0(%rbp)
jmp 0x5560
movl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0x5560
movl -0xac(%rbp), %eax
movl -0xb0(%rbp), %ecx
movsbl 0x22695(%rip), %edx     # 0x27c08
imull %edx, %ecx
movsbl 0x2268c(%rip), %edx     # 0x27c09
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x24(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x24(%rbp), %eax
je 0x55b0
movq 0x21a44(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movl -0x24(%rbp), %edx
movl -0x20(%rbp), %ecx
leaq 0x1a65c(%rip), %rsi     # 0x1fc00
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movb $0x1, 0x22674(%rip)     # 0x27c2b
jmp 0x5ba9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x19e89(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3430
movb %al, 0x226af(%rip)      # 0x27c91
movsbl 0x226a8(%rip), %eax     # 0x27c91
cmpl $0x0, %eax
je 0x5635
movsbl 0x2269c(%rip), %eax     # 0x27c91
cmpl $0x1, %eax
je 0x5635
movq 0x219d7(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1a63b(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
movsbl 0x21d33(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x5630
movq -0x18(%rbp), %rdi
leaq 0x1a61d(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
callq 0x78a0
xorl %eax, %eax
movl %eax, %edi
leaq 0x19e18(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x56b4
movq -0x30(%rbp), %rdi
callq 0x3430
movb %al, 0x22633(%rip)      # 0x27c92
movsbl 0x2262c(%rip), %eax     # 0x27c92
cmpl $0x0, %eax
je 0x56b2
movsbl 0x22620(%rip), %eax     # 0x27c92
cmpl $0x1, %eax
je 0x56b2
movq 0x2195a(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1a5be(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
movsbl 0x21cb6(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x56ad
movq -0x18(%rbp), %rdi
leaq 0x1a5a0(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x56ef
movq 0x2191d(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1a5bd(%rip), %rsi     # 0x1fc82
movb $0x0, %al
callq 0x33f0
movsbl 0x21c79(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x56ea
movq -0x18(%rbp), %rdi
leaq 0x1a59f(%rip), %rsi     # 0x1fc82
movb $0x0, %al
callq 0x33f0
callq 0x78a0
xorl %eax, %eax
movl %eax, %edi
leaq 0x19d5e(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x576e
movq -0x30(%rbp), %rdi
callq 0x3430
movb %al, 0x2257a(%rip)      # 0x27c93
movsbl 0x22573(%rip), %eax     # 0x27c93
cmpl $0x0, %eax
je 0x576c
movsbl 0x22567(%rip), %eax     # 0x27c93
cmpl $0x1, %eax
je 0x576c
movq 0x218a0(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1a504(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
movsbl 0x21bfc(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x5767
movq -0x18(%rbp), %rdi
leaq 0x1a4e6(%rip), %rsi     # 0x1fc46
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x57a9
movq 0x21863(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x1a503(%rip), %rsi     # 0x1fc82
movb $0x0, %al
callq 0x33f0
movsbl 0x21bbf(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x57a4
movq -0x18(%rbp), %rdi
leaq 0x1a4e5(%rip), %rsi     # 0x1fc82
movb $0x0, %al
callq 0x33f0
callq 0x78a0
jmp 0x5ba9
movb 0x22454(%rip), %al      # 0x27c08
movb %al, -0x4d(%rbp)
movb 0x2244c(%rip), %al      # 0x27c09
movb %al, -0x4e(%rbp)
movsbl -0x4d(%rbp), %ecx
movl %ecx, %eax
imull %eax, %eax
movl %ecx, %edx
addl %eax, %edx
movsbl -0x4e(%rbp), %eax
imull %eax, %ecx
movl %ecx, %eax
movl %edx, %ecx
leal 0x1(%rax,%rcx), %eax
movl %eax, -0x54(%rbp)
movsbl -0x4d(%rbp), %ecx
movl %ecx, %edx
imull %edx, %edx
movl %ecx, %eax
addl %edx, %eax
movsbl -0x4e(%rbp), %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x58(%rbp)
movl $0x18, %edi
callq 0x32a0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
callq 0x79c0
jmp 0x5816
movq -0xb8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x19c24(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x589c
movq -0x60(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3390
movq -0xc0(%rbp), %rdi
callq 0x7a00
xorl %eax, %eax
movl %eax, %edi
leaq 0x19be9(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, -0x30(%rbp)
jmp 0x583d
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
movl $0x18, %esi
callq 0x32b0
jmp 0x5f37
movq -0x60(%rbp), %rdi
callq 0x7aa0
cltd
idivl -0x54(%rbp)
cmpl $0x0, %edx
je 0x58f3
movq 0x21723(%rip), %rax     # 0x26fd8
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0xc4(%rbp)
movq -0x60(%rbp), %rdi
callq 0x7aa0
movq -0xd0(%rbp), %rdi
movl -0xc4(%rbp), %edx
movl %eax, %ecx
leaq 0x1a3d3(%rip), %rsi     # 0x1fcba
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movq -0x60(%rbp), %rdi
callq 0x7aa0
cltd
idivl -0x54(%rbp)
movb %al, 0x21a54(%rip)      # 0x2735a
movsbq 0x21a4c(%rip), %rdi     # 0x2735a
movl $0x8, %esi
callq 0x3180
movq %rax, 0x21a41(%rip)     # 0x27360
movsbl 0x21a34(%rip), %eax     # 0x2735a
imull -0x58(%rbp), %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x21a2a(%rip)     # 0x27368
movl $0x0, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x60(%rbp), %rdi
callq 0x7aa0
cltd
idivl -0x54(%rbp)
movl %eax, %ecx
movl -0xd4(%rbp), %eax
cmpl %ecx, %eax
jge 0x5a06
movq -0x60(%rbp), %rdi
movl -0x78(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
callq 0x7ab0
movq 0x219c5(%rip), %rax     # 0x27360
movl -0x70(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x70(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x58(%rbp), %eax
jge 0x59f6
movq -0x60(%rbp), %rdi
movl -0x78(%rbp), %esi
movl %esi, %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
callq 0x7ab0
movq 0x21990(%rip), %rax     # 0x27368
movl -0x74(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x74(%rbp)
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x59b5
jmp 0x59f8
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x595a
movq -0x60(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, %rax
je 0x5a34
movq -0xe0(%rbp), %rdi
callq 0x7b40
movq -0xe0(%rbp), %rdi
movl $0x18, %esi
callq 0x32b0
jmp 0x5ba9
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x3130
movl %eax, -0x34(%rbp)
movl $0x1, -0x20(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x5aa7
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movslq -0x84(%rbp), %rcx
movsbl (%rax,%rcx), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2c, %edx
cmovel %ecx, %eax
movsbl %al, %eax
addl -0x20(%rbp), %eax
movl %eax, -0x20(%rbp)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x5a5e
cmpl $0x3, -0x20(%rbp)
jge 0x5acd
movq 0x21524(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movl -0x20(%rbp), %edx
leaq 0x1a24a(%rip), %rsi     # 0x1fd0b
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movl -0x20(%rbp), %eax
subl $0x2, %eax
movb %al, 0x2185f(%rip)      # 0x27338
cmpq $0x0, 0x2184f(%rip)     # 0x27330
je 0x5aef
movq 0x21846(%rip), %rdi     # 0x27330
callq 0x3350
movl -0x20(%rbp), %eax
subl $0x2, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x21827(%rip)     # 0x27330
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x1993c(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3430
movb %al, 0x217f9(%rip)      # 0x27328
xorl %eax, %eax
movl %eax, %edi
leaq 0x1991e(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
cvttsd2si %xmm0, %eax
movl %eax, 0x217db(%rip)     # 0x2732c
movl $0x2, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x5ba7
xorl %eax, %eax
movl %eax, %edi
leaq 0x198e7(%rip), %rsi     # 0x1f458
callq 0x3440
movq %rax, %rdi
callq 0x3390
movq 0x217ab(%rip), %rax     # 0x27330
movl -0x88(%rbp), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x5b5b
jmp 0x5ba9
jmp 0x5bab
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x4f8d
movsbl 0x21bc6(%rip), %eax     # 0x27786
movsbl 0x22042(%rip), %ecx     # 0x27c09
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x5c1d
movq 0x21403(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x21ba7(%rip), %edx     # 0x27786
addl $0x1, %edx
leaq 0x19c65(%rip), %rsi     # 0x1f84e
movb $0x0, %al
callq 0x33f0
movsbl 0x21755(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x5c18
movq -0x18(%rbp), %rdi
movsbl 0x21b7f(%rip), %edx     # 0x27786
addl $0x1, %edx
leaq 0x19c3d(%rip), %rsi     # 0x1f84e
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x21750(%rip), %eax     # 0x27374
movsbl 0x21fde(%rip), %ecx     # 0x27c09
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x5c81
movq 0x2139f(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x21731(%rip), %edx     # 0x27374
addl $0x1, %edx
leaq 0x19b0a(%rip), %rsi     # 0x1f757
movb $0x0, %al
callq 0x33f0
movsbl 0x216f1(%rip), %eax     # 0x2734c
cmpl $0x1, %eax
jne 0x5c7c
movq -0x18(%rbp), %rdi
movsbl 0x21709(%rip), %edx     # 0x27374
addl $0x1, %edx
leaq 0x19ae2(%rip), %rsi     # 0x1f757
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x216b0(%rip), %eax     # 0x27338
cmpl $0x0, %eax
jne 0x5ca9
movsbl 0x21694(%rip), %eax     # 0x27328
cmpl $0x0, %eax
jne 0x5ca9
movsbl 0x216b6(%rip), %eax     # 0x27356
cmpl $0xe, %eax
jne 0x5d68
movsbl 0x21688(%rip), %eax     # 0x27338
cmpl $0x1, %eax
jne 0x5cd1
movsbl 0x2166c(%rip), %eax     # 0x27328
cmpl $0x1, %eax
jne 0x5cd1
movsbl 0x2168e(%rip), %eax     # 0x27356
cmpl $0xe, %eax
je 0x5d68
movsbl 0x21660(%rip), %eax     # 0x27338
cmpl $0x1, %eax
jne 0x5cf5
movsbl 0x21644(%rip), %eax     # 0x27328
cmpl $0x2, %eax
jne 0x5cf5
movsbl 0x21666(%rip), %eax     # 0x27356
cmpl $0xe, %eax
je 0x5d68
movsbl 0x2163c(%rip), %eax     # 0x27338
cmpl $0x1, %eax
jne 0x5d19
movsbl 0x21620(%rip), %eax     # 0x27328
cmpl $0x3, %eax
jne 0x5d19
movsbl 0x21642(%rip), %eax     # 0x27356
cmpl $0xe, %eax
je 0x5d68
movsbl 0x21618(%rip), %eax     # 0x27338
cmpl $0x1, %eax
jne 0x5d3d
movsbl 0x215fc(%rip), %eax     # 0x27328
cmpl $0x4, %eax
jne 0x5d3d
movsbl 0x2161e(%rip), %eax     # 0x27356
cmpl $0xe, %eax
je 0x5d68
movq 0x21294(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x215da(%rip), %edx     # 0x27328
movsbl 0x215e3(%rip), %ecx     # 0x27338
leaq 0x19ff2(%rip), %rsi     # 0x1fd4e
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x215e7(%rip), %eax     # 0x27356
cmpl $0xe, %eax
jne 0x5da4
movsbl 0x21e8d(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
je 0x5da4
movq 0x21251(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
movsbl 0x21e77(%rip), %edx     # 0x27c08
leaq 0x1a000(%rip), %rsi     # 0x1fd98
movb $0x0, %al
callq 0x33f0
callq 0x78a0
movsbl 0x215a0(%rip), %eax     # 0x2734b
cmpl $0x1, %eax
jne 0x5df7
movsbl 0x2159f(%rip), %eax     # 0x27356
cmpl $0xb, %eax
je 0x5dc8
movsbl 0x21593(%rip), %eax     # 0x27356
cmpl $0xc, %eax
jne 0x5df7
testb $0x1, 0x21e5b(%rip)     # 0x27c2a
je 0x5dda
testb $0x1, 0x21e53(%rip)     # 0x27c2b
jne 0x5df7
movq 0x211f7(%rip), %rax     # 0x26fd8
movq (%rax), %rdi
leaq 0x19ffe(%rip), %rsi     # 0x1fde9
movb $0x0, %al
callq 0x33f0
callq 0x78a0
testb $0x1, 0x21e2c(%rip)     # 0x27c2a
jne 0x5e5f
movsbl 0x21e01(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
jne 0x5e18
movsbl 0x21df6(%rip), %eax     # 0x27c09
cmpl $0x2, %eax
je 0x5e5f
cmpq $0x0, 0x214f8(%rip)     # 0x27318
je 0x5e2e
movq 0x214ef(%rip), %rdi     # 0x27318
callq 0x3350
movsbl 0x21dd3(%rip), %eax     # 0x27c08
movsbl 0x21dcc(%rip), %ecx     # 0x27c08
addl $0x1, %ecx
movsbl 0x21dc3(%rip), %edx     # 0x27c09
addl %edx, %ecx
imull %ecx, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x214b9(%rip)     # 0x27318
testb $0x1, 0x21dc5(%rip)     # 0x27c2b
jne 0x5f2e
movsbl 0x21d95(%rip), %eax     # 0x27c08
cmpl $0x2, %eax
jne 0x5e88
movsbl 0x21d8a(%rip), %eax     # 0x27c09
cmpl $0x2, %eax
je 0x5f2e
cmpq $0x0, 0x21490(%rip)     # 0x27320
je 0x5e9e
movq 0x21487(%rip), %rdi     # 0x27320
callq 0x3350
movsbl 0x21d63(%rip), %eax     # 0x27c08
movsbl 0x21d5c(%rip), %ecx     # 0x27c08
addl $0x1, %ecx
movsbl 0x21d53(%rip), %edx     # 0x27c09
addl %edx, %ecx
imull %ecx, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3180
movq %rax, 0x21451(%rip)     # 0x27320
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
movsbl 0x21d22(%rip), %ecx     # 0x27c08
movsbl 0x21d1b(%rip), %edx     # 0x27c08
addl $0x1, %edx
movsbl 0x21d12(%rip), %esi     # 0x27c09
addl %esi, %edx
imull %edx, %ecx
cmpl %ecx, %eax
jge 0x5f2c
movq 0x21419(%rip), %rax     # 0x27320
movslq -0x8c(%rbp), %rcx
movsd 0x1810a(%rip), %xmm0    # 0x1e020
movsd %xmm0, (%rax,%rcx,8)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x5ed9
jmp 0x5f2e
addq $0xe0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x34c0