// File: /workspace/github_cpp_makefile_star2_O1/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 $0x38, %rsp
movq %rdx, (%rsp)
cmpl $0x2, %edi
jl 0x5fbf
movq %rsi, %r12
movl %edi, %r15d
movl $0x1, %r14d
movq %r15, 0x8(%rsp)
movq %rsi, 0x28(%rsp)
movq (%r12,%r14,8), %rax
cmpb $0x2d, (%rax)
jne 0x5fbf
leaq 0x1(%r14), %rcx
cmpq %r15, %rcx
jae 0x618d
movzbl 0x1(%rax), %eax
cmpl $0x6a, %eax
movq %r14, 0x18(%rsp)
jg 0x5961
cmpl $0x30, %eax
je 0x59c2
cmpl $0x42, %eax
je 0x5b79
cmpl $0x63, %eax
leaq 0xf98d(%rip), %rbx      # 0x15285
jne 0x5fad
movsbl 0x18252(%rip), %r15d    # 0x1db58
movsbl 0x1824c(%rip), %ebp     # 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 0x18(%rsp), %rax
movq 0x8(%r12,%rax,8), %rdi
movq %rbx, %rsi
callq 0x3350
testq %rax, %rax
je 0x5a50
movq %rax, %rdi
callq 0x32a0
movq %r13, %rdi
callq 0x7240
xorl %edi, %edi
jmp 0x593c
cmpl $0x6b, %eax
je 0x5a14
cmpl $0x6c, %eax
je 0x5bfa
cmpl $0x75, %eax
jne 0x5fad
movq 0x18(%rsp), %rbx
movq 0x8(%r12,%rbx,8), %r15
movq %r15, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5cfe
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ebp
xorl %ecx, %ecx
leaq 0xf8dc(%rip), %r14      # 0x15285
xorl %edx, %edx
cmpb $0x2c, (%r15,%rcx)
sete %dl
addl %edx, %ebp
incq %rcx
cmpq %rcx, %rax
jne 0x59a9
jmp 0x5d0a
movq 0x8(%r12,%r14,8), %r15
movq %r15, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5c34
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 0x5f0e
incq %rcx
cmpq %rcx, %rax
jne 0x59e3
jmp 0x5f1d
movq 0x8(%r12,%r14,8), %r15
movq %r15, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5c3e
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %r13d
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x2c, (%r15,%rcx)
sete %dl
addl %edx, %r13d
incq %rcx
cmpq %rcx, %rax
jne 0x5a36
jmp 0x5c44
movl %r15d, %r14d
imull %r14d, %r14d
movq %rbp, %r12
movl %ebp, %ecx
imull %r15d, %ecx
addl %r15d, %r14d
leal (%rcx,%r14), %ebp
incl %ebp
movl (%r13), %esi
movl %esi, %eax
cltd
idivl %ebp
testl %edx, %edx
jne 0x61b9
movq %r15, %rbx
movl %eax, %r15d
addl %ecx, %r14d
movb %r15b, 0x17820(%rip)    # 0x1d2aa
movsbq %r15b, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x17811(%rip)     # 0x1d2b0
movsbl %r15b, %eax
imull %r14d, %eax
movslq %eax, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x177fd(%rip)     # 0x1d2b8
movl (%r13), %eax
cltd
idivl %ebp
testl %eax, %eax
jle 0x5b55
addl %ebx, %r12d
incl %r12d
imull %ebx, %r12d
negl %r12d
xorl %ebx, %ebx
xorl %r15d, %r15d
movl $0x0, 0x14(%rsp)
movq %r14, 0x30(%rsp)
movl %ebp, 0x24(%rsp)
movq %r13, %rdi
movl %r15d, %esi
callq 0x729e
incl %r15d
movq 0x177ae(%rip), %rax     # 0x1d2b0
movsd %xmm0, (%rax,%rbx,8)
testl %r14d, %r14d
jle 0x5b47
movslq 0x14(%rsp), %rbp
xorl %r14d, %r14d
movq %r13, %rdi
movl %r15d, %esi
callq 0x729e
movq 0x17792(%rip), %rax     # 0x1d2b8
movsd %xmm0, (%rax,%rbp,8)
incq %rbp
incl %r15d
decl %r14d
cmpl %r14d, %r12d
jne 0x5b14
subl %r14d, 0x14(%rsp)
movq 0x30(%rsp), %r14
movl 0x24(%rsp), %ebp
incq %rbx
movl (%r13), %eax
cltd
idivl %ebp
cmpl %ebx, %eax
jg 0x5aed
movq %r13, %rdi
callq 0x72e0
movl $0x18, %esi
movq %r13, %rdi
callq 0x3200
movq 0x28(%rsp), %r12
movq 0x8(%rsp), %r15
jmp 0x5fad
movq 0x8(%r12,%r14,8), %rdi
leaq 0xf700(%rip), %rbx      # 0x15285
movq %rbx, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x3340
movb %al, 0x18046(%rip)      # 0x1dbe1
testb $-0x2, %al
jne 0x61c0
xorl %edi, %edi
movq %rbx, %rsi
callq 0x3350
testq %rax, %rax
je 0x61e4
movq %rax, %rdi
callq 0x3340
movb %al, 0x1801e(%rip)      # 0x1dbe2
testb $-0x2, %al
jne 0x61c9
xorl %edi, %edi
movq %rbx, %rsi
callq 0x3350
testq %rax, %rax
je 0x61db
movq %rax, %rdi
callq 0x3340
movb %al, 0x17ff6(%rip)      # 0x1dbe3
testb $-0x2, %al
je 0x5fad
jmp 0x61d2
movq 0x8(%r12,%r14,8), %r15
movq %r15, %rdi
callq 0x30f0
testl %eax, %eax
jle 0x5e06
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
movl $0x1, %ebp
xorl %ecx, %ecx
xorl %edx, %edx
cmpb $0x2c, (%r15,%rcx)
sete %dl
addl %edx, %ebp
incq %rcx
cmpq %rcx, %rax
jne 0x5c1b
jmp 0x5e0b
movl $0x1, %ebp
jmp 0x5f1d
movl $0x1, %r13d
cmpl $0x3, %r13d
jb 0x61b1
leal -0x2(%r13), %ebx
movb %bl, 0x17630(%rip)      # 0x1d288
movq 0x17621(%rip), %rdi     # 0x1d280
testq %rdi, %rdi
movq 0x8(%rsp), %r15
je 0x5c6e
callq 0x3270
movslq %ebx, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x175fe(%rip)     # 0x1d280
movq 0x8(%r12,%r14,8), %rdi
leaq 0xf5f7(%rip), %r14      # 0x15285
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x3340
movb %al, 0x175d4(%rip)      # 0x1d278
xorl %edi, %edi
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
cvttsd2si %xmm0, %eax
movl %eax, 0x175bc(%rip)     # 0x1d27c
cmpl $0x4, %r13d
movl $0x3, %eax
cmovbl %eax, %r13d
addq $-0x2, %r13
xorl %ebx, %ebx
xorl %edi, %edi
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x17594(%rip), %rax     # 0x1d280
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r13
jne 0x5cd3
jmp 0x5fad
movl $0x1, %ebp
leaq 0xf57b(%rip), %r14      # 0x15285
movq 0x1755f(%rip), %rdi     # 0x1d270
testq %rdi, %rdi
je 0x5d1b
callq 0x3270
movl %ebp, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x3120
movq %rax, 0x1753e(%rip)     # 0x1d270
movq 0x8(%r12,%rbx,8), %rdi
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x17522(%rip), %rax     # 0x1d270
movsd %xmm0, (%rax)
cmpl $0x2, %ebp
jb 0x5d82
movl $0x1, %ebx
xorl %edi, %edi
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x174fb(%rip), %rax     # 0x1d270
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x5d5c
movsbl 0x17dcf(%rip), %eax     # 0x1db58
movb 0x1750c(%rip), %dl      # 0x1d29b
movl $0x1, %ecx
cmpb $0x1, %dl
jne 0x5db8
movb 0x17506(%rip), %sil     # 0x1d2a6
addb $-0xb, %sil
cmpb $0x1, %sil
movq 0x8(%rsp), %r15
ja 0x5dbd
movsbl 0x17db2(%rip), %ecx     # 0x1db68
jmp 0x5dbd
movq 0x8(%rsp), %r15
xorb $0x1, %dl
imull %eax, %ecx
movb 0x174dc(%rip), %sil     # 0x1d2a6
xorb $0xb, %sil
orb %dl, %sil
movsbl 0x17d90(%rip), %edx     # 0x1db68
movl $0x1, %esi
cmovnel %esi, %edx
movsbl 0x17d72(%rip), %esi     # 0x1db59
imull %edx, %esi
leal (%rcx,%rsi), %edi
incl %edi
imull %eax, %edi
cmpl %edi, %ebp
jne 0x61a3
movb $0x1, 0x17d7a(%rip)     # 0x1db7b
jmp 0x5fad
movl $0x1, %ebp
movq 0x17456(%rip), %rdi     # 0x1d268
testq %rdi, %rdi
je 0x5e1c
callq 0x3270
movl %ebp, %r15d
movl $0x8, %esi
movq %r15, %rdi
callq 0x3120
movq %rax, 0x17435(%rip)     # 0x1d268
movq 0x8(%r12,%r14,8), %rdi
leaq 0xf446(%rip), %r14      # 0x15285
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x17412(%rip), %rax     # 0x1d268
movsd %xmm0, (%rax)
cmpl $0x2, %ebp
jb 0x5e8a
movl $0x1, %ebx
xorl %edi, %edi
movq %r14, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x173eb(%rip), %rax     # 0x1d268
movsd %xmm0, (%rax,%rbx,8)
incq %rbx
cmpq %rbx, %r15
jne 0x5e64
movsbl 0x17cc7(%rip), %eax     # 0x1db58
movb 0x17404(%rip), %dl      # 0x1d29b
movl $0x1, %ecx
cmpb $0x1, %dl
jne 0x5ec0
movb 0x173fe(%rip), %sil     # 0x1d2a6
addb $-0xb, %sil
cmpb $0x1, %sil
movq 0x8(%rsp), %r15
ja 0x5ec5
movsbl 0x17caa(%rip), %ecx     # 0x1db68
jmp 0x5ec5
movq 0x8(%rsp), %r15
xorb $0x1, %dl
imull %eax, %ecx
movb 0x173d4(%rip), %sil     # 0x1d2a6
xorb $0xb, %sil
orb %dl, %sil
movsbl 0x17c88(%rip), %edx     # 0x1db68
movl $0x1, %esi
cmovnel %esi, %edx
movsbl 0x17c6a(%rip), %esi     # 0x1db59
imull %edx, %esi
leal (%rcx,%rsi), %edi
incl %edi
imull %eax, %edi
cmpl %edi, %ebp
jne 0x61aa
movb $0x1, 0x17c71(%rip)     # 0x1db7a
jmp 0x5fad
leaq 0x173bf(%rip), %rdi     # 0x1d2d4
movq %r15, %rsi
callq 0x31c0
movq 0x17334(%rip), %rdi     # 0x1d258
testq %rdi, %rdi
je 0x5f2e
callq 0x3270
movslq %ebp, %r15
movl $0x8, %esi
movq %r15, %rdi
callq 0x3120
movq %rax, 0x17313(%rip)     # 0x1d258
movb %r15b, 0x17314(%rip)    # 0x1d260
movq 0x8(%r12,%r14,8), %rdi
leaq 0xf32d(%rip), %r13      # 0x15285
movq %r13, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x172e9(%rip), %rax     # 0x1d258
movsd %xmm0, (%rax)
cmpl $0x2, %r15d
movq 0x8(%rsp), %r15
jl 0x5fad
movl %ebp, %ebx
movl $0x1, %r14d
xorl %edi, %edi
movq %r13, %rsi
callq 0x3350
movq %rax, %rdi
callq 0x32a0
movq 0x172b9(%rip), %rax     # 0x1d258
movsd %xmm0, (%rax,%r14,8)
incq %r14
cmpq %r14, %rbx
jne 0x5f86
movq 0x18(%rsp), %r14
addq $0x2, %r14
cmpq %r15, %r14
jb 0x58b0
movb 0x17711(%rip), %cl      # 0x1d6d6
movb 0x17b8e(%rip), %al      # 0x1db59
cmpb %cl, %al
jle 0x61ed
movb 0x172eb(%rip), %cl      # 0x1d2c4
cmpb %cl, %al
jle 0x61f9
movb 0x172a1(%rip), %dl      # 0x1d288
movb 0x1728a(%rip), %sil     # 0x1d278
movl %edx, %ecx
orb %sil, %cl
sete %dil
movb 0x172a9(%rip), %cl      # 0x1d2a6
cmpb $0xe, %cl
setne %r8b
testb %r8b, %dil
jne 0x605f
movl %edx, %edi
xorb $0x1, %dil
movl %esi, %r9d
xorb $0x1, %r9b
orb %dil, %r9b
movl %ecx, %r8d
xorb $0xe, %r8b
orb %r8b, %r9b
je 0x605f
movl %esi, %r9d
xorb $0x2, %r9b
orb %dil, %r9b
orb %r8b, %r9b
je 0x605f
movl %esi, %r9d
xorb $0x3, %r9b
orb %r9b, %dil
orb %r8b, %dil
je 0x605f
cmpb $0x1, %dl
jne 0x6212
cmpb $0x4, %sil
jne 0x6212
cmpb $0xe, %cl
jne 0x6212
cmpb $0xe, %cl
sete %sil
movb 0x17aec(%rip), %dl      # 0x1db58
cmpb $0x2, %dl
setne %dil
andb %sil, %dil
cmpb $0x1, %dil
je 0x6205
cmpb $0x1, 0x17214(%rip)     # 0x1d29b
sete %sil
addb $-0xb, %cl
cmpb $0x2, %cl
setb %cl
andb %sil, %cl
cmpb $0x1, %cl
jne 0x60b6
cmpb $0x1, 0x17ad7(%rip)     # 0x1db7a
jne 0x620d
cmpb $0x0, 0x17acb(%rip)     # 0x1db7b
je 0x620d
xorb $0x2, %dl
xorb $0x2, %al
orb %dl, %al
setne %al
cmpb $0x0, 0x17ab3(%rip)     # 0x1db7a
jne 0x6107
testb %al, %al
je 0x6107
movq 0x17194(%rip), %rdi     # 0x1d268
testq %rdi, %rdi
je 0x60de
callq 0x3270
movsbl 0x17a73(%rip), %eax     # 0x1db58
movsbl 0x17a6d(%rip), %ecx     # 0x1db59
addl %eax, %ecx
incl %ecx
imull %eax, %ecx
movslq %ecx, %rdi
movl $0x8, %esi
callq 0x3120
movq %rax, 0x17161(%rip)     # 0x1d268
cmpb $0x0, 0x17a6d(%rip)     # 0x1db7b
jne 0x617e
cmpb $0x2, 0x17a41(%rip)     # 0x1db58
jne 0x6122
cmpb $0x2, 0x17a39(%rip)     # 0x1db59
je 0x617e
movq 0x17147(%rip), %rdi     # 0x1d270
testq %rdi, %rdi
je 0x6133
callq 0x3270
movsbl 0x17a1e(%rip), %eax     # 0x1db58
movsbl 0x17a18(%rip), %ecx     # 0x1db59
leal (%rax,%rcx), %ebp
incl %ebp
imull %eax, %ebp
movslq %ebp, %rbx
movl $0x8, %esi
movq %rbx, %rdi
callq 0x3120
movq %rax, 0x17110(%rip)     # 0x1d270
testl %ebx, %ebx
jle 0x617e
movl %ebp, %ecx
xorl %edx, %edx
movabsq $0x3ff0000000000000, %rsi # imm = 0x3FF0000000000000
movq %rsi, (%rax,%rdx,8)
incq %rdx
cmpq %rdx, %rcx
jne 0x6172
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfc73(%rip), %rdi      # 0x15e07
callq 0x3320
movl $0x1, %edi
callq 0x3280
movl %ebp, %esi
callq 0x3b79
movl %ebp, %esi
callq 0x3baa
movl %r13d, %edi
callq 0x397f
movl %ebp, %edi
callq 0x39ae
movq (%rsp), %rdi
callq 0x39df
movq (%rsp), %rdi
callq 0x3a31
movq (%rsp), %rdi
callq 0x3a83
movq (%rsp), %rdi
callq 0x3ad5
movq (%rsp), %rdi
callq 0x3b27
movzbl %cl, %edi
movq (%rsp), %rsi
callq 0x3bdb
movzbl %cl, %edi
movq (%rsp), %rsi
callq 0x3c34
movzbl %dl, %edi
callq 0x3cf3
callq 0x3cc2
movzbl %sil, %edi
movzbl %dl, %esi
callq 0x3c8d