// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/src/lib/redirect/redirect/redirect_call.cc
// Function: void redirect_call_get_output_param_blocks_val<float>(_redirect_call_t*, char const*, float**, long, long, long*)
void redirect_call_get_output_param_blocks_val(redirect_call_t *rc, const char *id, 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 */
  {
    bool transfer_dense = false;
    rdint_t transfer_stride;

    redirect_call_get_output_conf_rdint(rc, "stride", &transfer_stride);
    TRACE_F("transfer stride: %" rdint_fmt, transfer_stride);

    if (*stride == 0) *stride = transfer_stride;

    rdint_t alloc_stride, recv_stride;

#if REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PLAIN
    transfer_dense = true;
    alloc_stride = transfer_stride;
    recv_stride = transfer_stride;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_IP
    transfer_dense = true;
    alloc_stride = z_max(*stride, transfer_stride);
    recv_stride = transfer_stride;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_OP
    transfer_dense = true;
    alloc_stride = *stride;
    recv_stride = transfer_stride;
#elif REDIRECT_CALL_OUTPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PIECES
    transfer_dense = false;
    alloc_stride = *stride;
    recv_stride = *stride;
#endif

    TRACE_F("alloc stride: %" rdint_fmt ", recv stride: %" rdint_fmt, alloc_stride, recv_stride);

    if (*b == NULL) *b = static_cast<T *>(redirect_call_alloc_buf(rc, get_blocks_cont_size(count, size, alloc_stride) * sizeof(T)));

    T* b_recv = *b;

#if REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_OP
    T *b_tmp = 0;
    if (recv_stride != *stride) b_recv = b_tmp = static_cast<T *>(malloc(get_blocks_cont_size(count, size, transfer_stride) * sizeof(T)));
#endif

    if (recv_stride == transfer_stride || transfer_dense)
    {
      TRACE_F("consume dense: %" rdint_fmt, get_blocks_cont_size(count, size, recv_stride));
      consume_output_dense<T>(rc, b_recv, get_blocks_cont_size(count, size, recv_stride));

    } else
    {
      TRACE_F("consume blocks: %" rdint_fmt " x %" rdint_fmt " / %" rdint_fmt, count, size, recv_stride);
      consume_output_blocks<T>(rc, b_recv, count, size, recv_stride);
    }

    if (recv_stride != *stride)
    {
#if REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PLAIN
      TRACE_F("set stride %" rdint_fmt, recv_stride);
      *stride = recv_stride;
#elif REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_IP
      TRACE_F("transform in-place to stride %" rdint_fmt, *stride);
      redirect_data_blocks_transform_val<T>(count, size, recv_stride, b_recv, *stride, NULL);
#elif REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_OP
      TRACE_F("transform out-of-place to stride: %" rdint_fmt, *stride);
      redirect_data_blocks_transform_val<T>(count, size, recv_stride, b_recv, *stride, *b);
      free(b_tmp);
#elif REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PIECES
      /* this should never occur, because pieces are received with the correct stride */
      ASSERT(false);
#endif
    }

  } else /* server */
  {
    if (*b == NULL)
    {
      /* default stride is size */
      if (*stride == 0) *stride = size;

      /* FIXME: use output instead of allocation */

      /* allocate buffer */
      *b = static_cast<T *>(redirect_call_alloc_buf(rc, get_blocks_cont_size(count, size, *stride) * sizeof(T)));
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r12
movq %rcx, %r13
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movq 0x738d7(%rip), %rbp     # 0x8bfa0
movq (%rbp), %rdi
leaq 0x51155(%rip), %rsi     # 0x69829
leaq 0x51836(%rip), %rdx     # 0x69f11
xorl %eax, %eax
callq 0xb7a0
movq (%rbp), %rdi
movq (%r15), %r8
leaq 0x5168f(%rip), %rsi     # 0x69d7f
movq %r14, %rdx
movq %rbx, %rcx
movq %r13, 0x8(%rsp)
movq %r13, %r9
movq %rbp, %r13
movq 0x10(%rsp), %rbp
xorl %eax, %eax
pushq (%rbp)
pushq %r12
callq 0xb7a0
addq $0x10, %rsp
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
cmpl $0x0, (%r14)
je 0x18801
movq 0x160(%r14), %rax
leaq (%r14,%rax), %rdi
addq $0x568, %rdi            # imm = 0x568
leaq 0x20(%rsp), %rbx
movq %rbx, %rsi
callq 0x12005
addq %rax, 0x160(%r14)
movq (%r13), %rdi
leaq 0x510ca(%rip), %rsi     # 0x69829
leaq 0x517ab(%rip), %rdx     # 0x69f11
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rdi
movq (%rbx), %rdx
leaq 0x51661(%rip), %rsi     # 0x69ddc
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
cmpq $0x0, (%rbp)
movq (%rbx), %rbp
jne 0x187a2
movq 0x10(%rsp), %rax
movq %rbp, (%rax)
movq (%r13), %rdi
leaq 0x5107c(%rip), %rsi     # 0x69829
leaq 0x5175d(%rip), %rdx     # 0x69f11
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rdi
leaq 0x51684(%rip), %rsi     # 0x69e4a
movq %rbp, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
movq (%r15), %rbx
testq %rbx, %rbx
jne 0x1887e
movslq 0xb20(%r14), %rax
cmpq $0xf, %rax
jle 0x18833
movq %r15, %rcx
xorl %ebx, %ebx
jmp 0x1887b
cmpq $0x0, (%r15)
jne 0x18974
movq (%rbp), %rdi
testq %rdi, %rdi
jne 0x1881b
movq %r12, (%rbp)
movq %r12, %rdi
movslq 0xb20(%r14), %rbx
cmpq $0xf, %rbx
jle 0x18938
xorl %eax, %eax
jmp 0x18971
movq %rax, 0x18(%rsp)
movq 0x8(%rsp), %rax
leaq -0x1(%rax), %rdi
imulq %rbp, %rdi
addq %r12, %rdi
shlq $0x2, %rdi
testq %r12, %r12
cmoveq %r12, %rdi
testq %rax, %rax
cmoveq %rax, %rdi
callq 0xb6f0
movq %r15, %rcx
movq %rax, %rbx
movq 0x18(%rsp), %rax
movq %rbx, 0xb28(%r14,%rax,8)
incl %eax
movl %eax, 0xb20(%r14)
movq %rbx, (%rcx)
movq 0x8(%rsp), %rcx
leaq -0x1(%rcx), %rax
imulq %rbp, %rax
addq %r12, %rax
testq %r12, %r12
cmoveq %r12, %rax
cmpq $0x1, %rcx
movq (%r13), %rdi
leaq 0x5166d(%rip), %rdx     # 0x69f11
leaq 0x50f7e(%rip), %rsi     # 0x69829
movl $0x0, %r15d
cmovaeq %rax, %r15
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rdi
leaq 0x515a7(%rip), %rsi     # 0x69e6e
movq %r15, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x12a1c
movq 0x10(%rsp), %rbx
cmpq (%rbx), %rbp
je 0x18974
movq (%r13), %rdi
leaq 0x50f27(%rip), %rsi     # 0x69829
leaq 0x51608(%rip), %rdx     # 0x69f11
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rdi
leaq 0x51620(%rip), %rsi     # 0x69f3b
movq %rbp, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%r13), %rsi
movl $0xa, %edi
callq 0xb690
movq %rbp, (%rbx)
jmp 0x18974
movq 0x8(%rsp), %rcx
leaq -0x1(%rcx), %rax
imulq %rax, %rdi
addq %r12, %rdi
shlq $0x2, %rdi
testq %r12, %r12
cmoveq %r12, %rdi
testq %rcx, %rcx
cmoveq %rcx, %rdi
callq 0xb6f0
movq %rax, 0xb28(%r14,%rbx,8)
leal 0x1(%rbx), %ecx
movl %ecx, 0xb20(%r14)
movq %rax, (%r15)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq