// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/sam.c
// Function: cigar_iref2iseq_set
static inline int cigar_iref2iseq_set(uint32_t **cigar, uint32_t *cigar_max, int *icig, int *iseq, int *iref)
{
    int pos = *iref;
    if ( pos < 0 ) return -1;
    *icig = 0;
    *iseq = 0;
    *iref = 0;
    while ( *cigar<cigar_max )
    {
        int cig  = (**cigar) & BAM_CIGAR_MASK;
        int ncig = (**cigar) >> BAM_CIGAR_SHIFT;

        if ( cig==BAM_CSOFT_CLIP ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
        if ( cig==BAM_CHARD_CLIP || cig==BAM_CPAD ) { (*cigar)++; *icig = 0; continue; }
        if ( cig==BAM_CMATCH || cig==BAM_CEQUAL || cig==BAM_CDIFF )
        {
            pos -= ncig;
            if ( pos < 0 ) { *icig = ncig + pos; *iseq += *icig; *iref += *icig; return BAM_CMATCH; }
            (*cigar)++; *iseq += ncig; *icig = 0; *iref += ncig;
            continue;
        }
        if ( cig==BAM_CINS ) { (*cigar)++; *iseq += ncig; *icig = 0; continue; }
        if ( cig==BAM_CDEL || cig==BAM_CREF_SKIP )
        {
            pos -= ncig;
            if ( pos<0 ) pos = 0;
            (*cigar)++; *icig = 0; *iref += ncig;
            continue;
        }
        fprintf(stderr,"todo: cigar %d\n", cig);
        assert(0);
    }
    *iseq = -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 -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0xae857
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaea44
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movq (%rax), %rax
cmpq -0x18(%rbp), %rax
jae 0xaea33
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
andl $0xf, %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movl (%rax), %eax
shrl $0x4, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x4, -0x38(%rbp)
jne 0xae8cf
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xae875
cmpl $0x5, -0x38(%rbp)
je 0xae8db
cmpl $0x6, -0x38(%rbp)
jne 0xae8f5
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xae875
cmpl $0x0, -0x38(%rbp)
je 0xae907
cmpl $0x7, -0x38(%rbp)
je 0xae907
cmpl $0x8, -0x38(%rbp)
jne 0xae97f
movl -0x3c(%rbp), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0xae94c
movl -0x3c(%rbp), %ecx
addl -0x34(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0xaea44
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0xae875
cmpl $0x1, -0x38(%rbp)
jne 0xae9ad
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x28(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xae875
cmpl $0x2, -0x38(%rbp)
je 0xae9b9
cmpl $0x3, -0x38(%rbp)
jne 0xae9f9
movl -0x3c(%rbp), %ecx
movl -0x34(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0xae9d1
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
addq $0x4, %rcx
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x30(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0xae875
movq 0x565d0(%rip), %rax     # 0x104fd0
movq (%rax), %rdi
movl -0x38(%rbp), %edx
leaq 0x35f98(%rip), %rsi     # 0xe49a5
movb $0x0, %al
callq 0x6a80
leaq 0x2ed60(%rip), %rdi     # 0xdd77b
leaq 0x35ef4(%rip), %rsi     # 0xe4916
movl $0x6a1, %edx            # imm = 0x6A1
leaq 0x35f87(%rip), %rcx     # 0xe49b5
callq 0x6450
movq -0x28(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)