// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/sam.c
// Function: aux_parse
static inline int aux_parse(char *start, char *end, bam1_t *b, int lenient,
                            khash_t(tag) *tag_whitelist) {
    int overflow = 0;
    int checkpoint;
    char logbuf[40];
    char *q = start, *p = end;

#define _parse_err(cond, ...)                   \
    do {                                        \
        if (cond) {                             \
            if (lenient) {                      \
                while (q < p && !isspace_c(*q))   \
                    q++;                        \
                while (q < p && isspace_c(*q))    \
                    q++;                        \
                b->l_data = checkpoint;         \
                goto loop;                      \
            } else {                            \
                hts_log_error(__VA_ARGS__);     \
                goto err_ret;                   \
            }                                   \
        }                                       \
    } while (0)

    while (q < p) loop: {
        char type;
        checkpoint = b->l_data;
        if (p - q < 5) {
            if (lenient) {
                break;
            } else {
                hts_log_error("Incomplete aux field");
                goto err_ret;
            }
        }
        _parse_err(q[0] < '!' || q[1] < '!', "invalid aux tag id");

        if (lenient && (q[2] | q[4]) != ':') {
            while (q < p && !isspace_c(*q))
                q++;
            while (q < p && isspace_c(*q))
                q++;
            continue;
        }

        if (tag_whitelist) {
            int tt = q[0]*256 + q[1];
            if (kh_get(tag, tag_whitelist, tt) == kh_end(tag_whitelist)) {
                while (q < p && *q != '\t')
                    q++;
                continue;
            }
        }

        // Copy over id
        if (possibly_expand_bam_data(b, 2) < 0) goto err_ret;
        memcpy(b->data + b->l_data, q, 2); b->l_data += 2;
        q += 3; type = *q++; ++q; // q points to value
        if (type != 'Z' && type != 'H') // the only zero length acceptable fields
            _parse_err(*q <= '\t', "incomplete aux field");

        // Ensure enough space for a double + type allocated.
        if (possibly_expand_bam_data(b, 16) < 0) goto err_ret;

        if (type == 'A' || type == 'a' || type == 'c' || type == 'C') {
            b->data[b->l_data++] = 'A';
            b->data[b->l_data++] = *q++;
        } else if (type == 'i' || type == 'I') {
            if (*q == '-') {
                int32_t x = hts_str2int(q, &q, 32, &overflow);
                if (x >= INT8_MIN) {
                    b->data[b->l_data++] = 'c';
                    b->data[b->l_data++] = x;
                } else if (x >= INT16_MIN) {
                    b->data[b->l_data++] = 's';
                    i16_to_le(x, b->data + b->l_data);
                    b->l_data += 2;
                } else {
                    b->data[b->l_data++] = 'i';
                    i32_to_le(x, b->data + b->l_data);
                    b->l_data += 4;
                }
            } else {
                uint32_t x = hts_str2uint(q, &q, 32, &overflow);
                if (x <= UINT8_MAX) {
                    b->data[b->l_data++] = 'C';
                    b->data[b->l_data++] = x;
                } else if (x <= UINT16_MAX) {
                    b->data[b->l_data++] = 'S';
                    u16_to_le(x, b->data + b->l_data);
                    b->l_data += 2;
                } else {
                    b->data[b->l_data++] = 'I';
                    u32_to_le(x, b->data + b->l_data);
                    b->l_data += 4;
                }
            }
        } else if (type == 'f') {
            b->data[b->l_data++] = 'f';
            float_to_le(strtod(q, &q), b->data + b->l_data);
            b->l_data += sizeof(float);
        } else if (type == 'd') {
            b->data[b->l_data++] = 'd';
            double_to_le(strtod(q, &q), b->data + b->l_data);
            b->l_data += sizeof(double);
        } else if (type == 'Z' || type == 'H') {
            char *end = strchr(q, '\t');
            if (!end) end = q + strlen(q);
            _parse_err(type == 'H' && ((end-q)&1) != 0,
                       "hex field does not have an even number of digits");
            b->data[b->l_data++] = type;
            if (possibly_expand_bam_data(b, end - q + 1) < 0) goto err_ret;
            memcpy(b->data + b->l_data, q, end - q);
            b->l_data += end - q;
            b->data[b->l_data++] = '\0';
            q = end;
        } else if (type == 'B') {
            type = *q++; // q points to the first ',' following the typing byte
            _parse_err(*q && *q != ',' && *q != '\t',
                       "B aux field type not followed by ','");

            if (sam_parse_B_vals(type, q, &q, b) < 0)
                goto err_ret;
        } else _parse_err(1, "unrecognized type %s", hts_strprint(logbuf, sizeof logbuf, '\'', &type, 1));

        while (*q > '\t') { q++; } // Skip any junk to next tab
        q++;
    }

    _parse_err(!lenient && overflow != 0, "numeric value out of allowed range");
#undef _parse_err

    return 0;

err_ret:
    return -2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r13
movl %ecx, %r14d
movq %rdx, %r15
movq %rsi, %r12
movq %rdi, %rbp
leaq 0x14(%rsp), %rax
andl $0x0, (%rax)
movq %rsp, %rax
movq %rdi, (%rax)
movl %ecx, 0x10(%rsp)
cmpq %r12, %rbp
jae 0x2299b
movq %r12, %rax
subq %rbp, %rax
cmpq $0x4, %rax
jle 0x22958
movsbl (%rbp), %esi
cmpl $0x21, %esi
jl 0x223ed
movsbl 0x1(%rbp), %eax
cmpl $0x20, %eax
jg 0x2242c
testl %r14d, %r14d
je 0x22961
cmpq %r12, %rbp
jae 0x22418
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22418
incq %rbp
movq %rbp, (%rsp)
jmp 0x223f6
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x223cb
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22411
jmp 0x223cb
movl 0x40(%r15), %ebx
testl %r14d, %r14d
je 0x22444
movb 0x4(%rbp), %cl
orb 0x2(%rbp), %cl
cmpb $0x3a, %cl
jne 0x226c1
testq %r13, %r13
je 0x22460
shll $0x8, %esi
orl %eax, %esi
movq %r13, %rdi
callq 0x245e4
cmpl (%r13), %eax
je 0x226fe
movq %r15, %rdi
pushq $0x2
popq %rsi
callq 0x2200f
testl %eax, %eax
js 0x22989
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
movq (%rsp), %rdx
movzwl (%rdx), %edx
movw %dx, (%rax,%rcx)
addl $0x2, 0x40(%r15)
movq (%rsp), %rbp
leaq 0x4(%rbp), %rax
movq %rax, (%rsp)
movzbl 0x3(%rbp), %r14d
addq $0x5, %rbp
movb %r14b, 0xf(%rsp)
movq %rbp, (%rsp)
cmpl $0x48, %r14d
je 0x22503
cmpl $0x5a, %r14d
je 0x22503
cmpb $0x9, (%rbp)
jg 0x22503
cmpl $0x0, 0x10(%rsp)
je 0x229ff
cmpq %r12, %rbp
jae 0x224e8
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x224e8
incq %rbp
movq %rbp, (%rsp)
jmp 0x224c6
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x226ac
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x224e1
jmp 0x226ac
movq %r15, %rdi
pushq $0x10
popq %rsi
callq 0x2200f
testl %eax, %eax
js 0x22989
leal -0x41(%r14), %eax
cmpl $0x22, %eax
ja 0x22533
movabsq $0x500000005, %rcx      # imm = 0x500000005
btq %rax, %rcx
jb 0x22712
movl %r14d, %eax
andb $-0x21, %al
cmpb $0x49, %al
je 0x22763
cmpl $0x42, %r14d
je 0x2263d
cmpl $0x48, %r14d
je 0x225b6
cmpl $0x5a, %r14d
je 0x225b6
cmpl $0x64, %r14d
je 0x228cf
cmpl $0x66, %r14d
je 0x22907
cmpl $0x0, 0x10(%rsp)
je 0x229c9
movq (%rsp), %rbp
cmpq %r12, %rbp
jae 0x2259b
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x2259b
incq %rbp
movq %rbp, (%rsp)
jmp 0x22579
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x226ac
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22594
jmp 0x226ac
movq %r13, 0x18(%rsp)
movq (%rsp), %rbp
movq %rbp, %rdi
pushq $0x9
popq %rsi
callq 0x4190
movq %rax, %r13
testq %rax, %rax
jne 0x225e0
movq %rbp, %rdi
callq 0x41d0
movq %rax, %r13
addq %rbp, %r13
cmpb $0x48, %r14b
jne 0x227a1
movl %r13d, %eax
subl %ebp, %eax
testb $0x1, %al
je 0x227a1
cmpl $0x0, 0x10(%rsp)
je 0x229b9
movq 0x18(%rsp), %r13
cmpq %r12, %rbp
jae 0x22629
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22629
incq %rbp
movq %rbp, (%rsp)
jmp 0x22607
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x226ac
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22622
jmp 0x226ac
movq (%rsp), %rcx
leaq 0x1(%rcx), %rbp
movq %rbp, (%rsp)
movb (%rcx), %al
movb %al, 0xf(%rsp)
movzbl 0x1(%rcx), %ecx
cmpq $0x2c, %rcx
ja 0x2266d
movabsq $0x100000000201, %rdx   # imm = 0x100000000201
btq %rcx, %rdx
jb 0x22815
cmpl $0x0, 0x10(%rsp)
je 0x22a12
cmpq %r12, %rbp
jae 0x2269a
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x2269a
incq %rbp
movq %rbp, (%rsp)
jmp 0x22678
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x226ac
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x22693
movl %ebx, 0x40(%r15)
movl 0x10(%rsp), %r14d
jmp 0x223cb
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x226dc
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
je 0x226ba
jmp 0x226dc
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x223c2
movsbl (%rbp), %edi
callq 0x28b20
testl %eax, %eax
jne 0x226d5
jmp 0x223c2
incq %rbp
movq %rbp, (%rsp)
cmpq %r12, %rbp
jae 0x223c2
cmpb $0x9, (%rbp)
jne 0x226f7
jmp 0x223c2
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%r15)
movb $0x41, (%rax,%rcx)
movq (%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%rsp)
movb (%rax), %al
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x40(%r15)
movb %al, (%rcx,%rdx)
movq (%rsp), %rax
movl 0x10(%rsp), %r14d
leaq 0x1(%rax), %rbp
cmpb $0x9, (%rax)
movq %rbp, (%rsp)
movq %rbp, %rax
jg 0x2274e
jmp 0x223c2
movq (%rsp), %rdi
cmpb $0x2d, (%rdi)
jne 0x2283f
movq %rsp, %rsi
pushq $0x20
popq %rdx
leaq 0x14(%rsp), %rcx
callq 0x22273
cmpl $-0x80, %eax
jl 0x22880
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x40(%r15)
movb $0x63, (%rcx,%rdx)
jmp 0x22869
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%r15)
movb %r14b, (%rax,%rcx)
movq %r13, %rsi
subq (%rsp), %rsi
incq %rsi
movq %r15, %rdi
callq 0x2200f
testl %eax, %eax
js 0x22989
movslq 0x40(%r15), %rdi
addq 0x38(%r15), %rdi
movq (%rsp), %rsi
movq %r13, %rdx
subq %rsi, %rdx
callq 0x43c0
movl (%rsp), %eax
movl %r13d, %ecx
subl %eax, %ecx
movl 0x40(%r15), %eax
leal (%rax,%rcx), %edx
movq 0x38(%r15), %rsi
addl %ecx, %eax
incl %eax
movl %eax, 0x40(%r15)
movslq %edx, %rax
movb $0x0, (%rsi,%rax)
movq %r13, (%rsp)
movq 0x18(%rsp), %r13
jmp 0x22745
andl $0x0, 0x20(%rsp)
movsbl %al, %edi
xorl %esi, %esi
movq %rbp, %rdx
movq %rsp, %rcx
movq %r15, %r8
leaq 0x20(%rsp), %r9
callq 0x28b40
testl %eax, %eax
jns 0x22745
jmp 0x22989
movq %rsp, %rsi
pushq $0x20
popq %rdx
leaq 0x14(%rsp), %rcx
callq 0x2204d
cmpl $0xff, %eax
ja 0x228a0
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x40(%r15)
movb $0x43, (%rcx,%rdx)
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
leal 0x1(%rdx), %esi
movl %esi, 0x40(%r15)
movb %al, (%rcx,%rdx)
jmp 0x22745
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %esi
movq 0x38(%r15), %rdx
movl %esi, 0x40(%r15)
cmpl $0xffff8000, %eax       # imm = 0xFFFF8000
jb 0x22939
movb $0x73, (%rdx,%rcx)
jmp 0x228be
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %esi
movq 0x38(%r15), %rdx
movl %esi, 0x40(%r15)
cmpl $0xffff, %eax           # imm = 0xFFFF
ja 0x2293f
movb $0x53, (%rdx,%rcx)
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
movw %ax, (%rcx,%rdx)
leal 0x2(%rdx), %eax
jmp 0x228fe
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%r15)
movb $0x64, (%rax,%rcx)
movq (%rsp), %rdi
movq %rsp, %rsi
callq 0x4350
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
movsd %xmm0, (%rax,%rcx)
leal 0x8(%rcx), %eax
movl %eax, 0x40(%r15)
jmp 0x22745
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
leal 0x1(%rcx), %edx
movl %edx, 0x40(%r15)
movb $0x66, (%rax,%rcx)
movq (%rsp), %rdi
movq %rsp, %rsi
callq 0x4350
cvtsd2ss %xmm0, %xmm0
movq 0x38(%r15), %rax
movslq 0x40(%r15), %rcx
movss %xmm0, (%rax,%rcx)
jmp 0x2294e
movb $0x69, (%rdx,%rcx)
jmp 0x22943
movb $0x49, (%rdx,%rcx)
movq 0x38(%r15), %rcx
movslq 0x40(%r15), %rdx
movl %eax, (%rcx,%rdx)
addl $0x4, 0x40(%r15)
jmp 0x22745
testl %r14d, %r14d
je 0x22971
xorl %eax, %eax
jmp 0x2298c
leaq 0x57ad8(%rip), %rsi     # 0x7a440
leaq 0x57af0(%rip), %rdx     # 0x7a45f
jmp 0x2297f
leaq 0x57ac8(%rip), %rsi     # 0x7a440
leaq 0x57acb(%rip), %rdx     # 0x7a44a
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x110c6
pushq $-0x2
popq %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testl %r14d, %r14d
jne 0x2298c
cmpl $0x0, 0x14(%rsp)
je 0x2298c
leaq 0x57a90(%rip), %rsi     # 0x7a440
leaq 0x57b3b(%rip), %rdx     # 0x7a4f2
jmp 0x2297f
leaq 0x57a80(%rip), %rsi     # 0x7a440
leaq 0x57ac0(%rip), %rdx     # 0x7a487
jmp 0x2297f
leaq 0x20(%rsp), %rdi
pushq $0x28
popq %rsi
pushq $0x27
popq %rdx
leaq 0xf(%rsp), %rcx
pushq $0x1
popq %r8
callq 0x2b8d6
leaq 0x57a57(%rip), %rsi     # 0x7a440
leaq 0x57aed(%rip), %rdx     # 0x7a4dd
pushq $0x1
popq %rdi
movq %rax, %rcx
xorl %eax, %eax
callq 0x110c6
jmp 0x22989
leaq 0x57a3a(%rip), %rsi     # 0x7a440
leaq 0x57a65(%rip), %rdx     # 0x7a472
jmp 0x2297f
leaq 0x57a27(%rip), %rsi     # 0x7a440
leaq 0x57a98(%rip), %rdx     # 0x7a4b8
jmp 0x2297f