// File: /workspace/github_c_makefile_star2_O1/icebert[P]pblat/htslib/cram/cram_codecs.c
// Function: cram_huffman_encode_store
int cram_huffman_encode_store(cram_codec *c, cram_block *b, char *prefix,
			      int version) {
    int i, len = 0;
    cram_huffman_code *codes = c->e_huffman.codes;
    /*
     * Up to code length 127 means 2.5e+26 bytes of data required (worst
     * case huffman tree needs symbols with freqs matching the Fibonacci
     * series). So guaranteed 1 byte per code.
     *
     * Symbols themselves could be 5 bytes (eg -1 is 5 bytes in itf8).
     *
     * Therefore 6*ncodes + 5 + 5 + 1 + 5 is max memory
     */
    char *tmp = malloc(6*c->e_huffman.nvals+16);
    char *tp = tmp;

    if (!tmp)
	return -1;

    if (prefix) {
	size_t l = strlen(prefix);
	BLOCK_APPEND(b, prefix, l);
	len += l;
    }

    tp += itf8_put(tp, c->e_huffman.nvals);
    for (i = 0; i < c->e_huffman.nvals; i++) {
	tp += itf8_put(tp, codes[i].symbol);
    }

    tp += itf8_put(tp, c->e_huffman.nvals);
    for (i = 0; i < c->e_huffman.nvals; i++) {
	tp += itf8_put(tp, codes[i].len);
    }

    len += itf8_put_blk(b, c->codec);
    len += itf8_put_blk(b, tp-tmp);
    BLOCK_APPEND(b, tmp, tp-tmp);
    len += tp-tmp;

    free(tmp);

    return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r15
movq 0x30(%rdi), %r13
movslq 0x38(%rdi), %rax
leaq (%rax,%rax,2), %rax
leaq 0x10(,%rax,2), %rdi
callq 0x69d0
testq %rax, %rax
je 0x8a0b0
testq %r12, %r12
movq %rax, (%rsp)
je 0x8a0bb
movq %r12, %rdi
callq 0x62d0
movq %rax, %r14
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r14), %rcx
cmpq %rcx, %rax
ja 0x8a097
movl $0x400, %ebp            # imm = 0x400
movq %rax, %xmm0
punpckldq 0x1fdd(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1fe5(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x67a9(%rip), %xmm1     # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xe0b9(%rip), %xmm1     # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %rbp, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rbx), %rdi
callq 0x6c80
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r14), %rcx
cmpq %rcx, %rax
jbe 0x8a026
addq 0x20(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x30(%rbx)
movq (%rsp), %rax
jmp 0x8a0be
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x8a4c1
xorl %r14d, %r14d
movl 0x38(%r15), %edx
cmpq $0x7f, %rdx
ja 0x8a0d4
movb %dl, (%rax)
movl $0x1, %ebp
jmp 0x8a15f
movl %edx, %ecx
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x8a0f0
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rax)
movb %dl, 0x1(%rax)
movl $0x2, %ebp
jmp 0x8a15f
cmpl $0x1fffff, %edx         # imm = 0x1FFFFF
ja 0x8a10d
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rax)
movb %dh, 0x1(%rax)
movb %dl, 0x2(%rax)
movl $0x3, %ebp
jmp 0x8a15f
cmpl $0xfffffff, %edx        # imm = 0xFFFFFFF
ja 0x8a132
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rax)
movl %edx, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rax)
movb %dh, 0x2(%rax)
movb %dl, 0x3(%rax)
movl $0x4, %ebp
jmp 0x8a15f
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rax)
movl %edx, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rax)
movl %edx, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rax)
movl %edx, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rax)
movl %edx, %ecx
andb $0xf, %cl
movb %cl, 0x4(%rax)
movl $0x5, %ebp
addq %rax, %rbp
testl %edx, %edx
jle 0x8a268
movq %rdx, %rax
movq %rdx, %rcx
shlq $0x4, %rcx
xorl %edx, %edx
movl (%r13,%rdx), %esi
cmpl $0x7f, %esi
ja 0x8a18e
movb %sil, (%rbp)
movl $0x1, %esi
jmp 0x8a256
cmpl $0x3fff, %esi           # imm = 0x3FFF
ja 0x8a1b4
shrl $0x8, %esi
orb $-0x80, %sil
movb %sil, (%rbp)
movb (%r13,%rdx), %sil
movb %sil, 0x1(%rbp)
movl $0x2, %esi
jmp 0x8a256
cmpl $0x1fffff, %esi         # imm = 0x1FFFFF
ja 0x8a1e0
shrl $0x10, %esi
orb $-0x40, %sil
movb %sil, (%rbp)
movb 0x1(%r13,%rdx), %sil
movb %sil, 0x1(%rbp)
movb (%r13,%rdx), %sil
movb %sil, 0x2(%rbp)
movl $0x3, %esi
jmp 0x8a256
cmpl $0xfffffff, %esi        # imm = 0xFFFFFFF
ja 0x8a215
shrl $0x18, %esi
orb $-0x20, %sil
movb %sil, (%rbp)
movb 0x2(%r13,%rdx), %sil
movb %sil, 0x1(%rbp)
movb 0x1(%r13,%rdx), %sil
movb %sil, 0x2(%rbp)
movb (%r13,%rdx), %sil
movb %sil, 0x3(%rbp)
movl $0x4, %esi
jmp 0x8a256
shrl $0x1c, %esi
orb $-0x10, %sil
movb %sil, (%rbp)
movl (%r13,%rdx), %esi
shrl $0x14, %esi
movb %sil, 0x1(%rbp)
movl (%r13,%rdx), %esi
shrl $0xc, %esi
movb %sil, 0x2(%rbp)
movl (%r13,%rdx), %esi
shrl $0x4, %esi
movb %sil, 0x3(%rbp)
movb (%r13,%rdx), %sil
andb $0xf, %sil
movb %sil, 0x4(%rbp)
movl $0x5, %esi
addq %rsi, %rbp
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x8a176
jmp 0x8a26b
movq %rdx, %rax
cmpl $0x7f, %eax
ja 0x8a27d
movb %al, (%rbp)
movl $0x1, %eax
jmp 0x8a306
movl %eax, %ecx
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x8a299
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movb %al, 0x1(%rbp)
movl $0x2, %eax
jmp 0x8a306
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x8a2b6
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbp)
movb %ah, 0x1(%rbp)
movb %al, 0x2(%rbp)
movl $0x3, %eax
jmp 0x8a306
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x8a2db
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x1(%rbp)
movb %ah, 0x2(%rbp)
movb %al, 0x3(%rbp)
movl $0x4, %eax
jmp 0x8a306
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
andb $0xf, %al
movb %al, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
cmpl $0x0, 0x38(%r15)
jle 0x8a3f2
addq $0xc, %r13
xorl %eax, %eax
movl (%r13), %ecx
cmpl $0x7f, %ecx
ja 0x8a330
movb %cl, (%rbp)
movl $0x1, %ecx
jmp 0x8a3db
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x8a352
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movb (%r13), %cl
movb %cl, 0x1(%rbp)
movl $0x2, %ecx
jmp 0x8a3db
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x8a378
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, (%rbp)
movb 0x1(%r13), %cl
movb %cl, 0x1(%rbp)
movb (%r13), %cl
movb %cl, 0x2(%rbp)
movl $0x3, %ecx
jmp 0x8a3db
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x8a3a5
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, (%rbp)
movb 0x2(%r13), %cl
movb %cl, 0x1(%rbp)
movb 0x1(%r13), %cl
movb %cl, 0x2(%rbp)
movb (%r13), %cl
movb %cl, 0x3(%rbp)
movl $0x4, %ecx
jmp 0x8a3db
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, (%rbp)
movl (%r13), %ecx
shrl $0x14, %ecx
movb %cl, 0x1(%rbp)
movl (%r13), %ecx
shrl $0xc, %ecx
movb %cl, 0x2(%rbp)
movl (%r13), %ecx
shrl $0x4, %ecx
movb %cl, 0x3(%rbp)
movb (%r13), %cl
andb $0xf, %cl
movb %cl, 0x4(%rbp)
movl $0x5, %ecx
addq %rcx, %rbp
incq %rax
movslq 0x38(%r15), %rcx
addq $0x10, %r13
cmpq %rcx, %rax
jl 0x8a31a
movl (%r15), %esi
movq %rbx, %rdi
callq 0x5597a
movl %eax, %r15d
subq (%rsp), %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x5597a
movl %eax, %r12d
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%rbp), %rcx
cmpq %rcx, %rax
ja 0x8a499
movl $0x400, %r13d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x1bdb(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1be3(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x63a7(%rip), %xmm1     # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xdcb7(%rip), %xmm1     # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r13, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rbx), %rdi
callq 0x6c80
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%rbp), %rcx
cmpq %rcx, %rax
jbe 0x8a428
addq 0x20(%rbx), %rdi
movq (%rsp), %r13
movq %r13, %rsi
movq %rbp, %rdx
callq 0x6570
addq %rbp, 0x30(%rbx)
addl %ebp, %r14d
addl %r12d, %r15d
addl %r14d, %r15d
movq %r13, %rdi
callq 0x68a0
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq