// File: /workspace/github_cpp_makefile_star2_O2/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 0x3ee7e
movq %rdx, %r12
movq %rdx, %rdi
callq 0x4210
movq %rax, %r13
movl $0x400, %ebp            # imm = 0x400
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%r13), %rcx
cmpq %rcx, %rax
ja 0x3ee66
movq %rax, %xmm0
punpckldq 0x4b7f(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4b87(%rip), %xmm0     # 0x439a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x5bb3(%rip), %xmm1     # 0x449e0
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x4adb(%rip), %xmm1     # 0x43918
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 0x48c0
movq %rax, 0x20(%rbx)
jmp 0x3edf3
addq 0x20(%rbx), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4420
addq %r13, 0x30(%rbx)
movslq %r13d, %r12
jmp 0x3ee81
xorl %r12d, %r12d
movl (%r14), %eax
cmpl $0x7f, %eax
ja 0x3ee93
leaq 0x1(%rsp), %rbp
jmp 0x3ef18
cmpl $0x3fff, %eax           # imm = 0x3FFF
ja 0x3eeac
leaq 0x2(%rsp), %rbp
movl %eax, %ecx
shrl $0x8, %ecx
orb $-0x80, %cl
movb %cl, -0x2(%rbp)
jmp 0x3ef18
cmpl $0x1fffff, %eax         # imm = 0x1FFFFF
ja 0x3eec9
leaq 0x3(%rsp), %rbp
movl %eax, %ecx
shrl $0x10, %ecx
orb $-0x40, %cl
movb %cl, -0x3(%rbp)
movb %ah, 0x1(%rsp)
jmp 0x3ef18
cmpl $0xfffffff, %eax        # imm = 0xFFFFFFF
ja 0x3eeee
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 0x3ef18
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 0x3ef46
movb $0x5, (%rbp)
movb 0x30(%r14), %al
movb %al, 0x1(%rbp)
movl 0x34(%r14), %eax
movl %eax, 0x2(%rbp)
addq $0x6, %rbp
jmp 0x3f01c
movl 0x34(%r14), %eax
cmpl $0x80, %eax
jae 0x3ef66
movb $0x2, (%rbp)
movb 0x30(%r14), %cl
movb %cl, 0x1(%rbp)
movb %al, 0x2(%rbp)
pushq $0x1
jmp 0x3f014
cmpl $0x4000, %eax           # imm = 0x4000
jae 0x3ef8d
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)
pushq $0x2
jmp 0x3f014
cmpl $0x200000, %eax         # imm = 0x200000
jae 0x3efb4
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)
pushq $0x3
jmp 0x3f014
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 0x3efec
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)
pushq $0x4
jmp 0x3f014
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)
pushq $0x5
popq %rax
addq %rax, %rbp
addq $0x2, %rbp
movq %rsp, %rax
subq %rax, %rbp
movl $0x400, %r14d           # imm = 0x400
movq 0x28(%rbx), %rax
movq 0x30(%rbx), %rdi
leaq (%rdi,%rbp), %rcx
cmpq %rcx, %rax
ja 0x3f09b
movq %rax, %xmm0
punpckldq 0x494a(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x4952(%rip), %xmm0     # 0x439a0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x597e(%rip), %xmm1     # 0x449e0
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0x48a6(%rip), %xmm1     # 0x43918
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 0x48c0
movq %rax, 0x20(%rbx)
jmp 0x3f028
addq 0x20(%rbx), %rdi
movq %rsp, %rsi
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