// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/sam.c
// Function: parse_cigar
static int parse_cigar(const char *in, uint32_t *a_cigar, uint32_t n_cigar) {
    int i, overflow = 0;
    const char *p = in;
    for (i = 0; i < n_cigar; i++) {
        uint32_t len;
        int op;
        char *q;
        len = hts_str2uint(p, &q, 28, &overflow)<<BAM_CIGAR_SHIFT;
        if (q == p) {
            hts_log_error("CIGAR length invalid at position %d (%s)", (int)(i+1), p);
            return 0;
        }
        if (overflow) {
            hts_log_error("CIGAR length too long at position %d (%.*s)", (int)(i+1), (int)(q-p+1), p);
            return 0;
        }
        p = q;
        op = bam_cigar_table[(unsigned char)*p++];
        if (op < 0) {
            hts_log_error("Unrecognized CIGAR operator");
            return 0;
        }
        a_cigar[i] = len;
        a_cigar[i] |= op;
    }

    return p-in;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r13
movq %rdi, 0x8(%rsp)
testl %edx, %edx
je 0x29bff
movl %edx, %ebp
xorl %r14d, %r14d
movq 0x8(%rsp), %r13
xorl %r12d, %r12d
xorl %eax, %eax
cmpb $0x2b, (%r13)
sete %al
leaq (%rax,%r13), %rbx
movb (%r13,%rax), %dil
leal -0x30(%rdi), %ecx
cmpb $0x9, %cl
ja 0x29ae4
leaq (%rax,%r13), %rdx
addq $0x8, %rdx
xorl %esi, %esi
xorl %eax, %eax
leaq (%rax,%rax,4), %rax
movzbl %dil, %ecx
leaq (%rcx,%rax,2), %rax
addq $-0x30, %rax
cmpl $0x7, %esi
setne %cl
je 0x29aea
movb 0x1(%rbx,%rsi), %dil
leal -0x30(%rdi), %r8d
incq %rsi
cmpb $0x9, %r8b
jbe 0x29ab5
addq %rsi, %rbx
jmp 0x29aed
movb $0x1, %cl
xorl %eax, %eax
jmp 0x29aed
movq %rdx, %rbx
testb %cl, %cl
jne 0x29b48
movzbl (%rbx), %ecx
leal -0x3a(%rcx), %edx
cmpl $-0xa, %edx
jb 0x29b48
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x29b48
cmpq $0x1999999, %rax        # imm = 0x1999999
jb 0x29b13
jne 0x29b2e
cmpl $0x6, %ecx
jae 0x29b2e
leaq (%rax,%rax,4), %rax
movl %ecx, %ecx
leaq (%rcx,%rax,2), %rax
movzbl 0x1(%rbx), %ecx
incq %rbx
addl $-0x30, %ecx
cmpl $0xa, %ecx
jb 0x29b04
jmp 0x29b48
movzbl 0x1(%rbx), %eax
incq %rbx
addl $-0x30, %eax
cmpl $0xa, %eax
jb 0x29b2e
movl $0xfffffff, %eax        # imm = 0xFFFFFFF
movl $0x1, %r12d
cmpq %r13, %rbx
je 0x29b80
testl %r12d, %r12d
je 0x29ba6
subl %r13d, %ebx
incl %ebx
leal 0x1(%r14), %ecx
xorl %r15d, %r15d
movl $0x1, %edi
leaq 0x7105e(%rip), %rsi     # 0x9abc8
leaq 0x71b36(%rip), %rdx     # 0x9b6a7
movl %ebx, %r8d
movq %r13, %r9
xorl %eax, %eax
callq 0x14378
jmp 0x29bee
leal 0x1(%r14), %ecx
xorl %r15d, %r15d
movl $0x1, %edi
leaq 0x71035(%rip), %rsi     # 0x9abc8
leaq 0x71ae4(%rip), %rdx     # 0x9b67e
movq %r13, %r8
xorl %eax, %eax
callq 0x14378
jmp 0x29bee
movzbl (%rbx), %ecx
incq %rbx
leaq 0x7084d(%rip), %rdx     # 0x9a400
movsbl (%rcx,%rdx), %ecx
testl %ecx, %ecx
js 0x29bce
shll $0x4, %eax
orl %ecx, %eax
movq 0x10(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
movb $0x1, %r15b
jmp 0x29beb
xorl %r15d, %r15d
movl $0x1, %edi
leaq 0x70feb(%rip), %rsi     # 0x9abc8
leaq 0x71aef(%rip), %rdx     # 0x9b6d3
xorl %eax, %eax
callq 0x14378
movq %rbx, %r13
testb %r15b, %r15b
je 0x29c06
incq %r14
cmpq %rbp, %r14
jne 0x29a8e
subl 0x8(%rsp), %r13d
jmp 0x29c09
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq