// File: /workspace/github_cpp_makefile_star2_O3/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 0x12700
movq %r12, %rdi
movq %r13, %rdx
callq 0xb3f0
movl 0xb00(%rbx), %eax
addl %r13d, %eax
movl %eax, 0xb00(%rbx)
subq %r13, %rbp
jle 0x12744
movq 0xb08(%rbx), %rdi
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x12744
xorl %esi, %esi
callq *%rax
cmpq $0x1, %rax
jne 0x12744
addq %r13, %r12
movq 0xb08(%rbx), %rcx
movq 0x10(%rcx), %rsi
movl $0x0, 0xb00(%rbx)
xorl %eax, %eax
jmp 0x126d6
movq 0xba8(%rbx), %rdi
testq %rdi, %rdi
je 0x12863
movslq 0xb20(%rbx), %rax
movq $-0x1, %r13
testq %rax, %rax
jle 0x12780
xorl %ecx, %ecx
cmpq %r15, 0xb28(%rbx,%rcx,8)
je 0x1277d
incq %rcx
cmpq %rcx, %rax
jne 0x12769
jmp 0x12780
movq %rcx, %r13
movl $0x3, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0xf843
testq %rax, %r13
js 0x12863
movq %rax, %r12
movq 0x797fd(%rip), %rbp     # 0x8bfa0
movq (%rbp), %rdi
leaq 0x5707b(%rip), %rsi     # 0x69829
leaq 0x57343(%rip), %rdx     # 0x69af8
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %rdi
testq %r12, %r12
js 0x127f5
leaq 0x57340(%rip), %rsi     # 0x69b0c
movq %r12, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %rsi
movl $0xa, %edi
callq 0xb690
movq 0xba8(%rbx), %rdi
movq %r12, %rsi
callq 0xf881
jmp 0x12833
leaq 0x5732c(%rip), %rsi     # 0x69b28
movl $0x3, %edx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %rsi
movl $0xa, %edi
callq 0xb690
movq 0xba8(%rbx), %rdi
movl $0x3, %esi
movq %r14, %rdx
movq %r15, %rcx
callq 0xf710
testq %r13, %r13
js 0x12863
movslq 0xb20(%rbx), %rax
cmpq %rax, %r13
jge 0x12863
leaq -0x1(%rax), %rcx
movl %ecx, 0xb20(%rbx)
cmpq %rcx, %r13
je 0x12863
movq 0xb20(%rbx,%rax,8), %rax
movq %rax, 0xb28(%rbx,%r13,8)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq