// File: /workspace/github_c_makefile_star2_O1/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 0x8b293
movq (%rcx,%rax,8), %r13
jmp 0x8b2d6
movq (%rdi), %rcx
movslq 0x20(%rcx), %rcx
testq %rcx, %rcx
jle 0x8b2d3
movq 0x10(%rdi), %rdx
xorl %edi, %edi
movq (%rdx,%rdi,8), %r10
testq %r10, %r10
je 0x8b2c3
cmpl $0x4, 0x8(%r10)
jne 0x8b2c3
cmpl %eax, 0xc(%r10)
jne 0x8b2c3
xorl %r9d, %r9d
movq %r10, %r13
jmp 0x8b2c6
movb $0x1, %r9b
testb %r9b, %r9b
je 0x8b2d6
incq %rdi
cmpq %rdi, %rcx
jne 0x8b2a5
xorl %r13d, %r13d
testq %r13, %r13
je 0x8b341
movslq 0x1c(%r13), %r9
movslq 0x14(%r13), %r11
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %r11d, %r9d
jge 0x8b4b6
movq 0x20(%r13), %rdi
leaq (%rdi,%r9), %r15
movq 0x28(%r14), %r10
movq 0x30(%r14), %rdx
movb 0x30(%rsi), %al
movq %r11, %rcx
subq %r9, %rcx
subq %rdx, %r10
cmpq %r10, %rcx
jae 0x8b34d
addq 0x20(%r14), %rdx
cmpl %r11d, %r9d
je 0x8b331
movb (%r15), %sil
cmpb %al, %sil
je 0x8b331
incq %r15
movb %sil, (%rdx)
incq %rdx
decq %rcx
jne 0x8b31b
subq 0x20(%r14), %rdx
movq %rdx, 0x30(%r14)
movq %r15, %rbp
jmp 0x8b49b
xorl %eax, %eax
cmpl (%r8), %eax
sbbl %eax, %eax
jmp 0x8b4b6
movq %r15, %rbp
cmpl %r11d, %r9d
je 0x8b36b
addq %r11, %rdi
movq %r15, %rbp
cmpb %al, (%rbp)
je 0x8b36b
incq %rbp
decq %rcx
jne 0x8b35b
movq %rdi, %rbp
movq %r8, (%rsp)
movq %rbp, %r12
subq %r15, %r12
movq 0x28(%r14), %rax
movq 0x30(%r14), %rdi
leaq (%rdi,%r12), %rcx
cmpq %rcx, %rax
ja 0x8b3fc
movl $0x400, %ebx            # imm = 0x400
movq %rax, %xmm0
punpckldq 0xc78(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc80(%rip), %xmm0      # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x5444(%rip), %xmm1     # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xcd54(%rip), %xmm1     # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r14)
movq 0x20(%r14), %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rdi
leaq (%rdi,%r12), %rcx
cmpq %rcx, %rax
jbe 0x8b38b
addq 0x20(%r14), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x6570
movq 0x30(%r14), %rcx
addq %r12, %rcx
movq %rcx, 0x30(%r14)
movq 0x28(%r14), %rax
addq %r12, %rcx
cmpq %rcx, %rax
ja 0x8b497
movl $0x400, %ebx            # imm = 0x400
movq %rax, %xmm0
punpckldq 0xbdc(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xbe4(%rip), %xmm0      # 0x8c020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0x53a8(%rip), %xmm1     # 0x907f8
cvttsd2si %xmm1, %rcx
movq %rcx, %rdx
subsd 0xccb8(%rip), %xmm1     # 0x98118
cvttsd2si %xmm1, %rsi
sarq $0x3f, %rdx
andq %rdx, %rsi
orq %rcx, %rsi
testq %rax, %rax
cmoveq %rbx, %rsi
movq %rsi, 0x28(%r14)
movq 0x20(%r14), %rdi
callq 0x6c80
movq %rax, 0x20(%r14)
movq 0x28(%r14), %rax
movq 0x30(%r14), %rcx
addq %r12, %rcx
cmpq %rcx, %rax
jbe 0x8b427
movq (%rsp), %r8
movl 0x20(%r13), %eax
movl 0x1c(%r13), %ecx
addl %eax, %ecx
movl %ebp, %edx
subl %ecx, %edx
movl %edx, (%r8)
subl %eax, %ebp
incl %ebp
movl %ebp, 0x1c(%r13)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq