// File: karel-brinda[P]ococo/ext/htslib/cram/cram_codecs.c
// Function: cram_byte_array_stop_decode_char
static int cram_byte_array_stop_decode_char(cram_slice *slice, cram_codec *c,
					    cram_block *in, char *out,
					    int *out_size) {
    cram_block *b = NULL;
    char *cp, ch;

    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;
    if (out) {
	while ((ch = *cp) != (char)c->byte_array_stop.stop) {
	    if (cp - (char *)b->data >= b->uncomp_size)
		return -1;
	    *out++ = ch;
	    cp++;
	}
    } else {
	// Consume input, but produce no output
	while ((ch = *cp) != (char)c->byte_array_stop.stop) {
	    if (cp - (char *)b->data >= b->uncomp_size)
		return -1;
	    cp++;
	}
    }

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

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x34(%rax), %esi
callq 0x6de20
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x73e4a
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 0x73f7e
movq -0x38(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x38(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jl 0x73e66
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x73f7e
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x38(%rbp), %rcx
movslq 0x1c(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x73eea
jmp 0x73e86
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, -0x41(%rbp)
movsbl %al, %eax
movq -0x18(%rbp), %rcx
movsbl 0x30(%rcx), %ecx
cmpl %ecx, %eax
je 0x73ee8
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movq -0x38(%rbp), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
jl 0x73ec6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x73f7e
movb -0x41(%rbp), %cl
movq -0x28(%rbp), %rax
movq %rax, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %cl, (%rax)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x73e86
jmp 0x73f39
jmp 0x73eec
movq -0x40(%rbp), %rax
movb (%rax), %al
movb %al, -0x41(%rbp)
movsbl %al, %eax
movq -0x18(%rbp), %rcx
movsbl 0x30(%rcx), %ecx
cmpl %ecx, %eax
je 0x73f37
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movq 0x20(%rcx), %rcx
subq %rcx, %rax
movq -0x38(%rbp), %rcx
movslq 0x14(%rcx), %rcx
cmpq %rcx, %rax
jl 0x73f29
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x73f7e
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x73eec
jmp 0x73f39
movq -0x40(%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 -0x40(%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)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)