// File: /workspace/github_cpp_makefile_star2_O3/karel-brinda[P]ococo/src/stats.h
// Function: ococo::stats_t<unsigned short, 3, 4>::print_pileup_line(_IO_FILE*, int, long, ococo::pos_stats_uncompr_t const&) const
int stats_t<T, counter_size, refbase_size>::print_pileup_line(
    FILE *pileup_file, int32_t seqid, int64_t pos,
    const pos_stats_uncompr_t &psu) const {
    assert(check_allocation());
    assert(pileup_file != nullptr);

    // todo: fix situation when depth is larger (use the printing buffer more
    // timess)

    const int32_t max_depth = 1000;

    assert(psu.sum < max_depth);
    char bases[max_depth];
    char qualities[max_depth];

    char ref_nt256 = nt16_nt256[psu.nt16];

    if (psu.sum == 0) {
        return 0;
    }

    if (ref_nt256 == '=') {
        ref_nt256 = 'N';
    }

    int32_t j = 0;

    for (int32_t nt4 = 0; nt4 < 4; nt4++) {
        const char filling_char =
            nt4_nt16[nt4] == psu.nt16 ? '.' : nt4_nt256[nt4];
        for (int32_t i = 0; i < psu.counters[nt4]; i++, j++) {
            bases[j]     = filling_char;
            qualities[j] = '~';
        }
    }

    if (psu.sum >= max_depth) {
        ococo::error("Too high coverage at position %" PRId64
                     ". Pileup does not support coverage higher than %" PRId32
                     ".",
                     pos, max_depth);
        return -1;
    }

    bases[j]     = '\0';
    qualities[j] = '\0';

    fprintf(pileup_file, "%s\t%" PRId64 "\t%c\t%" PRId32 "\t%s\t%s\n",
            seq_name[seqid].c_str(), pos + 1, ref_nt256, psu.sum, bases,
            qualities);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x808, %rsp            # imm = 0x808
movq %r8, %r13
movq %rcx, %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
callq 0x8f4c
testb %al, %al
je 0xa01b
testq %r14, %r14
je 0xa03a
movl 0x14(%r13), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jge 0xa059
testl %eax, %eax
je 0xa007
movq %r15, 0x18(%rsp)
movl %ebp, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movzbl (%r13), %r14d
leaq 0x45c43(%rip), %rax     # 0x4fb70
movb (%r14,%rax), %al
movb %al, 0xf(%rsp)
xorl %r12d, %r12d
leaq 0x45c11(%rip), %rbp     # 0x4fb50
xorl %ebx, %ebx
movb $0x2e, %al
cmpb %r14b, (%r12,%rbp)
je 0x9f54
leaq 0x44dd1(%rip), %rax     # 0x4ed21
movb (%r12,%rax), %al
movslq 0x4(%r13,%r12,4), %r15
testq %r15, %r15
jle 0x9f8f
movslq %ebx, %rbx
leaq (%rsp,%rbx), %rdi
addq $0x420, %rdi            # imm = 0x420
movzbl %al, %esi
movq %r15, %rdx
callq 0x42d0
leaq (%rsp,%rbx), %rdi
addq $0x30, %rdi
movl $0x7e, %esi
movq %r15, %rdx
callq 0x42d0
addl %r15d, %ebx
incq %r12
cmpq $0x4, %r12
jne 0x9f41
testb %r14b, %r14b
movzbl 0xf(%rsp), %eax
movl $0x4e, %esi
cmovnel %eax, %esi
movslq %ebx, %rax
xorl %edx, %edx
movb %dl, 0x420(%rsp,%rax)
movb %dl, 0x30(%rsp,%rax)
movq 0x18(%rsp), %rax
movq 0x18(%rax), %rax
movslq 0x10(%rsp), %rdx
shlq $0x5, %rdx
movq (%rax,%rdx), %rdx
movq 0x28(%rsp), %rcx
incq %rcx
movsbl %sil, %r8d
leaq 0x30(%rsp), %r10
leaq 0x420(%rsp), %r11
leaq 0x44d39(%rip), %rsi     # 0x4ed27
movq 0x20(%rsp), %rdi
movl 0x14(%rsp), %r9d
xorl %eax, %eax
pushq %r10
pushq %r11
callq 0x4770
addq $0x10, %rsp
xorl %eax, %eax
addq $0x808, %rsp            # imm = 0x808
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x44355(%rip), %rdi     # 0x4e377
leaq 0x44361(%rip), %rsi     # 0x4e38a
leaq 0x44c14(%rip), %rcx     # 0x4ec44
movl $0x211, %edx            # imm = 0x211
callq 0x4350
leaq 0x44cb5(%rip), %rdi     # 0x4ecf6
leaq 0x44342(%rip), %rsi     # 0x4e38a
leaq 0x44bf5(%rip), %rcx     # 0x4ec44
movl $0x212, %edx            # imm = 0x212
callq 0x4350
leaq 0x44cad(%rip), %rdi     # 0x4ed0d
leaq 0x44323(%rip), %rsi     # 0x4e38a
leaq 0x44bd6(%rip), %rcx     # 0x4ec44
movl $0x219, %edx            # imm = 0x219
callq 0x4350