// File: /workspace/github_cpp_makefile_star2_O3/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 0x4ea9a(%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 0x4eae0(%rip), %r12     # 0x5b4ee
movq %r12, %rdi
movq %r15, %rsi
callq 0xc8e7
movq %r12, %rdi
movq %r14, %rsi
callq 0xc917
testq %r14, %r14
je 0xca3b
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movb $0x6e, 0x30(%r14)
movups %xmm0, 0x38(%r14)
cmpb $0x67, (%r13)
jne 0xcaf1
cmpb $0x65, 0x1(%r13)
jne 0xcaf1
cmpb $0x74, 0x2(%r13)
jne 0xcaf1
leaq 0x4ea9e(%rip), %rsi     # 0x5b501
movl $0x6, %edx
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcb83
leaq 0x4ea8e(%rip), %rsi     # 0x5b512
movl $0x6, %edx
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcb9e
leaq 0x4ea84(%rip), %rsi     # 0x5b524
movl $0x6, %edx
movq %r12, %rdi
callq 0xb240
testl %eax, %eax
je 0xcbee
movq %r15, %rdi
callq 0xcc2b
cmpb $0x0, (%r12)
je 0xcbb2
leaq 0x4ea7b(%rip), %rsi     # 0x5b54a
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0xb4e0
cmpl $0x1, %eax
jne 0xcbb2
movq 0x10(%rsp), %rax
jmp 0xcbc0
movq %r15, %rdi
callq 0xcc2b
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
movq 0x10(%r14), %rdi
leaq 0x4ea44(%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 0x4e9b6(%rip), %rdi     # 0x5b4ee
movq %r14, %rsi
callq 0xc917
movq (%rbx), %rdx
addq $0x8, %rbx
decq %rdx
leaq 0x4ea2a(%rip), %rsi     # 0x5b57b
movq %rbx, %rdi
callq 0xb2a0
leaq 0x4ea36(%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
testq %r15, %r15
je 0xcb31
leaq 0x4e979(%rip), %rsi     # 0x5b508
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x21b7e
jmp 0xcb31
testq %r15, %r15
je 0xcb31
leaq 0x4e96f(%rip), %rsi     # 0x5b519
movq %r14, %rdi
movq %r15, %rdx
jmp 0xcc1f
movq $0x2, 0x10(%rsp)
movl $0x2, %eax
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
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 0xc947
jmp 0xcb31
testq %r15, %r15
je 0xcb31
leaq 0x4e92d(%rip), %rsi     # 0x5b52b
leaq 0x4e92e(%rip), %r12     # 0x5b533
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x21b7e
leaq 0x4e927(%rip), %rsi     # 0x5b540
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x21d0e
jmp 0xcb31