// File: /workspace/github_cpp_makefile_star2_O2/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 0x37d1e(%rip), %rdi     # 0x44485
movq %rbp, %rdx
movq %r13, %rcx
movq %r8, 0x8(%rsp)
movq %r15, %r9
xorl %eax, %eax
pushq %rbx
pushq %r14
callq 0xb070
popq %rcx
popq %rdx
leaq 0x37d66(%rip), %r12     # 0x444ee
movq %r12, %rdi
movq %r15, %rsi
callq 0xc669
movq %r12, %rdi
movq %r14, %rsi
callq 0xc699
testq %r14, %r14
je 0xc7b5
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%r14)
movb $0x6e, 0x30(%r14)
movups %xmm0, 0x38(%r14)
cmpb $0x67, (%r13)
jne 0xc865
cmpb $0x65, 0x1(%r13)
jne 0xc865
cmpb $0x74, 0x2(%r13)
jne 0xc865
leaq 0x37d24(%rip), %rsi     # 0x44501
pushq $0x6
popq %rdx
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xb260
testl %eax, %eax
je 0xc8f7
leaq 0x37d16(%rip), %rsi     # 0x44512
pushq $0x6
popq %rdx
movq %r12, %rdi
callq 0xb260
testl %eax, %eax
je 0xc912
leaq 0x37d0e(%rip), %rsi     # 0x44524
pushq $0x6
popq %rdx
movq %r12, %rdi
callq 0xb260
testl %eax, %eax
je 0xc95c
movq %r15, %rdi
callq 0xc999
cmpb $0x0, (%r12)
je 0xc926
leaq 0x37d07(%rip), %rsi     # 0x4454a
leaq 0x10(%rsp), %rdx
movq %r12, %rdi
xorl %eax, %eax
callq 0xb510
cmpl $0x1, %eax
jne 0xc926
movq 0x10(%rsp), %rax
jmp 0xc932
movq %r15, %rdi
callq 0xc999
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
movq 0x10(%r14), %rdi
leaq 0x37cd0(%rip), %rsi     # 0x44554
movq %rbp, %rdx
movq %r13, %rcx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0xb0c0
cltq
movq %rax, 0x20(%r14)
movq %rax, 0x28(%r14)
movb $0x78, 0x30(%r14)
leaq 0x37c42(%rip), %rdi     # 0x444ee
movq %r14, %rsi
callq 0xc699
movq (%rbx), %rdx
addq $0x8, %rbx
decq %rdx
leaq 0x37cb6(%rip), %rsi     # 0x4457b
movq %rbx, %rdi
callq 0xb2c0
leaq 0x37cc2(%rip), %rdi     # 0x44596
pushq $0x1
popq %r14
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0xb070
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r15, %r15
je 0xc8a5
leaq 0x37c05(%rip), %rsi     # 0x44508
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x1c16f
jmp 0xc8a5
testq %r15, %r15
je 0xc8a5
leaq 0x37bfb(%rip), %rsi     # 0x44519
movq %r14, %rdi
movq %r15, %rdx
jmp 0xc98d
movq $0x2, 0x10(%rsp)
pushq $0x2
popq %rax
movb $0x0, 0x4(%r14)
movl $0x74786574, (%r14)     # imm = 0x74786574
imulq $0xd, %rax, %rcx
movq %rcx, 0x28(%r14)
movb $0x78, 0x30(%r14)
movq %rax, 0x40(%r14)
movq %r14, %rdi
callq 0xc6c9
jmp 0xc8a5
testq %r15, %r15
je 0xc8a5
leaq 0x37bbf(%rip), %rsi     # 0x4452b
leaq 0x37bc0(%rip), %r12     # 0x44533
movq %r15, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1c16f
leaq 0x37bb9(%rip), %rsi     # 0x44540
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1c29a
jmp 0xc8a5