// File: /workspace/github_c_makefile_star2_O1/johsteffens[P]beth/lib/bcore/bcore_sources.c
// Function: buffer_flow_src
static uz_t buffer_flow_src( bcore_source_buffer_s* o, vd_t data, uz_t size )
{
    if( size < o->size - o->index )
    {
        bcore_memcpy( data, o->data + o->index, size );
        o->index += size;
        return size;
    }

    uz_t size1 = o->size - o->index;
    bcore_memcpy( data, o->data + o->index, size1 );
    o->index += size1;
    data = ( u0_t* )data + size1;
    size -= size1;
    o->size = o->index = 0;
    if( !o->ext_supplier ) return size1;

    // the code below handles the case with supplier

    if( size > o->prefetch_size ) return bcore_source_a_get_data( o->ext_supplier, data, size ) + size1;

    if( o->space < o->prefetch_size )
    {
        o->data = bcore_bn_alloc( o->data, o->space,                0, &o->space );
        o->data = bcore_bn_alloc( o->data, o->space, o->prefetch_size, &o->space );
    }
    o->size = bcore_source_a_get_data( o->ext_supplier, o->data, o->prefetch_size );

    if( o->size < o->prefetch_size )
    {
        if( bcore_source_a_eos( o->ext_supplier ) ) o->ext_supplier = NULL;
    }

    if( size < o->size )
    {
        bcore_memcpy( data, o->data, size );
        o->index += size;
        return size1 + size;
    }
    else
    {
        bcore_memcpy( data, o->data, o->size );
        o->size = o->index = 0;
        return size1 + o->size;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %r13
movq 0x10(%rdi), %rbx
movq 0x20(%rdi), %rsi
subq %rsi, %rbx
addq 0x8(%rdi), %rsi
movq %rdx, %r15
subq %rbx, %r15
jae 0xede45
movq %r14, %rdi
movq %r12, %rdx
callq 0xc83f1
addq %r12, 0x20(%r13)
jmp 0xee176
movq %r14, %rdi
movq %rbx, %rdx
callq 0xc83f1
xorl %eax, %eax
movq %rax, 0x20(%r13)
movq %rax, 0x10(%r13)
movq 0x28(%r13), %rbp
testq %rbp, %rbp
je 0xee173
addq %rbx, %r14
movq 0x30(%r13), %rax
cmpq %rax, %r15
jbe 0xedf3a
movq (%rbp), %r12
leaq 0xbbe46(%rip), %rax     # 0x1a9cc8
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r12, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r12, %rdx
je 0xededc
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r12, %rdx
je 0xededc
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r12, %rdx
je 0xededc
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r12, %rdx
jne 0xee188
movq (%rax,%rcx), %r13
testq %r13, %r13
jne 0xedf0c
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r12, %rsi
callq 0xf3f85
movq %rax, %r13
leaq 0xbbdc7(%rip), %rdi     # 0x1a9cc8
movq %r12, %rsi
movq %rax, %rdx
callq 0x12128c
cmpq $0x0, 0x10(%r13)
jne 0xedf22
leaq 0x57004(%rip), %rsi     # 0x144f1e
movq %r13, %rdi
callq 0xf592c
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq *0x10(%r13)
movq %rax, %r12
addq %rbx, %r12
jmp 0xee176
movq %r14, 0x20(%rsp)
movq 0x18(%r13), %rsi
cmpq %rax, %rsi
jae 0xedf75
leaq 0x18(%r13), %r14
movq 0x8(%r13), %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0xc8334
movq %rax, 0x8(%r13)
movq 0x18(%r13), %rsi
movq 0x30(%r13), %rdx
movq %rax, %rdi
movq %r14, %rcx
callq 0xc8334
movq %rax, 0x8(%r13)
movq 0x8(%r13), %rsi
movq 0x28(%r13), %r8
movq 0x30(%r13), %rdx
movq (%r8), %rbp
leaq 0xbbd3d(%rip), %rdi     # 0x1a9cc8
movl (%rdi), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rdi,%rax,8), %rcx
movq 0x18(%rdi,%rax,8), %rdi
andq %rbp, %rdi
shlq $0x4, %rdi
leaq (%rcx,%rdi), %rax
movq (%rcx,%rdi), %rdi
movl $0x8, %ecx
cmpq %rbp, %rdi
je 0xedfe4
movq 0x10(%rax), %rdi
movl $0x18, %ecx
cmpq %rbp, %rdi
je 0xedfe4
movq 0x20(%rax), %rdi
movl $0x28, %ecx
cmpq %rbp, %rdi
je 0xedfe4
movq 0x30(%rax), %rdi
movl $0x38, %ecx
cmpq %rbp, %rdi
jne 0xee190
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0xee032
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rsi, 0x8(%rsp)
movq %rbp, %rsi
movq %rdx, 0x18(%rsp)
movq %r8, 0x10(%rsp)
callq 0xf3f85
movq %rax, %r14
leaq 0xbbcb0(%rip), %rdi     # 0x1a9cc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x10(%rsp), %r8
movq 0x18(%rsp), %rdx
movq 0x8(%rsp), %rsi
cmpq $0x0, 0x10(%r14)
jne 0xee062
movq %rsi, 0x8(%rsp)
leaq 0x56ed9(%rip), %rsi     # 0x144f1e
movq %r14, %rdi
movq %rdx, %rbp
movq %r8, 0x10(%rsp)
callq 0xf592c
movq 0x10(%rsp), %r8
movq %rbp, %rdx
movq 0x8(%rsp), %rsi
movq %r8, %rdi
callq *0x10(%r14)
movq %rax, 0x10(%r13)
cmpq 0x30(%r13), %rax
jae 0xee144
movq 0x28(%r13), %rdi
movq (%rdi), %rbp
leaq 0xbbc43(%rip), %rdx     # 0x1a9cc8
movl (%rdx), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rdx,%rax,8), %rcx
movq 0x18(%rdx,%rax,8), %rdx
andq %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0xee0de
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0xee0de
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0xee0de
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0xee198
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0xee118
movq %rdi, 0x8(%rsp)
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xf3f85
movq %rax, %r14
leaq 0xbbbc0(%rip), %rdi     # 0x1a9cc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x12128c
movq 0x8(%rsp), %rdi
cmpq $0x0, 0x40(%r14)
jne 0xee134
leaq 0x56deb(%rip), %rsi     # 0x144f11
movq %rdi, %rbp
movq %r14, %rdi
callq 0xf592c
movq %rbp, %rdi
callq *0x40(%r14)
testb %al, %al
je 0xee144
movq $0x0, 0x28(%r13)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
cmpq %rdx, %r15
movq 0x20(%rsp), %rdi
jae 0xee164
movq %r15, %rdx
callq 0xc83f1
addq %r15, 0x20(%r13)
jmp 0xee176
callq 0xc83f1
xorl %eax, %eax
movq %rax, 0x20(%r13)
movq %rax, 0x10(%r13)
movq %rbx, %r12
movq %r12, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0xedee0
xorl %r14d, %r14d
jmp 0xedfe8
xorl %r14d, %r14d
jmp 0xee0e2