// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/src/lib/scdc/scdc.cc
// Function: scdc_dataset_cmd_intern
scdcint_t scdc_dataset_cmd_intern(scdc_dataset_t dataset, const char *cmd, scdc_dataset_input_t *input, scdc_dataset_output_t *output, scdc_args_t *args)
{
  SCDC_TRACE(__func__ << ": dataset: '" << dataset << "', cmd = '" << string(cmd) << "'" << ", input = " << static_cast<void *>(input) << ", output = " << static_cast<void *>(output));

  scdcint_t cmd_size = strlen(cmd);

  string adhoc_cmd;

  if (dataset == SCDC_DATASET_NULL)
  {
    dataset = new _scdc_dataset_t;
    dataset->dataset = 0;

    cmd_size = strlen(cmd);

    string suri, scmd, sparams;
    split_cmdline(cmd, cmd_size, &scmd, &suri, &sparams);

    if (suri.size() <= 0)
    {
      SCDC_RESULT_SET_STR(scdc_main_context.data->result, "no URI given");
      SCDC_FAIL(__func__ << ": " << SCDC_RESULT_STR(scdc_main_context.data->result));
      delete dataset;
      return SCDC_FAILURE;
    }

    string sscheme, sauthority, spath;
    split_uri(suri.c_str(), suri.size(), &sscheme, &sauthority, &spath);

    scdc_args xargs(args);

    dataset->nodeconn = scdc_main_context.data->nodeconns.open(sscheme.c_str(), sauthority.c_str(), &xargs);

    if (!dataset->nodeconn)
    {
      SCDC_RESULT_SET_STR(scdc_main_context.data->result, "open connection failed");
      SCDC_FAIL(__func__ << ": " << SCDC_RESULT_STR(scdc_main_context.data->result));
      delete dataset;
      return SCDC_FAILURE;
    }

    join_uri(0, 0, spath.c_str(), suri);
    suri = ":" + suri;

    join_cmdline(scmd.c_str(), suri.c_str(), sparams.c_str(), adhoc_cmd);

    cmd = adhoc_cmd.c_str();
    cmd_size = adhoc_cmd.size();
  }

  SCDC_TRACE(__func__ << ": adhoc command: '" << adhoc_cmd << "'");

  scdc_dataset_input_t input_null = *SCDC_DATASET_INPUT_NONE;
  if (!input) input = &input_null;

  scdc_dataset_output_t output_null = *SCDC_DATASET_OUTPUT_ENDL;
  if (!output) output = &output_null;

  /* backup original output */
  scdc_dataset_output_t output_given = *output;
  scdc_dataset_inout_intern_t output_intern_given = (output->intern)?*output->intern:SCDC_DATASET_OUTPUT_INTERN_NULL;

  SCDC_TRACE_DATASET_INPUT(input, "scdc_dataset_cmd_intern: IN input: ");
  SCDC_TRACE_DATASET_OUTPUT(output, "scdc_dataset_cmd_intern: IN output: ");

  scdcint_t output_next_hash_in = scdc_dataset_inout_next_hash(output);

  bool ret;
  scdc_result result;

  double cmd_timing = z_time_wtime();

  if (dataset->dataset) ret = dataset->dataset->do_cmd(string(cmd, cmd_size), input, output, result);
  else ret = dataset->nodeconn->dataset_cmd(string(cmd, cmd_size), input, output, result);

  cmd_timing = z_time_wtime() - cmd_timing;
  SCDC_TRACE(__func__ << ": timing: " << cmd_timing);

  SCDC_TRACE(__func__ << ": result: '" << result << "'");

  SCDC_RESULT_SET_STR(scdc_main_context.data->result, result.c_str());

  scdcint_t output_next_hash_out = scdc_dataset_inout_next_hash(output);

  SCDC_TRACE_DATASET_INPUT(input, "scdc_dataset_cmd_intern: OUT input: ");
  SCDC_TRACE_DATASET_OUTPUT(output, "scdc_dataset_cmd_intern: OUT output: ");

  /* if there was an output next given, but the resulting cmd output is different */
  if (output_given.next && output_next_hash_in != output_next_hash_out)
  {
    SCDC_TRACE(__func__ << ": redirecting cmd output to given output");
    scdc_dataset_output_redirect(output, "to:outputsink", &output_given);

    /* restore original output */
    *output = output_given;

    if (output->intern) *output->intern = output_intern_given;
  }

  if (ret)
  {
    SCDC_TRACE(__func__ << ": successful");

/*    SCDC_INFO("scdc_dataset_cmd: timing: " << cmd_timing << ", input: " << ((input)?input->total_size:0) / cmd_timing * 1e-6 << " MB/s, output: " << ((output)?output->total_size:0) / cmd_timing * 1e-6 << " MB/s");*/

  } else SCDC_TRACE(__func__ << ": failed: '" << SCDC_DATASET_OUTPUT_STR(output) << "'");

  if (!dataset->dataset)
  {
    scdc_main_context.data->nodeconns.close(dataset->nodeconn);

    delete dataset;
    dataset = SCDC_DATASET_NULL;
  }

/*  if (ret) SCDC_INFO("using dataset " << dataset << " to execute command '" << cmd << "'");*/

  return (ret)?SCDC_SUCCESS:SCDC_FAILURE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1f8, %rsp            # imm = 0x1F8
movq %r8, %rbp
movq %rcx, %r14
movq %rdx, %r13
movq %rdi, %rbx
movq %rsi, 0x38(%rsp)
movq %rsi, %rdi
callq 0xb200
movq %rax, 0x30(%rsp)
leaq 0xa0(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
testq %rbx, %rbx
jne 0x1a723
movl $0x20, %edi
callq 0xb500
movq %rax, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x4000, %edi           # imm = 0x4000
callq 0xb040
movq %rax, 0x10(%rbx)
movq $0x4000, 0x18(%rbx)     # imm = 0x4000
xorl %eax, %eax
movq %rax, 0x8(%rbx)
leaq 0xe0(%rsp), %r15
movq %r15, -0x10(%r15)
movq %rax, -0x8(%r15)
movb %al, (%r15)
leaq 0x138(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x70(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x128(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
leaq 0x60(%rsp), %r8
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1c48f
movq 0xd8(%rsp), %rsi
testq %rsi, %rsi
je 0x1a419
leaq 0x50(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq 0xc0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movq 0xd0(%rsp), %rdi
leaq 0x40(%rsp), %rdx
leaq 0x8(%rsp), %rcx
leaq 0xb0(%rsp), %r8
callq 0x1c7df
leaq 0x1c0(%rsp), %rax
movq %rax, 0x8(%rax)
movq %rax, (%rax)
movq $0x0, 0x10(%rax)
movups (%rbp), %xmm0
movups 0x10(%rbp), %xmm1
movaps %xmm0, -0x20(%rax)
movaps %xmm1, -0x10(%rax)
movl $0x98, %edi
addq 0x722b5(%rip), %rdi     # 0x8c5f0
movq 0x40(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
callq 0x32d26
movq %rax, (%rbx)
testq %rax, %rax
setne %al
movl %eax, 0x2c(%rsp)
je 0x1a53b
movq 0xb0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
xorl %edi, %edi
xorl %esi, %esi
callq 0x1caa6
movq %r15, %rbp
leaq 0x4ffdc(%rip), %rsi     # 0x6a364
leaq 0x180(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0x1b7aa
leaq 0xd0(%rsp), %rdi
leaq 0x180(%rsp), %r15
movq %r15, %rsi
callq 0xb670
movq (%r15), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x1a3d5
movq 0x190(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x128(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0x60(%rsp), %rdx
leaq 0x90(%rsp), %rcx
movq %rbp, %r15
callq 0x1c718
movq 0x90(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x1a650
movq 0x721d0(%rip), %rax     # 0x8c5f0
movq (%rax), %rdi
movq (%rdi), %rdx
addq $0x8, %rdi
decq %rdx
leaq 0x4fdd6(%rip), %rsi     # 0x6a20a
callq 0xb2a0
movq 0x72130(%rip), %rdi     # 0x8c570
cmpq $0x0, 0x8(%rdi)
je 0x1a513
addq $0x20, %rdi
callq 0xb7d0
movq 0x72115(%rip), %rax     # 0x8c570
movq 0x8(%rax), %rbp
leaq 0x4fd42(%rip), %rsi     # 0x6a1a8
movl $0xb, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fd3a(%rip), %rsi     # 0x6a1b4
movl $0x9, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fd89(%rip), %rsi     # 0x6a217
movl $0x17, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x53671(%rip), %rsi     # 0x6db13
movl $0x2, %edx
movq %rbp, %rdi
callq 0xb5f0
movq 0x7213a(%rip), %rax     # 0x8c5f0
movq (%rax), %r15
addq $0x8, %r15
movq %r15, %rdi
callq 0xb200
movq %rbp, %rdi
movq %r15, %rsi
leaq 0xe0(%rsp), %r15
movq %rax, %rdx
callq 0xb5f0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq 0x72066(%rip), %rdi     # 0x8c570
addq $0x20, %rdi
callq 0xb3b0
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a521
callq 0xb6c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0xb510
movl $0x0, 0x2c(%rsp)
jmp 0x1a6ba
movq 0x720ae(%rip), %rax     # 0x8c5f0
movq (%rax), %rdi
movq (%rdi), %rdx
addq $0x8, %rdi
decq %rdx
leaq 0x4fcd9(%rip), %rsi     # 0x6a22f
callq 0xb2a0
movq 0x7200e(%rip), %rdi     # 0x8c570
cmpq $0x0, 0x8(%rdi)
je 0x1a635
addq $0x20, %rdi
callq 0xb7d0
movq 0x71ff3(%rip), %rax     # 0x8c570
movq 0x8(%rax), %rbp
leaq 0x4fc20(%rip), %rsi     # 0x6a1a8
movl $0xb, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fc18(%rip), %rsi     # 0x6a1b4
movl $0x9, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fc67(%rip), %rsi     # 0x6a217
movl $0x17, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x5354f(%rip), %rsi     # 0x6db13
movl $0x2, %edx
movq %rbp, %rdi
callq 0xb5f0
movq 0x72018(%rip), %rax     # 0x8c5f0
movq (%rax), %r15
addq $0x8, %r15
movq %r15, %rdi
callq 0xb200
movq %rbp, %rdi
movq %r15, %rsi
leaq 0xe0(%rsp), %r15
movq %rax, %rdx
callq 0xb5f0
movq (%rbp), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbp, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq 0x71f44(%rip), %rdi     # 0x8c570
addq $0x20, %rdi
callq 0xb3b0
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a643
callq 0xb6c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0xb510
leaq 0x1a0(%rsp), %rdi
callq 0x1b76c
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1a682
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1a69e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1a6ba
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1a6d6
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x1a6fb
movq 0x138(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a718
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0xb510
cmpb $0x0, 0x2c(%rsp)
je 0x1a99c
leaq 0x508e6(%rip), %rsi     # 0x6b010
leaq 0x1a0(%rsp), %rax
movl $0xb, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
testq %r13, %r13
cmoveq %rax, %r13
movq %r13, %r15
leaq 0x6fc12(%rip), %rsi     # 0x8a360
leaq 0xd0(%rsp), %rdi
movl $0xb, %ecx
testq %r14, %r14
cmoveq %rdi, %r14
rep  movsq (%rsi), %es:(%rdi)
leaq 0x128(%rsp), %rdi
movl $0xb, %ecx
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq 0x48(%r14), %rax
testq %rax, %rax
jne 0x1a788
leaq 0x50860(%rip), %rax     # 0x6afe8
movq 0x20(%rax), %rcx
movq %rcx, 0x80(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm1, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movq 0x40(%r14), %r13
xorq 0x38(%r14), %r13
xorq 0x50(%r14), %r13
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8(%rsp), %rsi
movl $0x1, %edi
callq 0xb480
movq 0x8(%rbx), %rbp
testq %rbp, %rbp
je 0x1a81a
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x1be38
movq (%rbp), %rax
leaq 0x8(%rsp), %rsi
leaq 0x40(%rsp), %r8
movq %rbp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq *0x10(%rax)
jmp 0x1a858
movq (%rbx), %rbp
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x1be38
movq 0x60(%rbp), %rdi
movq (%rdi), %rax
leaq 0x8(%rsp), %rsi
leaq 0x40(%rsp), %r8
movq %r15, %rdx
movq %r14, %rcx
callq *0x20(%rax)
movl %eax, %ebp
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a871
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
leaq 0x8(%rsp), %rsi
movl $0x1, %edi
callq 0xb480
movq 0x71d69(%rip), %rax     # 0x8c5f0
movq (%rax), %rdi
movq 0x40(%rsp), %rsi
movq (%rdi), %rdx
addq $0x8, %rdi
decq %rdx
callq 0xb2a0
cmpq $0x0, 0x160(%rsp)
je 0x1a90c
movq 0x40(%r14), %rax
xorq 0x38(%r14), %rax
xorq 0x50(%r14), %rax
cmpq %rax, %r13
je 0x1a90c
leaq 0x4f985(%rip), %rsi     # 0x6a246
leaq 0x128(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e106
leaq 0x128(%rsp), %rsi
movl $0xb, %ecx
movq %r14, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x1a90c
movq 0x80(%rsp), %rcx
movq %rcx, 0x20(%rax)
movaps 0x60(%rsp), %xmm0
movaps 0x70(%rsp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
cmpq $0x0, 0x8(%rbx)
jne 0x1a942
movl $0x98, %edi
addq 0x71cd1(%rip), %rdi     # 0x8c5f0
movq (%rbx), %rsi
callq 0x330f0
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a935
callq 0xb6c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0xb510
movzbl %bpl, %ebx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1a962
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
leaq 0xa0(%rsp), %r12
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a987
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xb510
movq %rbx, %rax
addq $0x1f8, %rsp            # imm = 0x1F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebx, %ebx
jmp 0x1a96a
jmp 0x1aa07
movq %r15, %rbp
movq %rax, %r14
jmp 0x1aa17
jmp 0x1a9c6
jmp 0x1a9e4
movq %rax, %r14
movl $0x20, %esi
movq %rbx, %rdi
jmp 0x1aad5
movq %rax, %r14
jmp 0x1aada
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1a9e7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x1a9e7
jmp 0x1a9e4
movq %rax, %r14
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1aada
movq 0x50(%rsp), %rsi
jmp 0x1aad2
movq %r15, %rbp
movq %rax, %r14
leaq 0x1a0(%rsp), %rdi
callq 0x1b76c
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1aa3c
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1aa58
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1aa7c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x1aa7c
movq %r15, %rbp
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1aa98
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x1aabd
movq 0x138(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1aada
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x1aaff
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xb510
movq %r14, %rdi
callq 0xb9c0