// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/sam.c
// Function: sam_parse_B_vals_r
HTS_ALIGN32
static int sam_parse_B_vals_r(char type, uint32_t nalloc, char *in,
                              char **end, bam1_t *b,
                              int *ctr) {
    // Protect against infinite recursion when dealing with invalid input.
    // An example string is "XX:B:C,-".  The lack of a number means min=0,
    // but it overflowed due to "-" and so we repeat ad-infinitum.
    //
    // Loop detection is the safest solution incase there are other
    // strange corner cases with malformed inputs.
    if (++(*ctr) > 2) {
        hts_log_error("Malformed data in B:%c array", type);
        return -1;
    }

    int orig_l = b->l_data;
    char *q = in;
    int32_t size;
    size_t bytes;
    int overflow = 0;

    size = aux_type2size(type);
    if (size <= 0 || size > 4) {
        hts_log_error("Unrecognized type B:%c", type);
        return -1;
    }

    // Ensure space for type + values.
    // The first pass through here we don't know the number of entries and
    // nalloc == 0.  We start with a small working set and then parse the
    // data, growing as needed.
    //
    // If we have a second pass through we do know the number of entries
    // and nalloc is already known.  We have no need to expand the bam data.
    if (!nalloc)
         nalloc=7;

    // Ensure allocated memory is big enough (for current nalloc estimate)
    bytes = (size_t) nalloc * (size_t) size;
    if (bytes / size != nalloc
        || possibly_expand_bam_data(b, bytes + 2 + sizeof(uint32_t))) {
        hts_log_error("Out of memory");
        return -1;
    }

    uint32_t nused = 0;

    b->data[b->l_data++] = 'B';
    b->data[b->l_data++] = type;
    // 32-bit B-array length is inserted later once we know it.
    int b_len_idx = b->l_data;
    b->l_data += sizeof(uint32_t);

    if (type == 'c') {
        if (!(q = sam_parse_Bc_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 'C') {
        if (!(q = sam_parse_BC_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 's') {
        if (!(q = sam_parse_Bs_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 'S') {
        if (!(q = sam_parse_BS_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 'i') {
        if (!(q = sam_parse_Bi_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 'I') {
        if (!(q = sam_parse_BI_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    } else if (type == 'f') {
        if (!(q = sam_parse_Bf_vals(b, q, &nused, &nalloc, &overflow)))
            return -1;
    }
    if (*q != '\t' && *q != '\0') {
        // Unknown B array type or junk in the numbers
        hts_log_error("Malformed B:%c", type);
        return -1;
    }
    i32_to_le(nused, b->data + b_len_idx);

    if (!overflow) {
        *end = q;
        return 0;
    } else {
        int64_t max = 0, min = 0, val;
        // Given type was incorrect.  Try to rescue the situation.
        char *r = q;
        q = in;
        overflow = 0;
        b->l_data = orig_l;
        // Find out what range of values is present
        while (q < r) {
            val = hts_str2int(q + 1, &q, 64, &overflow);
            if (max < val) max = val;
            if (min > val) min = val;
            skip_to_comma_(q);
        }
        // Retry with appropriate type
        if (!overflow) {
            if (min < 0) {
                if (min >= INT8_MIN && max <= INT8_MAX) {
                    return sam_parse_B_vals_r('c', nalloc, in, end, b, ctr);
                } else if (min >= INT16_MIN && max <= INT16_MAX) {
                    return sam_parse_B_vals_r('s', nalloc, in, end, b, ctr);
                } else if (min >= INT32_MIN && max <= INT32_MAX) {
                    return sam_parse_B_vals_r('i', nalloc, in, end, b, ctr);
                }
            } else {
                if (max < UINT8_MAX) {
                    return sam_parse_B_vals_r('C', nalloc, in, end, b, ctr);
                } else if (max <= UINT16_MAX) {
                    return sam_parse_B_vals_r('S', nalloc, in, end, b, ctr);
                } else if (max <= UINT32_MAX) {
                    return sam_parse_B_vals_r('I', nalloc, in, end, b, ctr);
                }
            }
        }
        // If here then at least one of the values is too big to store
        hts_log_error("Numeric value in B array out of allowed range");
        return -1;
    }
#undef skip_to_comma_
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %dil, %al
movb %al, -0x5(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movl (%rcx), %eax
addl $0x1, %eax
movl %eax, (%rcx)
cmpl $0x2, %eax
jle 0x45cfe
movsbl -0x5(%rbp), %ecx
movl $0x1, %edi
leaq 0xacdfc(%rip), %rsi     # 0xf2ae0
leaq 0xace08(%rip), %rdx     # 0xf2af3
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
movq -0x28(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x54(%rbp)
movzbl -0x5(%rbp), %edi
callq 0x41940
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jle 0x45d2f
cmpl $0x4, -0x44(%rbp)
jle 0x45d59
movsbl -0x5(%rbp), %ecx
movl $0x1, %edi
leaq 0xacda1(%rip), %rsi     # 0xf2ae0
leaq 0xacdca(%rip), %rdx     # 0xf2b10
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
cmpl $0x0, -0xc(%rbp)
jne 0x45d66
movl $0x7, -0xc(%rbp)
movl -0xc(%rbp), %eax
movslq -0x44(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl -0xc(%rbp), %ecx
cmpq %rcx, %rax
jne 0x45da4
movq -0x28(%rbp), %rdi
movq -0x50(%rbp), %rsi
addq $0x2, %rsi
addq $0x4, %rsi
callq 0x3a350
cmpl $0x0, %eax
je 0x45dca
movl $0x1, %edi
leaq 0xacd30(%rip), %rsi     # 0xf2ae0
leaq 0xabdf9(%rip), %rdx     # 0xf1bb0
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
movl $0x0, -0x58(%rbp)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x28(%rbp), %rdx
movl 0x40(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0x40(%rdx)
movslq %ecx, %rcx
movb $0x42, (%rax,%rcx)
movb -0x5(%rbp), %dl
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x28(%rbp), %rsi
movl 0x40(%rsi), %ecx
movl %ecx, %edi
addl $0x1, %edi
movl %edi, 0x40(%rsi)
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movq -0x28(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x5c(%rbp)
movq -0x28(%rbp), %rax
movslq 0x40(%rax), %rcx
addq $0x4, %rcx
movl %ecx, 0x40(%rax)
movsbl -0x5(%rbp), %eax
cmpl $0x63, %eax
jne 0x45e65
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x462a0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45e60
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fd6
movsbl -0x5(%rbp), %eax
cmpl $0x43, %eax
jne 0x45ea2
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46360
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45e9d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fd4
movsbl -0x5(%rbp), %eax
cmpl $0x73, %eax
jne 0x45edf
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46480
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45eda
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fd2
movsbl -0x5(%rbp), %eax
cmpl $0x53, %eax
jne 0x45f1c
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46540
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45f17
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fd0
movsbl -0x5(%rbp), %eax
cmpl $0x69, %eax
jne 0x45f56
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46680
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45f54
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fce
movsbl -0x5(%rbp), %eax
cmpl $0x49, %eax
jne 0x45f90
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46740
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45f8e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fcc
movsbl -0x5(%rbp), %eax
cmpl $0x66, %eax
jne 0x45fca
movq -0x28(%rbp), %rdi
movq -0x40(%rbp), %rsi
leaq -0x58(%rbp), %rdx
leaq -0xc(%rbp), %rcx
leaq -0x54(%rbp), %r8
callq 0x46880
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
jne 0x45fc8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
jmp 0x45fca
jmp 0x45fcc
jmp 0x45fce
jmp 0x45fd0
jmp 0x45fd2
jmp 0x45fd4
jmp 0x45fd6
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x9, %eax
je 0x46018
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x46018
movsbl -0x5(%rbp), %ecx
movl $0x1, %edi
leaq 0xacae2(%rip), %rsi     # 0xf2ae0
leaq 0xacb22(%rip), %rdx     # 0xf2b27
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x4628d
movl -0x58(%rbp), %edi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rsi
movslq -0x5c(%rbp), %rax
addq %rax, %rsi
callq 0x45b90
cmpl $0x0, -0x54(%rbp)
jne 0x4604c
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4628d
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x54(%rbp)
movl -0x34(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x40(%rax)
movq -0x40(%rbp), %rax
cmpq -0x80(%rbp), %rax
jae 0x46119
movq -0x40(%rbp), %rdi
addq $0x1, %rdi
leaq -0x40(%rbp), %rsi
movl $0x40, %edx
leaq -0x54(%rbp), %rcx
callq 0x3a890
movq %rax, -0x78(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x78(%rbp), %rax
jge 0x460bb
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rax
cmpq -0x78(%rbp), %rax
jle 0x460cd
movq -0x78(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x460cf
jmp 0x460d1
movq -0x40(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x9, %ecx
movb %al, -0x81(%rbp)
jle 0x460f8
movq -0x40(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2c, %eax
setne %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0x46104
jmp 0x46112
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x460d1
jmp 0x46114
jmp 0x4607d
cmpl $0x0, -0x54(%rbp)
jne 0x4626c
cmpq $0x0, -0x70(%rbp)
jge 0x461dc
cmpq $-0x80, -0x70(%rbp)
jl 0x46161
cmpq $0x7f, -0x68(%rbp)
jg 0x46161
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x63, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
cmpq $-0x8000, -0x70(%rbp)   # imm = 0x8000
jl 0x4619a
cmpq $0x7fff, -0x68(%rbp)    # imm = 0x7FFF
jg 0x4619a
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x73, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
cmpq $-0x80000000, -0x70(%rbp) # imm = 0x80000000
jl 0x461d3
cmpq $0x7fffffff, -0x68(%rbp) # imm = 0x7FFFFFFF
jg 0x461d3
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x69, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
jmp 0x461d5
jmp 0x461d7
jmp 0x4626a
cmpq $0xff, -0x68(%rbp)
jge 0x4620b
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x43, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
cmpq $0xffff, -0x68(%rbp)    # imm = 0xFFFF
jg 0x46237
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x53, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpq %rax, -0x68(%rbp)
jg 0x46264
movl -0xc(%rbp), %esi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %r8
movq -0x30(%rbp), %r9
movl $0x49, %edi
callq 0x45ca0
movl %eax, -0x4(%rbp)
jmp 0x4628d
jmp 0x46266
jmp 0x46268
jmp 0x4626a
jmp 0x4626c
movl $0x1, %edi
leaq 0xac868(%rip), %rsi     # 0xf2ae0
leaq 0xac8b7(%rip), %rdx     # 0xf2b36
movb $0x0, %al
callq 0x1b030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)