// File: /workspace/github_cpp_makefile_star2_O1/millanek[P]evo/process_vcf_utils.cpp
// Function: getThisVariantCountsSimple(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&, Counts*)
void getThisVariantCountsSimple(const std::vector<std::string>& fields, Counts* thisVariantCounts) {
    int numSamples = (int)fields.size()-NUM_NON_GENOTYPE_COLUMNS;
    thisVariantCounts->individualsWithVariant.assign(numSamples,0);
    thisVariantCounts->missingGenotypesPerIndividual.assign(numSamples,false);
    thisVariantCounts->haplotypesWithVariant.assign(numSamples*2,0);
    //std::cerr << "Fields: " << (fields.size()-NUM_NON_GENOTYPE_COLUMNS) << std::endl;
    std::vector<std::string> format = split(fields[8], ':');
    std::vector<std::string> altAlleles = split(fields[4], ',');
    const int numAltAlleles = (int)altAlleles.size();
    
    int alleleAsMissing = -1;
    if (numAltAlleles > 1) {
        string lastAlt = altAlleles.back();
        if (lastAlt == "*") {
            alleleAsMissing = numAltAlleles;
            if ((numAltAlleles - 1) > 1) {
                thisVariantCounts->bIsMultiallelic = true;
            }
        } else {
            if (numAltAlleles > 1) {
                thisVariantCounts->bIsMultiallelic = true;
            }
        }
    }
    
    // Find the position of GQ (genotype quality) in the genotypeData vector below
    if (fields[NUM_NON_GENOTYPE_COLUMNS][1] == '|') { thisVariantCounts->bPhased = true; }
    for (std::vector<std::string>::size_type i = NUM_NON_GENOTYPE_COLUMNS; i != fields.size(); i++) {
        char v1 = fields[i][0]; char v2 = fields[i][2];
        if (thisVariantCounts->bPhased == false) randomisePhase(v1,v2);
        int v1int = v1 - '0'; int v2int = v2 - '0';
        if (v1 == '.' || v2 == '.' || v1int == alleleAsMissing || v2int == alleleAsMissing) {
            thisVariantCounts->bAnyMissingGenotypes = true;
            thisVariantCounts->missingGenotypesPerIndividual[i- NUM_NON_GENOTYPE_COLUMNS] = true;
        } else {
            thisVariantCounts->haplotypesWithVariant[2*(i-NUM_NON_GENOTYPE_COLUMNS)] = v1int;
            thisVariantCounts->haplotypesWithVariant[2*(i-NUM_NON_GENOTYPE_COLUMNS)+1] = v2int;
        }
        // Multiallelic sites will be ignored in the genotype record
        if (!thisVariantCounts->bIsMultiallelic) {
            if (v1 == '1') {
                thisVariantCounts->overall++;
                thisVariantCounts->individualsWithVariant[i- NUM_NON_GENOTYPE_COLUMNS]++;
            }
            if (v2 == '1') {
                thisVariantCounts->overall++;
                thisVariantCounts->individualsWithVariant[i-NUM_NON_GENOTYPE_COLUMNS]++;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %r13
movq 0x8(%rdi), %rbx
subq (%rdi), %rbx
movq %rsi, %r14
shrq $0x5, %rbx
leal -0x9(%rbx), %eax
leaq 0x70(%rsi), %rdi
movslq %eax, %r15
xorl %ebp, %ebp
leaq 0x18(%rsp), %r12
movl %ebp, (%r12)
movq %r15, %rsi
movq %r12, %rdx
callq 0x561e6
leaq 0xd0(%r14), %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x56642
leaq 0xb8(%r14), %rdi
leal -0x12(,%rbx,2), %eax
movslq %eax, %rsi
movl %ebp, (%r12)
leaq 0x18(%rsp), %rdx
movq %rdi, 0x10(%rsp)
callq 0x561e6
movl $0x100, %esi            # imm = 0x100
addq (%r13), %rsi
leaq 0x50(%rsp), %rdi
movl $0x3a, %edx
callq 0x50624
movq %r13, (%rsp)
movq (%r13), %rsi
subq $-0x80, %rsi
leaq 0x38(%rsp), %rdi
movl $0x2c, %edx
callq 0x50624
movq 0x40(%rsp), %rax
movq %rax, %r15
subq 0x38(%rsp), %r15
shrq $0x5, %r15
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2, %r15d
jl 0x512c9
leaq 0x28(%rsp), %r12
movq %r12, -0x10(%r12)
movq -0x20(%rax), %rsi
movq -0x18(%rax), %rdx
addq %rsi, %rdx
leaq 0x18(%rsp), %rdi
callq 0x2e45c
leaq 0x9844e(%rip), %rsi     # 0xe96d6
leaq 0x18(%rsp), %rdi
callq 0x8160
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x512a4
movl %r15d, %ecx
cmpl $0x2, %r15d
je 0x512af
movb $0x1, 0xf9(%r14)
movl %ecx, %r15d
movq 0x18(%rsp), %rdi
cmpq %r12, %rdi
je 0x512c6
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x8480
movl %r15d, %ebp
movq (%rsp), %r8
movq (%r8), %rax
movq 0x120(%rax), %rax
cmpb $0x7c, 0x1(%rax)
jne 0x512e2
movb $0x1, 0x68(%r14)
movq (%r8), %rax
movq 0x8(%r8), %rcx
subq %rax, %rcx
cmpq $0x120, %rcx            # imm = 0x120
je 0x5142c
movl $0x120, %r13d           # imm = 0x120
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorl %r12d, %r12d
addq $0x3f, %rcx
movq %rcx, 0x8(%rsp)
movq (%rax,%r13), %rax
movb (%rax), %r15b
movb 0x2(%rax), %bl
cmpb $0x0, 0x68(%r14)
jne 0x5134e
cmpb %bl, %r15b
je 0x5134e
callq 0x8140
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
divsd 0x78dc9(%rip), %xmm0    # 0xca108
ucomisd 0x7e109(%rip), %xmm0    # 0xcf450
jbe 0x51355
movl %r15d, %eax
jmp 0x5135a
movl %ebx, %eax
movl %r15d, %ebx
jmp 0x5135e
movl %ebx, %eax
movl %r15d, %ebx
movq (%rsp), %r8
cmpb $0x2e, %bl
je 0x5138e
cmpb $0x2e, %al
je 0x5138e
movsbl %bl, %ecx
addl $-0x30, %ecx
cmpl %ebp, %ecx
je 0x5138e
movsbl %al, %edx
addl $-0x30, %edx
cmpl %ebp, %edx
je 0x5138e
movq 0x10(%rsp), %rsi
movq (%rsi), %rsi
movl %ecx, (%rsi,%r12,8)
movl %edx, 0x4(%rsi,%r12,8)
jmp 0x513dc
movb $0x1, 0xf8(%r14)
leaq 0x3f(%r12), %rdx
testq %r12, %r12
cmovnsq %r12, %rdx
sarq $0x6, %rdx
shlq $0x3, %rdx
addq 0xd0(%r14), %rdx
movq %r12, %rcx
andq 0x8(%rsp), %rcx
xorl %esi, %esi
movabsq $-0x8000000000000000, %rdi # imm = 0x8000000000000000
cmpq %rdi, %rcx
setbe %sil
movl $0x1, %edi
movl %r12d, %ecx
shlq %cl, %rdi
orq %rdi, -0x8(%rdx,%rsi,8)
cmpb $0x0, 0xf9(%r14)
jne 0x51405
cmpb $0x31, %bl
jne 0x513f6
incl (%r14)
movq 0x70(%r14), %rcx
incl (%rcx,%r12,4)
cmpb $0x31, %al
jne 0x51405
incl (%r14)
movq 0x70(%r14), %rax
incl (%rax,%r12,4)
movq (%r8), %rax
movq 0x8(%r8), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
leaq 0x1(%r12), %rdx
addq $0xa, %r12
addq $0x20, %r13
cmpq %rcx, %r12
movq %rdx, %r12
jne 0x51315
leaq 0x38(%rsp), %rdi
callq 0x3123c
leaq 0x50(%rsp), %rdi
callq 0x3123c
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x3123c
jmp 0x51461
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3123c
movq %rbx, %rdi
callq 0x8840