// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/cram/cram_decode.c
// Function: cram_decode_TD
int cram_decode_TD(char *cp, const char *endp, cram_block_compression_hdr *h) {
    char *op = cp;
    unsigned char *dat;
    cram_block *b;
    int32_t blk_size = 0;
    int nTL, i, sz;

    if (!(b = cram_new_block(0, 0)))
	return -1;

    /* Decode */
    cp += safe_itf8_get(cp, endp, &blk_size);
    if (!blk_size) {
	h->nTL = 0;
	h->TL = NULL;
	cram_free_block(b);
	return cp - op;
    }

    if (blk_size < 0 || endp - cp < blk_size) {
        cram_free_block(b);
	return -1;
    }

    BLOCK_APPEND(b, cp, blk_size);
    cp += blk_size;
    sz = cp - op;
    // Force nul termination if missing
    if (BLOCK_DATA(b)[BLOCK_SIZE(b)-1])
	BLOCK_APPEND_CHAR(b, '\0');

    /* Set up TL lookup table */
    dat = BLOCK_DATA(b);

    // Count
    for (nTL = i = 0; i < BLOCK_SIZE(b); i++) {
	nTL++;
	while (dat[i])
	    i++;
    }

    // Copy
    h->nTL = nTL;
    if (!(h->TL = calloc(h->nTL, sizeof(unsigned char *)))) {
        cram_free_block(b);
        return -1;
    }
    for (nTL = i = 0; i < BLOCK_SIZE(b); i++) {
	h->TL[nTL++] = &dat[i];
	while (dat[i])
	    i++;
    }
    h->TD_blk = b;
    
    return sz;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r15
xorl %edi, %edi
xorl %esi, %esi
callq 0x55f07
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x74f5e
movq %rbp, %rcx
subq %r15, %rcx
cmpq $0x4, %rcx
jg 0x74ce6
xorl %eax, %eax
cmpq %rbp, %r15
jae 0x74d11
movzbl (%r15), %edx
shrl $0x4, %edx
leaq 0x23dd9(%rip), %rsi     # 0x98ab0
movslq (%rsi,%rdx,4), %rdx
movl $0x0, %r12d
cmpq %rdx, %rcx
jl 0x74d14
movzbl (%r15), %eax
movl $0x1, %r12d
testb %al, %al
jns 0x74d14
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %al
ja 0x74ece
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %r12d
jmp 0x74d14
xorl %r12d, %r12d
testl %eax, %eax
je 0x74eaf
js 0x74f51
movl %r12d, %ecx
addq %r15, %rcx
subq %rcx, %rbp
movl %eax, %r13d
cmpq %r13, %rbp
jl 0x74f51
movq %rcx, (%rsp)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rdi
leaq (%rdi,%r13), %rcx
cmpq %rcx, %rax
ja 0x74dc3
movl $0x400, %r12d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x172b1(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x172b9(%rip), %xmm0    # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1ba7d(%rip), %xmm1    # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x2338d(%rip), %xmm1    # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r12, %rsi
movq %rsi, 0x28(%r14)
movq 0x20(%r14), %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rdi
leaq (%rdi,%r13), %rcx
cmpq %rcx, %rax
jbe 0x74d52
addq 0x20(%r14), %rdi
movq (%rsp), %rsi
movq %r13, %rdx
callq 0x6570
movq 0x30(%r14), %rax
addq %r13, %rax
movq %rax, 0x30(%r14)
movq 0x20(%r14), %rcx
cmpb $0x0, -0x1(%rcx,%rax)
je 0x74e81
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
ja 0x74e75
movl $0x400, %r12d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x171ff(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x17207(%rip), %xmm0    # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1b9cb(%rip), %xmm1    # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x232db(%rip), %xmm1    # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r12, %rsi
movq %rsi, 0x28(%r14)
movq 0x20(%r14), %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
leaq 0x1(%rcx), %rdx
cmpq %rdx, %rax
jbe 0x74e04
movq 0x20(%r14), %rax
movq %rdx, 0x30(%r14)
movb $0x0, (%rax,%rcx)
movq 0x20(%r14), %rbp
movq 0x30(%r14), %r12
testq %r12, %r12
je 0x74ef3
xorl %ecx, %ecx
xorl %eax, %eax
movslq %ecx, %rdx
addq %rbp, %rdx
incl %ecx
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x74e98
incl %eax
movslq %ecx, %rdx
cmpq %rdx, %r12
ja 0x74e92
jmp 0x74ef5
movl $0x0, 0x58(%rbx)
movq $0x0, 0x60(%rbx)
movq %r14, %rdi
callq 0x567c0
movl %r12d, %eax
jmp 0x74f5e
cmpb $-0x21, %al
ja 0x74f6d
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %r12d
jmp 0x74d14
xorl %eax, %eax
movl %eax, 0x58(%rbx)
movl %eax, %edi
movl $0x8, %esi
callq 0x6470
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x74f51
movq (%rsp), %rdi
addl %r13d, %edi
testq %r12, %r12
je 0x74f46
xorl %eax, %eax
xorl %edx, %edx
xorl %ecx, %ecx
addq %rbp, %rdx
movq 0x60(%rbx), %rsi
movq %rdx, (%rsi,%rax,8)
movslq %ecx, %rdx
addq %rbp, %rdx
incl %ecx
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x74f30
incq %rax
movslq %ecx, %rdx
cmpq %rdx, %r12
ja 0x74f1f
subl %r15d, %edi
movq %r14, 0x50(%rbx)
movl %edi, %eax
jmp 0x74f5e
movq %r14, %rdi
callq 0x567c0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $-0x11, %al
ja 0x74f98
shll $0x10, %ecx
movzbl 0x2(%r15), %edx
shll $0x8, %edx
movzbl 0x3(%r15), %esi
andl $0xf, %eax
shll $0x18, %eax
orl %ecx, %eax
orl %edx, %eax
orl %esi, %eax
movl $0x4, %r12d
jmp 0x74d14
shll $0x1c, %eax
shll $0x14, %ecx
orl %eax, %ecx
movzbl 0x2(%r15), %eax
shll $0xc, %eax
orl %ecx, %eax
movzbl 0x3(%r15), %ecx
shll $0x4, %ecx
orl %eax, %ecx
movzbl 0x4(%r15), %eax
andl $0xf, %eax
orl %ecx, %eax
movl $0x5, %r12d
jmp 0x74d14