// File: /workspace/github_c_makefile_star2_O3/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 %rcx, %r14
movl 0x34(%rsi), %eax
cmpq $0x400, %rax            # imm = 0x400
setb %dl
movq 0x18(%rdi), %rcx
testq %rcx, %rcx
setne %r9b
testb %r9b, %dl
je 0x8ae41
movq (%rcx,%rax,8), %r13
testq %r13, %r13
je 0x8ae75
movslq 0x1c(%r13), %r9
movslq 0x14(%r13), %rdi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %edi, %r9d
jge 0x8afe6
movq 0x20(%r13), %rax
leaq (%rax,%r9), %r15
addq %rdi, %rax
movq 0x28(%r14), %rdx
movq 0x30(%r14), %rcx
movb 0x30(%rsi), %sil
subq %r9, %rdi
movq %rdx, %r9
subq %rcx, %r9
cmpq %r9, %rdi
jae 0x8ae81
addq 0x20(%r14), %rcx
movb (%r15), %dl
cmpb %sil, %dl
je 0x8ae34
incq %r15
movb %dl, (%rcx)
incq %rcx
decq %rdi
jne 0x8ae1c
movq %rax, %r15
subq 0x20(%r14), %rcx
movq %rcx, 0x30(%r14)
jmp 0x8afc8
movq (%rdi), %rcx
movslq 0x20(%rcx), %rcx
testq %rcx, %rcx
jle 0x8ae75
movq 0x10(%rdi), %rdx
xorl %edi, %edi
movq (%rdx,%rdi,8), %r13
testq %r13, %r13
je 0x8ae6d
cmpl $0x4, 0x8(%r13)
jne 0x8ae6d
cmpl %eax, 0xc(%r13)
je 0x8addd
incq %rdi
cmpq %rdi, %rcx
jne 0x8ae53
xorl %eax, %eax
cmpl (%r8), %eax
sbbl %eax, %eax
jmp 0x8afe6
movq %r15, %rbp
movq %r8, (%rsp)
cmpb %sil, (%rbp)
je 0x8ae99
incq %rbp
decq %rdi
jne 0x8ae88
movq %rax, %rbp
movq %rbp, %r12
subq %r15, %r12
leaq (%rcx,%r12), %rsi
movq 0x20(%r14), %rax
cmpq %rsi, %rdx
ja 0x8af21
movl $0x400, %ebx            # imm = 0x400
movq %rdx, %xmm0
punpckldq 0x1152(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x115a(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x5a0e(%rip), %xmm1     # 0x908e8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdi
sarq $0x3f, %rdi
subsd 0xd2e2(%rip), %xmm1     # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rcx, %rsi
testq %rdx, %rdx
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r14)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rdx
movq 0x30(%r14), %rcx
leaq (%rcx,%r12), %rsi
cmpq %rsi, %rdx
jbe 0x8aeb1
addq %rcx, %rax
movq %rax, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6570
movq 0x30(%r14), %rax
addq %r12, %rax
movq %rax, 0x30(%r14)
movq 0x28(%r14), %rcx
addq %r12, %rax
cmpq %rax, %rcx
ja 0x8afc1
movq 0x20(%r14), %rax
movl $0x400, %ebx            # imm = 0x400
movq %rcx, %xmm0
punpckldq 0x10b1(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x10b9(%rip), %xmm0     # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x596d(%rip), %xmm1     # 0x908e8
cvttsd2si %xmm1, %rdx
movq %rdx, %rdi
sarq $0x3f, %rdi
subsd 0xd241(%rip), %xmm1     # 0x981d0
cvttsd2si %xmm1, %rsi
andq %rdi, %rsi
orq %rdx, %rsi
testq %rcx, %rcx
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r14)
movq %rax, %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rcx
movq 0x30(%r14), %rdx
addq %r12, %rdx
cmpq %rdx, %rcx
jbe 0x8af52
movq %rbp, %r15
movq (%rsp), %r8
movl 0x20(%r13), %eax
movl 0x1c(%r13), %ecx
addl %eax, %ecx
movl %r15d, %edx
subl %ecx, %edx
movl %edx, (%r8)
subl %eax, %r15d
incl %r15d
movl %r15d, 0x1c(%r13)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq