// File: 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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3ffd0
addl $-0x9, %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
movslq -0x14(%rbp), %rsi
movl $0x0, -0x18(%rbp)
leaq -0x18(%rbp), %rdx
callq 0x838d0
movq -0x10(%rbp), %rdi
addq $0xd0, %rdi
movslq -0x14(%rbp), %rsi
movb $0x0, -0x19(%rbp)
leaq -0x19(%rbp), %rdx
callq 0x83900
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movl -0x14(%rbp), %eax
addl %eax, %eax
movslq %eax, %rsi
movl $0x0, -0x20(%rbp)
leaq -0x20(%rbp), %rdx
callq 0x838d0
movq -0x8(%rbp), %rdi
movl $0x8, %esi
callq 0x52960
movq %rax, %rsi
leaq -0x38(%rbp), %rdi
movl $0x3a, %edx
callq 0x7bbe0
movq -0x8(%rbp), %rdi
movl $0x4, %esi
callq 0x52960
movq %rax, %rsi
leaq -0x50(%rbp), %rdi
movl $0x2c, %edx
callq 0x7bbe0
jmp 0x7cf7d
leaq -0x50(%rbp), %rdi
callq 0x3ffd0
movl %eax, -0x60(%rbp)
movl $0xffffffff, -0x64(%rbp) # imm = 0xFFFFFFFF
cmpl $0x1, -0x60(%rbp)
jle 0x7d059
leaq -0x50(%rbp), %rdi
callq 0x5fcc0
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
callq 0xa250
jmp 0x7cfb4
leaq 0xd1227(%rip), %rsi     # 0x14e1e2
leaq -0x88(%rbp), %rdi
callq 0x2d770
movb %al, -0xb1(%rbp)
jmp 0x7cfcf
movb -0xb1(%rbp), %al
testb $0x1, %al
jne 0x7cfdb
jmp 0x7d03a
movl -0x60(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x60(%rbp), %eax
subl $0x1, %eax
cmpl $0x1, %eax
jle 0x7d038
movq -0x10(%rbp), %rax
movb $0x1, 0xf9(%rax)
jmp 0x7d038
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7d2f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7d2f0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0xac88
jmp 0x7d2f0
jmp 0x7d04d
cmpl $0x1, -0x60(%rbp)
jle 0x7d04b
movq -0x10(%rbp), %rax
movb $0x1, 0xf9(%rax)
jmp 0x7d04d
leaq -0x88(%rbp), %rdi
callq 0xac88
movq -0x8(%rbp), %rdi
movl $0x9, %esi
callq 0x52960
movq %rax, %rdi
movl $0x1, %esi
callq 0xa670
movsbl (%rax), %eax
cmpl $0x7c, %eax
jne 0x7d084
movq -0x10(%rbp), %rax
movb $0x1, 0x68(%rax)
movq $0x9, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3ffd0
movq %rax, %rcx
movq -0xc0(%rbp), %rax
cmpq %rcx, %rax
je 0x7d2d5
movq -0x8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x52960
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xa670
movb (%rax), %al
movb %al, -0x91(%rbp)
movq -0x8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x52960
movq %rax, %rdi
movl $0x2, %esi
callq 0xa670
movb (%rax), %al
movb %al, -0x92(%rbp)
movq -0x10(%rbp), %rax
movb 0x68(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x7d126
leaq -0x91(%rbp), %rdi
leaq -0x92(%rbp), %rsi
callq 0x7c6a0
movsbl -0x91(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x98(%rbp)
movsbl -0x92(%rbp), %eax
subl $0x30, %eax
movl %eax, -0x9c(%rbp)
movsbl -0x91(%rbp), %eax
cmpl $0x2e, %eax
je 0x7d174
movsbl -0x92(%rbp), %eax
cmpl $0x2e, %eax
je 0x7d174
movl -0x98(%rbp), %eax
cmpl -0x64(%rbp), %eax
je 0x7d174
movl -0x9c(%rbp), %eax
cmpl -0x64(%rbp), %eax
jne 0x7d1d9
movq -0x10(%rbp), %rax
movb $0x1, 0xf8(%rax)
movq -0x10(%rbp), %rdi
addq $0xd0, %rdi
movq -0x90(%rbp), %rsi
addq $-0x9, %rsi
callq 0x83940
movq %rdx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
jmp 0x7d1aa
movq -0xd0(%rbp), %rax
movq -0xc8(%rbp), %rcx
movq %rcx, -0xb0(%rbp)
movq %rax, -0xa8(%rbp)
leaq -0xb0(%rbp), %rdi
movl $0x1, %esi
callq 0x480d0
jmp 0x7d241
movl -0x98(%rbp), %eax
movl %eax, -0xd8(%rbp)
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movq -0x90(%rbp), %rsi
subq $0x9, %rsi
shlq %rsi
callq 0x4d100
movl -0xd8(%rbp), %ecx
movl %ecx, (%rax)
movl -0x9c(%rbp), %eax
movl %eax, -0xd4(%rbp)
movq -0x10(%rbp), %rdi
addq $0xb8, %rdi
movq -0x90(%rbp), %rsi
subq $0x9, %rsi
shlq %rsi
addq $0x1, %rsi
callq 0x4d100
movl -0xd4(%rbp), %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rax
testb $0x1, 0xf9(%rax)
jne 0x7d2bc
movsbl -0x91(%rbp), %eax
cmpl $0x31, %eax
jne 0x7d284
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
movq -0x90(%rbp), %rsi
subq $0x9, %rsi
callq 0x4d100
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movsbl -0x92(%rbp), %eax
cmpl $0x31, %eax
jne 0x7d2ba
movq -0x10(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x10(%rbp), %rdi
addq $0x70, %rdi
movq -0x90(%rbp), %rsi
subq $0x9, %rsi
callq 0x4d100
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
jmp 0x7d2bc
jmp 0x7d2be
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x7d08f
leaq -0x50(%rbp), %rdi
callq 0x3dfa0
leaq -0x38(%rbp), %rdi
callq 0x3dfa0
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x3dfa0
leaq -0x38(%rbp), %rdi
callq 0x3dfa0
movq -0x58(%rbp), %rdi
callq 0xab50
nopl (%rax,%rax)