// File: bobverity[P]MavericK/readIn.cpp
// Function: checkOptions(globals&)
void checkOptions(globals &globals) {
    
    /*
     The following checks are carried out (in this order):
     - fixLabels_on=true if producing any Qmatrix output
     - popCol_on=true if producing Qmatrix_pop files
     - admix_on=true if
        - producing Qmatrix_gene files
        - producing ML admixture freqs
     - outputQmatrix_?_on=true if outputQmatrixError_?_on=true
     - mainRepeats>1 if producing QmatrixError files
     - EMalgorithm_on=true if
        - producing model comp stats
        - producing ML output
     - (Kmax-Kmin)>=2 and mainRepeats>1 if outputEvanno_on=true
     - if using exhaustive approach, check that number of partitions required to sum over is reasonable. Otherwise throw warning
     - ensure that alpha and alphaPropSD vectors are of length 1 or (Kmax-Kmin+1). If former then duplicate value as needed.
     */
    
    // force fixLabels_on=true if producing any Qmatrix output
    if (!globals.fixLabels_on && (globals.outputQmatrix_ind_on || globals.outputQmatrix_pop_on || globals.outputQmatrix_gene_on)) {
        cerrAndLog("\nError: the label switching problem must be solved in order to produce Qmatrix output. Either set fixLabels_on to true, or turn off all Qmatrix output.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force popCol_on=true if producing Qmatrix_pop files
    if (!globals.popCol_on && globals.outputQmatrix_pop_on) {
        cerrAndLog("\nError: unable to produce population level Qmatrix, as population data not currently being used. Either read in population data (by setting popCol_on to true), or stop producing population level Qmatrix output (by setting outputQmatrix_pop_on to false and outputQmatrixError_pop_on to false).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force admix_on=true if producing Qmatrix_gene files
    if (!globals.admix_on && globals.outputQmatrix_gene_on) {
        cerrAndLog("\nError: admixture model must be turned on in order to produce gene level Qmatrix. Either switch to the admixture model (by setting admix_on to true) or stop producing gene level Qmatrix output (by setting outputQmatrix_gene_on and outputQmatrixError_gene_on to false).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force admix_on=true if producing maximum likelihood admixture frequencies
    if (!globals.admix_on && globals.outputMaxLike_admixFreqs_on) {
        cerrAndLog("\nError: admixture model must be turned on in order to produce maximum likelihood admixture frequency output. Either switch to the admixture model (by setting admix_on to true) or stop producing maximum likelihood admixture frequency output (by setting outputMaxLike_admixFreqs_on to false).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force outputQmatrix_?_on=true if outputQmatrixError_?_on=true for all Qmatrix types
    if ((globals.outputQmatrixError_ind_on && !globals.outputQmatrix_ind_on) || (globals.outputQmatrixError_pop_on && !globals.outputQmatrix_pop_on) || (globals.outputQmatrixError_gene_on && !globals.outputQmatrix_gene_on)) {
        cerrAndLog("\nError: if outputQmatrixError options are turned on then the corresponding outputQmatrix options must also be turned on.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force mainRepeats>1 if outputQmatrixError_?_on=true for all Qmatrix types
    if (globals.mainRepeats==1 && (globals.outputQmatrixError_ind_on || globals.outputQmatrixError_pop_on || globals.outputQmatrixError_gene_on)) {
        cerrAndLog("\nError: mainRepeats must be greater than 1 when any outputQmatrixError options are turned on.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force EMalgorithm_on=true if producing model comparison statistics
    if (!globals.EMalgorithm_on && globals.outputComparisonStatistics_on) {
        cerrAndLog("\nError: EM algorithm must be turned on in order to compute model comparison statistics. Either turn on the EM algorithm (by setting EMalgorithm_on to true) or stop producing model comparison statistics (by setting outputComparisonStatistics_on to false).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force EMalgorithm_on=true if producing maximum likelihood output
    if (!globals.EMalgorithm_on && (globals.outputMaxLike_alleleFreqs_on || globals.outputMaxLike_admixFreqs_on)) {
        cerrAndLog("\nError: EM algorithm must be turned on in order to produce maximum likelihood output files. Either turn on the EM algorithm (by setting EMalgorithm_on to true) or stop producing maximum likelihood output (by setting outputMaxLike_alleleFreqs_on and outputMaxLike_admixFreqs_on to false).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // force (Kmax-Kmin)>=2 and mainRepeats>1 if outputEvanno_on=true
    if ((globals.Kmax-globals.Kmin)<2 && globals.outputEvanno_on) {
        cerrAndLog("\nError: Kmax must be at least 2 greater than Kmin when calculating Evanno's delta K.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    if (globals.mainRepeats==1 && globals.outputEvanno_on) {
        cerrAndLog("\nError: mainRepeats must be greater than 1 when calculating Evanno's delta K.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    // if using exhaustive approach, check that number of partitions required to sum over is reasonable. Otherwise throw warning
    if (globals.exhaustive_on && !globals.suppressWarning1_on) {
        
        // calculate number of partitions. Number of ways of splitting n elements into i groups is given by the Stirling number of the second kind {n, i}. Number of ways of splitting n elements into UP TO K groups is given by sum_{i=1}^k {n, i}. Calculate this for all K that will be explored under current settings. The total number of partitions (in log space) is given by log_partitions.
        double log_partitions = log(double(0));
        for (int K=globals.Kmin; K<=globals.Kmax; K++) {
            vector<double> StirlingNumbers = globals.admix_on ? StirlingSecond(sum(globals.ploidy_vec)*globals.loci) : StirlingSecond(globals.n);
            for (int i=0; (i<K) & (i<int(StirlingNumbers.size())); i++) {
                log_partitions = logSum(log_partitions,StirlingNumbers[i]);
            }
        }
        
        // if very large then error
        if (log_partitions>180) {
            cerrAndLog("\nWarning: for this combination of data and parameters the number of partitions explored in the exhaustive approach is greater than the number of protons in the observable universe, and the program is unlikely to finish within your lifetime. Either turn off the exhaustive approach, or to override this warning and continue with the analysis insert the optional parameter \"suppressWarning1_on\" with value \"true\" in the parameters file.\n", globals.outputLog_on, globals.outputLog_fileStream);
            exit(1);
        }
        if (log_partitions>log(double(1e7))) {
            cerrAndLog("\nWarning: for this combination of data and parameters the number of partitions explored in the exhaustive approach is extremely large (greater than 1e7 in total), and the program may take a very long time to execute. Either turn off the exhaustive approach, or to override this warning and continue with the analysis insert the optional parameter \"suppressWarning1_on\" with value \"true\" in the parameters file.\n", globals.outputLog_on, globals.outputLog_fileStream);
            exit(1);
        }
        
    }
    
    // ensure that alpha and alphaPropSD vectors are of length 1 or (Kmax-Kmin+1). If former then duplicate value as needed.
    if (int(globals.alpha.size())==1) {
        globals.alpha = vector<double>(globals.Kmax-globals.Kmin+1, globals.alpha[0]);
    } else if (int(globals.alpha.size())!=(globals.Kmax-globals.Kmin+1)) {
        cerrAndLog("\nWarning: alpha must contain either a single value to apply to all K, or a comma-separated list of values of length (Kmax-Kmin+1) to apply to each K individually.\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
    if (int(globals.alphaPropSD.size())==1) {
        globals.alphaPropSD = vector<double>(globals.Kmax-globals.Kmin+1, globals.alphaPropSD[0]);
    } else if (int(globals.alphaPropSD.size())!=(globals.Kmax-globals.Kmin+1)) {
        cerrAndLog("\nWarning: alphaPropSD must contain either a single value to apply to all K, or a comma-separated list of values of length (Kmax-Kmin+1).\n", globals.outputLog_on, globals.outputLog_fileStream);
        exit(1);
    }
    
}

// Assembly:
subq $0x378, %rsp            # imm = 0x378
movq %rdi, 0x370(%rsp)
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4f(%rax)
jne 0x4ece6
movq 0x370(%rsp), %rax
testb $0x1, 0x2c3e(%rax)
jne 0x4ec1b
movq 0x370(%rsp), %rax
testb $0x1, 0x2c3f(%rax)
jne 0x4ec1b
movq 0x370(%rsp), %rax
testb $0x1, 0x2c40(%rax)
je 0x4ece6
leaq 0x34f(%rsp), %rdi
movq %rdi, 0xb8(%rsp)
callq 0x4740
movq 0xb8(%rsp), %rdx
leaq 0xee2d(%rip), %rsi      # 0x5da6c
leaq 0x350(%rsp), %rdi
callq 0x4580
jmp 0x4ec4e
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x350(%rsp), %rdi
callq 0x3a1b0
jmp 0x4ec79
leaq 0x350(%rsp), %rdi
callq 0x4270
leaq 0x34f(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4ecd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x350(%rsp), %rdi
callq 0x4270
leaq 0x34f(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2ba1(%rax)
jne 0x4eddb
movq 0x370(%rsp), %rax
testb $0x1, 0x2c3f(%rax)
je 0x4eddb
leaq 0x317(%rsp), %rdi
movq %rdi, 0xb0(%rsp)
callq 0x4740
movq 0xb0(%rsp), %rdx
leaq 0xedd1(%rip), %rsi      # 0x5db05
leaq 0x318(%rsp), %rdi
callq 0x4580
jmp 0x4ed43
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x318(%rsp), %rdi
callq 0x3a1b0
jmp 0x4ed6e
leaq 0x318(%rsp), %rdi
callq 0x4270
leaq 0x317(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4edc9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x318(%rsp), %rdi
callq 0x4270
leaq 0x317(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2bd0(%rax)
jne 0x4eed0
movq 0x370(%rsp), %rax
testb $0x1, 0x2c40(%rax)
je 0x4eed0
leaq 0x2ef(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0x4740
movq 0xa8(%rsp), %rdx
leaq 0xee02(%rip), %rsi      # 0x5dc2b
leaq 0x2f0(%rsp), %rdi
callq 0x4580
jmp 0x4ee38
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x2f0(%rsp), %rdi
callq 0x3a1b0
jmp 0x4ee63
leaq 0x2f0(%rsp), %rdi
callq 0x4270
leaq 0x2ef(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4eebe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x2f0(%rsp), %rdi
callq 0x4270
leaq 0x2ef(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2bd0(%rax)
jne 0x4efc5
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4c(%rax)
je 0x4efc5
leaq 0x2c7(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0x4740
movq 0xa0(%rsp), %rdx
leaq 0xee1b(%rip), %rsi      # 0x5dd39
leaq 0x2c8(%rsp), %rdi
callq 0x4580
jmp 0x4ef2d
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x2c8(%rsp), %rdi
callq 0x3a1b0
jmp 0x4ef58
leaq 0x2c8(%rsp), %rdi
callq 0x4270
leaq 0x2c7(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4efb3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x2c8(%rsp), %rdi
callq 0x4270
leaq 0x2c7(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2c41(%rax)
je 0x4efe7
movq 0x370(%rsp), %rax
testb $0x1, 0x2c3e(%rax)
je 0x4f033
movq 0x370(%rsp), %rax
testb $0x1, 0x2c42(%rax)
je 0x4f009
movq 0x370(%rsp), %rax
testb $0x1, 0x2c3f(%rax)
je 0x4f033
movq 0x370(%rsp), %rax
testb $0x1, 0x2c43(%rax)
je 0x4f0fe
movq 0x370(%rsp), %rax
testb $0x1, 0x2c40(%rax)
jne 0x4f0fe
leaq 0x29f(%rsp), %rdi
movq %rdi, 0x98(%rsp)
callq 0x4740
movq 0x98(%rsp), %rdx
leaq 0xee06(%rip), %rsi      # 0x5de5d
leaq 0x2a0(%rsp), %rdi
callq 0x4580
jmp 0x4f066
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x2a0(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f091
leaq 0x2a0(%rsp), %rdi
callq 0x4270
leaq 0x29f(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f0ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x2a0(%rsp), %rdi
callq 0x4270
leaq 0x29f(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
cmpl $0x1, 0x2c0c(%rax)
jne 0x4f215
movq 0x370(%rsp), %rax
testb $0x1, 0x2c41(%rax)
jne 0x4f14a
movq 0x370(%rsp), %rax
testb $0x1, 0x2c42(%rax)
jne 0x4f14a
movq 0x370(%rsp), %rax
testb $0x1, 0x2c43(%rax)
je 0x4f215
leaq 0x277(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0x4740
movq 0x90(%rsp), %rdx
leaq 0xed69(%rip), %rsi      # 0x5ded7
leaq 0x278(%rsp), %rdi
callq 0x4580
jmp 0x4f17d
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x278(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f1a8
leaq 0x278(%rsp), %rdi
callq 0x4270
leaq 0x277(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f203
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x278(%rsp), %rdi
callq 0x4270
leaq 0x277(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2c30(%rax)
jne 0x4f30a
movq 0x370(%rsp), %rax
testb $0x1, 0x2c49(%rax)
je 0x4f30a
leaq 0x24f(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x4740
movq 0x88(%rsp), %rdx
leaq 0xecd3(%rip), %rsi      # 0x5df36
leaq 0x250(%rsp), %rdi
callq 0x4580
jmp 0x4f272
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x250(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f29d
leaq 0x250(%rsp), %rdi
callq 0x4270
leaq 0x24f(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f2f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x250(%rsp), %rdi
callq 0x4270
leaq 0x24f(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2c30(%rax)
jne 0x4f410
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4b(%rax)
jne 0x4f345
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4c(%rax)
je 0x4f410
leaq 0x227(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x4740
movq 0x80(%rsp), %rdx
leaq 0xeccd(%rip), %rsi      # 0x5e036
leaq 0x228(%rsp), %rdi
callq 0x4580
jmp 0x4f378
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x228(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f3a3
leaq 0x228(%rsp), %rdi
callq 0x4270
leaq 0x227(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f3fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x228(%rsp), %rdi
callq 0x4270
leaq 0x227(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
movl 0x2bcc(%rax), %eax
movq 0x370(%rsp), %rcx
subl 0x2bc8(%rcx), %eax
cmpl $0x2, %eax
jge 0x4f50f
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4a(%rax)
je 0x4f50f
leaq 0x1ff(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x4740
movq 0x78(%rsp), %rdx
leaq 0xecef(%rip), %rsi      # 0x5e157
leaq 0x200(%rsp), %rdi
callq 0x4580
jmp 0x4f477
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x200(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f4a2
leaq 0x200(%rsp), %rdi
callq 0x4270
leaq 0x1ff(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f4fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x200(%rsp), %rdi
callq 0x4270
leaq 0x1ff(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
cmpl $0x1, 0x2c0c(%rax)
jne 0x4f5fe
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4a(%rax)
je 0x4f5fe
leaq 0x1d7(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x4740
movq 0x70(%rsp), %rdx
leaq 0xec56(%rip), %rsi      # 0x5e1ad
leaq 0x1d8(%rsp), %rdi
callq 0x4580
jmp 0x4f566
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x1d8(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f591
leaq 0x1d8(%rsp), %rdi
callq 0x4270
leaq 0x1d7(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f5ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x1d8(%rsp), %rdi
callq 0x4270
leaq 0x1d7(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movq 0x370(%rsp), %rax
testb $0x1, 0x2c08(%rax)
je 0x4f9a6
movq 0x370(%rsp), %rax
testb $0x1, 0x2c4e(%rax)
jne 0x4f9a6
xorps %xmm0, %xmm0
callq 0x4390
movsd %xmm0, 0x1c8(%rsp)
movq 0x370(%rsp), %rax
movl 0x2bc8(%rax), %eax
movl %eax, 0x1c4(%rsp)
movl 0x1c4(%rsp), %eax
movq 0x370(%rsp), %rcx
cmpl 0x2bcc(%rcx), %eax
jg 0x4f7d0
movq 0x370(%rsp), %rax
testb $0x1, 0x2bd0(%rax)
je 0x4f6ae
movq 0x370(%rsp), %rdi
addq $0x2cd0, %rdi           # imm = 0x2CD0
callq 0x8c80
movl %eax, %esi
movq 0x370(%rsp), %rax
imull 0x2d1c(%rax), %esi
leaq 0x1a8(%rsp), %rdi
callq 0x34a10
jmp 0x4f6c9
movq 0x370(%rsp), %rax
movl 0x2d18(%rax), %esi
leaq 0x1a8(%rsp), %rdi
callq 0x34a10
movl $0x0, 0x1a4(%rsp)
movl 0x1a4(%rsp), %eax
cmpl 0x1c4(%rsp), %eax
setl %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x6c(%rsp)
movl 0x1a4(%rsp), %eax
movl %eax, 0x68(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x9b80
movl 0x68(%rsp), %ecx
movq %rax, %rdx
movl 0x6c(%rsp), %eax
cmpl %edx, %ecx
setl %cl
andb $0x1, %cl
movzbl %cl, %ecx
andl %ecx, %eax
cmpl $0x0, %eax
je 0x4f7ad
movsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x58(%rsp)
movslq 0x1a4(%rsp), %rsi
leaq 0x1a8(%rsp), %rdi
callq 0x8c20
movsd 0x58(%rsp), %xmm0
movsd (%rax), %xmm1
callq 0x339b0
movsd %xmm0, 0x60(%rsp)
jmp 0x4f762
movsd 0x60(%rsp), %xmm0
movsd %xmm0, 0x1c8(%rsp)
movl 0x1a4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1a4(%rsp)
jmp 0x4f6d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x88b0
jmp 0x4fd71
leaq 0x1a8(%rsp), %rdi
callq 0x88b0
movl 0x1c4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c4(%rsp)
jmp 0x4f64e
movsd 0x1c8(%rsp), %xmm0
movsd 0xd63f(%rip), %xmm1     # 0x5ce20
ucomisd %xmm1, %xmm0
jbe 0x4f8b0
leaq 0x17f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x4740
movq 0x50(%rsp), %rdx
leaq 0xe9f3(%rip), %rsi      # 0x5e1fc
leaq 0x180(%rsp), %rdi
callq 0x4580
jmp 0x4f818
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x180(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f843
leaq 0x180(%rsp), %rdi
callq 0x4270
leaq 0x17f(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f89e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x4270
leaq 0x17f(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
movsd 0x1c8(%rsp), %xmm0
movsd %xmm0, 0x48(%rsp)
movsd 0xd561(%rip), %xmm0     # 0x5ce28
callq 0x4390
movaps %xmm0, %xmm1
movsd 0x48(%rsp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x4f9a4
leaq 0x157(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x4740
movq 0x40(%rsp), %rdx
leaq 0xeab3(%rip), %rsi      # 0x5e3b0
leaq 0x158(%rsp), %rdi
callq 0x4580
jmp 0x4f90c
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x158(%rsp), %rdi
callq 0x3a1b0
jmp 0x4f937
leaq 0x158(%rsp), %rdi
callq 0x4270
leaq 0x157(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4f992
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x4270
leaq 0x157(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
jmp 0x4f9a6
movq 0x370(%rsp), %rdi
addq $0x2bd8, %rdi           # imm = 0x2BD8
callq 0x9b80
cmpl $0x1, %eax
jne 0x4fa88
movq 0x370(%rsp), %rdi
movl 0x2bc8(%rdi), %ecx
movl 0x2bcc(%rdi), %eax
subl %ecx, %eax
incl %eax
cltq
movq %rax, 0x28(%rsp)
addq $0x2bd8, %rdi           # imm = 0x2BD8
xorl %eax, %eax
movl %eax, %esi
callq 0x8c20
movq %rax, 0x30(%rsp)
leaq 0x137(%rsp), %rdi
movq %rdi, 0x38(%rsp)
callq 0x8780
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
leaq 0x138(%rsp), %rdi
callq 0x8cf0
jmp 0x4fa27
movq 0x370(%rsp), %rdi
addq $0x2bd8, %rdi           # imm = 0x2BD8
leaq 0x138(%rsp), %rsi
callq 0x8be0
leaq 0x138(%rsp), %rdi
callq 0x88b0
leaq 0x137(%rsp), %rdi
callq 0x8910
jmp 0x4fb8a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x137(%rsp), %rdi
callq 0x8910
jmp 0x4fd71
movq 0x370(%rsp), %rdi
addq $0x2bd8, %rdi           # imm = 0x2BD8
callq 0x9b80
movq 0x370(%rsp), %rcx
movl 0x2bcc(%rcx), %ecx
movq 0x370(%rsp), %rdx
subl 0x2bc8(%rdx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x4fb88
leaq 0x10f(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x4740
movq 0x20(%rsp), %rdx
leaq 0xea6b(%rip), %rsi      # 0x5e54c
leaq 0x110(%rsp), %rdi
callq 0x4580
jmp 0x4faf0
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0x110(%rsp), %rdi
callq 0x3a1b0
jmp 0x4fb1b
leaq 0x110(%rsp), %rdi
callq 0x4270
leaq 0x10f(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4fb76
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0x110(%rsp), %rdi
callq 0x4270
leaq 0x10f(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
jmp 0x4fb8a
movq 0x370(%rsp), %rdi
addq $0x2bf0, %rdi           # imm = 0x2BF0
callq 0x9b80
cmpl $0x1, %eax
jne 0x4fc6c
movq 0x370(%rsp), %rdi
movl 0x2bc8(%rdi), %ecx
movl 0x2bcc(%rdi), %eax
subl %ecx, %eax
incl %eax
cltq
movq %rax, 0x8(%rsp)
addq $0x2bf0, %rdi           # imm = 0x2BF0
xorl %eax, %eax
movl %eax, %esi
callq 0x8c20
movq %rax, 0x10(%rsp)
leaq 0xef(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x8780
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rcx
leaq 0xf0(%rsp), %rdi
callq 0x8cf0
jmp 0x4fc0b
movq 0x370(%rsp), %rdi
addq $0x2bf0, %rdi           # imm = 0x2BF0
leaq 0xf0(%rsp), %rsi
callq 0x8be0
leaq 0xf0(%rsp), %rdi
callq 0x88b0
leaq 0xef(%rsp), %rdi
callq 0x8910
jmp 0x4fd69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0xef(%rsp), %rdi
callq 0x8910
jmp 0x4fd71
movq 0x370(%rsp), %rdi
addq $0x2bf0, %rdi           # imm = 0x2BF0
callq 0x9b80
movq 0x370(%rsp), %rcx
movl 0x2bcc(%rcx), %ecx
movq 0x370(%rsp), %rdx
subl 0x2bc8(%rdx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x4fd67
leaq 0xc7(%rsp), %rdi
movq %rdi, (%rsp)
callq 0x4740
movq (%rsp), %rdx
leaq 0xe92d(%rip), %rsi      # 0x5e5f0
leaq 0xc8(%rsp), %rdi
callq 0x4580
jmp 0x4fcd2
movq 0x370(%rsp), %rax
movq %rax, %rdx
addq $0x970, %rdx            # imm = 0x970
movzbl 0x2c3c(%rax), %esi
andl $0x1, %esi
leaq 0xc8(%rsp), %rdi
callq 0x3a1b0
jmp 0x4fcfd
leaq 0xc8(%rsp), %rdi
callq 0x4270
leaq 0xc7(%rsp), %rdi
callq 0x4490
movl $0x1, %edi
callq 0x44f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
jmp 0x4fd58
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x340(%rsp)
movl %eax, 0x33c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x4270
leaq 0xc7(%rsp), %rdi
callq 0x4490
jmp 0x4fd71
jmp 0x4fd69
addq $0x378, %rsp            # imm = 0x378
retq
movq 0x340(%rsp), %rdi
callq 0x4730
nop