// File: /workspace/github_c_makefile_star2_O2/icebert[P]pblat/htslib/cram/cram_codecs.c
// Function: cram_byte_array_stop_decode_block
int cram_byte_array_stop_decode_block(cram_slice *slice, cram_codec *c,
				      cram_block *in, char *out_,
				      int *out_size) {
    cram_block *b;
    cram_block *out = (cram_block *)out_;
    char *cp, *out_cp, *cp_end;
    char stop;

    b = cram_get_block_by_id(slice, c->byte_array_stop.content_id);
    if (!b)
        return *out_size?-1:0;

    if (b->idx >= b->uncomp_size)
	return -1;
    cp = (char *)b->data + b->idx;
    cp_end = (char *)b->data + b->uncomp_size;
    out_cp = (char *)BLOCK_END(out);

    stop = c->byte_array_stop.stop;
    if (cp_end - cp < out->alloc - out->byte) {
	while (cp != cp_end && *cp != stop)
	    *out_cp++ = *cp++;
	BLOCK_SIZE(out) = out_cp - (char *)BLOCK_DATA(out);
    } else {
	char *cp_start;
	for (cp_start = cp; cp != cp_end && *cp != stop; cp++)
	    ;
	BLOCK_APPEND(out, cp_start, cp - cp_start);
	BLOCK_GROW(out, cp - cp_start);
    }

    *out_size = cp - (char *)(b->data + b->idx);
    b->idx = cp - (char *)b->data + 1;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %r8, %rbx
movq %rcx, %r15
movq %rsi, %r13
movl 0x34(%rsi), %esi
callq 0x7686f
testq %rax, %rax
je 0x794e4
movq %rax, %r14
movslq 0x1c(%rax), %r8
movslq 0x14(%rax), %rcx
cmpl %ecx, %r8d
jge 0x794ef
movq 0x20(%r14), %rbp
leaq (%r8,%rbp), %r12
addq %rcx, %rbp
movq 0x20(%r15), %rdi
movq 0x28(%r15), %rax
movq 0x30(%r15), %rdx
movb 0x30(%r13), %sil
subq %r8, %rcx
movq %rax, %r8
subq %rdx, %r8
cmpq %r8, %rcx
jae 0x794f7
addq %rdx, %rdi
movq %rdi, %rax
negq %rax
xorl %edx, %edx
cmpq %rdx, %rcx
je 0x79516
movb (%r12,%rdx), %r8b
cmpb %sil, %r8b
je 0x79510
movb %r8b, (%rdi,%rdx)
decq %rax
incq %rdx
jmp 0x794ca
xorl %eax, %eax
cmpl (%rbx), %eax
sbbl %eax, %eax
jmp 0x79654
pushq $-0x1
popq %rax
jmp 0x79654
movq %r12, %r8
movq %rbx, (%rsp)
testq %rcx, %rcx
je 0x79529
cmpb %sil, (%r8)
je 0x79526
incq %r8
decq %rcx
jmp 0x794fe
addq %rdx, %r12
movq %r12, %rbp
addq 0x20(%r15), %rax
negq %rax
movq %rax, 0x30(%r15)
jmp 0x7963a
movq %r8, %rbp
movq %rbp, %r13
subq %r12, %r13
movl $0x400, %ebx            # imm = 0x400
leaq (%rdx,%r13), %rcx
cmpq %rcx, %rax
ja 0x795a6
movq %rax, %xmm0
punpckldq 0x1ac6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1ace(%rip), %xmm0     # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x6282(%rip), %xmm1     # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
subsd 0xdb56(%rip), %xmm1     # 0x870d0
cvttsd2si %xmm1, %rsi
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r15)
callq 0x6c80
movq %rax, %rdi
movq %rax, 0x20(%r15)
movq 0x28(%r15), %rax
movq 0x30(%r15), %rdx
jmp 0x79534
addq %rdx, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x6570
movq 0x30(%r15), %rcx
addq %r13, %rcx
movq %rcx, 0x30(%r15)
movl $0x400, %ebx            # imm = 0x400
movq 0x28(%r15), %rax
addq %r13, %rcx
cmpq %rcx, %rax
ja 0x79636
movq %rax, %xmm0
punpckldq 0x1a33(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x1a3b(%rip), %xmm0     # 0x7b020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x61ef(%rip), %xmm1     # 0x7f7e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xdac7(%rip), %xmm1     # 0x870d0
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r15)
movq 0x20(%r15), %rdi
callq 0x6c80
movq %rax, 0x20(%r15)
movq 0x30(%r15), %rcx
jmp 0x795c4
movq (%rsp), %rbx
movl 0x20(%r14), %eax
movl 0x1c(%r14), %ecx
addl %eax, %ecx
movl %ebp, %edx
subl %ecx, %edx
movl %edx, (%rbx)
subl %eax, %ebp
incl %ebp
movl %ebp, 0x1c(%r14)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq