// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4260
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0xcf90
movq %rax, %rsi
movl -0x18(%rbp), %edx
movl -0x1c(%rbp), %ecx
leaq 0xdfea9(%rip), %rdi     # 0xe6042
movb $0x0, %al
callq 0x4060
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x63c8
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x61d1
movl $0x2a, %edi
callq 0x46a0
jmp 0x63ae
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl 0x14(%rcx), %ecx
shll $0x2, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movzwl 0x12(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl 0x14(%rcx), %ecx
shll $0x2, %ecx
movl %ecx, %ecx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movzwl 0x12(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movl 0x18(%rcx), %ecx
addl $0x1, %ecx
sarl %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
sarl %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
xorl $-0x1, %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0xe0c73(%rip), %rax     # 0xe6ef0
movb (%rax,%rcx), %al
movb %al, -0x51(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movzwl 0x10(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x68(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x8(%rcx), %rcx
movb (%rax,%rcx), %al
movb %al, -0x7a(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x60(%rbp), %rdx
leaq -0x78(%rbp), %rcx
movl $0x1, %r8d
callq 0x40310
movl %eax, -0x64(%rbp)
cmpl $0x0, %eax
jle 0x6343
movb -0x78(%rbp), %al
movb %al, -0x79(%rbp)
cvtsi2sdl -0x6c(%rbp), %xmm0
movsd 0xdfd0f(%rip), %xmm1    # 0xe6008
movsd %xmm1, -0x88(%rbp)
addsd %xmm1, %xmm0
movsd 0xdfd03(%rip), %xmm1    # 0xe6010
mulsd %xmm1, %xmm0
movsd 0xdfcff(%rip), %xmm1    # 0xe6018
addsd %xmm1, %xmm0
callq 0x4230
movsd -0x88(%rbp), %xmm1
movsd 0xdfcee(%rip), %xmm2    # 0xe6020
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0x7a(%rbp)
jmp 0x6349
movb -0x51(%rbp), %al
movb %al, -0x79(%rbp)
cmpl $0x0, -0x68(%rbp)
je 0x6363
movsbl -0x79(%rbp), %esi
leaq 0xdfcf2(%rip), %rdi     # 0xe604c
movb $0x0, %al
callq 0x4060
jmp 0x6375
movsbl -0x79(%rbp), %esi
leaq 0xdfce9(%rip), %rdi     # 0xe6057
movb $0x0, %al
callq 0x4060
movzbl -0x7a(%rbp), %ecx
addl $0x21, %ecx
movl $0x7e, %eax
cmpl %ecx, %eax
jge 0x6392
movl $0x7e, %eax
movl %eax, -0x8c(%rbp)
jmp 0x639f
movzbl -0x7a(%rbp), %eax
addl $0x21, %eax
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %edi
leaq -0x38(%rbp), %rsi
callq 0x5cc0
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x10(%rbp)
jmp 0x61a7
movl $0x9, %edi
callq 0x46a0
cmpq $0x0, -0x38(%rbp)
je 0x63e6
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
jmp 0x63f6
leaq 0xe0e4d(%rip), %rax     # 0xe723a
movq %rax, -0x98(%rbp)
jmp 0x63f6
movq -0x98(%rbp), %rdi
callq 0x47d0
movq -0x28(%rbp), %rdi
callq 0x45b0
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)