// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/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_data[0] = ((char *)&id)[0];
	    tag_data[1] = ((char *)&id)[1];
	    tag_data[2] = ((char *)&id)[2];
	} 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;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
movl $0x1, 0x34(%rsp)
movq 0x40(%rdi), %rax
movq 0x3e0(%rax), %rsi
testq %rsi, %rsi
je 0x797f8
movq %rcx, %rbx
movq %rdx, %r12
movq %rdi, %rbp
leaq 0x13(%rsp), %r13
leaq 0x34(%rsp), %r8
movq %r15, %rdi
movq %r13, %rcx
callq *0x18(%rsi)
movl %eax, %edx
movzbl (%r13), %eax
movl %eax, 0x38(%rbx)
movl $0x0, 0x40(%rbx)
movq 0x88(%r15), %rcx
movl 0x30(%rcx), %ecx
movl %ecx, 0x3c(%rbx)
testl %eax, %eax
jle 0x797fd
xorl %r13d, %r13d
movq %rbx, 0x28(%rsp)
movq %r12, 0x20(%rsp)
movq %rbp, 0x18(%rsp)
movl $0x1, 0xc(%rsp)
movq 0x40(%rbp), %rax
movq 0x3b8(%rax), %rsi
testq %rsi, %rsi
je 0x79666
movl %edx, %r14d
movq %r15, %rdi
movq %r12, %rdx
leaq 0x8(%rsp), %rcx
leaq 0xc(%rsp), %r8
callq *0x18(%rsi)
cmpl $0x3, 0xc(%rsp)
jne 0x7966d
movb 0x8(%rsp), %bl
movb 0x9(%rsp), %r12b
movb 0xa(%rsp), %dil
jmp 0x7967d
xorl %eax, %eax
jmp 0x797e5
movl 0x8(%rsp), %edi
movl %edi, %ebx
shrl $0x10, %ebx
movl %edi, %r12d
shrl $0x8, %r12d
movq 0x40(%rbp), %rcx
movzbl %bl, %edx
leal (%rdx,%rdx,2), %edx
movzbl %r12b, %esi
addl %edx, %esi
andl $0x1f, %esi
movq 0x180(%rcx,%rsi,8), %rbp
testq %rbp, %rbp
movq 0x1296d(%rip), %xmm1    # 0x8c010
je 0x796c2
movl 0x8(%rsp), %ecx
movl %r14d, %edx
movl $0x400, %r14d           # imm = 0x400
cmpl %ecx, (%rbp)
je 0x796cb
movq 0x18(%rbp), %rbp
testq %rbp, %rbp
jne 0x796b2
jmp 0x796cb
movl %r14d, %edx
movl $0x400, %r14d           # imm = 0x400
orl %eax, %edx
testq %rbp, %rbp
je 0x797bd
movl %edi, 0x30(%rsp)
movl %edx, 0x14(%rsp)
movq 0x88(%r15), %rcx
movq 0x28(%rcx), %rax
movq 0x30(%rcx), %rdx
leaq 0x3(%rdx), %rsi
cmpq %rsi, %rax
ja 0x79763
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd 0x12919(%rip), %xmm0    # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x170dd(%rip), %xmm1    # 0x907f8
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
subsd 0x1e9ed(%rip), %xmm1    # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%rcx)
movq 0x20(%rcx), %rdi
callq 0x6c80
movq 0x128ba(%rip), %xmm1    # 0x8c010
movq 0x88(%r15), %rcx
movq %rax, 0x20(%rcx)
jmp 0x796e5
movq 0x20(%rcx), %rax
movb %bl, (%rax,%rdx)
movb %r12b, 0x1(%rax,%rdx)
movl 0x30(%rsp), %ecx
movb %cl, 0x2(%rax,%rdx)
movq 0x88(%r15), %rcx
addq $0x3, 0x30(%rcx)
movq 0x10(%rbp), %rsi
testq %rsi, %rsi
je 0x797d0
movq %r15, %rdi
movq 0x20(%rsp), %r12
movq %r12, %rdx
leaq 0xc(%rsp), %r8
callq *0x18(%rsi)
movl 0x14(%rsp), %edx
orl %eax, %edx
movl 0xc(%rsp), %eax
movq 0x28(%rsp), %rbx
movl 0x40(%rbx), %ecx
addl %ecx, %eax
addl $0x3, %eax
movl %eax, 0x40(%rbx)
movb $0x1, %al
jmp 0x797c9
xorl %eax, %eax
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rbp
jmp 0x797e5
xorl %eax, %eax
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rbp
movl 0x14(%rsp), %edx
testb %al, %al
je 0x797f8
incl %r13d
cmpl 0x38(%rbx), %r13d
jl 0x79621
jmp 0x797fd
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq