// File: /workspace/github_c_makefile_star2_O0/icebert[P]pblat/htslib/cram/cram_decode.c
// Function: cram_decode_aux
static int cram_decode_aux(cram_container *c, cram_slice *s,
			   cram_block *blk, cram_record *cr,
			   int *has_MD, int *has_NM) {
    int i, r = 0, out_sz = 1;
    int32_t TL = 0;
    unsigned char *TN;
    uint32_t ds = c->comp_hdr->data_series;
	    
    if (!(ds & (CRAM_TL|CRAM_aux))) {
	cr->aux = 0;
	cr->aux_size = 0;
	return 0;
    }

    if (!c->comp_hdr->codecs[DS_TL]) return -1;
    r |= c->comp_hdr->codecs[DS_TL]->decode(s, c->comp_hdr->codecs[DS_TL], blk,
					    (char *)&TL, &out_sz);
    if (r || TL < 0 || TL >= c->comp_hdr->nTL)
	return -1;

    TN = c->comp_hdr->TL[TL];
    cr->ntags = strlen((char *)TN)/3; // optimise to remove strlen

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

    if (!(ds & CRAM_aux))
	return 0;

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

	if (TN[0] == 'M' && TN[1] == 'D' && has_MD)
	    *has_MD = 1;
	if (TN[0] == 'N' && TN[1] == 'M' && has_NM)
	    *has_NM = 1;

	//printf("Tag %d/%d\n", i+1, cr->ntags);
	tag_data[0] = *TN++;
	tag_data[1] = *TN++;
	tag_data[2] = *TN++;
	id = (tag_data[0]<<16) | (tag_data[1]<<8) | tag_data[2];

	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);
	if (r) break;
	cr->aux_size += out_sz + 3;
    }
    
    return r;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x40(%rbp)
movl $0x1, -0x44(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movl 0x410(%rax), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %eax
andl $0x40004000, %eax       # imm = 0x40004000
cmpl $0x0, %eax
jne 0xb4775
movq -0x28(%rbp), %rax
movl $0x0, 0x3c(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x40(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xb4b22
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
cmpq $0x0, 0x380(%rax)
jne 0xb4793
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb4b22
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x380(%rax), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq 0x380(%rcx), %rsi
movq -0x20(%rbp), %rdx
leaq -0x48(%rbp), %rcx
leaq -0x44(%rbp), %r8
callq *%rax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
jne 0xb47e9
cmpl $0x0, -0x48(%rbp)
jl 0xb47e9
movl -0x48(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x40(%rcx), %rcx
cmpl 0x58(%rcx), %eax
jl 0xb47f5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb4b22
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x60(%rax), %rax
movslq -0x48(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x62c0
movl $0x3, %ecx
xorl %edx, %edx
divq %rcx
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x38(%rax)
movq -0x28(%rbp), %rax
movl $0x0, 0x40(%rax)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x30(%rax), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x3c(%rax)
movl -0x54(%rbp), %eax
andl $0x40000000, %eax       # imm = 0x40000000
cmpl $0x0, %eax
jne 0xb4865
movl $0x0, -0x4(%rbp)
jmp 0xb4b22
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x38(%rcx), %eax
jge 0xb4b1c
movl $0x1, -0x5c(%rbp)
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4d, %eax
jne 0xb48ad
movq -0x50(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x44, %eax
jne 0xb48ad
cmpq $0x0, -0x30(%rbp)
je 0xb48ad
movq -0x30(%rbp), %rax
movl $0x1, (%rax)
movq -0x50(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x4e, %eax
jne 0xb48d7
movq -0x50(%rbp), %rax
movzbl 0x1(%rax), %eax
cmpl $0x4d, %eax
jne 0xb48d7
cmpq $0x0, -0x38(%rbp)
je 0xb48d7
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movb (%rax), %al
movb %al, -0x5f(%rbp)
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movb (%rax), %al
movb %al, -0x5e(%rbp)
movq -0x50(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x50(%rbp)
movb (%rax), %al
movb %al, -0x5d(%rbp)
movzbl -0x5f(%rbp), %eax
shll $0x10, %eax
movzbl -0x5e(%rbp), %ecx
shll $0x8, %ecx
orl %ecx, %eax
movzbl -0x5d(%rbp), %ecx
orl %ecx, %eax
movl %eax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
addq $0x180, %rdi            # imm = 0x180
leaq -0x5f(%rbp), %rsi
movl -0x58(%rbp), %edx
callq 0xb9e20
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0xb495e
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb4b22
jmp 0xb4960
jmp 0xb4962
jmp 0xb4964
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x88(%rcx), %rcx
movq 0x30(%rcx), %rcx
addq $0x3, %rcx
cmpq %rcx, %rax
ja 0xb4a69
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0xb49e6
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x28(%rax), %xmm0
movaps 0x21668(%rip), %xmm1    # 0xd6020
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2166c(%rip), %xmm1    # 0xd6030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x25c95(%rip), %xmm1    # 0xda670
mulsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
jmp 0xb49f5
movsd 0x2e1ca(%rip), %xmm0    # 0xe2bb8
movsd %xmm0, -0x70(%rbp)
jmp 0xb49f5
movsd -0x70(%rbp), %xmm0
movsd 0x2d656(%rip), %xmm2    # 0xe2058
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x28(%rax), %rsi
callq 0x6c80
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq %rcx, 0x20(%rax)
jmp 0xb4964
jmp 0xb4a6b
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x88(%rcx), %rcx
movq 0x30(%rcx), %rcx
movw -0x5f(%rbp), %dx
movw %dx, (%rax,%rcx)
movb -0x5d(%rbp), %dl
movb %dl, 0x2(%rax,%rcx)
movq -0x18(%rbp), %rax
movq 0x88(%rax), %rax
movq 0x30(%rax), %rcx
addq $0x3, %rcx
movq %rcx, 0x30(%rax)
movq -0x68(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xb4ac3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xb4b22
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
movq -0x18(%rbp), %rdi
movq -0x68(%rbp), %rcx
movq 0x10(%rcx), %rsi
movq -0x20(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq 0x88(%rcx), %rcx
leaq -0x5c(%rbp), %r8
callq *%rax
orl -0x40(%rbp), %eax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x40(%rbp)
je 0xb4afe
jmp 0xb4b1c
movl -0x5c(%rbp), %ecx
addl $0x3, %ecx
movq -0x28(%rbp), %rax
addl 0x40(%rax), %ecx
movl %ecx, 0x40(%rax)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xb486c
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)