// File: /workspace/github_cpp_makefile_star2_O1/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 0x1a7c4
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 0x1c52f
movq 0xd8(%rsp), %rsi
testq %rsi, %rsi
je 0x1a4ba
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 0x1c885
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 0x72214(%rip), %rdi     # 0x8c5f0
movq 0x40(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x1a0(%rsp), %rcx
callq 0x330ba
movq %rax, (%rbx)
testq %rax, %rax
setne %al
movl %eax, 0x2c(%rsp)
je 0x1a5dc
movq 0xb0(%rsp), %rdx
leaq 0xd0(%rsp), %rcx
xorl %edi, %edi
xorl %esi, %esi
callq 0x1cb72
movq %r15, %rbp
leaq 0x4ff1b(%rip), %rsi     # 0x6a344
leaq 0x180(%rsp), %rdi
leaq 0xd0(%rsp), %rdx
callq 0x1b85e
leaq 0xd0(%rsp), %rdi
leaq 0x180(%rsp), %r15
movq %r15, %rsi
callq 0xb670
movq (%r15), %rdi
leaq 0x190(%rsp), %rax
cmpq %rax, %rdi
je 0x1a476
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 0x1c7be
movq 0x90(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x30(%rsp)
jmp 0x1a6f1
movq 0x7212f(%rip), %rax     # 0x8c5f0
movq (%rax), %rdi
movq (%rdi), %rdx
addq $0x8, %rdi
decq %rdx
leaq 0x4fd15(%rip), %rsi     # 0x6a1ea
callq 0xb2a0
movq 0x7208f(%rip), %rdi     # 0x8c570
cmpq $0x0, 0x8(%rdi)
je 0x1a5b4
addq $0x20, %rdi
callq 0xb7d0
movq 0x72074(%rip), %rax     # 0x8c570
movq 0x8(%rax), %rbp
leaq 0x4fc81(%rip), %rsi     # 0x6a188
movl $0xb, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fc79(%rip), %rsi     # 0x6a194
movl $0x9, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fcc8(%rip), %rsi     # 0x6a1f7
movl $0x17, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x53560(%rip), %rsi     # 0x6daa3
movl $0x2, %edx
movq %rbp, %rdi
callq 0xb5f0
movq 0x72099(%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 0x71fc5(%rip), %rdi     # 0x8c570
addq $0x20, %rdi
callq 0xb3b0
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a5c2
callq 0xb6c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0xb510
movl $0x0, 0x2c(%rsp)
jmp 0x1a75b
movq 0x7200d(%rip), %rax     # 0x8c5f0
movq (%rax), %rdi
movq (%rdi), %rdx
addq $0x8, %rdi
decq %rdx
leaq 0x4fc18(%rip), %rsi     # 0x6a20f
callq 0xb2a0
movq 0x71f6d(%rip), %rdi     # 0x8c570
cmpq $0x0, 0x8(%rdi)
je 0x1a6d6
addq $0x20, %rdi
callq 0xb7d0
movq 0x71f52(%rip), %rax     # 0x8c570
movq 0x8(%rax), %rbp
leaq 0x4fb5f(%rip), %rsi     # 0x6a188
movl $0xb, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fb57(%rip), %rsi     # 0x6a194
movl $0x9, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x4fba6(%rip), %rsi     # 0x6a1f7
movl $0x17, %edx
movq %rbp, %rdi
callq 0xb5f0
leaq 0x5343e(%rip), %rsi     # 0x6daa3
movl $0x2, %edx
movq %rbp, %rdi
callq 0xb5f0
movq 0x71f77(%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 0x71ea3(%rip), %rdi     # 0x8c570
addq $0x20, %rdi
callq 0xb3b0
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a6e4
callq 0xb6c0
movl $0x20, %esi
movq %rbx, %rdi
callq 0xb510
leaq 0x1a0(%rsp), %rdi
callq 0x1b820
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1a723
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1a73f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1a75b
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1a777
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x1a79c
movq 0x138(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0xd0(%rsp), %rdi
cmpq %r15, %rdi
je 0x1a7b9
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0xb510
cmpb $0x0, 0x2c(%rsp)
je 0x1aa3d
leaq 0x50825(%rip), %rsi     # 0x6aff0
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 0x6fae1(%rip), %rsi     # 0x8a2d0
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 0x1a829
leaq 0x5079f(%rip), %rax     # 0x6afc8
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 0x1a8bb
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x38(%rsp), %rsi
movq 0x30(%rsp), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %rdi
callq 0x1bee6
movq (%rbp), %rax
leaq 0x8(%rsp), %rsi
leaq 0x40(%rsp), %r8
movq %rbp, %rdi
movq %r15, %rdx
movq %r14, %rcx
callq *0x10(%rax)
jmp 0x1a8f9
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 0x1bee6
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 0x1a912
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
leaq 0x8(%rsp), %rsi
movl $0x1, %edi
callq 0xb480
movq 0x71cc8(%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 0x1a9ad
movq 0x40(%r14), %rax
xorq 0x38(%r14), %rax
xorq 0x50(%r14), %rax
cmpq %rax, %r13
je 0x1a9ad
leaq 0x4f8c4(%rip), %rsi     # 0x6a226
leaq 0x128(%rsp), %rdx
movq %r14, %rdi
xorl %eax, %eax
callq 0x2e3a8
leaq 0x128(%rsp), %rsi
movl $0xb, %ecx
movq %r14, %rdi
rep  movsq (%rsi), %es:(%rdi)
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x1a9ad
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 0x1a9e3
movl $0x98, %edi
addq 0x71c30(%rip), %rdi     # 0x8c5f0
movq (%rbx), %rsi
callq 0x33484
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x1a9d6
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 0x1aa03
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
leaq 0xa0(%rsp), %r12
movq 0x90(%rsp), %rdi
cmpq %r12, %rdi
je 0x1aa28
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 0x1aa0b
jmp 0x1aaa8
movq %r15, %rbp
movq %rax, %r14
jmp 0x1aab8
jmp 0x1aa67
jmp 0x1aa85
movq %rax, %r14
movl $0x20, %esi
movq %rbx, %rdi
jmp 0x1ab76
movq %rax, %r14
jmp 0x1ab7b
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1aa88
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x1aa88
jmp 0x1aa85
movq %rax, %r14
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1ab7b
movq 0x50(%rsp), %rsi
jmp 0x1ab73
movq %r15, %rbp
movq %rax, %r14
leaq 0x1a0(%rsp), %rdi
callq 0x1b820
movq 0xb0(%rsp), %rdi
leaq 0xc0(%rsp), %rax
cmpq %rax, %rdi
je 0x1aadd
movq 0xc0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x1aaf9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x1ab1d
movq 0x50(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x1ab1d
movq %r15, %rbp
movq %rax, %r14
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x1ab39
movq 0x70(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x128(%rsp), %rdi
leaq 0x138(%rsp), %rax
cmpq %rax, %rdi
je 0x1ab5e
movq 0x138(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0xd0(%rsp), %rdi
cmpq %rbp, %rdi
je 0x1ab7b
movq 0xe0(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x90(%rsp), %rdi
leaq 0xa0(%rsp), %rax
cmpq %rax, %rdi
je 0x1aba0
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0xb510
movq %r14, %rdi
callq 0xb9c0