// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/htslib/cram/cram_codecs.c
// Function: cram_byte_array_stop_encode_store
int cram_byte_array_stop_encode_store(cram_codec *c, cram_block *b,
				      char *prefix, int version) {
    int len = 0;
    char buf[20], *cp = buf;

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

    cp += itf8_put(cp, c->codec);

    if (CRAM_MAJOR_VERS(version) == 1) {
	cp += itf8_put(cp, 5);
	*cp++ = c->e_byte_array_stop.stop;
	*cp++ = (c->e_byte_array_stop.content_id >>  0) & 0xff;
	*cp++ = (c->e_byte_array_stop.content_id >>  8) & 0xff;
	*cp++ = (c->e_byte_array_stop.content_id >> 16) & 0xff;
	*cp++ = (c->e_byte_array_stop.content_id >> 24) & 0xff;
    } else {
	cp += itf8_put(cp, 1 + itf8_size(c->e_byte_array_stop.content_id));
	*cp++ = c->e_byte_array_stop.stop;
	cp += itf8_put(cp, c->e_byte_array_stop.content_id);
    }

    BLOCK_APPEND(b, buf, cp-buf);
    len += cp-buf;

    return len;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %ecx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
je 0x4daf8
movq %rdx, %r15
movq %rdx, %rdi
callq 0x4230
movq %rax, %r12
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r12), %rcx
cmpq %rcx, %rax
ja 0x4dae0
movl $0x400, %r13d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x4eb4(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4ebc(%rip), %xmm0     # 0x52940
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x5f70(%rip), %xmm1     # 0x53a08
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x4e60(%rip), %xmm1     # 0x52908
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 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r12), %rcx
cmpq %rcx, %rax
jbe 0x4da6f
addq 0x20(%rbx), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x4420
addq %r12, 0x30(%rbx)
movslq %r12d, %r12
jmp 0x4dafb
xorl %r12d, %r12d
movl (%r14), %ecx
cmpl $0x7f, %ecx
ja 0x4db0d
leaq 0x1(%rsp), %rax
jmp 0x4db96
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x4db27
leaq 0x2(%rsp), %rax
movl %ecx, %edx
shrl $0x8, %edx
orb $-0x80, %dl
movb %dl, -0x2(%rax)
jmp 0x4db96
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x4db45
leaq 0x3(%rsp), %rax
movl %ecx, %edx
shrl $0x10, %edx
orb $-0x40, %dl
movb %dl, -0x3(%rax)
movb %ch, 0x1(%rsp)
jmp 0x4db96
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x4db6b
leaq 0x4(%rsp), %rax
movl %ecx, %edx
shrl $0x18, %edx
orb $-0x20, %dl
movb %dl, -0x4(%rax)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, -0x3(%rax)
movb %ch, 0x2(%rsp)
jmp 0x4db96
leaq 0x5(%rsp), %rax
movl %ecx, %edx
shrl $0x1c, %edx
orb $-0x10, %dl
movb %dl, -0x5(%rax)
movl %ecx, %edx
shrl $0x14, %edx
movb %dl, -0x4(%rax)
movl %ecx, %edx
shrl $0xc, %edx
movb %dl, -0x3(%rax)
movl %ecx, %edx
shrl $0x4, %edx
movb %dl, -0x2(%rax)
andb $0xf, %cl
movb %cl, -0x1(%rax)
andl $0xffffff00, %ebp       # imm = 0xFFFFFF00
cmpl $0x100, %ebp            # imm = 0x100
jne 0x4dbc4
movb $0x5, (%rax)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rax)
movl 0x34(%r14), %ecx
movl %ecx, 0x2(%rax)
addq $0x6, %rax
movq %rax, %r15
jmp 0x4dcab
movl 0x34(%r14), %ecx
cmpl $0x80, %ecx
setb %dl
xorb $0x3, %dl
cmpl $0x4000, %ecx           # imm = 0x4000
movzbl %dl, %edx
movl $0x4, %esi
cmovbl %edx, %esi
cmpl $0x10000000, %ecx       # imm = 0x10000000
movb $0x6, %dl
sbbb $0x0, %dl
cmpl $0x200000, %ecx         # imm = 0x200000
movzbl %dl, %edx
cmovbl %esi, %edx
leaq 0x2(%rax), %r15
movb %dl, (%rax)
movb 0x30(%r14), %dl
movb %dl, 0x1(%rax)
cmpl $0x7f, %ecx
ja 0x4dc1b
movb %cl, (%r15)
movl $0x1, %eax
jmp 0x4dca8
movl %ecx, %edx
cmpl $0x3fff, %ecx           # imm = 0x3FFF
ja 0x4dc38
shrl $0x8, %edx
orb $-0x80, %dl
movb %dl, 0x2(%rax)
movb %cl, 0x3(%rax)
movl $0x2, %eax
jmp 0x4dca8
cmpl $0x1fffff, %ecx         # imm = 0x1FFFFF
ja 0x4dc56
shrl $0x10, %edx
orb $-0x40, %dl
movb %dl, 0x2(%rax)
movb %ch, 0x3(%rax)
movb %cl, 0x4(%rax)
movl $0x3, %eax
jmp 0x4dca8
cmpl $0xfffffff, %ecx        # imm = 0xFFFFFFF
ja 0x4dc7c
shrl $0x18, %edx
orb $-0x20, %dl
movb %dl, 0x2(%rax)
movl %ecx, %edx
shrl $0x10, %edx
movb %dl, 0x3(%rax)
movb %ch, 0x4(%rax)
movb %cl, 0x5(%rax)
movl $0x4, %eax
jmp 0x4dca8
shrl $0x1c, %edx
orb $-0x10, %dl
movb %dl, 0x2(%rax)
movl %ecx, %edx
shrl $0x14, %edx
movb %dl, 0x3(%rax)
movl %ecx, %edx
shrl $0xc, %edx
movb %dl, 0x4(%rax)
movl %ecx, %edx
shrl $0x4, %edx
movb %dl, 0x5(%rax)
andb $0xf, %cl
movb %cl, 0x6(%rax)
movl $0x5, %eax
addq %rax, %r15
movq %rsp, %rax
subq %rax, %r15
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r15), %rcx
cmpq %rcx, %rax
ja 0x4dd39
movl $0x400, %r14d           # imm = 0x400
movq %rax, %xmm0
punpckldq 0x4c5b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4c63(%rip), %xmm0     # 0x52940
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x5d17(%rip), %xmm1     # 0x53a08
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x4c07(%rip), %xmm1     # 0x52908
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %r14, %rsi
movq %rsi, 0x28(%rbx)
movq 0x20(%rbx), %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r15), %rcx
cmpq %rcx, %rax
jbe 0x4dcc8
addq 0x20(%rbx), %rdi
movq %rsp, %rsi
movq %r15, %rdx
callq 0x4420
addq %r15, 0x30(%rbx)
addl %r12d, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq