// File: /workspace/github_cpp_makefile_star2_O1/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 0xba02
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 0xd328
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 0x91a9
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 0xdfb6
leaq 0x58(%rsp), %rdi
callq 0xd250
movq 0x30(%rsp), %rdi
cmpb $0x2e, (%rdi)
je 0xb98b
movq 0x38(%rsp), %r12
movq 0x78(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd65c
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 0xd6d8
movq 0x8(%rsp), %rcx
movq (%r14), %rdx
shlq $0x5, %rcx
movq (%rdx,%rcx), %rcx
movsbl (%rcx,%r12), %ecx
addl $-0x30, %ecx
movl %ecx, 0x58(%rsp)
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb8c9
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb8d6
movq %rax, %rdi
leaq 0x58(%rsp), %rdx
callq 0xf5e6
movq 0x8(%rsp), %rax
movq (%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
movq (%rcx,%rdx), %rcx
cmpb $0x31, (%rcx,%r12)
jne 0xb911
incl (%r15)
movq 0x2c8(%r15), %rcx
incl (%rcx,%rax,4)
movq 0x80(%rsp), %rdi
leaq 0x10(%rsp), %rsi
callq 0xd65c
incl (%rax)
addq $0x2, %r12
cmpq %rbp, %r12
jbe 0xb88a
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 0xd2ac
movq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r12
leaq 0x30(%rsp), %rbp
movq 0x8(%rax), %rsi
cmpq 0x10(%rax), %rsi
je 0xb979
movsd 0x58(%rsp), %xmm0
movsd %xmm0, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x8(%rax)
jmp 0xb986
movq %rax, %rdi
leaq 0x58(%rsp), %rdx
callq 0xf2ce
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xb9a2
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xb9be
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 0xb7dd
jmp 0xba02
movq %rax, %rbx
cmpl $0x1, %edx
jne 0xba4f
movq %rbx, %rdi
callq 0x7170
callq 0x76a0
movq 0x50(%rsp), %rbx
leaq 0x8(%rsp), %r12
jmp 0xb9a2
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xba1a
jmp 0xba30
jmp 0xba30
movq %rax, %rbx
jmp 0xba4f
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0xd250
jmp 0xba4f
jmp 0xba30
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0xba4f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x7420
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0xba6b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x7420
movq %rbx, %rdi
callq 0x7740
nop