// File: /workspace/github_c_makefile_star2_O3/johsteffens[P]beth/lib/bcore/bcore_sources.c
// Function: string_refill
static void string_refill( bcore_source_string_s* o, uz_t min_remaining_size )
{
    if( !o->string ) o->string = st_s_create();
    if( o->string->size - o->index <= min_remaining_size )
    {
        if( o->index > 0 )
        {
            bcore_memmove( o->string->data, o->string->data + o->index, o->string->size - o->index );
            o->string->size -= o->index;
            o->string->data[ o->string->size ] = 0;
            o->index = 0;
        }
        uz_t refill_size = min_remaining_size - o->string->size > o->prefetch_size ? min_remaining_size - o->string->size : o->prefetch_size;
        st_s_set_min_space( o->string, o->string->size + refill_size + 1 );
        uz_t bytes_received = bcore_source_a_get_data( o->ext_supplier, o->string->data + o->string->size, refill_size );
        if( bytes_received < refill_size )
        {
            if( bcore_source_a_eos( o->ext_supplier ) ) o->ext_supplier = NULL; // detach supplier when empty
        }
        o->string->size += bytes_received;
        o->string->data[ o->string->size ] = 0;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
testq %rdi, %rdi
jne 0xe8a7b
xorl %eax, %eax
callq 0x109c82
movq %rax, %rdi
movq %rax, 0x8(%rbx)
movq 0x10(%rdi), %rax
movq 0x10(%rbx), %rsi
movq %rax, %rdx
subq %rsi, %rdx
cmpq %r14, %rdx
ja 0xe8c8e
testq %rsi, %rsi
je 0xe8acb
movq 0x8(%rdi), %rdi
addq %rdi, %rsi
callq 0xbe8fd
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rcx
movq 0x10(%rax), %rdx
subq 0x10(%rbx), %rdx
movq %rdx, 0x10(%rax)
movb $0x0, (%rcx,%rdx)
movq $0x0, 0x10(%rbx)
movq 0x8(%rbx), %rdi
movq 0x10(%rdi), %rax
subq %rax, %r14
movq 0x28(%rbx), %rcx
cmpq %rcx, %r14
cmovbeq %rcx, %r14
leaq (%rax,%r14), %rsi
incq %rsi
callq 0x10a26d
movq 0x8(%rbx), %rax
movq 0x18(%rbx), %r15
movq 0x8(%rax), %r12
addq 0x10(%rax), %r12
movq (%r15), %r13
leaq 0xb41c9(%rip), %rdx     # 0x19ccc8
movl (%rdx), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %r13, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r13, %rdx
je 0xe8b54
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r13, %rdx
je 0xe8b54
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r13, %rdx
je 0xe8b54
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r13, %rdx
jne 0xe8b5d
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0xe8b84
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r13, %rsi
callq 0xe9bc5
movq %rax, %rbp
leaq 0xb414f(%rip), %rdi     # 0x19ccc8
movq %r13, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x10(%rbp), %rax
testq %rax, %rax
jne 0xe8ba0
leaq 0x51202(%rip), %rsi     # 0x139d96
movq %rbp, %rdi
callq 0xeb49c
movq 0x10(%rbp), %rax
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq *%rax
movq %rax, %r15
cmpq %r14, %rax
jae 0xe8c77
movq 0x18(%rbx), %r14
movq (%r14), %r12
leaq 0xb4103(%rip), %rdx     # 0x19ccc8
movl (%rdx), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %r12, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0xe8c1a
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0xe8c1a
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0xe8c1a
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0xe8c23
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0xe8c4a
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r12, %rsi
callq 0xe9bc5
movq %rax, %r13
leaq 0xb4089(%rip), %rdi     # 0x19ccc8
movq %r12, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x40(%r13), %rax
testq %rax, %rax
jne 0xe8c66
leaq 0x5112f(%rip), %rsi     # 0x139d89
movq %r13, %rdi
callq 0xeb49c
movq 0x40(%r13), %rax
movq %r14, %rdi
callq *%rax
testb %al, %al
je 0xe8c77
movq $0x0, 0x18(%rbx)
movq 0x8(%rbx), %rax
movq 0x10(%rax), %rcx
addq %r15, %rcx
movq %rcx, 0x10(%rax)
movq 0x8(%rax), %rax
movb $0x0, (%rax,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq