// File: /workspace/github_cpp_makefile_star2_O3/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 $0x0, 0x8(%rsp)
movq 0x8(%rsi), %rax
cmpq (%rsi), %rax
je 0xb9b5
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0xc8(%rdi), %rax
movq %rax, 0x78(%rsp)
leaq 0x8(%rdi), %r13
leaq 0x98(%rdi), %rax
movq %rax, 0x80(%rsp)
leaq 0x38(%rdi), %rax
movq %rax, 0x70(%rsp)
leaq 0x8(%rsp), %r12
leaq 0x30(%rsp), %rbp
movq %rdx, 0x50(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
movb $0x0, 0x20(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd286
leaq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x7210
movq 0x8(%rsp), %rsi
shlq $0x5, %rsi
addq (%r14), %rsi
leaq 0x58(%rsp), %rdi
movl $0x3a, %edx
callq 0x91c1
movq 0x58(%rsp), %rax
leaq 0x40(%rsp), %rcx
movq %rcx, 0x30(%rsp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0xdf1c
leaq 0x58(%rsp), %rdi
callq 0xd1ac
movq 0x30(%rsp), %rdi
cmpb $0x2e, (%rdi)
je 0xb93e
movq 0x38(%rsp), %r12
movq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd5c2
movl %r12d, %ebx
shrl $0x1f, %ebx
addl %r12d, %ebx
sarl %ebx
incl %ebx
addl %ebx, (%rax)
movslq %r12d, %rbp
xorl %r12d, %r12d
movq %r13, %rdi
leaq 0x10(%rsp), %rsi
callq 0xd63e
movq 0x8(%rsp), %rcx
movq (%r14), %rdx
movq %rcx, %rsi
shlq $0x5, %rsi
movq (%rdx,%rsi), %rdx
movsbl (%rdx,%r12), %edi
addl $-0x30, %edi
movl %edi, 0x58(%rsp)
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb87c
movl %edi, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb89c
movq %rax, %rdi
leaq 0x58(%rsp), %rdx
callq 0xf7bc
movq 0x8(%rsp), %rcx
movq (%r14), %rax
movq %rcx, %rdx
shlq $0x5, %rdx
movq (%rax,%rdx), %rdx
cmpb $0x31, (%rdx,%r12)
jne 0xb8c4
incl (%r15)
movq 0x2c8(%r15), %rax
incl (%rax,%rcx,4)
movq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd5c2
incl (%rax)
addq $0x2, %r12
cmpq %rbp, %r12
jbe 0xb83a
movq 0x8(%rsp), %rax
movq 0x2c8(%r15), %rcx
cvtsi2sdl (%rcx,%rax,4), %xmm0
cvtsi2sd %ebx, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x58(%rsp)
movq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd20a
movq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r12
leaq 0x30(%rsp), %rbp
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb92c
movsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb939
movq %rax, %rdi
leaq 0x58(%rsp), %rdx
callq 0xf47e
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb955
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xb971
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x8(%rsp), %rax
incq %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rcx
subq (%r14), %rcx
sarq $0x5, %rcx
cmpq %rcx, %rax
jne 0xb78d
jmp 0xb9b5
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xba02
movq %rbx, %rdi
callq 0x7170
callq 0x76a0
movq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r12
jmp 0xb955
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb9cd
jmp 0xb9e3
jmp 0xb9e3
movq %rax, %rbx
jmp 0xba02
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0xd1ac
jmp 0xba02
jmp 0xb9e3
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xba02
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xba1e
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
movq %rbx, %rdi
callq 0x7740