// File: /workspace/github_cpp_makefile_star2_O1/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 0x902a
testb %al, %al
je 0xa0c9
testq %r14, %r14
je 0xa0e8
movl 0x14(%r13), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jge 0xa107
testl %eax, %eax
je 0xa0b5
movq %r15, 0x18(%rsp)
movl %ebp, 0x10(%rsp)
movl %eax, 0x14(%rsp)
movq %r14, 0x20(%rsp)
movq %rbx, 0x28(%rsp)
movzbl (%r13), %r14d
leaq 0x47b95(%rip), %rax     # 0x51b70
movb (%r14,%rax), %al
movb %al, 0xf(%rsp)
xorl %r12d, %r12d
leaq 0x47b63(%rip), %rbp     # 0x51b50
xorl %ebx, %ebx
movb $0x2e, %al
cmpb %r14b, (%r12,%rbp)
je 0xa002
leaq 0x46d23(%rip), %rax     # 0x50d21
movb (%r12,%rax), %al
movslq 0x4(%r13,%r12,4), %r15
testq %r15, %r15
jle 0xa03d
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 0x9fef
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 0x46c8b(%rip), %rsi     # 0x50d27
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 0x462a7(%rip), %rdi     # 0x50377
leaq 0x462b3(%rip), %rsi     # 0x5038a
leaq 0x46b66(%rip), %rcx     # 0x50c44
movl $0x211, %edx            # imm = 0x211
callq 0x4350
leaq 0x46c07(%rip), %rdi     # 0x50cf6
leaq 0x46294(%rip), %rsi     # 0x5038a
leaq 0x46b47(%rip), %rcx     # 0x50c44
movl $0x212, %edx            # imm = 0x212
callq 0x4350
leaq 0x46bff(%rip), %rdi     # 0x50d0d
leaq 0x46275(%rip), %rsi     # 0x5038a
leaq 0x46b28(%rip), %rcx     # 0x50c44
movl $0x219, %edx            # imm = 0x219
callq 0x4350