// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: cigar_iref2iseq_next
static inline int cigar_iref2iseq_next(const uint32_t **cigar,
                                       const uint32_t *cigar_max,
                                       hts_pos_t *icig,
                                       hts_pos_t *iseq,
                                       hts_pos_t *iref)
{
    while ( *cigar < cigar_max )
    {
        int cig  = (**cigar) & BAM_CIGAR_MASK;
        int ncig = (**cigar) >> BAM_CIGAR_SHIFT;

        if ( cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF )
        {
            if ( *icig >= ncig - 1 ) { *icig = -1;  (*cigar)++; continue; }
            (*iseq)++; (*icig)++; (*iref)++;
            return BAM_CMATCH;
        }
        if ( cig==BAM_CDEL || cig==BAM_CREF_SKIP ) { (*cigar)++; (*iref) += ncig; *icig = -1; continue; }
        if ( cig==BAM_CINS ) { (*cigar)++; *iseq += ncig; *icig = -1; continue; }
        if ( cig==BAM_CSOFT_CLIP ) { (*cigar)++; *iseq += ncig; *icig = -1; continue; }
        if ( cig==BAM_CHARD_CLIP || cig==BAM_CPAD ) { (*cigar)++; *icig = -1; continue; }
        hts_log_error("Unexpected cigar %d", cig);
        return -2;
    }
    *iseq = -1;
    *iref = -1;
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x18(%rbp), %rax
jae 0x4946f
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
shrl $0x4, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x4931d
cmpl $0x7, -0x34(%rbp)
je 0x4931d
cmpl $0x8, -0x34(%rbp)
jne 0x49383
movq -0x20(%rbp), %rax
movq (%rax), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cmpq %rcx, %rax
jl 0x4934d
movq -0x20(%rbp), %rax
movq $-0x1, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
jmp 0x492dc
movq -0x28(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4948c
cmpl $0x2, -0x34(%rbp)
je 0x4938f
cmpl $0x3, -0x34(%rbp)
jne 0x493bb
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movslq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $-0x1, (%rax)
jmp 0x492dc
cmpl $0x1, -0x34(%rbp)
jne 0x493ed
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movslq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $-0x1, (%rax)
jmp 0x492dc
cmpl $0x4, -0x34(%rbp)
jne 0x4941f
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movslq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $-0x1, (%rax)
jmp 0x492dc
cmpl $0x5, -0x34(%rbp)
je 0x4942b
cmpl $0x6, -0x34(%rbp)
jne 0x49449
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq $-0x1, (%rax)
jmp 0x492dc
movl -0x34(%rbp), %ecx
movl $0x1, %edi
leaq 0xa9a07(%rip), %rsi     # 0xf2e5f
leaq 0xa99ec(%rip), %rdx     # 0xf2e4b
movb $0x0, %al
callq 0x1b030
movl $0xfffffffe, -0x4(%rbp) # imm = 0xFFFFFFFE
jmp 0x4948c
movq -0x28(%rbp), %rax
movq $-0x1, (%rax)
movq -0x30(%rbp), %rax
movq $-0x1, (%rax)
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop