// File: /workspace/github_cpp_makefile_star2_O1/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 $0x28, %rsp
movq %r9, %rbp
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r12
movq %rsi, 0x8(%rsp)
movq %rdi, %r13
movq 0x791ad(%rip), %rbx     # 0x8bfa0
movq (%rbx), %rdi
leaq 0x56a0c(%rip), %rsi     # 0x69809
leaq 0x56ffd(%rip), %rdx     # 0x69e01
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rdi
movq %r12, 0x20(%rsp)
movq (%r12), %r8
movq %r15, %r12
movq %rbp, %r15
leaq 0x56f3b(%rip), %rsi     # 0x69d5f
movq %r13, %rdx
movq 0x8(%rsp), %rcx
movq %r12, %r9
xorl %eax, %eax
pushq (%rbp)
pushq %r14
callq 0xb7a0
addq $0x10, %rsp
movq (%rbx), %rsi
movl $0xa, %edi
callq 0xb690
cmpl $0x0, (%r13)
jne 0x1302d
movq 0x150(%r13), %rax
leaq (%rax,%r13), %rdi
addq $0x168, %rdi            # imm = 0x168
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
callq 0x12067
addq %rax, 0x150(%r13)
movq (%rbx), %rdi
leaq 0x56982(%rip), %rsi     # 0x69809
leaq 0x56f73(%rip), %rdx     # 0x69e01
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rdi
movq (%rbp), %rdx
leaq 0x56f19(%rip), %rsi     # 0x69dbc
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0xb690
movq %r15, 0x8(%rsp)
cmpq $0x0, (%r15)
jne 0x12ecf
movq 0x10(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
movq 0x10(%rsp), %rbp
movq (%rbx), %rdi
leaq 0x5692b(%rip), %rsi     # 0x69809
leaq 0x56f1c(%rip), %rdx     # 0x69e01
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rdi
leaq 0x56f34(%rip), %rsi     # 0x69e2a
movq %rbp, %rdx
movq %rbp, %rcx
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0xb690
movq 0x20(%rsp), %r15
cmpq $0x0, (%r15)
jne 0x12f6d
movslq 0xb20(%r13), %rax
cmpq $0xf, %rax
jle 0x12f2c
xorl %eax, %eax
jmp 0x12f6a
leaq -0x1(%r12), %rdi
imulq %rbp, %rdi
addq %r14, %rdi
shlq $0x2, %rdi
testq %r14, %r14
cmoveq %r14, %rdi
testq %r12, %r12
cmoveq %r12, %rdi
movq %rax, 0x18(%rsp)
callq 0xb6f0
movq 0x18(%rsp), %rcx
movq %rax, 0xb28(%r13,%rcx,8)
incl %ecx
movl %ecx, 0xb20(%r13)
movq %rax, (%r15)
leaq -0x1(%r12), %rax
imulq %rbp, %rax
addq %r14, %rax
testq %r14, %r14
cmoveq %r14, %rax
cmpq $0x1, %r12
movq (%r15), %r15
movq (%rbx), %rdi
leaq 0x56e70(%rip), %rdx     # 0x69e01
leaq 0x56871(%rip), %rsi     # 0x69809
movl $0x0, %r12d
cmovaeq %rax, %r12
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rdi
leaq 0x56e9b(%rip), %rsi     # 0x69e4e
movq %r12, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0xb690
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x126ce
movq 0x8(%rsp), %r14
cmpq (%r14), %rbp
je 0x1301e
movq (%rbx), %rdi
leaq 0x5681d(%rip), %rsi     # 0x69809
leaq 0x56e0e(%rip), %rdx     # 0x69e01
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rdi
leaq 0x56e5d(%rip), %rsi     # 0x69e61
movq %rbp, %rdx
xorl %eax, %eax
callq 0xb7a0
movq (%rbx), %rsi
movl $0xa, %edi
callq 0xb690
movq %rbp, (%r14)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xbfd8
jmp 0x12e57