// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x1, -0x34(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x3e0(%rax)
jne 0x54524
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x54705
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x3e0(%rax), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq 0x3e0(%rcx), %rsi
movq -0x20(%rbp), %rdx
leaq -0x35(%rbp), %rcx
leaq -0x34(%rbp), %r8
callq *%rax
orl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movzbl -0x35(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x50(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x58(%rax)
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq 0x30(%rax), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x54(%rax)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x50(%rcx), %eax
jge 0x546f6
movl $0x1, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, 0x3b8(%rax)
jne 0x545c8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x54705
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x3b8(%rax), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x48(%rcx), %rcx
movq 0x3b8(%rcx), %rsi
movq -0x20(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
leaq -0x40(%rbp), %r8
callq *%rax
orl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpl $0x3, -0x40(%rbp)
jne 0x54618
movw -0x3c(%rbp), %ax
movw %ax, -0x43(%rbp)
movb -0x3a(%rbp), %al
movb %al, -0x41(%rbp)
jmp 0x5463f
movl -0x3c(%rbp), %eax
sarl $0x10, %eax
andl $0xff, %eax
movb %al, -0x43(%rbp)
movl -0x3c(%rbp), %eax
sarl $0x8, %eax
andl $0xff, %eax
movb %al, -0x42(%rbp)
movl -0x3c(%rbp), %eax
andl $0xff, %eax
movb %al, -0x41(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq -0x43(%rbp), %rsi
movl -0x3c(%rbp), %edx
callq 0x59df0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x54671
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x54705
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rdi
leaq -0x43(%rbp), %rsi
movl $0x3, %edx
callq 0x4eff0
cmpl $0x0, %eax
jge 0x54691
jmp 0x546fe
movq -0x50(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x546a5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x54705
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x50(%rbp), %rcx
movq 0x10(%rcx), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq 0x90(%rcx), %rcx
leaq -0x40(%rbp), %r8
callq *%rax
orl -0x30(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x40(%rbp), %ecx
addl $0x3, %ecx
movq -0x28(%rbp), %rax
addl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x54593
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x54705
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop