// File: /workspace/github_cpp_makefile_star2_O1/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
subq $0x18, %rsp
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
shlq $0x2, %r14
movq 0xb08(%rdi), %rax
movq 0x10(%rax), %rbp
movq %rsi, 0x10(%rsp)
movq %r14, 0x8(%rsp)
movq 0xb08(%rbx), %rax
movq 0x20(%rax), %r13
movslq 0xb00(%rbx), %rsi
subq %rsi, %r13
cmpq %r13, %r14
cmovlq %r14, %r13
addq %rbp, %rsi
cmpq %rsi, %r12
je 0x1272d
movq %r12, %rdi
movq %r13, %rdx
callq 0xb3f0
addl %r13d, 0xb00(%rbx)
subq %r13, %r14
jle 0x12770
movq 0xb08(%rbx), %rdi
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x12770
xorl %r15d, %r15d
xorl %esi, %esi
callq *%rax
cmpq $0x1, %rax
jne 0x12773
movq 0xb08(%rbx), %rax
movq 0x10(%rax), %rbp
movl $0x0, 0xb00(%rbx)
movb $0x1, %r15b
jmp 0x12773
xorl %r15d, %r15d
addq %r13, %r12
testb %r15b, %r15b
jne 0x126fe
movq 0xba8(%rbx), %rdi
testq %rdi, %rdi
movq 0x10(%rsp), %rbp
je 0x128a2
movslq 0xb20(%rbx), %rax
movq $-0x1, %r13
testq %rax, %rax
jle 0x127bc
xorl %ecx, %ecx
cmpq %rbp, 0xb28(%rbx,%rcx,8)
je 0x127b9
incq %rcx
cmpq %rcx, %rax
jne 0x127a5
jmp 0x127bc
movq %rcx, %r13
movl $0x3, %esi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0xf830
testq %rax, %r13
js 0x128a2
movq %rax, %r12
movq 0x797bf(%rip), %r14     # 0x8bfa0
movq (%r14), %rdi
leaq 0x5701e(%rip), %rsi     # 0x69809
leaq 0x572e6(%rip), %rdx     # 0x69ad8
xorl %eax, %eax
callq 0xb7a0
movq (%r14), %rdi
testq %r12, %r12
js 0x12830
leaq 0x572e4(%rip), %rsi     # 0x69aec
movq %r12, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r14), %rsi
movl $0xa, %edi
callq 0xb690
movq 0xba8(%rbx), %rdi
movq %r12, %rsi
callq 0xf86e
jmp 0x12872
leaq 0x572d1(%rip), %rsi     # 0x69b08
movl $0x3, %edx
movq 0x8(%rsp), %r15
movq %r15, %rcx
movq %rbp, %r8
xorl %eax, %eax
callq 0xb7a0
movq (%r14), %rsi
movl $0xa, %edi
callq 0xb690
movq 0xba8(%rbx), %rdi
movl $0x3, %esi
movq %r15, %rdx
movq %rbp, %rcx
callq 0xf6db
testq %r13, %r13
js 0x128a2
movslq 0xb20(%rbx), %rax
cmpq %rax, %r13
jge 0x128a2
leaq -0x1(%rax), %rcx
movl %ecx, 0xb20(%rbx)
cmpq %rcx, %r13
je 0x128a2
movq 0xb20(%rbx,%rax,8), %rax
movq %rax, 0xb28(%rbx,%r13,8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq