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

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

  } else /* server */
  {
    bool transfer_dense = false;
    rdint_t send_stride = stride;
    rdint_t transfer_stride = stride;

    if (size < stride)
    {
#if REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PLAIN
      TRACE_F("transfer plain");
      transfer_dense = true;
      send_stride = stride;
      transfer_stride = stride;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_IP
      TRACE_F("transform in-place to stride: %" rdint_fmt, size);
      redirect_data_blocks_transform_val<T>(count, size, stride, const_cast<T *>(b), size, NULL);
      transfer_dense = true;
      send_stride = size;
      transfer_stride = size;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_OP
      TRACE_F("transform out-of-place to stride: %" rdint_fmt, size);
      T *b_tmp = static_cast<T *>(redirect_call_alloc_buf(rc, count * size * sizeof(T)));
      redirect_data_blocks_transform_val<T>(count, size, stride, const_cast<T *>(b), size, b_tmp);
      b = b_tmp;
      transfer_dense = true;
      send_stride = size;
      transfer_stride = size;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PIECES
      TRACE_F("process in pieces");
      transfer_dense = false;
      send_stride = stride;
      transfer_stride = size;
#endif
    }

    TRACE_F("send stride: %" rdint_fmt ", transfer stride: %" rdint_fmt, send_stride, transfer_stride);
    redirect_call_put_output_conf_rdint(rc, "stride", transfer_stride);

    if (size >= send_stride || transfer_dense)
    {
      TRACE_F("dense: %" rdint_fmt, get_blocks_cont_size(count, size, send_stride));
      register_param_dense<T>(rc, b, get_blocks_cont_size(count, size, send_stride));

    } else
    {
      TRACE_F("blocks: %" rdint_fmt " x %" rdint_fmt " / %" rdint_fmt, count, size, send_stride);
      register_param_blocks<T>(rc, b, count, size, send_stride);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq 0xbaea9(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c700(%rip), %rsi     # 0xa5811
leaq 0x8cdad(%rip), %rdx     # 0xa5ec5
movb $0x0, %al
callq 0xc9a0
movq 0xbae8a(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
leaq 0x8cc1f(%rip), %rsi     # 0xa5d67
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0xc9a0
movq 0xbae51(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c73f(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1917e
jmp 0x1939a
movb $0x0, -0x31(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
cmpq -0x30(%rbp), %rax
jge 0x19201
jmp 0x1919e
movq 0xbae0b(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c662(%rip), %rsi     # 0xa5811
leaq 0x8cd0f(%rip), %rdx     # 0xa5ec5
movb $0x0, %al
callq 0xc9a0
movq 0xbadec(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cbd5(%rip), %rsi     # 0xa5da3
movb $0x0, %al
callq 0xc9a0
movq 0xbadd4(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c6c2(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movb $0x1, -0x31(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x19203
movq 0xbada6(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c5fd(%rip), %rsi     # 0xa5811
leaq 0x8ccaa(%rip), %rdx     # 0xa5ec5
movb $0x0, %al
callq 0xc9a0
movq 0xbad87(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
movq -0x48(%rbp), %rcx
leaq 0x8cb77(%rip), %rsi     # 0xa5db2
movb $0x0, %al
callq 0xc9a0
movq 0xbad67(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c655(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0x8cb70(%rip), %rsi     # 0xa5dd9
callq 0x13110
movq -0x28(%rbp), %rax
cmpq -0x40(%rbp), %rax
jge 0x19282
testb $0x1, -0x31(%rbp)
je 0x19322
jmp 0x19284
movq 0xbad25(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c57c(%rip), %rsi     # 0xa5811
leaq 0x8cc29(%rip), %rdx     # 0xa5ec5
movb $0x0, %al
callq 0xc9a0
movq 0xbad06(%rip), %rax     # 0xd3fb0
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x189e0
movq -0x50(%rbp), %rdi
movq %rax, %rdx
leaq 0x8cb8e(%rip), %rsi     # 0xa5e5e
movb $0x0, %al
callq 0xc9a0
movq 0xbacd2(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c5c0(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x189e0
movq -0x60(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x17a80
jmp 0x19398
jmp 0x19324
movq 0xbac85(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c4dc(%rip), %rsi     # 0xa5811
leaq 0x8cb89(%rip), %rdx     # 0xa5ec5
movb $0x0, %al
callq 0xc9a0
movq 0xbac66(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %r8
leaq 0x8cb11(%rip), %rsi     # 0xa5e71
movb $0x0, %al
callq 0xc9a0
movq 0xbac42(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c530(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x40(%rbp), %r8
callq 0x18a30
jmp 0x1939a
addq $0x70, %rsp
popq %rbp
retq