// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/pileup_mod.c
// Function: process_mod_pileup1
void process_mod_pileup1(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", sam_hdr_tid2name(h, tid), pos);
    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)];
        putchar(c);
        kputc(MIN('~','!'+qual[p->qpos]), &s);

        // Simple mod detection; assumes at most 5 mods
        hts_base_mod_state *m = p->cd.p;
        hts_base_mod mod[5];
        int nm;
        if ((nm = bam_mods_at_qpos(p->b, p->qpos, m, mod, 5)) > 0) {
            int j;
            putchar('[');
            for (j = 0; j < nm && j < 5; j++) {
                if (mod[j].modified_base < 0)
                    // ChEBI
                    printf("%c(%d)%d", "+-"[mod[j].strand],
                           -mod[j].modified_base, mod[j].qual);
                else
                    printf("%c%c%d", "+-"[mod[j].strand],
                           mod[j].modified_base, mod[j].qual);
            }
            putchar(']');
        }
    }
    putchar('\t');
    puts(s.l ? s.s : "");

    free(s.s);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, %r15d
movl %ecx, %ebp
movq %rsi, %r14
movl %edx, %esi
callq 0xbaf0
leaq 0x8904a(%rip), %rdi     # 0x8f028
movq %rax, %rsi
movl %ebp, %edx
xorl %eax, %eax
callq 0x4060
testl %r15d, %r15d
jle 0x61c1
leaq 0x8903e(%rip), %rbx     # 0x8f038
leaq 0x8903a(%rip), %r13     # 0x8f03b
xorl %ebp, %ebp
movq $0x0, (%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movl %r15d, 0x14(%rsp)
testb $0x1, 0x14(%r14)
jne 0x60c5
movq (%r14), %rcx
movl 0x14(%rcx), %edx
movl 0x18(%rcx), %eax
shll $0x2, %edx
addq 0x38(%rcx), %rdx
movzwl 0x12(%rcx), %esi
addq %rdx, %rsi
incl %eax
sarl %eax
movl 0x8(%r14), %ecx
movl %ecx, %edx
sarl %edx
movslq %edx, %rdx
movzbl (%rdx,%rsi), %edx
shll $0x2, %ecx
notb %cl
andb $0x4, %cl
shrl %cl, %edx
movslq %eax, %r15
addq %rsi, %r15
andl $0xf, %edx
leaq 0x89e8f(%rip), %rax     # 0x8ff00
movzbl (%rax,%rdx), %edi
callq 0x46d0
movslq 0x8(%r14), %rax
movb (%rax,%r15), %r12b
movq 0x8(%rsp), %rax
addq $0x2, %rax
movq 0x18(%rsp), %r15
cmpq %rax, %r15
jae 0x60d4
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %rdx
shrq %rdx
testq %rcx, %rcx
movl $0x0, %r15d
cmoveq %rdx, %r15
addq %rax, %r15
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x4870
testq %rax, %rax
jne 0x60d8
jmp 0x610b
movl $0x2a, %edi
callq 0x46d0
jmp 0x619b
movq (%rsp), %rax
leal 0x21(%r12), %ecx
cmpb $0x5e, %r12b
movzbl %cl, %ecx
movl $0x7e, %edx
cmovael %edx, %ecx
movq 0x8(%rsp), %rdx
movb %cl, (%rax,%rdx)
movb $0x0, 0x1(%rax,%rdx)
leaq 0x1(%rdx), %rcx
movq %rcx, 0x8(%rsp)
movq %r15, 0x18(%rsp)
movq %rax, (%rsp)
movq 0x18(%r14), %rdx
movq (%r14), %rdi
movl 0x8(%r14), %esi
leaq 0x20(%rsp), %rcx
movl $0x5, %r8d
callq 0x2f1ba
testl %eax, %eax
jle 0x6196
movl %eax, %r15d
movl $0x5b, %edi
callq 0x46d0
decl %r15d
cmpq $0x4, %r15
movl $0x4, %eax
cmovaeq %rax, %r15
shll $0x4, %r15d
addq $0x10, %r15
xorl %r12d, %r12d
movl 0x20(%rsp,%r12), %edx
movslq 0x28(%rsp,%r12), %rax
movsbl (%rax,%rbx), %esi
testl %edx, %edx
js 0x616e
movl 0x2c(%rsp,%r12), %ecx
movq %r13, %rdi
jmp 0x617c
negl %edx
movl 0x2c(%rsp,%r12), %ecx
leaq 0x88eb3(%rip), %rdi     # 0x8f02f
xorl %eax, %eax
callq 0x4060
addq $0x10, %r12
cmpq %r12, %r15
jne 0x6152
movl $0x5d, %edi
callq 0x46d0
movl 0x14(%rsp), %r15d
incl %ebp
addq $0x28, %r14
cmpl %r15d, %ebp
jne 0x6022
cmpq $0x0, 0x8(%rsp)
leaq 0x8a056(%rip), %rbx     # 0x9020d
movq (%rsp), %r14
cmovneq %r14, %rbx
jmp 0x61cb
leaq 0x8a045(%rip), %rbx     # 0x9020d
xorl %r14d, %r14d
movl $0x9, %edi
callq 0x46d0
movq %rbx, %rdi
callq 0x47f0
movq %r14, %rdi
callq 0x45d0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq