// File: /workspace/github_c_makefile_star2_O3/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
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r12
movq %rdi, %r15
xorl %edi, %edi
xorl %esi, %esi
callq 0x56309
movq %rax, %r14
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x74cb3
movq %r12, %rax
subq %r15, %rax
cmpq $0x5, %rax
jge 0x749e2
xorl %ebp, %ebp
cmpq %r12, %r15
jae 0x74c24
movzbl (%r15), %edx
movl %edx, %ecx
shrl $0x4, %ecx
leaq 0x241cc(%rip), %rsi     # 0x98ba0
movslq (%rsi,%rcx,4), %rcx
cmpq %rcx, %rax
jge 0x749e5
jmp 0x74c24
movb (%r15), %dl
movzbl %dl, %eax
movl $0x1, %ebp
testb %al, %al
jns 0x74a7f
movzbl 0x1(%r15), %ecx
cmpb $-0x41, %dl
ja 0x74a0e
andl $0x3f, %eax
shll $0x8, %eax
orl %ecx, %eax
movl $0x2, %ebp
jmp 0x74a7f
cmpb $-0x21, %dl
ja 0x74a2c
shll $0x8, %ecx
movzbl 0x2(%r15), %edx
andl $0x1f, %eax
shll $0x10, %eax
orl %ecx, %eax
orl %edx, %eax
movl $0x3, %ebp
jmp 0x74a7f
cmpb $-0x11, %dl
ja 0x74a54
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, %ebp
jmp 0x74a7f
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, %ebp
testl %eax, %eax
je 0x74c24
js 0x74ca6
movl %ebp, %ebp
addq %r15, %rbp
subq %rbp, %r12
movl %eax, %r13d
cmpq %r13, %r12
jl 0x74ca6
movq 0x20(%r14), %rax
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
leaq (%rdx,%r13), %rsi
cmpq %rsi, %rcx
ja 0x74b2c
movl $0x400, %r12d           # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x17547(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1754f(%rip), %xmm0    # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1be03(%rip), %xmm1    # 0x908e8
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0x236d7(%rip), %xmm1    # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %r12, %rsi
movq %rsi, 0x28(%r14)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
leaq (%rdx,%r13), %rsi
cmpq %rsi, %rcx
jbe 0x74abc
addq %rdx, %rax
movq %rax, %rdi
movq %rbp, 0x8(%rsp)
movq %rbp, %rsi
movq %r13, %rdx
callq 0x6570
movq 0x30(%r14), %rbp
addq %r13, %rbp
movq %rbp, 0x30(%r14)
movq 0x20(%r14), %r12
cmpb $0x0, -0x1(%r12,%rbp)
je 0x74bfe
movq %r15, 0x10(%rsp)
movq 0x28(%r14), %rax
leaq 0x1(%rbp), %rcx
cmpq %rcx, %rax
ja 0x74be8
movl $0x400, %r15d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x1748e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x17496(%rip), %xmm0    # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x1bd4a(%rip), %xmm1    # 0x908e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0x2361e(%rip), %xmm1    # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r15, %rsi
movq %rsi, 0x28(%r14)
movq %r12, %rdi
callq 0x6c80
movq %rax, %r12
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rbp
leaq 0x1(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x74b75
movq %rcx, 0x30(%r14)
movb $0x0, (%r12,%rbp)
movq 0x20(%r14), %r12
movq 0x30(%r14), %rbp
movq 0x10(%rsp), %r15
testq %rbp, %rbp
je 0x74c3f
xorl %ecx, %ecx
xorl %eax, %eax
movslq %ecx, %rdx
addq %r12, %rdx
incl %ecx
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x74c0d
incl %eax
movslq %ecx, %rdx
cmpq %rdx, %rbp
ja 0x74c07
jmp 0x74c41
movl $0x0, 0x58(%rbx)
movq $0x0, 0x60(%rbx)
movq %r14, %rdi
callq 0x56a50
movl %ebp, %eax
jmp 0x74cb3
xorl %eax, %eax
movl %eax, 0x58(%rbx)
movl %eax, %edi
movl $0x8, %esi
callq 0x6470
movq %rax, 0x60(%rbx)
testq %rax, %rax
je 0x74ca6
movq 0x8(%rsp), %rax
addl %r13d, %eax
movq %rax, 0x8(%rsp)
testq %rbp, %rbp
je 0x74c98
xorl %eax, %eax
xorl %edx, %edx
xorl %ecx, %ecx
addq %r12, %rdx
movq 0x60(%rbx), %rsi
movq %rdx, (%rsi,%rax,8)
movslq %ecx, %rdx
addq %r12, %rdx
incl %ecx
cmpb $0x0, (%rdx)
leaq 0x1(%rdx), %rdx
jne 0x74c82
incq %rax
movslq %ecx, %rdx
cmpq %rdx, %rbp
ja 0x74c71
movq 0x8(%rsp), %rax
subl %r15d, %eax
movq %r14, 0x50(%rbx)
jmp 0x74cb3
movq %r14, %rdi
callq 0x56a50
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq