// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x3c(%rbp)
xorl %esi, %esi
movl %esi, %edi
callq 0x7e1a0
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xaec62
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf02f
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq -0x3c(%rbp), %rdx
callq 0xaf040
movl %eax, %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
cmpl $0x0, -0x3c(%rbp)
jne 0xaecbc
movq -0x20(%rbp), %rax
movl $0x0, 0x58(%rax)
movq -0x20(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x38(%rbp), %rdi
callq 0x7f750
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x4(%rbp)
jmp 0xaf02f
cmpl $0x0, -0x3c(%rbp)
jl 0xaecd6
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
movslq -0x3c(%rbp), %rcx
cmpq %rcx, %rax
jge 0xaeceb
movq -0x38(%rbp), %rdi
callq 0x7f750
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf02f
jmp 0xaeced
jmp 0xaecef
jmp 0xaecf1
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rcx
movslq -0x3c(%rbp), %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0xaedc1
movq -0x38(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0xaed5a
movq -0x38(%rbp), %rax
movq 0x28(%rax), %xmm0
movaps 0x272f4(%rip), %xmm1    # 0xd6020
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x272f8(%rip), %xmm1    # 0xd6030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x2b921(%rip), %xmm1    # 0xda670
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
jmp 0xaed69
movsd 0x33e56(%rip), %xmm0    # 0xe2bb8
movsd %xmm0, -0x50(%rbp)
jmp 0xaed69
movsd -0x50(%rbp), %xmm0
movsd 0x332e2(%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 -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x6c80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xaecf1
jmp 0xaedc3
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rax
addq 0x30(%rax), %rdi
movq -0x10(%rbp), %rsi
movslq -0x3c(%rbp), %rdx
callq 0x6570
movslq -0x3c(%rbp), %rcx
movq -0x38(%rbp), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
movl -0x3c(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
subq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rcx
subq $0x1, %rcx
cmpb $0x0, (%rax,%rcx)
je 0xaef23
jmp 0xaee2f
jmp 0xaee31
jmp 0xaee33
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x38(%rbp), %rcx
movq 0x30(%rcx), %rcx
addq $0x1, %rcx
cmpq %rcx, %rax
ja 0xaef00
movq -0x38(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0xaee99
movq -0x38(%rbp), %rax
movq 0x28(%rax), %xmm0
movaps 0x271b5(%rip), %xmm1    # 0xd6020
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x271b9(%rip), %xmm1    # 0xd6030
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x2b7e2(%rip), %xmm1    # 0xda670
mulsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0xaeea8
movsd 0x33d17(%rip), %xmm0    # 0xe2bb8
movsd %xmm0, -0x58(%rbp)
jmp 0xaeea8
movsd -0x58(%rbp), %xmm0
movsd 0x331a3(%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 -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x6c80
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0xaee33
jmp 0xaef02
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rdx
movq 0x30(%rdx), %rcx
movq %rcx, %rsi
addq $0x1, %rsi
movq %rsi, 0x30(%rdx)
movb $0x0, (%rax,%rcx)
jmp 0xaef23
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movslq -0x44(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0xaef7a
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xaef6d
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xaef54
jmp 0xaef6f
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xaef3d
movl -0x40(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x58(%rax)
movq -0x20(%rbp), %rax
movslq 0x58(%rax), %rdi
movl $0x8, %esi
callq 0x6460
movq -0x20(%rbp), %rcx
movq %rax, 0x60(%rcx)
cmpq $0x0, %rax
jne 0xaefb6
movq -0x38(%rbp), %rdi
callq 0x7f750
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xaf02f
movl $0x0, -0x44(%rbp)
movl $0x0, -0x40(%rbp)
movslq -0x44(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x30(%rcx), %rax
jae 0xaf01d
movq -0x30(%rbp), %rdx
movslq -0x44(%rbp), %rax
addq %rax, %rdx
movq -0x20(%rbp), %rax
movq 0x60(%rax), %rax
movl -0x40(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x40(%rbp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0xaf010
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xaeff7
jmp 0xaf012
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xaefc4
movq -0x38(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x50(%rax)
movl -0x48(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)