// File: /workspace/github_cpp_makefile_star2_O1/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 0x676fc
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 0x669b2
leaq 0x8953(%rip), %rsi      # 0x6df55
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x668c4
leaq 0x28(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x885c(%rip), %rsi      # 0x6de8d
leaq 0x38(%rsp), %rdi
callq 0xb110
movl %eax, %ebp
testl %eax, %eax
je 0x65738
leaq 0x883f(%rip), %rsi      # 0x6de8b
leaq 0x38(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x6572d
leaq 0x26f0b(%rip), %r12     # 0x8c570
movq (%r12), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x6572d
addq $0x20, %rdi
callq 0xb7d0
movq (%r12), %rax
movq 0x18(%rax), %r15
leaq 0x4ebd(%rip), %rsi      # 0x6a549
movl $0xd, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0x879d(%rip), %rsi      # 0x6de3d
movl $0x1e, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0x4c90(%rip), %rsi      # 0x6a344
movl $0x1, %edx
movq %r15, %rdi
callq 0xb5f0
movq %r15, %rdi
movl $0x531, %esi            # imm = 0x531
callq 0xb9a0
movq %rax, %r15
leaq 0x87bb(%rip), %rsi      # 0x6de93
movl $0x11, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x679c(%rip), %rsi      # 0x6be88
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
movq $0x0, 0x10(%rsp)
jmp 0x6575f
movq %rbx, %rdi
callq 0x67000
movq 0x8(%r14), %rdi
leaq 0x30(%rbx), %rsi
leaq 0x18(%rsp), %rdx
callq 0x1e73c
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x67100
leaq 0x38(%rsp), %rsi
movq %rbx, %rdi
callq 0x66c34
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 0x665d8
cmpb $0x1, 0xe(%rsp)
jne 0x657c7
leaq 0x105e(%rip), %rax      # 0x66813
movq %rax, 0x90(%rsp)
movq %rbx, 0x98(%rsp)
jmp 0x657fe
cmpb $0x1, 0x2d2(%rbx)
jne 0x657f0
leaq 0x103c(%rip), %rax      # 0x66813
movq %rax, 0x90(%rsp)
movq %rbx, 0x98(%rsp)
movb $0x0, 0x2d2(%rbx)
jmp 0x657fe
leaq 0x90(%rsp), %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
leaq 0xe8(%rsp), %rax
cmpb $0x1, 0xf(%rsp)
leaq 0x1071(%rip), %rcx      # 0x66883
jne 0x65829
movq %rcx, %r15
movq %rcx, 0xe8(%rsp)
movq %rbx, 0xf0(%rsp)
jmp 0x65832
movq %rcx, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
testl %ebp, %ebp
je 0x65857
leaq 0x38(%rsp), %rsi
leaq 0x58(%rsp), %rdx
leaq 0xb0(%rsp), %rcx
leaq 0x18(%rsp), %r8
movq %r14, %rdi
callq 0x67984
jmp 0x65882
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x65bb4
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 0xf87(%rip), %rax       # 0x66813
cmpq %rax, 0x90(%rsp)
jne 0x659a0
leaq 0x101d(%rip), %rax      # 0x668be
leaq 0x58(%rsp), %rsi
movq %rax, 0x38(%rsi)
movq $0x0, 0x40(%rsi)
leaq 0xe(%rsp), %rdx
movq %rbx, %rdi
callq 0x665d8
cmpb $0x1, 0xe(%rsp)
jne 0x659a0
leaq 0x26c9f(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x659a0
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r13
leaq 0x4c51(%rip), %rsi      # 0x6a549
movl $0xd, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x8531(%rip), %rsi      # 0x6de3d
movl $0x1e, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x4a24(%rip), %rsi      # 0x6a344
movl $0x1, %edx
movq %r13, %rdi
callq 0xb5f0
movq %r13, %rdi
movl $0x578, %esi            # imm = 0x578
callq 0xb9a0
movq %rax, %r13
leaq 0x8ac0(%rip), %rsi      # 0x6e404
movl $0xe, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x6530(%rip), %rsi      # 0x6be88
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 0x26bdc(%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 0x6649a
cmpq %r15, 0xe8(%rsp)
jne 0x659d2
xorps %xmm0, %xmm0
leaq 0xe8(%rsp), %rax
movups %xmm0, (%rax)
testb %r12b, %r12b
je 0x659e3
leaq 0x3b56(%rip), %r12      # 0x69534
jmp 0x65a7f
leaq 0x26b86(%rip), %r15     # 0x8c570
movq (%r15), %rdi
leaq 0x847f(%rip), %r12      # 0x6de73
cmpq $0x0, 0x8(%rdi)
je 0x65a7f
addq $0x20, %rdi
callq 0xb7d0
movq (%r15), %rax
movq 0x8(%rax), %r13
leaq 0x4772(%rip), %rsi      # 0x6a188
movl $0xb, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x83d5(%rip), %rsi      # 0x6ddff
movl $0x14, %edx
movq %r13, %rdi
callq 0xb5f0
leaq 0x89d5(%rip), %rsi      # 0x6e413
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 0x668c4
testl %ebp, %ebp
je 0x65ab7
leaq 0x83ea(%rip), %rsi      # 0x6de8b
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x668c4
jmp 0x65b0d
cmpq $0x0, 0x10(%rsp)
je 0x65b0d
leaq 0x83c7(%rip), %rsi      # 0x6de8d
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x668c4
leaq 0x8a22(%rip), %rsi      # 0x6e503
movl $0x1, %edx
movq %rbx, %rdi
callq 0x672f6
movq 0x8(%r14), %rdi
leaq 0x70(%rbx), %rdx
leaq 0x18(%rsp), %rcx
movq 0x10(%rsp), %rsi
callq 0x1e95a
movq %rbx, %rdi
callq 0x66f26
leaq 0x8391(%rip), %rsi      # 0x6dea5
movq %rbx, %rdi
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x668c4
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq %rbx, %rdi
callq 0x66f58
leaq 0xb0(%rsp), %rsi
movq %rbx, %rdi
callq 0x66740
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 0x65b86
movq 0x28(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x65ba2
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 0x269b5(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x65c4c
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x48a6(%rip), %rsi      # 0x6a488
movl $0xc, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x8209(%rip), %rsi      # 0x6ddff
movl $0x14, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x87e5(%rip), %rsi      # 0x6e3ef
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 0x65885
jmp 0x65c5f
jmp 0x65c5f
movq %rax, %rbx
jmp 0x65c7e
jmp 0x65c5f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x65c7e
movq 0x28(%rsp), %rsi
incq %rsi
callq 0xb510
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x65c9a
movq 0x48(%rsp), %rsi
incq %rsi
callq 0xb510
movq %rbx, %rdi
callq 0xb9c0