// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/src/components/compcoup/compcoup_transport.cc
// Function: scdc_compcoup_transport::on_dataset_cmd(scdc_transport_connection_t*)
void scdc_compcoup_transport::on_dataset_cmd(scdc_transport_connection_t *conn)
{
  SCDC_TRACE("on_dataset_cmd:");

  /* read request: DATASET_CMD <output-info> (STATE <state>|NOSTATE) <cmd> (<input-info> <input-data> )+ */

  bool output_next = false;
  scdc_dataset_transport::read_output_info(conn, 0, output_next);

  scdc_dataset_output_t output = *transport->acquire_outgoing_dataset_output(conn);

  string s;
  scdc_dataset_transport::read_delim(conn, &s, default_delim);

  /* send answer: DATASET_CMD (<output-info> <output-data> )+(OK|FAILED) (STATE <state>|<NOSTATE) RESULT <string> (<output-info> <output-data> )+ */

  scdc_dataset_transport::write_delim(conn, "DATASET_CMD", -1, default_delim);

  bool stateless = true;
  scdc_dataset *dataset = 0;

  scdc_result result;

  if (s == "STATE")
  {
    stateless = false;

    scdc_dataset_transport::read_state_begin(conn);
    dataset = dataprovs->dataset_open_read_state(conn->get_incoming(), result);
    scdc_dataset_transport::read_state_end(conn);

  } else
  {
    SCDC_ASSERT(s == "NOSTATE");
  }

  /* read cmd */
  scdc_dataset_transport::read_string(conn, &s);

  /* prepare input */
  scdc_dataset_input_t input = *transport->acquire_incoming_dataset_input(conn);

  input.next = 0;
  input.data = 0;

  bool input_next;
  dataset_input_incoming_consume(conn, &input, &input_next);

  if (input_next)
  {
    input.next = read_input_next;
    input.data = conn;

  } else
  {
    if (conn->current_incoming_input_intern)
    {
      input.next = read_input_next;
      input.data = conn;

      conn->current_incoming_input_intern = false;

    } else
    {
      input.next = 0;
      input.data = 0;
    }
  }

  /* prepare output */
  if (output_next)
  {
    output.next = write_output_next;
    output.data = conn;

  } else
  {
    output.next = 0;
    output.data = 0;
  }

  bool ret = false;

  if (stateless)
  {
    ret = scdc_compcoup::dataset_cmd(s, &input, &output, result);

  } else if (dataset)
  {
    ret = dataset->do_cmd(s, &input, &output, result);

  } else
  {
    /* error: not stateless but also no dataset handle available */
    SCDC_ERROR("no dataset available");
  }

  if (input.next == read_input_next)
  {
    /* consume remaining input */
    input.next = read_input_next_dummy;
    input.data = 0;

    dataset_input_incoming_consume(conn, &input, &input_next);
    SCDC_ASSERT(!input_next);
  }

  transport->release_incoming_dataset_input(conn);

  /* finalize immediate output */
  dataset_output_outgoing_produce(conn, 0);

  if (output.next == write_output_next)
  {
    output.next = 0;
    output.data = 0;
  }

  if (ret)
  {
    scdc_dataset_transport::write_delim(conn, "OK", -1, default_delim);

  } else
  {
    SCDC_FAIL("on_dataset_cmd: dataset_cmd failed");
    scdc_dataset_transport::write_delim(conn, "FAILED", -1, default_delim);
  }

  if (stateless)
  {
    scdc_dataset_transport::write_delim(conn, "NOSTATE", -1, default_delim);

  } else if (dataset)
  {
    scdc_dataset_transport::write_delim(conn, "STATE", -1, default_delim);
    scdc_dataset_transport::write_state_begin(conn);
    dataprovs->dataset_close_write_state(dataset, conn->get_outgoing(), result);
    scdc_dataset_transport::write_state_end(conn);
  }

  scdc_dataset_transport::write_delim(conn, "RESULT", -1, default_delim);
  scdc_dataset_transport::write_string(conn, result.c_str(), result.size());

  dataset_output_outgoing_produce(conn, &output);

  transport->release_outgoing_dataset_output(conn);

  transport->send_outgoing(conn);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r14
xorl %r15d, %r15d
leaq 0xf(%rsp), %rdx
movb %r15b, (%rdx)
movq %rsi, %rdi
xorl %esi, %esi
callq 0x675a6
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x98(%rax)
leaq 0xb0(%rsp), %rdi
movl $0xb, %ecx
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb %r15b, (%rax)
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x66504
leaq 0x8e4f(%rip), %rsi      # 0x6dfc5
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x8d58(%rip), %rsi      # 0x6defd
leaq 0x38(%rsp), %rdi
callq 0xb110
movl %eax, %ebp
testl %eax, %eax
je 0x652a6
leaq 0x8d3b(%rip), %rsi      # 0x6defb
leaq 0x38(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x652a1
leaq 0x27397(%rip), %r12     # 0x8c570
movq (%r12), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x652a1
addq $0x20, %rdi
callq 0xb7d0
movq (%r12), %rax
movq 0x18(%rax), %r15
leaq 0x5369(%rip), %rsi      # 0x6a569
movl $0xd, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0x8c99(%rip), %rsi      # 0x6dead
movl $0x1e, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0x513c(%rip), %rsi      # 0x6a364
movl $0x1, %edx
movq %r15, %rdi
callq 0xb5f0
movq %r15, %rdi
movl $0x531, %esi            # imm = 0x531
callq 0xb9a0
movq %rax, %r15
leaq 0x8cb7(%rip), %rsi      # 0x6df03
movl $0x11, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x6ca0(%rip), %rsi      # 0x6bf00
movl $0x8, %edx
movq %r15, %rdi
callq 0xb5f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r15, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3b0
xorl %r15d, %r15d
jmp 0x652cb
movq %rbx, %rdi
callq 0x66ed8
movq 0x8(%r14), %rdi
leaq 0x30(%rbx), %rsi
leaq 0x18(%rsp), %rdx
callq 0x1e62c
movq %rax, %r15
movq %rbx, %rdi
callq 0x67026
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x667ca
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x88(%rax)
leaq 0x58(%rsp), %r8
movl $0xb, %ecx
movq %r8, %rdi
movq %rax, %rsi
rep  movsq (%rsi), %es:(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%r8)
leaq 0xe(%rsp), %rdx
movq %rbx, %rdi
movq %r8, %rsi
callq 0x6608c
cmpb $0x1, 0xe(%rsp)
movq %r15, 0x10(%rsp)
jne 0x65338
leaq 0xfa9(%rip), %rax       # 0x662cf
movq %rax, 0x90(%rsp)
movq %rbx, 0x98(%rsp)
jmp 0x6536f
cmpb $0x1, 0x2d2(%rbx)
jne 0x65361
leaq 0xf87(%rip), %rax       # 0x662cf
movq %rax, 0x90(%rsp)
movq %rbx, 0x98(%rsp)
movb $0x0, 0x2d2(%rbx)
jmp 0x6536f
leaq 0x90(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0xfd2(%rip), %r15       # 0x66348
xorl %eax, %eax
cmpb $0x0, 0xf(%rsp)
movl $0x0, %ecx
cmovneq %r15, %rcx
cmovneq %rbx, %rax
movq %rcx, 0xe8(%rsp)
movq %rax, 0xf0(%rsp)
testl %ebp, %ebp
je 0x653bf
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %r14, %rdi
callq 0x67834
jmp 0x653ea
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x65710
movq (%rdi), %rax
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x18(%rsp), %r8
callq *0x10(%rax)
movl %eax, %r12d
leaq 0xedb(%rip), %rax       # 0x662cf
cmpq %rax, 0x90(%rsp)
jne 0x65508
leaq 0xf7a(%rip), %rax       # 0x66383
leaq 0x58(%rsp), %rsi
movq %rax, 0x38(%rsi)
movq $0x0, 0x40(%rsi)
leaq 0xe(%rsp), %rdx
movq %rbx, %rdi
callq 0x6608c
cmpb $0x1, 0xe(%rsp)
jne 0x65508
leaq 0x27137(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x65508
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r13
leaq 0x5109(%rip), %rsi      # 0x6a569
movl $0xd, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x8a39(%rip), %rsi      # 0x6dead
movl $0x1e, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x4edc(%rip), %rsi      # 0x6a364
movl $0x1, %edx
movq %r13, %rdi
callq 0xb5f0
movq %r13, %rdi
movl $0x578, %esi            # imm = 0x578
callq 0xb9a0
movq %rax, %r13
leaq 0x8fc8(%rip), %rsi      # 0x6e474
movl $0xe, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x6a40(%rip), %rsi      # 0x6bf00
movl $0x8, %edx
movq %r13, %rdi
callq 0xb5f0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r13, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
leaq 0x27074(%rip), %rax     # 0x8c570
movq (%rax), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x90(%rax)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x65f4e
cmpq %r15, 0xe8(%rsp)
jne 0x6553a
leaq 0xe8(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
testb %r12b, %r12b
je 0x6554b
leaq 0x400e(%rip), %r12      # 0x69554
jmp 0x655e7
leaq 0x2701e(%rip), %r15     # 0x8c570
movq (%r15), %rdi
leaq 0x8987(%rip), %r12      # 0x6dee3
cmpq $0x0, 0x8(%rdi)
je 0x655e7
addq $0x20, %rdi
callq 0xb7d0
movq (%r15), %rax
movq 0x8(%rax), %r13
leaq 0x4c2a(%rip), %rsi      # 0x6a1a8
movl $0xb, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x88dd(%rip), %rsi      # 0x6de6f
movl $0x14, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x8edd(%rip), %rsi      # 0x6e483
movl $0x22, %edx
movq %r13, %rdi
callq 0xb5f0
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r13, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r15), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq %rbx, %rdi
movq %r12, %rsi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
testl %ebp, %ebp
je 0x6561f
leaq 0x88f2(%rip), %rsi      # 0x6defb
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
jmp 0x65669
cmpq $0x0, 0x10(%rsp)
je 0x65669
leaq 0x88cf(%rip), %rsi      # 0x6defd
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
movq %rbx, %rdi
callq 0x66bfe
movq 0x8(%r14), %rdi
leaq 0x70(%rbx), %rdx
leaq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rsi
callq 0x1e84a
movq %rbx, %rdi
callq 0x66c76
leaq 0x88a5(%rip), %rsi      # 0x6df15
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x66d5a
leaq 0xb0(%rsp), %rsi
movq %rbx, %rdi
callq 0x661f4
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xa0(%rax)
movq 0x10(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0xd0(%rax)
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x656e2
movq 0x28(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x656fe
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26e59(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x657a8
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x4d6a(%rip), %rsi      # 0x6a4a8
movl $0xc, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x871d(%rip), %rsi      # 0x6de6f
movl $0x14, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x8cf9(%rip), %rsi      # 0x6e45f
movl $0x14, %edx
movq %r12, %rdi
callq 0xb5f0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r12, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r13), %rdi
addq $0x20, %rdi
callq 0xb3b0
xorl %r12d, %r12d
jmp 0x653ed
jmp 0x657bb
jmp 0x657bb
movq %rax, %rbx
jmp 0x657da
jmp 0x657bb
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x657da
movq 0x28(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x657f6
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
movq %rbx, %rdi
callq 0xb9c0