// File: /workspace/github_c_makefile_star2_O3/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, %rbp
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 0xe3cf7
movq %rbp, %rdi
movq %r12, %rdx
callq 0xbe87d
addq %r12, 0x20(%r13)
jmp 0xe4039
movq %rbp, %rdi
movq %rbx, %rdx
callq 0xbe87d
xorl %eax, %eax
movq %rax, 0x20(%r13)
movq %rax, 0x10(%r13)
movq 0x28(%r13), %rdi
testq %rdi, %rdi
je 0xe4036
addq %rbx, %rbp
movq 0x30(%r13), %rdx
cmpq %rdx, %r15
jbe 0xe3df6
movq (%rdi), %r14
leaq 0xb8f95(%rip), %rax     # 0x19ccc8
movl (%rax), %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
movq 0x20(%rax,%rcx,8), %rdx
movq 0x18(%rax,%rcx,8), %rcx
andq %r14, %rcx
shlq $0x4, %rcx
leaq (%rdx,%rcx), %rax
movq (%rdx,%rcx), %rdx
movl $0x8, %ecx
cmpq %r14, %rdx
je 0xe3d89
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %r14, %rdx
je 0xe3d89
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %r14, %rdx
je 0xe3d89
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %r14, %rdx
jne 0xe3d92
movq (%rax,%rcx), %r12
testq %r12, %r12
jne 0xe3dbf
movq %rdi, %r13
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r14, %rsi
callq 0xe9bc5
movq %rax, %r12
leaq 0xb8f17(%rip), %rdi     # 0x19ccc8
movq %r14, %rsi
movq %rax, %rdx
callq 0x115fac
movq %r13, %rdi
movq 0x10(%r12), %rax
testq %rax, %rax
jne 0xe3de3
leaq 0x55fc6(%rip), %rsi     # 0x139d96
movq %rdi, %r14
movq %r12, %rdi
callq 0xeb49c
movq %r14, %rdi
movq 0x10(%r12), %rax
movq %rbp, %rsi
movq %r15, %rdx
callq *%rax
movq %rax, %r12
addq %rbx, %r12
jmp 0xe4039
movq 0x8(%r13), %r8
movq 0x18(%r13), %rsi
cmpq %rdx, %rsi
jae 0xe3e3a
leaq 0x18(%r13), %r14
movq %r8, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0xbe7d0
movq %rax, 0x8(%r13)
movq 0x18(%r13), %rsi
movq 0x30(%r13), %rdx
movq %rax, %rdi
movq %r14, %rcx
callq 0xbe7d0
movq %rax, %r8
movq %rax, 0x8(%r13)
movq 0x28(%r13), %rdi
movq 0x30(%r13), %rdx
movq %rbp, 0x18(%rsp)
movq (%rdi), %r14
leaq 0xb8e7f(%rip), %rsi     # 0x19ccc8
movl (%rsi), %eax
cltq
leaq (%rax,%rax,2), %rax
movq 0x20(%rsi,%rax,8), %rcx
movq 0x18(%rsi,%rax,8), %rsi
andq %r14, %rsi
shlq $0x4, %rsi
leaq (%rcx,%rsi), %rax
movq (%rcx,%rsi), %rsi
movl $0x8, %ecx
cmpq %r14, %rsi
je 0xe3e9e
movq 0x10(%rax), %rsi
movl $0x18, %ecx
cmpq %r14, %rsi
je 0xe3e9e
movq 0x20(%rax), %rsi
movl $0x28, %ecx
cmpq %r14, %rsi
je 0xe3e9e
movq 0x30(%rax), %rsi
movl $0x38, %ecx
cmpq %r14, %rsi
jne 0xe3ea7
movq (%rax,%rcx), %rbp
testq %rbp, %rbp
jne 0xe3eec
movq %rdi, 0x8(%rsp)
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %r14, %rsi
movq %r8, 0x20(%rsp)
movq %rdx, 0x10(%rsp)
callq 0xe9bc5
movq %rax, %rbp
leaq 0xb8df6(%rip), %rdi     # 0x19ccc8
movq %r14, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x10(%rsp), %rdx
movq 0x20(%rsp), %r8
movq 0x8(%rsp), %rdi
movq 0x10(%rbp), %rax
testq %rax, %rax
jne 0xe3f22
leaq 0x55e9a(%rip), %rsi     # 0x139d96
movq %rdi, 0x8(%rsp)
movq %rbp, %rdi
movq %r8, %r14
movq %rdx, 0x10(%rsp)
callq 0xeb49c
movq 0x10(%rsp), %rdx
movq %r14, %r8
movq 0x8(%rsp), %rdi
movq 0x10(%rbp), %rax
movq %r8, %rsi
callq *%rax
movq %rax, 0x10(%r13)
cmpq 0x30(%r13), %rax
jae 0xe4002
movq 0x28(%r13), %rdi
movq (%rdi), %rbp
leaq 0xb8d85(%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 %rbp, %rdx
shlq $0x4, %rdx
leaq (%rcx,%rdx), %rax
movq (%rcx,%rdx), %rdx
movl $0x8, %ecx
cmpq %rbp, %rdx
je 0xe3f98
movq 0x10(%rax), %rdx
movl $0x18, %ecx
cmpq %rbp, %rdx
je 0xe3f98
movq 0x20(%rax), %rdx
movl $0x28, %ecx
cmpq %rbp, %rdx
je 0xe3f98
movq 0x30(%rax), %rdx
movl $0x38, %ecx
cmpq %rbp, %rdx
jne 0xe3fa1
movq (%rax,%rcx), %r14
testq %r14, %r14
jne 0xe3fd2
movq %rdi, 0x8(%rsp)
movabsq $-0x7e8ee9b9b4bbaa8, %rdi # imm = 0xF817116464B44558
movq %rbp, %rsi
callq 0xe9bc5
movq %rax, %r14
leaq 0xb8d06(%rip), %rdi     # 0x19ccc8
movq %rbp, %rsi
movq %rax, %rdx
callq 0x115fac
movq 0x8(%rsp), %rdi
movq 0x40(%r14), %rax
testq %rax, %rax
jne 0xe3ff4
leaq 0x55da7(%rip), %rsi     # 0x139d89
movq %rdi, %rbp
movq %r14, %rdi
callq 0xeb49c
movq %rbp, %rdi
movq 0x40(%r14), %rax
callq *%rax
testb %al, %al
je 0xe4002
movq $0x0, 0x28(%r13)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
cmpq %rdx, %r15
jae 0xe4022
movq 0x18(%rsp), %rdi
movq %r15, %rdx
callq 0xbe87d
addq %r15, 0x20(%r13)
jmp 0xe4039
movq 0x18(%rsp), %rdi
callq 0xbe87d
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