// File: /workspace/github_cpp_makefile_star2_O2/millanek[P]Dsuite/Dsuite_utils.cpp
// Function: GeneralSetCountsWithSplits::getBasicCountsWithSplitsNew(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::map<unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<unsigned long>, std::allocator<std::pair<unsigned long const, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>> const&)
void GeneralSetCountsWithSplits::getBasicCountsWithSplitsNew(const std::vector<std::string>& genotypes, const std::map<size_t, string>& posToSpeciesMap) {
    
    // Go through the genotypes - only biallelic markers are allowed
    for (std::vector<std::string>::size_type i = 0; i != genotypes.size(); i++) {
        bool speciesDefined = true;
        std::string species; try { species = posToSpeciesMap.at(i); } catch (const std::out_of_range& oor) {
            speciesDefined = false;
        }
        
        if (speciesDefined) {
            string onlyGenotypeCalls = split(genotypes[i], ':')[0];   // The string with 0/0, 0/1, 1/0, 1/1, or e.g. 0/0/1/1 for a tetraploid
            if (onlyGenotypeCalls[0] == '.') {
                continue;   // Ignore missing data
            }
            // Find ploidy
            int l = (int)onlyGenotypeCalls.length();
            int numGTs = (l/2)+1;
            setAlleleCounts[species] += numGTs;
            
            // Go through the genotypes and fill in the data structure "GeneralSetCountsWithSplits"
            for (std::vector<std::string>::size_type j = 0; j <= l; j = j+2) {
               // std::cerr << "genotypes[i][j]: " << genotypes[i][j] << std::endl;
                setGenotypes[species].push_back(genotypes[i][j] - '0');
                if (genotypes[i][j] == '1') {
                    overall++; individualsWithVariant[i]++;
                    setAltCounts[species]++;
                }
            }
            double individualAF = (double)individualsWithVariant[i]/numGTs;
            
            /* std::cerr << "onlyGenotypeCalls: " << onlyGenotypeCalls << std::endl;
            std::cerr << "individualsWithVariant[i]: " << individualsWithVariant[i] << std::endl;
            std::cerr << "numGTs: " << numGTs << std::endl;
            std::cerr << "individualAF: " << individualAF << std::endl;
            */
            setIndividualAFs[species].push_back(individualAF);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, 0x38(%rsp)
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc8(%rdi), %rax
movq %rax, 0x30(%rsp)
leaq 0x8(%rdi), %r13
leaq 0x98(%rdi), %rax
movq %rax, 0x40(%rsp)
leaq 0x38(%rdi), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
leaq 0x68(%rsp), %r12
movq %rax, (%rsp)
movq 0x8(%r14), %rcx
subq (%r14), %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
je 0xa665
leaq 0x78(%rsp), %rax
movq %rax, 0x68(%rsp)
andq $0x0, 0x70(%rsp)
movb $0x0, 0x78(%rsp)
movq 0x38(%rsp), %rdi
movq %rsp, %rsi
callq 0xb894
movq %r12, %rdi
movq %rax, %rsi
callq 0x7240
movq (%rsp), %rsi
shlq $0x5, %rsi
addq (%r14), %rsi
leaq 0x10(%rsp), %rdi
pushq $0x3a
popq %rdx
callq 0x88f1
movq 0x10(%rsp), %rsi
leaq 0x48(%rsp), %rdi
callq 0x7590
leaq 0x10(%rsp), %rdi
callq 0xb80c
movq 0x48(%rsp), %rax
cmpb $0x2e, (%rax)
je 0xa630
movq 0x50(%rsp), %rbp
movl %ebp, %eax
cltd
pushq $0x2
popq %rcx
idivl %ecx
movl %eax, %ebx
movq 0x30(%rsp), %rdi
movq %r12, %rsi
callq 0xbb88
incl %ebx
movl %ebx, 0xc(%rsp)
addl %ebx, (%rax)
movslq %ebp, %rbp
xorl %ebx, %ebx
cmpq %rbp, %rbx
ja 0xa5f6
movq %r13, %rdi
movq %r12, %rsi
callq 0xbbee
movq (%rsp), %rcx
movq (%r14), %rdx
shlq $0x5, %rcx
movq (%rdx,%rcx), %rcx
movsbl (%rcx,%rbx), %ecx
addl $-0x30, %ecx
movl %ecx, 0x10(%rsp)
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0xd98a
movq (%rsp), %rax
movq (%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
movq (%rcx,%rdx), %rcx
cmpb $0x31, (%rcx,%rbx)
jne 0xa5f0
incl (%r15)
movq 0x2c8(%r15), %rcx
incl (%rcx,%rax,4)
movq 0x40(%rsp), %rdi
movq %r12, %rsi
callq 0xbb88
incl (%rax)
addq $0x2, %rbx
jmp 0xa585
movq (%rsp), %rax
movq 0x2c8(%r15), %rcx
cvtsi2sdl (%rcx,%rax,4), %xmm0
cvtsi2sdl 0xc(%rsp), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0xb82e
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0xb9de
leaq 0x48(%rsp), %rdi
callq 0x7898
movq %r12, %rdi
callq 0x7898
movq (%rsp), %rax
incq %rax
jmp 0xa4d8
movq %rax, %rbp
cmpl $0x1, %edx
jne 0xa6a0
movq %rbp, %rdi
callq 0x7190
callq 0x76a0
jmp 0xa63a
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa67d
jmp 0xa693
jmp 0xa693
movq %rax, %rbp
jmp 0xa6a0
movq %rax, %rbp
leaq 0x10(%rsp), %rdi
callq 0xb80c
jmp 0xa6a0
jmp 0xa693
movq %rax, %rbp
leaq 0x48(%rsp), %rdi
callq 0x7898
leaq 0x68(%rsp), %rdi
callq 0x7898
movq %rbp, %rdi
callq 0x7750