// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/cram/cram_decode.c
// Function: cram_decode_aux_1_0
static int cram_decode_aux_1_0(cram_container *c, cram_slice *s,
                               cram_block *blk, cram_record *cr) {
    int i, r = 0, out_sz = 1;
    unsigned char ntags;

    if (!c->comp_hdr->codecs[DS_TC]) return -1;
    r |= c->comp_hdr->codecs[DS_TC]->decode(s, c->comp_hdr->codecs[DS_TC], blk,
                                            (char *)&ntags, &out_sz);
    cr->ntags = ntags;

    //printf("TC=%d\n", cr->ntags);
    cr->aux_size = 0;
    cr->aux = BLOCK_SIZE(s->aux_blk);

    for (i = 0; i < cr->ntags; i++) {
        int32_t id, out_sz = 1;
        unsigned char tag_data[3];
        cram_map *m;

        //printf("Tag %d/%d\n", i+1, cr->ntags);
        if (!c->comp_hdr->codecs[DS_TN]) return -1;
        r |= c->comp_hdr->codecs[DS_TN]->decode(s, c->comp_hdr->codecs[DS_TN],
                                                blk, (char *)&id, &out_sz);
        if (out_sz == 3) {
            // Tag name stored as 3 chars instead of an int?
            memcpy(tag_data, &id, 3);
        } else {
            tag_data[0] = (id>>16) & 0xff;
            tag_data[1] = (id>>8)  & 0xff;
            tag_data[2] = id       & 0xff;
        }

        m = map_find(c->comp_hdr->tag_encoding_map, tag_data, id);
        if (!m)
            return -1;
        BLOCK_APPEND(s->aux_blk, (char *)tag_data, 3);

        if (!m->codec) return -1;
        r |= m->codec->decode(s, m->codec, blk, (char *)s->aux_blk, &out_sz);

        cr->aux_size += out_sz + 3;
    }

    return r;

 block_err:
    return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r12
movl $0x1, 0x1c(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x48(%rdi), %rax
movq 0x3e0(%rax), %rsi
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %rsi, %rsi
je 0x3a79e
movq %rcx, %rbx
movq %rdx, %r14
leaq 0xf(%rsp), %r13
leaq 0x1c(%rsp), %r8
movq %r12, %rdi
movq %r13, %rcx
callq *0x28(%rsi)
movl %eax, %ebp
movzbl (%r13), %eax
movl %eax, 0x50(%rbx)
movl $0x0, 0x58(%rbx)
movq 0x90(%r12), %rcx
movl 0x30(%rcx), %ecx
movl %ecx, 0x54(%rbx)
testl %eax, %eax
je 0x3a79e
xorl %eax, %eax
movq %rbx, 0x30(%rsp)
movq %r14, 0x20(%rsp)
movl %eax, 0x18(%rsp)
movl $0x1, 0x8(%rsp)
movq 0x28(%rsp), %rax
movq 0x48(%rax), %rax
movq 0x3b8(%rax), %rsi
testq %rsi, %rsi
je 0x3a799
movq %r12, %rdi
movq 0x20(%rsp), %rdx
leaq 0x4(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq *0x28(%rsi)
movl %eax, %edi
cmpl $0x3, 0x8(%rsp)
jne 0x3a67e
movb 0x4(%rsp), %r8b
movb 0x5(%rsp), %r14b
movb 0x6(%rsp), %r9b
movl 0x4(%rsp), %eax
jmp 0x3a693
movl 0x4(%rsp), %eax
movl %eax, %r8d
shrl $0x10, %r8d
movl %eax, %r14d
shrl $0x8, %r14d
movl %eax, %r9d
movq 0x28(%rsp), %rcx
movq 0x48(%rcx), %rcx
movzbl %r8b, %edx
leal (%rdx,%rdx,2), %edx
movzbl %r14b, %esi
addl %edx, %esi
andl $0x1f, %esi
movq 0x180(%rcx,%rsi,8), %rbx
testq %rbx, %rbx
je 0x3a799
cmpl %eax, (%rbx)
je 0x3a6c7
movq 0x18(%rbx), %rbx
jmp 0x3a6b4
movq 0x90(%r12), %r15
movq 0x28(%r15), %rax
movq 0x30(%r15), %rcx
leaq 0x3(%rcx), %r13
cmpq %r13, %rax
jbe 0x3a6e6
movq 0x20(%r15), %rax
jmp 0x3a73a
leaq 0x320(%rax), %rcx
shrq $0x2, %rcx
addq %rcx, %rax
addq $0x320, %rax            # imm = 0x320
cmpq %r13, %rax
cmovaq %rax, %r13
movl %edi, 0x14(%rsp)
movq 0x20(%r15), %rdi
movq %r13, %rsi
movl %r8d, 0x10(%rsp)
movb %r9b, 0x3(%rsp)
callq 0x4840
movb 0x3(%rsp), %r9b
movl 0x10(%rsp), %r8d
movl 0x14(%rsp), %edi
testq %rax, %rax
je 0x3a799
movq %r13, 0x28(%r15)
movq %rax, 0x20(%r15)
movq 0x30(%r15), %rcx
movb %r8b, (%rax,%rcx)
movb %r14b, 0x1(%rax,%rcx)
movb %r9b, 0x2(%rax,%rcx)
addq $0x3, 0x30(%r15)
movq 0x10(%rbx), %rsi
testq %rsi, %rsi
je 0x3a799
movq 0x90(%r12), %rcx
movl %edi, %ebx
movq %r12, %rdi
movq 0x20(%rsp), %rdx
leaq 0x8(%rsp), %r8
callq *0x28(%rsi)
orl %ebx, %ebp
orl %eax, %ebp
movl 0x8(%rsp), %eax
movq 0x30(%rsp), %rbx
movl 0x58(%rbx), %ecx
addl %ecx, %eax
addl $0x3, %eax
movl %eax, 0x58(%rbx)
movl 0x18(%rsp), %eax
incl %eax
cmpl 0x50(%rbx), %eax
jl 0x3a626
jmp 0x3a79e
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq