// File: /workspace/github_c_makefile_star2_O3/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
leaq (%rax,%rax,2), %rax
leaq 0x10(,%rax,2), %rdi
callq 0x69d0
testq %rax, %rax
je 0x89c2d
movq %rax, %rcx
testq %r12, %r12
movq %rax, (%rsp)
je 0x89c38
movq %r12, %rdi
callq 0x62d0
movq %rax, %r14
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r14), %rsi
cmpq %rsi, %rcx
ja 0x89c0e
movl $0x400, %ebp            # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x2465(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x246d(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x6d21(%rip), %xmm1     # 0x908e8
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0xe5f5(%rip), %xmm1     # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %rbp, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r14), %rsi
cmpq %rsi, %rcx
jbe 0x89b9e
addq %rdx, %rax
movq %rax, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x6570
addq %r14, 0x30(%rbx)
movl 0x38(%r15), %edx
movq (%rsp), %rcx
jmp 0x89c3e
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x8a019
xorl %r14d, %r14d
movq %rbp, %rdx
cmpl $0x7f, %edx
movq %rdx, %rsi
ja 0x89c59
movb %dl, (%rcx)
movl $0x1, %ebp
addq %rcx, %rbp
testl %edx, %edx
jg 0x89cc2
jmp 0x89d85
movl %edx, %eax
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x89c76
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rcx)
movl $0x2, %ebp
movl $0x1, %eax
jmp 0x89cbc
cmpl $0x1fffff, %edx         # imm = 0x1FFFFF
ja 0x89c94
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rcx)
movb %dh, 0x1(%rcx)
movl $0x3, %ebp
movl $0x2, %eax
jmp 0x89cbc
cmpl $0xfffffff, %edx        # imm = 0xFFFFFFF
ja 0x89dfe
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rcx)
movl %edx, %eax
shrl $0x10, %eax
movb %al, 0x1(%rcx)
movb %dh, 0x2(%rcx)
movl $0x4, %ebp
movl $0x3, %eax
movb %dl, (%rcx,%rax)
addq %rcx, %rbp
movq %rsi, %rax
movl %eax, %eax
movq %r13, %rcx
movl (%rcx), %edx
cmpl $0x7f, %edx
ja 0x89cde
movb %dl, (%rbp)
movl $0x1, %edx
jmp 0x89d75
cmpl $0x3fff, %edx           # imm = 0x3FFF
ja 0x89cfb
shrl $0x8, %edx
orb $-0x80, %dl
movb %dl, (%rbp)
movb (%rcx), %dl
movb %dl, 0x1(%rbp)
movl $0x2, %edx
jmp 0x89d75
cmpl $0x1fffff, %edx         # imm = 0x1FFFFF
ja 0x89d1e
shrl $0x10, %edx
orb $-0x40, %dl
movb %dl, (%rbp)
movb 0x1(%rcx), %dl
movb %dl, 0x1(%rbp)
movb (%rcx), %dl
movb %dl, 0x2(%rbp)
movl $0x3, %edx
jmp 0x89d75
cmpl $0xfffffff, %edx        # imm = 0xFFFFFFF
ja 0x89d47
shrl $0x18, %edx
orb $-0x20, %dl
movb %dl, (%rbp)
movb 0x2(%rcx), %dl
movb %dl, 0x1(%rbp)
movb 0x1(%rcx), %dl
movb %dl, 0x2(%rbp)
movb (%rcx), %dl
movb %dl, 0x3(%rbp)
movl $0x4, %edx
jmp 0x89d75
shrl $0x1c, %edx
orb $-0x10, %dl
movb %dl, (%rbp)
movl (%rcx), %edx
shrl $0x14, %edx
movb %dl, 0x1(%rbp)
movl (%rcx), %edx
shrl $0xc, %edx
movb %dl, 0x2(%rbp)
movl (%rcx), %edx
shrl $0x4, %edx
movb %dl, 0x3(%rbp)
movb (%rcx), %dl
andb $0xf, %dl
movb %dl, 0x4(%rbp)
movl $0x5, %edx
addq %rdx, %rbp
addq $0x10, %rcx
decq %rax
jne 0x89cca
movq %rsi, %rcx
cmpl $0x7f, %ecx
ja 0x89d9a
movb %cl, (%rbp)
movl $0x1, %eax
jmp 0x89e59
movl %ecx, %eax
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x89db9
shrl $0x8, %eax
orb $-0x80, %al
movb %al, (%rbp)
movb %cl, 0x1(%rbp)
movl $0x2, %eax
jmp 0x89e59
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x89dd9
shrl $0x10, %eax
orb $-0x40, %al
movb %al, (%rbp)
movb %ch, 0x1(%rbp)
movb %cl, 0x2(%rbp)
movl $0x3, %eax
jmp 0x89e59
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x89e2e
shrl $0x18, %eax
orb $-0x20, %al
movb %al, (%rbp)
movl %ecx, %eax
shrl $0x10, %eax
movb %al, 0x1(%rbp)
movb %ch, 0x2(%rbp)
movb %cl, 0x3(%rbp)
movl $0x4, %eax
jmp 0x89e59
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rcx)
movl %edx, %eax
shrl $0x14, %eax
movb %al, 0x1(%rcx)
movl %edx, %eax
shrl $0xc, %eax
movb %al, 0x2(%rcx)
movl %edx, %eax
shrl $0x4, %eax
movb %al, 0x3(%rcx)
movl %edx, %eax
andb $0xf, %al
movb %al, 0x4(%rcx)
movl $0x5, %ebp
jmp 0x89c4d
shrl $0x1c, %eax
orb $-0x10, %al
movb %al, (%rbp)
movl %ecx, %eax
shrl $0x14, %eax
movb %al, 0x1(%rbp)
movl %ecx, %eax
shrl $0xc, %eax
movb %al, 0x2(%rbp)
movl %ecx, %eax
shrl $0x4, %eax
movb %al, 0x3(%rbp)
andb $0xf, %cl
movb %cl, 0x4(%rbp)
movl $0x5, %eax
addq %rax, %rbp
cmpl $0x0, 0x38(%r15)
jle 0x89f45
addq $0xc, %r13
xorl %eax, %eax
movl (%r13), %ecx
cmpl $0x7f, %ecx
ja 0x89e83
movb %cl, (%rbp)
movl $0x1, %ecx
jmp 0x89f2e
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x89ea5
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, (%rbp)
movb (%r13), %cl
movb %cl, 0x1(%rbp)
movl $0x2, %ecx
jmp 0x89f2e
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x89ecb
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 0x89f2e
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x89ef8
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 0x89f2e
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 0x89e6d
movl (%r15), %esi
movq %rbx, %rdi
callq 0x55da8
movl %eax, %r15d
subq (%rsp), %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0x55da8
movl %eax, %r12d
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%rbp), %rsi
cmpq %rsi, %rcx
ja 0x89fef
movl $0x400, %r13d           # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x2084(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x208c(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x6940(%rip), %xmm1     # 0x908e8
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0xe214(%rip), %xmm1     # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %r13, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%rbp), %rsi
cmpq %rsi, %rcx
jbe 0x89f7f
addq %rdx, %rax
movq %rax, %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