// File: /workspace/github_cpp_makefile_star2_O1/mh0fm4[P]SCDC/test/units/dataprov_hook/hook.c
// Function: hook_dataset_cmd
scdcint_t hook_dataset_cmd(void *dataprov, void *dataset, const char *cmd, const char *params, scdc_dataset_input_t *input, scdc_dataset_output_t *output, scdc_result_t *result)
{
  ptrdiff_t x;

  printf("hook_dataset_cmd: dataprov: %p, dataset: %p, cmd: '%s', params: '%s', input: %p, output: %p, result: %p\n", dataprov, dataset, cmd, params, input, output, result);
  print_dataset_input("hook_dataset_cmd: ", input);
  print_dataset_output("hook_dataset_cmd: ", output);

  clear_output(output);

  if (strncmp(cmd, "get", 3) == 0)
  {
    if (strncmp(params, "in2out", 6) == 0)
    {
      if (input)
      {
        scdc_dataset_input_redirect(input, "to:output", output);
      }

    } else if (strncmp(params, "in4out", 6) == 0)
    {
      if (input)
      {
        scdc_dataset_output_redirect(output, "from:input", input);
      }

    } else if (strncmp(params, "in5out", 6) == 0)
    {
      /* stored */
      if (input)
      {
        scdc_dataset_input_redirect(input, "to:file", "hook_get.tmp");

        scdc_dataset_output_redirect(output, "from:file", "hook_get.tmp");
      }

    } else
    {
      consume_input("hook_dataset_cmd: ", input);

      if (strlen(params) > 0 && sscanf(params, "x%td", &x) == 1);
      else x = 2;

      strcpy(output->format, "text");

      output->total_size = x * DEFAULT_GET_SIZE;
      output->total_size_given = SCDC_DATASET_INOUT_TOTAL_SIZE_GIVEN_EXACT;

      output->data = (void *) x;

      hook_dataset_get_next(output, 0);
    }

  } else
  {
    consume_input("hook_dataset_cmd: ", input);

    strcpy(output->format, "text");

    SCDC_DATASET_INOUT_BUF_CURRENT(output) = sprintf(SCDC_DATASET_INOUT_BUF_PTR(output), "dataset: '%p', cmd: '%s', params: '%s'", dataset, cmd, params);
    output->total_size = SCDC_DATASET_INOUT_BUF_CURRENT(output);
    output->total_size_given = SCDC_DATASET_INOUT_TOTAL_SIZE_GIVEN_EXACT;
  }

  print_dataset_output("hook_dataset_cmd: ", output);

  SCDC_RESULT_SET_STR(result, "result of hook_dataset_cmd");
  printf("hook_dataset_cmd: return: %" scdcint_fmt ", result: '%s'", SCDC_SUCCESS, SCDC_RESULT_STR(result));

  return SCDC_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %r14
movq %r8, %r15
movq %rcx, %r8
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %rsi
movq 0x50(%rsp), %rbx
leaq 0x4ea74(%rip), %rdi     # 0x5b485
movq %rbp, %rdx
movq %r13, %rcx
movq %r8, 0x8(%rsp)
movq %r15, %r9
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0xb080
addq $0x10, %rsp
leaq 0x4eaba(%rip), %r12     # 0x5b4ee
movq %r12, %rdi
movq %r15, %rsi
callq 0xc90d
movq %r12, %rdi
movq %r14, %rsi
callq 0xc93d
testq %r14, %r14
je 0xca61
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movb $0x6e, 0x30(%r14)
movups %xmm0, 0x38(%r14)
leaq 0x4f5f6(%rip), %rsi     # 0x5c05e
movl $0x3, %edx
movq %r13, %rdi
callq 0xb240
testl %eax, %eax
je 0xcb0f
movq %r15, %rdi
callq 0xcc45
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
movq 0x10(%r14), %rdi
leaq 0x4eab8(%rip), %rsi     # 0x5b554
movq %rbp, %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0xb0d0
cltq
movq %rax, 0x20(%r14)
movq %rax, 0x28(%r14)
movb $0x78, 0x30(%r14)
leaq 0x4ea2a(%rip), %rdi     # 0x5b4ee
movq %r14, %rsi
callq 0xc93d
movq (%rbx), %rdx
addq $0x8, %rbx
decq %rdx
leaq 0x4ea9e(%rip), %rsi     # 0x5b57b
movq %rbx, %rdi
callq 0xb2a0
leaq 0x4eaaa(%rip), %rdi     # 0x5b596
movl $0x1, %esi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb080
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4e9eb(%rip), %rsi     # 0x5b501
movl $0x6, %edx
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcbce
leaq 0x4e9db(%rip), %rsi     # 0x5b512
movl $0x6, %edx
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcbf0
leaq 0x4e9d1(%rip), %rsi     # 0x5b524
movl $0x6, %edx
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcc08
movq %r15, %rdi
callq 0xcc45
cmpb $0x0, (%r12)
je 0xcb92
leaq 0x4e9cc(%rip), %rsi     # 0x5b54a
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0xb4e0
cmpl $0x1, %eax
je 0xcb9b
movq $0x2, 0x10(%rsp)
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
movq 0x10(%rsp), %rax
leaq (%rax,%rax,2), %rcx
leaq (%rax,%rcx,4), %rcx
movq %rcx, 0x28(%r14)
movb $0x78, 0x30(%r14)
movq %rax, 0x40(%r14)
movq %r14, %rdi
callq 0xc96d
jmp 0xcabd
testq %r15, %r15
je 0xcabd
leaq 0x4e92a(%rip), %rsi     # 0x5b508
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21d8f
jmp 0xcabd
testq %r15, %r15
je 0xcabd
leaq 0x4e919(%rip), %rsi     # 0x5b519
movq %r14, %rdi
movq %r15, %rdx
jmp 0xcc39
testq %r15, %r15
je 0xcabd
leaq 0x4e913(%rip), %rsi     # 0x5b52b
leaq 0x4e914(%rip), %r12     # 0x5b533
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x21d8f
leaq 0x4e90d(%rip), %rsi     # 0x5b540
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x21f24
jmp 0xcabd