// File: 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
movq %rsp, %rbp
subq $0x90, %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 0xbb426(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cc7d(%rip), %rsi     # 0xa5811
leaq 0x8d26e(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb407(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x8(%rbp), %rdx
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq (%rax), %r8
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %r10
movq -0x30(%rbp), %rax
movq (%rax), %rax
leaq 0x8d196(%rip), %rsi     # 0xa5d67
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0xc9a0
movq 0xbb3c8(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8ccb6(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
jmp 0x18bfb
movq -0x8(%rbp), %rax
cmpl $0x0, (%rax)
je 0x18c1c
movq 0xbb3cd(%rip), %rax     # 0xd3fd8
movq (%rax), %rdi
leaq 0x8ce96(%rip), %rsi     # 0xa5aab
movb $0x0, %al
callq 0xc9a0
jmp 0x18c1e
movb $0x0, -0x31(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x8d1ac(%rip), %rsi     # 0xa5dd9
leaq -0x40(%rbp), %rdx
callq 0x13080
movq 0xbb373(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cbca(%rip), %rsi     # 0xa5811
leaq 0x8d1bb(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb354(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x40(%rbp), %rdx
leaq 0x8d15a(%rip), %rsi     # 0xa5dc4
movb $0x0, %al
callq 0xc9a0
movq 0xbb338(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cc26(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x18c9e
movq -0x40(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movb $0x1, -0x31(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq 0xbb2f7(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cb4e(%rip), %rsi     # 0xa5811
leaq 0x8d13f(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb2d8(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
leaq 0x8d148(%rip), %rsi     # 0xa5e32
movb $0x0, %al
callq 0xc9a0
movq 0xbb2b8(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cba6(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x18(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x18d46
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0x189e0
movq -0x60(%rbp), %rdi
movq %rax, %rsi
shlq $0x2, %rsi
callq 0x172d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
je 0x18d65
testb $0x1, -0x31(%rbp)
je 0x18e05
jmp 0x18d67
movq 0xbb242(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8ca99(%rip), %rsi     # 0xa5811
leaq 0x8d08a(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb223(%rip), %rax     # 0xd3fb0
movq (%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x189e0
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x8d0a3(%rip), %rsi     # 0xa5e56
movb $0x0, %al
callq 0xc9a0
movq 0xbb1ef(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8cadd(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x50(%rbp), %rdx
callq 0x189e0
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq %rax, %rdx
callq 0x17d30
jmp 0x18e7b
jmp 0x18e07
movq 0xbb1a2(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c9f9(%rip), %rsi     # 0xa5811
leaq 0x8cfea(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb183(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x50(%rbp), %r8
leaq 0x8d026(%rip), %rsi     # 0xa5e69
movb $0x0, %al
callq 0xc9a0
movq 0xbb15f(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8ca4d(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x50(%rbp), %r8
callq 0x18f00
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq (%rcx), %rax
je 0x18ee8
jmp 0x18e8a
movq 0xbb11f(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c976(%rip), %rsi     # 0xa5811
leaq 0x8cf67(%rip), %rdx     # 0xa5e09
movb $0x0, %al
callq 0xc9a0
movq 0xbb100(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
movq -0x50(%rbp), %rdx
leaq 0x8cfcb(%rip), %rsi     # 0xa5e89
movb $0x0, %al
callq 0xc9a0
movq 0xbb0e4(%rip), %rax     # 0xd3fb0
movq (%rax), %rdi
leaq 0x8c9d2(%rip), %rsi     # 0xa58a8
movb $0x0, %al
callq 0xc9a0
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)