// File: /workspace/github_cpp_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, 0x10(%rsp)
movq %rsi, 0x8(%rsp)
cmpl $0x2, %edi
jl 0x6016
movl %edi, %r13d
movl $0x1, %r12d
leaq 0xf9d2(%rip), %r15      # 0x152b5
movq %r13, 0x28(%rsp)
movq 0x8(%rsp), %rax
movq (%rax,%r12,8), %rax
cmpb $0x2d, (%rax)
jne 0x6016
leaq 0x1(%r12), %rcx
cmpq %r13, %rcx
jae 0x627b
movzbl 0x1(%rax), %eax
cmpl $0x6a, %eax
jg 0x5998
cmpl $0x30, %eax
je 0x59f1
cmpl $0x42, %eax
je 0x5c63
cmpl $0x63, %eax
jne 0x5f5b
movsbl 0x18221(%rip), %ebp     # 0x1db58
movsbl 0x1821a(%rip), %r14d    # 0x1db59
movl $0x18, %edi
callq 0x31f0
movq %rax, %r13
movabsq $0x4e2000000000, %rax   # imm = 0x4E2000000000
movq %rax, (%r13)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x8(%r13)
movq %r12, 0x30(%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rdi
movq %r15, %rsi
callq 0x3350
testq %rax, %rax
je 0x5b36
movq %rax, %rdi
callq 0x32a0
movq %r13, %rdi
callq 0x7384
xorl %edi, %edi
jmp 0x5973
cmpl $0x6b, %eax
je 0x5a4b
cmpl $0x6c, %eax
je 0x5ce9
cmpl $0x75, %eax
jne 0x5f5b
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rbx
movq %rbx, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5d31
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x2c, (%rbx,%rcx)
sete %dl
addl %edx, %ebp
incq %rcx
cmpq %rcx, %rax
jne 0x59d9
jmp 0x5d36
movq %r12, %r14
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %r15
movq %r15, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5d27
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ebp
xorl %ecx, %ecx
movl %ebp, %edx
movb (%r15,%rcx), %sil
xorl %ebp, %ebp
cmpb $0x2c, %sil
sete %bpl
addl %edx, %ebp
andb $-0x21, %sil
addb $-0x41, %sil
cmpb $0x19, %sil
jbe 0x5f6d
incq %rcx
cmpq %rcx, %rax
jne 0x5a1a
jmp 0x5f7c
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rbx
movq %rbx, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x629f
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %r13d
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x2c, (%rbx,%rcx)
sete %dl
addl %edx, %r13d
incq %rcx
cmpq %rcx, %rax
jne 0x5a72
cmpl $0x3, %r13d
jb 0x62a5
leal -0x2(%r13), %ebx
movb %bl, 0x177ee(%rip)      # 0x1d288
movq 0x177df(%rip), %rdi     # 0x1d280
testq %rdi, %rdi
je 0x5aab
callq 0x3270
movslq %ebx, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x177c1(%rip)     # 0x1d280
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rdi
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x3340
movb %al, 0x17799(%rip)      # 0x1d278
xorl %edi, %edi
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
cvttsd2si %xmm0, %eax
movl %eax, 0x17781(%rip)     # 0x1d27c
movl %r13d, %ebx
addq $-0x2, %rbx
xorl %r14d, %r14d
movq 0x28(%rsp), %r13
xorl %edi, %edi
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x1775d(%rip), %rax     # 0x1d280
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x5b0a
jmp 0x5f5b
movl %r14d, %ecx
imull %ebp, %ecx
leal 0x1(%rbp), %r15d
imull %ebp, %r15d
leal (%r15,%rcx), %edi
incl %edi
movl (%r13), %esi
movl %esi, %eax
cltd
movl %edi, 0x1c(%rsp)
idivl %edi
testl %edx, %edx
jne 0x62ad
movl %eax, %ebx
addl %ecx, %r15d
movb %bl, 0x17740(%rip)      # 0x1d2aa
movsbq %bl, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x17731(%rip)     # 0x1d2b0
movsbl %bl, %eax
imull %r15d, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x1771e(%rip)     # 0x1d2b8
testl %ebx, %ebx
jle 0x5c3f
leal 0x1(%r15), %eax
movl %eax, 0x20(%rsp)
addl %ebp, %r14d
incl %r14d
imull %ebp, %r14d
negl %r14d
xorl %ebp, %ebp
xorl %ebx, %ebx
xorl %r12d, %r12d
movq %r15, 0x38(%rsp)
movq %r13, %rdi
movl %ebx, %esi
callq 0x73ec
movq %rbx, %rcx
incl %ebx
movq 0x176d7(%rip), %rax     # 0x1d2b0
movsd %xmm0, (%rax,%rbp,8)
testl %r15d, %r15d
jle 0x5c2f
movl %r12d, 0x24(%rsp)
movslq %r12d, %r12
addl 0x20(%rsp), %ecx
movq %rcx, 0x40(%rsp)
xorl %r15d, %r15d
movq %r13, %rdi
movl %ebx, %esi
callq 0x73ec
movq 0x176b0(%rip), %rax     # 0x1d2b8
movsd %xmm0, (%rax,%r12,8)
incq %r12
incl %ebx
decl %r15d
cmpl %r15d, %r14d
jne 0x5bf7
movl 0x24(%rsp), %r12d
subl %r15d, %r12d
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %rbx
jmp 0x5c2f
incq %rbp
movl (%r13), %eax
cltd
idivl 0x1c(%rsp)
cmpl %ebp, %eax
jg 0x5bc3
movq %r13, %rdi
callq 0x742e
movl $0x18, %esi
movq %r13, %rdi
callq 0x3200
movq 0x28(%rsp), %r13
movq 0x30(%rsp), %r12
jmp 0x5f54
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rdi
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x3340
movb %al, 0x17f5e(%rip)      # 0x1dbe1
testb $-0x2, %al
jne 0x62b6
xorl %edi, %edi
movq %r15, %rsi
callq 0x3350
testq %rax, %rax
je 0x62de
movq %rax, %rdi
callq 0x3340
movb %al, 0x17f36(%rip)      # 0x1dbe2
testb $-0x2, %al
jne 0x62c0
xorl %edi, %edi
movq %r15, %rsi
callq 0x3350
testq %rax, %rax
je 0x62d4
movq %rax, %rdi
callq 0x3340
movb %al, 0x17f0e(%rip)      # 0x1dbe3
testb $-0x2, %al
leaq 0xf5d7(%rip), %r15      # 0x152b5
je 0x5f5b
jmp 0x62ca
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r12,8), %rbx
movq %rbx, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5e45
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x2c, (%rbx,%rcx)
sete %dl
addl %edx, %ebp
incq %rcx
cmpq %rcx, %rax
jne 0x5d0f
jmp 0x5e4a
movl $0x1, %ebp
jmp 0x5f7c
movl $0x1, %ebp
movq %r12, %r14
movq 0x17530(%rip), %rdi     # 0x1d270
testq %rdi, %rdi
je 0x5d4a
callq 0x3270
movl %ebp, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x3120
movq %rax, 0x1750f(%rip)     # 0x1d270
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r14,8), %rdi
leaq 0xf543(%rip), %r12      # 0x152b5
movq %r12, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x174e7(%rip), %rax     # 0x1d270
movsd %xmm0, (%rax)
cmpl $0x2, %ebp
jb 0x5dbd
movl $0x1, %ebx
xorl %edi, %edi
movq %r12, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x174c0(%rip), %rax     # 0x1d270
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x5d97
movsbl 0x17d94(%rip), %eax     # 0x1db58
movb 0x174d1(%rip), %cl      # 0x1d29b
movb 0x174d6(%rip), %dl      # 0x1d2a6
cmpb $0x1, %cl
jne 0x5df7
leal -0xb(%rdx), %esi
cmpb $0x2, %sil
movl 0x17d86(%rip), %edi     # 0x1db68
movl %edi, %esi
movl $0x1, %r8d
cmovael %r8d, %esi
movsbl %sil, %esi
movq %r14, %r12
jmp 0x5e0c
movl $0x1, %esi
movb 0x17d65(%rip), %dil     # 0x1db68
movq %r14, %r12
movl $0x1, %r8d
xorb $0x1, %cl
imull %eax, %esi
xorb $0xb, %dl
orb %cl, %dl
movsbl %dil, %ecx
cmovnel %r8d, %ecx
movsbl 0x17d33(%rip), %edx     # 0x1db59
imull %ecx, %edx
leal (%rsi,%rdx), %edi
incl %edi
imull %eax, %edi
cmpl %edi, %ebp
jne 0x6291
movb $0x1, 0x17d3b(%rip)     # 0x1db7b
jmp 0x5f54
movl $0x1, %ebp
movq %r12, %r14
movq 0x17414(%rip), %rdi     # 0x1d268
testq %rdi, %rdi
je 0x5e5e
callq 0x3270
movl %ebp, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x3120
movq %rax, 0x173f3(%rip)     # 0x1d268
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r14,8), %rdi
leaq 0xf42f(%rip), %r12      # 0x152b5
movq %r12, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x173cb(%rip), %rax     # 0x1d268
movsd %xmm0, (%rax)
cmpl $0x2, %ebp
jb 0x5ed1
movl $0x1, %ebx
xorl %edi, %edi
movq %r12, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x173a4(%rip), %rax     # 0x1d268
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x5eab
movsbl 0x17c80(%rip), %eax     # 0x1db58
movb 0x173bd(%rip), %cl      # 0x1d29b
movb 0x173c2(%rip), %dl      # 0x1d2a6
cmpb $0x1, %cl
jne 0x5f0b
leal -0xb(%rdx), %esi
cmpb $0x2, %sil
movl 0x17c72(%rip), %edi     # 0x1db68
movl %edi, %esi
movl $0x1, %r8d
cmovael %r8d, %esi
movsbl %sil, %esi
movq %r14, %r12
jmp 0x5f20
movl $0x1, %esi
movb 0x17c51(%rip), %dil     # 0x1db68
movq %r14, %r12
movl $0x1, %r8d
xorb $0x1, %cl
imull %eax, %esi
xorb $0xb, %dl
orb %cl, %dl
movsbl %dil, %ecx
cmovnel %r8d, %ecx
movsbl 0x17c1f(%rip), %edx     # 0x1db59
imull %ecx, %edx
leal (%rsi,%rdx), %edi
incl %edi
imull %eax, %edi
cmpl %edi, %ebp
jne 0x6298
movb $0x1, 0x17c26(%rip)     # 0x1db7a
leaq 0xf35a(%rip), %r15      # 0x152b5
addq $0x2, %r12
cmpq %r13, %r12
jb 0x58e8
jmp 0x6016
leaq 0x17360(%rip), %rdi     # 0x1d2d4
movq %r15, %rsi
callq 0x31c0
movq 0x172d5(%rip), %rdi     # 0x1d258
testq %rdi, %rdi
je 0x5f8d
callq 0x3270
movslq %ebp, %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, 0x172b4(%rip)     # 0x1d258
movb %bl, 0x172b6(%rip)      # 0x1d260
movq %r14, %r12
movq 0x8(%rsp), %rax
movq 0x8(%rax,%r14,8), %rdi
leaq 0xf2f7(%rip), %r15      # 0x152b5
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x17283(%rip), %rax     # 0x1d258
movsd %xmm0, (%rax)
cmpl $0x2, %ebx
jl 0x5f5b
movl %ebp, %ebx
movl $0x1, %r14d
xorl %edi, %edi
movq %r15, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x17255(%rip), %rax     # 0x1d258
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x5fea
jmp 0x5f5b
movb 0x176ba(%rip), %al      # 0x1d6d6
movb 0x17b37(%rip), %bl      # 0x1db59
cmpb %al, %bl
jle 0x62e8
movb 0x17294(%rip), %al      # 0x1d2c4
cmpb %al, %bl
jle 0x62f5
movb 0x1724a(%rip), %al      # 0x1d288
movb 0x17234(%rip), %dl      # 0x1d278
movl %eax, %ecx
orb %dl, %cl
sete %sil
movb 0x17254(%rip), %cl      # 0x1d2a6
cmpb $0xe, %cl
setne %dil
testb %dil, %sil
je 0x60aa
movb 0x17af3(%rip), %bpl     # 0x1db58
cmpb $0x2, %bpl
setne %al
cmpb $0x1, 0x17228(%rip)     # 0x1d29b
sete %dl
addb $-0xb, %cl
cmpb $0x2, %cl
setb %sil
andb %dl, %sil
movb 0x17af1(%rip), %cl      # 0x1db7a
cmpb $0x1, %sil
jne 0x6116
testb $0x1, %cl
je 0x60a5
cmpb $0x0, 0x17adc(%rip)     # 0x1db7b
jne 0x6165
callq 0x3cf3
movl %eax, %esi
xorb $0x1, %sil
movl %edx, %r8d
xorb $0x1, %r8b
orb %sil, %r8b
movl %ecx, %edi
xorb $0xe, %dil
orb %dil, %r8b
je 0x60fd
movl %edx, %r8d
xorb $0x2, %r8b
orb %sil, %r8b
orb %dil, %r8b
je 0x60fd
movl %edx, %r8d
xorb $0x3, %r8b
orb %r8b, %sil
orb %dil, %sil
je 0x60fd
cmpb $0x1, %al
jne 0x630a
cmpb $0x4, %dl
jne 0x630a
cmpb $0xe, %cl
jne 0x630a
movb 0x17a55(%rip), %al      # 0x1db58
cmpb $0x2, %al
jne 0x6302
movb $0x2, %bpl
movb 0x17a66(%rip), %cl      # 0x1db7a
xorl %eax, %eax
cmpb $0x2, %bl
setne %dl
testb $0x1, %cl
jne 0x6165
orb %al, %dl
je 0x6165
movq 0x1713c(%rip), %rdi     # 0x1d268
testq %rdi, %rdi
je 0x6143
callq 0x3270
movb 0x17a1b(%rip), %bpl     # 0x1db58
movb 0x17a16(%rip), %bl      # 0x1db59
movsbl %bpl, %eax
movsbl %bl, %ecx
addl %eax, %ecx
incl %ecx
imull %eax, %ecx
movslq %ecx, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x17103(%rip)     # 0x1d268
cmpb $0x0, 0x17a0f(%rip)     # 0x1db7b
jne 0x626c
movl %ebp, %eax
xorb $0x2, %al
movl %ebx, %ecx
xorb $0x2, %cl
orb %al, %cl
je 0x626c
movq 0x170e6(%rip), %rdi     # 0x1d270
testq %rdi, %rdi
je 0x61a1
callq 0x3270
movb 0x179bd(%rip), %bpl     # 0x1db58
movb 0x179b8(%rip), %bl      # 0x1db59
movsbl %bpl, %eax
movsbl %bl, %ecx
leal (%rax,%rcx), %r14d
incl %r14d
imull %eax, %r14d
movslq %r14d, %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, 0x170a6(%rip)     # 0x1d270
testl %ebx, %ebx
jle 0x626c
movl %r14d, %ecx
incl %r14d
andl $-0x2, %r14d
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0xef0f(%rip), %xmm1     # 0x15100
xorl %ecx, %ecx
movdqa 0xef15(%rip), %xmm2     # 0x15110
pxor %xmm2, %xmm0
movabsq $0x3ff0000000000000, %rdx # imm = 0x3FF0000000000000
pcmpeqd %xmm3, %xmm3
movdqa 0xef0b(%rip), %xmm4     # 0x15120
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %esi
notl %esi
testb $0x1, %sil
je 0x624b
movq %rdx, (%rax,%rcx,8)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0x625f
movq %rdx, 0x8(%rax,%rcx,8)
addq $0x2, %rcx
paddq %xmm4, %xmm1
cmpq %rcx, %r14
jne 0x6215
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfbb5(%rip), %rdi      # 0x15e37
callq 0x3320
movl $0x1, %edi
callq 0x3280
movl %ebp, %esi
callq 0x3b79
movl %ebp, %esi
callq 0x3baa
movl $0x1, %r13d
movl %r13d, %edi
callq 0x397f
movl 0x1c(%rsp), %edi
callq 0x39ae
movq 0x10(%rsp), %rdi
callq 0x39df
movq 0x10(%rsp), %rdi
callq 0x3a31
movq 0x10(%rsp), %rdi
callq 0x3a83
movq 0x10(%rsp), %rdi
callq 0x3ad5
movq 0x10(%rsp), %rdi
callq 0x3b27
movzbl %al, %edi
movq 0x10(%rsp), %rsi
callq 0x3bdb
movzbl %al, %edi
movq 0x10(%rsp), %rsi
callq 0x3c34
movzbl %al, %edi
callq 0x3cc2
movzbl %dl, %edi
movzbl %al, %esi
callq 0x3c8d