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

  SCDC_ASSERT(dataprovs);

  /* read request: DATASET_OPEN <path> */

  string path;
  scdc_dataset_transport::read_string(conn, &path);
  SCDC_TRACE("on_dataset_open: path: '" << path << "'");

  /* send answer: DATASET_OPEN (OK|FAILED) (STATE <state>|NOSTATE) RESULT <string> */

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

  scdc_result result;

  scdc_dataset *dataset = dataprovs->dataset_open(path, result);

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

    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);

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

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

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

  transport->send_outgoing(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0xa0cbd
jmp 0xa0cbf
movq -0x70(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0xa0d81
jmp 0xa0cd0
leaq 0x339d1(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
cmpq $0x0, %rax
je 0xa0d7d
leaq 0x339b8(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e900
leaq 0x339a9(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
movq %rax, %rdi
leaq 0x5858(%rip), %rsi      # 0xa6569
callq 0xc670
movq %rax, %rdi
leaq 0x9165(%rip), %rsi      # 0xa9e85
callq 0xc670
movq %rax, %rdi
leaq 0x5635(%rip), %rsi      # 0xa6364
callq 0xc670
movq %rax, %rdi
movl $0x4c0, %esi            # imm = 0x4C0
callq 0xcb80
movq %rax, %rdi
leaq 0x96ae(%rip), %rsi      # 0xaa3f9
callq 0xc670
movq %rax, %rdi
leaq 0x71b2(%rip), %rsi      # 0xa7f0c
callq 0xc670
movq %rax, %rdi
movq 0x33257(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x33933(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e920
jmp 0xa0d7f
jmp 0xa0d81
jmp 0xa0d83
leaq -0x30(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0xc960
movq -0x78(%rbp), %rsi
movq -0x10(%rbp), %rdi
callq 0xa31d0
jmp 0xa0d9f
jmp 0xa0da1
jmp 0xa0da3
jmp 0xa0da5
movq -0x10(%rbp), %rdi
leaq 0x90ac(%rip), %rsi      # 0xa9e5c
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa0dc3
leaq -0x60(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0xc960
movq -0x70(%rbp), %rax
movq -0x88(%rbp), %rdx
movq 0x8(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2d950
movq %rax, -0x80(%rbp)
jmp 0xa0df1
movq -0x80(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0xa0ed2
movq -0x10(%rbp), %rdi
leaq 0x472d(%rip), %rsi      # 0xa553c
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa0e22
movq -0x10(%rbp), %rdi
leaq 0x90a8(%rip), %rsi      # 0xa9ed5
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa0e40
movq -0x10(%rbp), %rdi
callq 0xa3700
jmp 0xa0e4b
movq -0x70(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa3730
movq %rax, -0x90(%rbp)
jmp 0xa0e77
movq -0x90(%rbp), %rdx
movq -0x98(%rbp), %rsi
movq -0xa0(%rbp), %rdi
leaq -0x60(%rbp), %rcx
callq 0x2e120
jmp 0xa0e97
movq -0x10(%rbp), %rdi
callq 0xa3750
jmp 0xa0ea2
jmp 0xa0fe4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0xa107d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xc3e0
jmp 0xa107d
jmp 0xa0ed4
leaq 0x337cd(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, -0xa8(%rbp)
jmp 0xa0eec
movq -0xa8(%rbp), %rax
cmpq $0x0, %rax
je 0xa0fa2
leaq 0x337a4(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25800
jmp 0xa0f0e
leaq 0x33793(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, -0xb0(%rbp)
jmp 0xa0f26
movq -0xb0(%rbp), %rdi
leaq 0x527c(%rip), %rsi      # 0xa61b0
callq 0xc670
movq %rax, -0xb8(%rbp)
jmp 0xa0f42
movq -0xb8(%rbp), %rdi
leaq 0x8ef7(%rip), %rsi      # 0xa9e47
callq 0xc670
movq %rax, -0xc0(%rbp)
jmp 0xa0f5e
movq -0xc0(%rbp), %rdi
leaq 0x949a(%rip), %rsi      # 0xaa406
callq 0xc670
movq %rax, -0xc8(%rbp)
jmp 0xa0f7a
movq -0xc8(%rbp), %rdi
movq 0x33038(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
jmp 0xa0f8f
leaq 0x33712(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0xa0fa0
jmp 0xa0fa2
jmp 0xa0fa4
jmp 0xa0fa6
movq -0x10(%rbp), %rdi
leaq 0x8f0a(%rip), %rsi      # 0xa9ebb
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa0fc4
movq -0x10(%rbp), %rdi
leaq 0x8f04(%rip), %rsi      # 0xa9ed3
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa0fe2
jmp 0xa0fe4
movq -0x10(%rbp), %rdi
leaq 0x8efe(%rip), %rsi      # 0xa9eed
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0xa2c90
jmp 0xa1002
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xc260
movq -0xe0(%rbp), %rdi
movq %rax, -0xd0(%rbp)
callq 0xc460
movq -0xd8(%rbp), %rdi
movq -0xd0(%rbp), %rsi
movq %rax, %rdx
callq 0xa37d0
jmp 0xa1048
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
movq 0xd0(%rax), %rax
callq *%rax
jmp 0xa1062
leaq -0x60(%rbp), %rdi
callq 0xc3e0
leaq -0x30(%rbp), %rdi
callq 0xc3e0
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0xc3e0
movq -0x38(%rbp), %rdi
callq 0xcba0
nop