// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/lib/redirect/redirect/redirect_call.cc
// Function: void consume_input_dense<float>(_redirect_call_t*, float*, long)
static void consume_input_dense(redirect_call_t *rc, T *buf, rdint_t size)
{
  rdint_t size_left = size * sizeof(T);

  char *src = static_cast<char *>(SCDC_DATASET_INOUT_BUF_PTR(rc->input));
  char *dst = reinterpret_cast<char *>(buf);

  do
  {
    rdint_t t = z_min(size_left, SCDC_DATASET_INOUT_BUF_CURRENT(rc->input) - rc->input_offset);
    if (dst != src + rc->input_offset) memcpy(dst, src + rc->input_offset, t);
    rc->input_offset += t;
    dst += t;
    size_left -= t;

    /* done */
    if (size_left <= 0) break;

    /* have no next or next fails? */
    if (rc->input->next == 0 || rc->input->next(rc->input, 0) != SCDC_SUCCESS) break;

    src = static_cast<char *>(SCDC_DATASET_INOUT_BUF_PTR(rc->input));
    rc->input_offset = 0;

  } while (1);

#if REDIRECT_CALL_PARAMS_CACHE
  /* try to add an entry to the cache (dense input is cacheable) */
  if (rc->cache)
  {
    rdint_t size_cache = size * sizeof(T);
    rdint_t buf_index = redirect_call_find_buf(rc, buf);
    rdint_t entry_index = redirect_cache_find_entry(rc->cache, get_type<T>(), size_cache, buf);

    /* caching entry if buffer is allocated or entry is already cached */
    if (buf_index >= 0 || entry_index >= 0)
    {
      if (entry_index >= 0)
      {
        TRACE_F("updating entry %" rdint_fmt " of cache", entry_index);
        redirect_cache_update_entry(rc->cache, entry_index);

      } else
      {
        TRACE_F("adding entry [%d,%" rdint_fmt ",%p] to cache", get_type<T>(), size_cache, buf);
        redirect_cache_put_entry(rc->cache, get_type<T>(), size_cache, buf);
      }

      if (buf_index >= 0) redirect_call_remove_buf(rc, buf_index);
    }
  }
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
shlq $0x2, %r14
movq 0xb08(%rdi), %rcx
movq 0x10(%rcx), %rsi
movl 0xb00(%rdi), %eax
movq %r15, %r12
movq %r14, %rbp
movq 0x20(%rcx), %r13
movslq %eax, %rcx
subq %rcx, %r13
cmpq %r13, %rbp
cmovlq %rbp, %r13
addq %rcx, %rsi
cmpq %rsi, %r12
je 0x11848
movq %r12, %rdi
movq %r13, %rdx
callq 0xb420
movl 0xb00(%rbx), %eax
addl %r13d, %eax
movl %eax, 0xb00(%rbx)
subq %r13, %rbp
jle 0x11889
movq 0xb08(%rbx), %rdi
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x11889
xorl %esi, %esi
callq *%rax
cmpq $0x1, %rax
jne 0x11889
addq %r13, %r12
movq 0xb08(%rbx), %rcx
movq 0x10(%rcx), %rsi
andl $0x0, 0xb00(%rbx)
xorl %eax, %eax
jmp 0x1181e
movq 0xba8(%rbx), %r13
testq %r13, %r13
je 0x11975
movq %rbx, %rdi
movq %r15, %rsi
callq 0x11508
movq %rax, %r12
pushq $0x3
popq %rsi
movq %r13, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0xec77
testq %rax, %r12
js 0x11975
movq %rax, %r13
movq 0x636ed(%rip), %rbp     # 0x74fb8
movq (%rbp), %rdi
leaq 0x3ef33(%rip), %rsi     # 0x50809
leaq 0x3f1fb(%rip), %rdx     # 0x50ad8
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %rdi
testq %r13, %r13
js 0x1191b
leaq 0x3f1f8(%rip), %rsi     # 0x50aec
movq %r13, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq 0xba8(%rbx), %rdi
movq %r13, %rsi
callq 0xecb4
jmp 0x11957
leaq 0x3f1e6(%rip), %rsi     # 0x50b08
pushq $0x3
popq %r13
movl %r13d, %edx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0xb7c0
movq (%rbp), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq 0xba8(%rbx), %rdi
movl %r13d, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0xeb5f
testq %r12, %r12
js 0x11975
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11530
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq