// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/pileup_mod.c
// Function: process_mod_pileup2
void process_mod_pileup2(sam_hdr_t *h, const bam_pileup1_t *p,
                        int tid, int pos, int n) {
    kstring_t s = {0,0};
    printf("%s\t%d\t%d\t", sam_hdr_tid2name(h, tid), pos, n);
    int i;
    for (i = 0; i < n; i++, p++) {
        if (p->is_del) {
            putchar('*');
            continue;
        }

        uint8_t *seq = bam_get_seq(p->b);
        uint8_t *qual = bam_get_qual(p->b);
        unsigned char c = seq_nt16_str[bam_seqi(seq, p->qpos)];

        // Simple mod detection; assumes at most 2 non-ChEBI mods
        hts_base_mod_state *m = p->cd.p;
        int n, is_rev = bam_is_rev(p->b);
        hts_base_mod mod;
        char base;
        uint8_t q = qual[p->qpos];
        if ((n = bam_mods_at_qpos(p->b, p->qpos, m, &mod, 1)) > 0) {
            base = mod.modified_base;
            // base mod as phred scale
            q = -10 * log10(1-((mod.qual+0.5)/256)) + 0.5;
        } else {
            base = c;
        }

        // Case is inappropriate here as some mods (eg "a") are lc.
        // So we dim/bold them instead using ANSI escape codes.
        // It's a test script, so I'm not going to care about curses.
        if (is_rev) {
            printf("\033[2m%c\033[0m", base);
        } else {
            printf("\033[1m%c\033[0m", base);
        }
        kputc(MIN('~','!'+q), &s);
    }
    putchar('\t');
    puts(s.l ? s.s : "");

    free(s.s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %ebx
movl %ecx, %ebp
movq %rsi, %r14
movl %edx, %esi
callq 0xbaf0
leaq 0x88e2a(%rip), %rdi     # 0x8f042
xorl %r12d, %r12d
movq %rax, %rsi
movl %ebp, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x4060
testl %ebx, %ebx
jle 0x63c1
addq $0x18, %r14
xorl %r12d, %r12d
movq $0x0, 0x8(%rsp)
xorl %ebp, %ebp
testb $0x1, -0x4(%r14)
jne 0x637c
movq %r12, 0x10(%rsp)
movq -0x18(%r14), %rdi
movl 0x14(%rdi), %eax
shll $0x2, %eax
addq 0x38(%rdi), %rax
movq (%r14), %rdx
movzwl 0x12(%rdi), %ecx
addq %rax, %rcx
movl 0x18(%rdi), %eax
incl %eax
sarl %eax
cltq
addq %rcx, %rax
movslq -0x10(%r14), %rsi
movl %esi, %r8d
sarl %r8d
movslq %r8d, %r8
movzbl (%r8,%rcx), %r8d
leal (,%rsi,4), %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %r8d
andl $0xf, %r8d
leaq 0x89c5d(%rip), %rcx     # 0x8ff00
movb (%rcx,%r8), %r15b
movzwl 0x10(%rdi), %r13d
movb (%rsi,%rax), %r12b
leaq 0x18(%rsp), %rcx
movl $0x1, %r8d
callq 0x2f1ba
testl %eax, %eax
jle 0x6308
xorps %xmm0, %xmm0
cvtsi2sdl 0x24(%rsp), %xmm0
movb 0x18(%rsp), %r15b
movsd 0x88d2e(%rip), %xmm1    # 0x8f008
addsd %xmm1, %xmm0
mulsd 0x88d2a(%rip), %xmm0    # 0x8f010
addsd 0x88d2a(%rip), %xmm0    # 0x8f018
callq 0x4240
mulsd 0x88d25(%rip), %xmm0    # 0x8f020
addsd 0x88d05(%rip), %xmm0    # 0x8f008
cvttsd2si %xmm0, %r12d
testb $0x10, %r13b
movsbl %r15b, %esi
leaq 0x88d35(%rip), %rdi     # 0x8f04c
leaq 0x88d39(%rip), %rax     # 0x8f057
cmoveq %rax, %rdi
xorl %eax, %eax
callq 0x4060
movzbl %r12b, %r15d
cmpb $0x5d, %r15b
movl $0x5d, %eax
cmovael %eax, %r15d
leaq 0x2(%rbp), %rax
movq 0x8(%rsp), %r13
cmpq %rax, %r13
jae 0x6388
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
testq %rcx, %rcx
movl $0x0, %r13d
cmoveq %rdx, %r13
addq %rax, %r13
movq 0x10(%rsp), %r12
movq %r12, %rdi
movq %r13, %rsi
callq 0x4870
testq %rax, %rax
jne 0x638d
jmp 0x63a5
movl $0x2a, %edi
callq 0x46d0
jmp 0x63a5
movq 0x10(%rsp), %rax
addb $0x21, %r15b
movb %r15b, (%rax,%rbp)
movb $0x0, 0x1(%rax,%rbp)
incq %rbp
movq %r13, 0x8(%rsp)
movq %rax, %r12
addq $0x28, %r14
decl %ebx
jne 0x6243
testq %rbp, %rbp
leaq 0x89e52(%rip), %rbx     # 0x9020d
cmovneq %r12, %rbx
jmp 0x63c8
leaq 0x89e45(%rip), %rbx     # 0x9020d
movl $0x9, %edi
callq 0x46d0
movq %rbx, %rdi
callq 0x47f0
movq %r12, %rdi
callq 0x45d0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq