// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: bam_plp_insertion_mod
int bam_plp_insertion_mod(const bam_pileup1_t *p,
                          hts_base_mod_state *m,
                          kstring_t *ins, int *del_len) {
    int j, k, indel, nb = 0;
    uint32_t *cigar;

    if (p->indel <= 0) {
        if (ks_resize(ins, 1) < 0)
            return -1;
        ins->l = 0;
        ins->s[0] = '\0';
        return 0;
    }

    if (del_len)
        *del_len = 0;

    // Measure indel length including pads
    indel = 0;
    k = p->cigar_ind+1;
    cigar = bam_get_cigar(p->b);
    while (k < p->b->core.n_cigar) {
        switch (cigar[k] & BAM_CIGAR_MASK) {
        case BAM_CPAD:
        case BAM_CINS:
            indel += (cigar[k] >> BAM_CIGAR_SHIFT);
            break;
        default:
            k = p->b->core.n_cigar;
            break;
        }
        k++;
    }
    nb = ins->l = indel;

    // Produce sequence
    if (ks_resize(ins, indel+1) < 0)
        return -1;
    indel = 0;
    k = p->cigar_ind+1;
    j = 1;
    while (k < p->b->core.n_cigar) {
        int l, c;
        switch (cigar[k] & BAM_CIGAR_MASK) {
        case BAM_CPAD:
            for (l = 0; l < (cigar[k]>>BAM_CIGAR_SHIFT); l++)
                ins->s[indel++] = '*';
            break;
        case BAM_CINS:
            for (l = 0; l < (cigar[k]>>BAM_CIGAR_SHIFT); l++, j++) {
                c = p->qpos + j - p->is_del < p->b->core.l_qseq
                    ? seq_nt16_str[bam_seqi(bam_get_seq(p->b),
                                            p->qpos + j - p->is_del)]
                    : 'N';
                ins->s[indel++] = c;
                int nm;
                hts_base_mod mod[256];
                if (m && (nm = bam_mods_at_qpos(p->b, p->qpos + j - p->is_del,
                                                m, mod, 256)) > 0) {
                    int o_indel = indel;
                    if (ks_resize(ins, ins->l + nm*16+3) < 0)
                        return -1;
                    ins->s[indel++] = '[';
                    int j;
                    for (j = 0; j < nm; j++) {
                        char qual[20];
                        if (mod[j].qual >= 0)
                            snprintf(qual, sizeof(qual), "%d", mod[j].qual);
                        else
                            *qual=0;
                        if (mod[j].modified_base < 0)
                            // ChEBI
                            indel += snprintf(&ins->s[indel], ins->m - indel,
                                              "%c(%d)%s",
                                              "+-"[mod[j].strand],
                                              -mod[j].modified_base,
                                              qual);
                        else
                            indel += snprintf(&ins->s[indel], ins->m - indel,
                                              "%c%c%s",
                                              "+-"[mod[j].strand],
                                              mod[j].modified_base,
                                              qual);
                    }
                    ins->s[indel++] = ']';
                    ins->l += indel - o_indel; // grow by amount we used
                }
            }
            break;
        case BAM_CDEL:
            // eg cigar 1M2I1D gives mpileup output in T+2AA-1C style
            if (del_len)
                *del_len = cigar[k]>>BAM_CIGAR_SHIFT;
            // fall through
        default:
            k = p->b->core.n_cigar;
            break;
        }
        k++;
    }
    ins->s[indel] = '\0';
    ins->l = indel; // string length

    return nb;      // base length
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1080, %rsp           # imm = 0x1080
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
jg 0x42e4d
movq -0x20(%rbp), %rdi
movl $0x1, %esi
callq 0x3f730
cmpl $0x0, %eax
jge 0x42e2b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x433a9
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movb $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x433a9
cmpq $0x0, -0x28(%rbp)
je 0x42e5e
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
movzwl 0x12(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jae 0x42ef7
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x1074(%rbp)
subl $0x1, %eax
je 0x42ec9
jmp 0x42ebc
movl -0x1074(%rbp), %eax
subl $0x6, %eax
jne 0x42edf
jmp 0x42ec9
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
shrl $0x4, %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x42eec
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x42e92
movslq -0x34(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rax, (%rcx)
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x3f730
cmpl $0x0, %eax
jge 0x42f28
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x433a9
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
movl $0x1, -0x2c(%rbp)
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x14(%rcx), %eax
jae 0x43388
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %eax
andl $0xf, %eax
movl %eax, -0x1078(%rbp)
subl $0x1, %eax
je 0x42fd9
jmp 0x42f71
movl -0x1078(%rbp), %eax
subl $0x2, %eax
je 0x43350
jmp 0x42f82
movl -0x1078(%rbp), %eax
subl $0x6, %eax
jne 0x4336d
jmp 0x42f93
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
shrl $0x4, %ecx
cmpl %ecx, %eax
jae 0x42fd4
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0x2a, (%rax,%rcx)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x42f9a
jmp 0x4337a
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x30(%rbp), %rdx
movl (%rcx,%rdx,4), %ecx
shrl $0x4, %ecx
cmpl %ecx, %eax
jae 0x4334e
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
addl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x14(%rcx), %ecx
andl $0x1, %ecx
subl %ecx, %eax
movq -0x10(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x18(%rcx), %eax
jge 0x430a6
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
movl 0x8(%rcx), %ecx
addl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rdx
movl 0x14(%rdx), %edx
andl $0x1, %edx
subl %edx, %ecx
sarl %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x10(%rbp), %rcx
movl 0x8(%rcx), %ecx
addl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rdx
movl 0x14(%rdx), %edx
andl $0x1, %edx
subl %edx, %ecx
xorl $-0x1, %ecx
andl $0x1, %ecx
shll $0x2, %ecx
sarl %cl, %eax
andl $0xf, %eax
movslq %eax, %rcx
leaq 0xacb96(%rip), %rax     # 0xefc30
movsbl (%rax,%rcx), %eax
movl %eax, -0x107c(%rbp)
jmp 0x430b3
movl $0x4e, %eax
movl %eax, -0x107c(%rbp)
jmp 0x430b3
movl -0x107c(%rbp), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x34(%rbp)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
cmpq $0x0, -0x18(%rbp)
je 0x43335
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
addl -0x2c(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x1, %eax
subl %eax, %esi
movq -0x18(%rbp), %rdx
leaq -0x1050(%rbp), %rcx
movl $0x100, %r8d            # imm = 0x100
callq 0x4ad30
movl %eax, -0x4c(%rbp)
cmpl $0x0, %eax
jle 0x43335
movl -0x34(%rbp), %eax
movl %eax, -0x1054(%rbp)
movq -0x20(%rbp), %rdi
movq -0x20(%rbp), %rax
movq (%rax), %rsi
movl -0x4c(%rbp), %eax
shll $0x4, %eax
cltq
addq %rax, %rsi
addq $0x3, %rsi
callq 0x3f730
cmpl $0x0, %eax
jge 0x4315d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x433a9
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0x5b, (%rax,%rcx)
movl $0x0, -0x1058(%rbp)
movl -0x1058(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x43305
movslq -0x1058(%rbp), %rcx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, 0xc(%rax)
jl 0x431df
leaq -0x1070(%rbp), %rdi
movslq -0x1058(%rbp), %rcx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl 0xc(%rax), %ecx
movl $0x14, %esi
leaq 0xac6e9(%rip), %rdx     # 0xef8bf
movb $0x0, %al
callq 0x47e0
jmp 0x431e6
movb $0x0, -0x1070(%rbp)
movslq -0x1058(%rbp), %rcx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
cmpl $0x0, (%rax)
jge 0x4327a
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movslq -0x34(%rbp), %rax
subq %rax, %rsi
movslq -0x1058(%rbp), %rcx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rcx
leaq 0xaf1b6(%rip), %rax     # 0xf23f4
movsbl (%rax,%rcx), %ecx
movslq -0x1058(%rbp), %rdx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rdx
addq %rdx, %rax
xorl %r8d, %r8d
subl (%rax), %r8d
leaq -0x1070(%rbp), %r9
leaq 0xaf180(%rip), %rdx     # 0xf23eb
movb $0x0, %al
callq 0x47e0
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x432ef
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movslq -0x34(%rbp), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rsi
movslq -0x34(%rbp), %rax
subq %rax, %rsi
movslq -0x1058(%rbp), %rcx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movslq 0x8(%rax), %rcx
leaq 0xaf13c(%rip), %rax     # 0xf23f4
movsbl (%rax,%rcx), %ecx
movslq -0x1058(%rbp), %rdx
leaq -0x1050(%rbp), %rax
shlq $0x4, %rdx
addq %rdx, %rax
movl (%rax), %r8d
leaq -0x1070(%rbp), %r9
leaq 0xaf115(%rip), %rdx     # 0xf23f7
movb $0x0, %al
callq 0x47e0
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x432f1
movl -0x1058(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1058(%rbp)
jmp 0x43181
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x34(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movslq %ecx, %rcx
movb $0x5d, (%rax,%rcx)
movl -0x34(%rbp), %eax
subl -0x1054(%rbp), %eax
movslq %eax, %rcx
movq -0x20(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
jmp 0x43337
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x42fe0
jmp 0x4337a
cmpq $0x0, -0x28(%rbp)
je 0x4336b
movq -0x40(%rbp), %rax
movslq -0x30(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
shrl $0x4, %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
jmp 0x4336d
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x42f43
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x34(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movslq -0x34(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x1080, %rsp           # imm = 0x1080
popq %rbp
retq
nopw %cs:(%rax,%rax)