// File: /workspace/github_c_makefile_star2_O2/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
movq %rax, %rbp
imulq $0x6, %rax, %rdi
addq $0x10, %rdi
callq 0x69d0
testq %rax, %rax
je 0x7858b
testq %r12, %r12
movq %rax, (%rsp)
je 0x78594
movq %r12, %rdi
callq 0x62d0
movq %rax, %r14
movl $0x400, %ebp            # imm = 0x400
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r14), %rcx
cmpq %rcx, %rax
ja 0x7856e
movq %rax, %xmm0
punpckldq 0x2af7(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2aff(%rip), %xmm0     # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x72b3(%rip), %xmm1     # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xeb8b(%rip), %xmm1     # 0x870d0
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)
jmp 0x784fb
addq 0x20(%rbx), %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x30(%rbx)
movl 0x38(%r15), %edx
movq (%rsp), %rax
jmp 0x7859a
pushq $-0x1
popq %r15
jmp 0x789c2
xorl %r14d, %r14d
movq %rbp, %rdx
pushq $0x2
popq %r11
pushq $0x3
popq %rcx
pushq $0x4
popq %r12
pushq $0x5
popq %rsi
cmpl $0x7f, %edx
ja 0x785b7
movb %dl, (%rax)
pushq $0x1
popq %rbp
jmp 0x78648
movl %edx, %edi
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x785d3
shrl $0x8, %edi
orb $-0x80, %dil
movb %dil, (%rax)
movb %dl, 0x1(%rax)
movq %r11, %rbp
jmp 0x78648
cmpl $0x1fffff, %edx         # imm = 0x1FFFFF
ja 0x785f0
shrl $0x10, %edi
orb $-0x40, %dil
movb %dil, (%rax)
movb %dh, 0x1(%rax)
movb %dl, 0x2(%rax)
movq %rcx, %rbp
jmp 0x78648
cmpl $0xfffffff, %edx        # imm = 0xFFFFFFF
ja 0x78616
shrl $0x18, %edi
orb $-0x20, %dil
movb %dil, (%rax)
movl %edx, %edi
shrl $0x10, %edi
movb %dil, 0x1(%rax)
movb %dh, 0x2(%rax)
movb %dl, 0x3(%rax)
movq %r12, %rbp
jmp 0x78648
shrl $0x1c, %edi
orb $-0x10, %dil
movb %dil, (%rax)
movl %edx, %edi
shrl $0x14, %edi
movb %dil, 0x1(%rax)
movl %edx, %edi
shrl $0xc, %edi
movb %dil, 0x2(%rax)
movl %edx, %edi
shrl $0x4, %edi
movb %dil, 0x3(%rax)
movl %edx, %edi
andb $0xf, %dil
movb %dil, 0x4(%rax)
movq %rsi, %rbp
pushq $0x1
popq %rdi
addq %rax, %rbp
xorl %r8d, %r8d
testl %edx, %edx
movl $0x0, %r9d
cmovgl %edx, %r9d
shlq $0x4, %r9
cmpq %r8, %r9
je 0x78757
movl (%r13,%r8), %r10d
cmpl $0x7f, %r10d
ja 0x78681
movb %r10b, (%rbp)
movq %rdi, %r10
jmp 0x7874b
cmpl $0x3fff, %r10d          # imm = 0x3FFF
ja 0x786a7
shrl $0x8, %r10d
orb $-0x80, %r10b
movb %r10b, (%rbp)
movb (%r13,%r8), %r10b
movb %r10b, 0x1(%rbp)
movq %r11, %r10
jmp 0x7874b
cmpl $0x1fffff, %r10d        # imm = 0x1FFFFF
ja 0x786d3
shrl $0x10, %r10d
orb $-0x40, %r10b
movb %r10b, (%rbp)
movb 0x1(%r13,%r8), %r10b
movb %r10b, 0x1(%rbp)
movb (%r13,%r8), %r10b
movb %r10b, 0x2(%rbp)
movq %rcx, %r10
jmp 0x7874b
cmpl $0xfffffff, %r10d       # imm = 0xFFFFFFF
ja 0x78708
shrl $0x18, %r10d
orb $-0x20, %r10b
movb %r10b, (%rbp)
movb 0x2(%r13,%r8), %r10b
movb %r10b, 0x1(%rbp)
movb 0x1(%r13,%r8), %r10b
movb %r10b, 0x2(%rbp)
movb (%r13,%r8), %r10b
movb %r10b, 0x3(%rbp)
movq %r12, %r10
jmp 0x7874b
shrl $0x1c, %r10d
orb $-0x10, %r10b
movb %r10b, (%rbp)
movl (%r13,%r8), %r10d
shrl $0x14, %r10d
movb %r10b, 0x1(%rbp)
movl (%r13,%r8), %r10d
shrl $0xc, %r10d
movb %r10b, 0x2(%rbp)
movl (%r13,%r8), %r10d
shrl $0x4, %r10d
movb %r10b, 0x3(%rbp)
movb (%r13,%r8), %r10b
andb $0xf, %r10b
movb %r10b, 0x4(%rbp)
movq %rsi, %r10
addq %r10, %rbp
addq $0x10, %r8
jmp 0x78661
cmpl $0x7f, %edx
ja 0x78769
movq %rdx, %r9
movb %dl, (%rbp)
pushq $0x1
jmp 0x787f3
movl %edx, %eax
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x78785
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movq %rdx, %r9
movb %dl, 0x1(%rbp)
pushq $0x2
jmp 0x787f3
cmpl $0x1fffff, %edx         # imm = 0x1FFFFF
ja 0x787a2
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb %dh, 0x1(%rbp)
movq %rdx, %r9
movb %dl, 0x2(%rbp)
pushq $0x3
jmp 0x787f3
cmpl $0xfffffff, %edx        # imm = 0xFFFFFFF
ja 0x787c7
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x1(%rbp)
movb %dh, 0x2(%rbp)
movq %rdx, %r9
movb %dl, 0x3(%rbp)
pushq $0x4
jmp 0x787f3
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl %edx, %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl %edx, %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl %edx, %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
movq %rdx, %r9
movl %edx, %eax
andb $0xf, %al
movb %al, 0x4(%rbp)
pushq $0x5
popq %rax
addq %rax, %rbp
addq $0xc, %r13
xorl %eax, %eax
pushq $0x1
popq %rcx
pushq $0x2
popq %rdx
pushq $0x3
popq %rsi
pushq $0x4
popq %rdi
pushq $0x5
popq %r8
movslq %r9d, %r9
cmpq %r9, %rax
jge 0x78902
movl (%r13), %r9d
cmpl $0x7f, %r9d
ja 0x7882f
movb %r9b, (%rbp)
movq %rcx, %r9
jmp 0x788ef
cmpl $0x3fff, %r9d           # imm = 0x3FFF
ja 0x78854
shrl $0x8, %r9d
orb $-0x80, %r9b
movb %r9b, (%rbp)
movb (%r13), %r9b
movb %r9b, 0x1(%rbp)
movq %rdx, %r9
jmp 0x788ef
cmpl $0x1fffff, %r9d         # imm = 0x1FFFFF
ja 0x7887e
shrl $0x10, %r9d
orb $-0x40, %r9b
movb %r9b, (%rbp)
movb 0x1(%r13), %r9b
movb %r9b, 0x1(%rbp)
movb (%r13), %r9b
movb %r9b, 0x2(%rbp)
movq %rsi, %r9
jmp 0x788ef
cmpl $0xfffffff, %r9d        # imm = 0xFFFFFFF
ja 0x788b0
shrl $0x18, %r9d
orb $-0x20, %r9b
movb %r9b, (%rbp)
movb 0x2(%r13), %r9b
movb %r9b, 0x1(%rbp)
movb 0x1(%r13), %r9b
movb %r9b, 0x2(%rbp)
movb (%r13), %r9b
movb %r9b, 0x3(%rbp)
movq %rdi, %r9
jmp 0x788ef
shrl $0x1c, %r9d
orb $-0x10, %r9b
movb %r9b, (%rbp)
movl (%r13), %r9d
shrl $0x14, %r9d
movb %r9b, 0x1(%rbp)
movl (%r13), %r9d
shrl $0xc, %r9d
movb %r9b, 0x2(%rbp)
movl (%r13), %r9d
shrl $0x4, %r9d
movb %r9b, 0x3(%rbp)
movb (%r13), %r9b
andb $0xf, %r9b
movb %r9b, 0x4(%rbp)
movq %r8, %r9
addq %r9, %rbp
incq %rax
movl 0x38(%r15), %r9d
addq $0x10, %r13
jmp 0x7880d
movl (%r15), %esi
movq %rbx, %rdi
callq 0x4d6ec
movl %eax, %r15d
subq (%rsp), %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x4d6ec
movl %eax, %r12d
movl $0x400, %r13d           # imm = 0x400
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%rbp), %rcx
cmpq %rcx, %rax
ja 0x7899a
movq %rax, %xmm0
punpckldq 0x26cb(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x26d3(%rip), %xmm0     # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x6e87(%rip), %xmm1     # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xe75f(%rip), %xmm1     # 0x870d0
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)
jmp 0x78927
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