// File: mh0fm4[P]SCDC/src/lib/redirect/redirect/redirect_call.cc
// Function: void redirect_call_put_output_param_dense_val<char>(_redirect_call_t*, char const*, char const*, long)
static void redirect_call_put_output_param_dense_val(redirect_call_t *rc, const char *id, const T *b, rdint_t n)
{
  TRACE_F("rc: %p, id: '%s', b: %p, n: %" rdint_fmt, rc, id, b, n);

  if (rc->client) /* client */
  {
    /* FIXME: use buffer for output */

  } else /* server */
  {
    /* register dense output */
    register_param_dense<T>(rc, b, n);

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

      /* 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>(), static_cast<rdint_t>(n * sizeof(T)), b);
          redirect_cache_put_entry(rc->cache, get_type<T>(), n * sizeof(T), b);
        }

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq 0xc0471(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91cc8(%rip), %rsi     # 0xa5811
leaq 0x91fe2(%rip), %rdx     # 0xa5b32
movb $0x0, %al
callq 0xc9a0
movq 0xc0452(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
leaq 0x91e8b(%rip), %rsi     # 0xa5a03
movb $0x0, %al
callq 0xc9a0
movq 0xc042a(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91d18(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x13ba5
jmp 0x13d40
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x171f0
movq -0x8(%rbp), %rax
cmpq $0x0, 0xba8(%rax)
je 0x13d3e
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x17650
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0xba8(%rax), %rax
movq %rax, -0x38(%rbp)
callq 0x152e0
movq -0x38(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rdx
shlq $0x0, %rdx
movq -0x18(%rbp), %rcx
callq 0x116f0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0x13c1a
cmpq $0x0, -0x30(%rbp)
jl 0x13d3c
cmpq $0x0, -0x30(%rbp)
jl 0x13c8f
jmp 0x13c23
movq 0xc0386(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91bdd(%rip), %rsi     # 0xa5811
leaq 0x91ef7(%rip), %rdx     # 0xa5b32
movb $0x0, %al
callq 0xc9a0
movq 0xc0367(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x30(%rbp), %rdx
leaq 0x91e9d(%rip), %rsi     # 0xa5af4
movb $0x0, %al
callq 0xc9a0
movq 0xc034b(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91c39(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
movq 0xba8(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x117b0
jmp 0x13d26
jmp 0x13c91
movq 0xc0318(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91b6f(%rip), %rsi     # 0xa5811
leaq 0x91e89(%rip), %rdx     # 0xa5b32
movb $0x0, %al
callq 0xc9a0
movq 0xc02f9(%rip), %rax     # 0xd3fb0
movq (%rax), %rax
movq %rax, -0x40(%rbp)
callq 0x152e0
movq -0x40(%rbp), %rdi
movl %eax, %edx
movq -0x20(%rbp), %rcx
shlq $0x0, %rcx
movq -0x18(%rbp), %r8
leaq 0x91e34(%rip), %rsi     # 0xa5b10
movb $0x0, %al
callq 0xc9a0
movq 0xc02c6(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x91bb4(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
movq 0xba8(%rax), %rax
movq %rax, -0x48(%rbp)
callq 0x152e0
movq -0x48(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rdx
shlq $0x0, %rdx
movq -0x18(%rbp), %rcx
callq 0x11520
cmpq $0x0, -0x28(%rbp)
jl 0x13d3a
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x176c0
jmp 0x13d3c
jmp 0x13d3e
jmp 0x13d40
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)