// File: /workspace/github_c_makefile_star2_O2/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, %ebp
movl %ecx, %r15d
movq %rsi, %rbx
xorpd %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movapd %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movl %edx, %esi
callq 0x9fa5
leaq 0x6b1ba(%rip), %rdi     # 0x71042
movq %rax, %rsi
movl %r15d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x4060
testl %ebp, %ebp
movl $0x0, %r13d
cmovgl %ebp, %r13d
addq $0x18, %rbx
pushq $0x2a
popq %r12
subl $0x1, %r13d
jb 0x5fbb
testb $0x1, -0x4(%rbx)
jne 0x5f95
movq -0x18(%rbx), %rdi
movl 0x14(%rdi), %eax
shll $0x2, %eax
addq 0x38(%rdi), %rax
movq (%rbx), %rdx
movzwl 0x12(%rdi), %ecx
addq %rax, %rcx
movl 0x18(%rdi), %eax
incl %eax
sarl %eax
cltq
addq %rcx, %rax
movslq -0x10(%rbx), %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 0x6bff1(%rip), %rcx     # 0x71f00
movb (%rcx,%r8), %r15b
movzwl 0x10(%rdi), %ebp
movb (%rsi,%rax), %r14b
movq %rsp, %rcx
pushq $0x1
popq %r8
callq 0x257a0
testl %eax, %eax
jle 0x5f6b
cvtsi2sdl 0xc(%rsp), %xmm0
movb (%rsp), %r15b
movsd 0x6b0cb(%rip), %xmm1    # 0x71008
addsd %xmm1, %xmm0
mulsd 0x6b0c7(%rip), %xmm0    # 0x71010
addsd 0x6b0c7(%rip), %xmm0    # 0x71018
callq 0x4240
mulsd 0x6b0c2(%rip), %xmm0    # 0x71020
addsd 0x6b0a2(%rip), %xmm0    # 0x71008
cvttsd2si %xmm0, %r14d
leaq 0x6b0e5(%rip), %rdi     # 0x71057
testb $0x10, %bpl
je 0x5f7f
leaq 0x6b0cd(%rip), %rdi     # 0x7104c
movsbl %r15b, %esi
xorl %eax, %eax
callq 0x4060
cmpb $0x5d, %r14b
jb 0x5f9f
pushq $0x5d
popq %rax
jmp 0x5fa3
movl %r12d, %edi
callq 0x46d0
jmp 0x5fb2
movzbl %r14b, %eax
addb $0x21, %al
movzbl %al, %edi
leaq 0x10(%rsp), %rsi
callq 0x5be7
addq $0x28, %rbx
jmp 0x5eab
pushq $0x9
popq %rdi
callq 0x46d0
cmpq $0x0, 0x10(%rsp)
movq 0x20(%rsp), %rbx
leaq 0x6c271(%rip), %rdi     # 0x72246
cmovneq %rbx, %rdi
callq 0x47f0
movq %rbx, %rdi
callq 0x45d0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq