// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/lib/redirect/redirect/redirect_call.cc
// Function: void redirect_call_get_input_param_blocks_val<float>(_redirect_call_t*, char const*, float**, long, long, long*)
static void redirect_call_get_input_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);

  /* server only */
  ASSERT(!rc->client);

  bool transfer_dense = false;
  rdint_t transfer_stride;

  redirect_call_get_input_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_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PLAIN
  transfer_dense = true;
  alloc_stride = transfer_stride;
  recv_stride = transfer_stride;
#elif REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_IP
  transfer_dense = true;
  alloc_stride = z_max(*stride, transfer_stride);
  recv_stride = transfer_stride;
#elif REDIRECT_CALL_INPUT_PARAM_BLOCKS == REDIRECT_CALL_BLOCKS_PACK_OP
  transfer_dense = true;
  alloc_stride = *stride;
  recv_stride = transfer_stride;
#elif REDIRECT_CALL_INPUT_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_input_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_input_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 to %" 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
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r14
movq %rsi, (%rsp)
movq %rdi, %r15
movq 0x63143(%rip), %r13     # 0x74fb8
movq (%r13), %rdi
leaq 0x3e989(%rip), %rsi     # 0x50809
leaq 0x3ef7a(%rip), %rdx     # 0x50e01
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
movq %r14, 0x8(%rsp)
movq (%r14), %r8
movq %r15, %r14
movq %r12, %r15
movq %rbp, %r12
movq %rbx, %rbp
leaq 0x3eeb2(%rip), %rsi     # 0x50d5f
movq %r14, %rdx
movq (%rsp), %rcx
movq %r15, %r9
xorl %eax, %eax
pushq (%rbx)
pushq %r12
callq 0xb7c0
popq %rcx
popq %rdx
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
cmpl $0x0, (%r14)
jne 0x12081
leaq 0x10(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rdx
callq 0xf9d0
movq (%r13), %rdi
leaq 0x3e914(%rip), %rsi     # 0x50809
leaq 0x3ef05(%rip), %rdx     # 0x50e01
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
movq (%rbx), %rdx
leaq 0x3eeab(%rip), %rsi     # 0x50dbc
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq %rbp, (%rsp)
cmpq $0x0, (%rbp)
movq (%rbx), %rbp
jne 0x11f39
movq (%rsp), %rax
movq %rbp, (%rax)
movq (%r13), %rdi
leaq 0x3e8c5(%rip), %rsi     # 0x50809
leaq 0x3eeb6(%rip), %rdx     # 0x50e01
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
leaq 0x3eecd(%rip), %rsi     # 0x50e2a
movq %rbp, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq 0x8(%rsp), %rax
movq (%rax), %rbx
testq %rbx, %rbx
jne 0x11fc4
leaq -0x1(%r15), %rsi
imulq %rbp, %rsi
addq %r12, %rsi
shlq $0x2, %rsi
testq %r12, %r12
cmoveq %r12, %rsi
testq %r15, %r15
cmoveq %r15, %rsi
movq %r14, %rdi
movq %r15, %r13
movq %r14, %r15
movq %rax, %r14
callq 0x114ce
movq %rax, %rbx
movq %rax, (%r14)
movq %r15, %r14
movq %r13, %r15
movq 0x62ff4(%rip), %r13     # 0x74fb8
leaq -0x1(%r15), %rax
imulq %rbp, %rax
addq %r12, %rax
testq %r12, %r12
cmoveq %r12, %rax
cmpq $0x1, %r15
movq (%r13), %rdi
leaq 0x3ee1c(%rip), %rdx     # 0x50e01
leaq 0x3e81d(%rip), %rsi     # 0x50809
movl $0x0, %r15d
cmovaeq %rax, %r15
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
leaq 0x3ee46(%rip), %rsi     # 0x50e4e
movq %r15, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x117ef
movq (%rsp), %rbx
cmpq (%rbx), %rbp
je 0x12072
movq (%r13), %rdi
leaq 0x3e7c9(%rip), %rsi     # 0x50809
leaq 0x3edba(%rip), %rdx     # 0x50e01
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rdi
leaq 0x3ee08(%rip), %rsi     # 0x50e61
movq %rbp, %rdx
xorl %eax, %eax
callq 0xb7c0
movq (%r13), %rsi
pushq $0xa
popq %rdi
callq 0xb6b0
movq %rbp, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x62f50(%rip), %rax     # 0x74fd8
movq (%rax), %rcx
leaq 0x3ea11(%rip), %rdi     # 0x50aa3
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0xba80
jmp 0x11eda