// File: /workspace/github_cpp_makefile_star2_O3/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, %r15d
movq %rsi, %rbx
movq %rdi, %r14
testq %rdx, %rdx
je 0x4ca14
movq %rdx, %r12
movq %rdx, %rdi
callq 0x4230
movq %rax, %r13
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r13), %rsi
cmpq %rsi, %rcx
ja 0x4c9fa
movl $0x400, %ebp            # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x3fe9(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x3ff1(%rip), %xmm0     # 0x50990
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x50ad(%rip), %xmm1     # 0x51a60
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0x3f41(%rip), %xmm1     # 0x50908
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %rbp, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%r13), %rsi
cmpq %rsi, %rcx
jbe 0x4c98a
addq %rdx, %rax
movq %rax, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4420
addq %r13, 0x30(%rbx)
movslq %r13d, %r12
jmp 0x4ca17
xorl %r12d, %r12d
movl (%r14), %eax
cmpl $0x7f, %eax
ja 0x4ca29
leaq 0x1(%rsp), %rbp
jmp 0x4caae
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x4ca42
leaq 0x2(%rsp), %rbp
movl %eax, %ecx
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, -0x2(%rbp)
jmp 0x4caae
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x4ca5f
leaq 0x3(%rsp), %rbp
movl %eax, %ecx
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, -0x3(%rbp)
movb %ah, 0x1(%rsp)
jmp 0x4caae
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x4ca84
leaq 0x4(%rsp), %rbp
movl %eax, %ecx
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, -0x4(%rbp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, -0x3(%rbp)
movb %ah, 0x2(%rsp)
jmp 0x4caae
leaq 0x5(%rsp), %rbp
movl %eax, %ecx
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, -0x5(%rbp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, -0x4(%rbp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, -0x3(%rbp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, -0x2(%rbp)
andb $0xf, %al
movb %al, -0x1(%rbp)
andl $0xffffff00, %r15d      # imm = 0xFFFFFF00
cmpl $0x100, %r15d           # imm = 0x100
jne 0x4cadc
movb $0x5, (%rbp)
movb 0x30(%r14), %al
movb %al, 0x1(%rbp)
movl 0x34(%r14), %eax
movl %eax, 0x2(%rbp)
addq $0x6, %rbp
jmp 0x4cbc0
movl 0x34(%r14), %eax
cmpl $0x80, %eax
jae 0x4caff
movb $0x2, (%rbp)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rbp)
movb %al, 0x2(%rbp)
movl $0x1, %eax
jmp 0x4cbb9
cmpl $0x4000, %eax           # imm = 0x4000
jae 0x4cb29
movb $0x3, (%rbp)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rbp)
movl %eax, %ecx
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, 0x2(%rbp)
movb %al, 0x3(%rbp)
movl $0x2, %eax
jmp 0x4cbb9
cmpl $0x200000, %eax         # imm = 0x200000
jae 0x4cb53
movb $0x4, (%rbp)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rbp)
movl %eax, %ecx
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, 0x2(%rbp)
movb %ah, 0x3(%rbp)
movb %al, 0x4(%rbp)
movl $0x3, %eax
jmp 0x4cbb9
cmpl $0x10000000, %eax       # imm = 0x10000000
movb $0x6, %cl
sbbb $0x0, %cl
movb %cl, (%rbp)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rbp)
movl %eax, %ecx
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x4cb8e
shrl $0x18, %ecx
orb $-0x20, %cl
movb %cl, 0x2(%rbp)
movl %eax, %ecx
shrl $0x10, %ecx
movb %cl, 0x3(%rbp)
movb %ah, 0x4(%rbp)
movb %al, 0x5(%rbp)
movl $0x4, %eax
jmp 0x4cbb9
shrl $0x1c, %ecx
orb $-0x10, %cl
movb %cl, 0x2(%rbp)
movl %eax, %ecx
shrl $0x14, %ecx
movb %cl, 0x3(%rbp)
movl %eax, %ecx
shrl $0xc, %ecx
movb %cl, 0x4(%rbp)
movl %eax, %ecx
shrl $0x4, %ecx
movb %cl, 0x5(%rbp)
andb $0xf, %al
movb %al, 0x6(%rbp)
movl $0x5, %eax
addq %rax, %rbp
addq $0x2, %rbp
movq %rsp, %rax
subq %rax, %rbp
movq 0x20(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%rbp), %rsi
cmpq %rsi, %rcx
ja 0x4cc51
movl $0x400, %r14d           # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x3d92(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x3d9a(%rip), %xmm0     # 0x50990
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x4e56(%rip), %xmm1     # 0x51a60
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0x3cea(%rip), %xmm1     # 0x50908
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %r14, %rsi
movq %rsi, 0x28(%rbx)
movq %rax, %rdi
callq 0x48d0
movq %rax, 0x20(%rbx)
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
leaq (%rdx,%rbp), %rsi
cmpq %rsi, %rcx
jbe 0x4cbe1
addq %rdx, %rax
movq %rsp, %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x4420
addq %rbp, 0x30(%rbx)
addl %r12d, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq