// File: /workspace/github_c_makefile_star2_O0/samtools[P]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_;
    unsigned char *cp, *cp_end;
    unsigned char stop;

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

    if (b->idx >= b->uncomp_size)
        return -1;
    cp = b->data + b->idx;
    cp_end = b->data + b->uncomp_size;

    // STOP byte is hard-coded as zero by our name tokeniser decoder
    // implementation, so we may ignore what was requested.
    stop = b->orig_method == TOK3 ? 0 : c->u.byte_array_stop.stop;

    if (cp_end - cp < out->alloc - out->byte) {
        unsigned char *out_cp = BLOCK_END(out);
        while (cp != cp_end && *cp != stop)
            *out_cp++ = *cp++;
        BLOCK_SIZE(out) = out_cp - BLOCK_DATA(out);
    } else {
        unsigned 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 - (b->data + b->idx);
    b->idx = cp - b->data + 1;

    return 0;

 block_err:
    return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x64(%rax), %esi
callq 0xe1ab0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0xeb78a
movq -0x30(%rbp), %rax
movl (%rax), %edx
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0xeb95f
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jl 0xeb7a6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xeb95f
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x14(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rax
cmpl $0x8, 0x4(%rax)
jne 0xeb7e5
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0xeb7f0
movq -0x18(%rbp), %rax
movzbl 0x60(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movb %al, -0x51(%rbp)
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rcx, %rax
movq -0x40(%rbp), %rcx
movq 0x28(%rcx), %rcx
movq -0x40(%rbp), %rdx
subq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jae 0xeb892
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x40(%rbp), %rcx
addq 0x30(%rcx), %rax
movq %rax, -0x60(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq -0x50(%rbp), %rcx
movb %al, -0x6d(%rbp)
je 0xeb84c
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x6d(%rbp)
movb -0x6d(%rbp), %al
testb $0x1, %al
jne 0xeb855
jmp 0xeb879
movq -0x48(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x48(%rbp)
movb (%rax), %cl
movq -0x60(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x60(%rbp)
movb %cl, (%rax)
jmp 0xeb82a
movq -0x60(%rbp), %rcx
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
subq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xeb911
movq -0x48(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq -0x50(%rbp), %rcx
movb %al, -0x6e(%rbp)
je 0xeb8bc
movq -0x48(%rbp), %rax
movzbl (%rax), %eax
movzbl -0x51(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x6e(%rbp)
movb -0x6e(%rbp), %al
testb $0x1, %al
jne 0xeb8c5
jmp 0xeb8d5
jmp 0xeb8c7
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xeb89a
movq -0x40(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x68(%rbp), %rax
subq %rax, %rdx
callq 0xe2300
cmpl $0x0, %eax
jge 0xeb8f4
jmp 0xeb958
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x68(%rbp), %rax
subq %rax, %rsi
callq 0xeb970
cmpl $0x0, %eax
jge 0xeb90f
jmp 0xeb958
jmp 0xeb911
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
movq -0x38(%rbp), %rdx
movslq 0x1c(%rdx), %rdx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
addq $0x1, %rax
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x1c(%rax)
movl $0x0, -0x4(%rbp)
jmp 0xeb95f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)