// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x21265
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 0x2126a
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 0x210d3
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 0x210da
movb 0x8(%rsp), %bl
movb 0x9(%rsp), %r12b
movb 0xa(%rsp), %dil
jmp 0x210ea
xorl %eax, %eax
jmp 0x21252
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 0x31820(%rip), %xmm1    # 0x52930
je 0x2112f
movl 0x8(%rsp), %ecx
movl %r14d, %edx
movl $0x400, %r14d           # imm = 0x400
cmpl %ecx, (%rbp)
je 0x21138
movq 0x18(%rbp), %rbp
testq %rbp, %rbp
jne 0x2111f
jmp 0x21138
movl %r14d, %edx
movl $0x400, %r14d           # imm = 0x400
orl %eax, %edx
testq %rbp, %rbp
je 0x2122a
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 0x211d0
movq %rax, %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd 0x317cc(%rip), %xmm0    # 0x52940
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x32880(%rip), %xmm1    # 0x53a08
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
subsd 0x31770(%rip), %xmm1    # 0x52908
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 0x48d0
movq 0x3176d(%rip), %xmm1    # 0x52930
movq 0x88(%r15), %rcx
movq %rax, 0x20(%rcx)
jmp 0x21152
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 0x2123d
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 0x21236
xorl %eax, %eax
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rbp
jmp 0x21252
xorl %eax, %eax
movq 0x28(%rsp), %rbx
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %rbp
movl 0x14(%rsp), %edx
testb %al, %al
je 0x21265
incl %r13d
cmpl 0x38(%rbx), %r13d
jl 0x2108e
jmp 0x2126a
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq