// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/src/components/compcoup/compcoup_transport.cc
// Function: scdc_compcoup_transport::dataset_close(scdc_dataset*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
bool scdc_compcoup_transport::dataset_close(scdc_dataset *dataset, scdc_result &result)
{
  SCDC_TRACE("dataset_close: dataset: '" << dataset << "'");

  if (!transport_connection->acquire())
  {
    result = "acquiring connection failed";
    SCDC_FAIL(__func__ << ": " << result);
    return false;
  }

  bool ret = true;

  scdc_dataset_transport *dataset_transport = static_cast<scdc_dataset_transport *>(dataset);

  /* send request: DATASET_CLOSE <state> */

  ret = ret && scdc_dataset_transport::write_delim(transport_connection, "DATASET_CLOSE", -1, default_delim);
  ret = ret && dataset_transport->write_state();

  ret = ret && transport->send_outgoing(transport_connection);

  if (!ret)
  {
    result = "sending close request failed";
    SCDC_FAIL(__func__ << ": " << result);
    transport_connection->release();
    return false;
  }

  /* read answer: DATASET_CLOSE (OK|FAILED) RESULT <string> */

  string s;

  ret = ret && scdc_dataset_transport::read_delim(transport_connection, &s, default_delim);
  SCDC_ASSERT(s == "DATASET_CLOSE");

  ret = ret && scdc_dataset_transport::read_delim(transport_connection, &s, default_delim);
  if (s == "OK")
  {
    /* nothing to do here */

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

  ret = ret && scdc_dataset_transport::read_delim(transport_connection, &s, default_delim);
  SCDC_ASSERT(s == "RESULT");
  ret = ret && scdc_dataset_transport::read_string(transport_connection, &result);

  if (!ret)
  {
    result = "reading close answer failed";
    SCDC_FAIL(__func__ << ": " << result);
    delete dataset_transport;
    transport_connection->release();
    return false;
  }

  delete dataset_transport;
  dataset_transport = 0;

  transport_connection->release();

  return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x5f3b8
testb %al, %al
je 0x63418
movq 0x18(%rbx), %rdi
leaq 0xaca9(%rip), %rsi      # 0x6df66
movq $-0x1, %rdx
movl $0x20, %ecx
callq 0x6638a
testb %al, %al
je 0x634f4
movq %r15, %rdi
callq 0x66b3c
testb %al, %al
je 0x634f4
movq 0x10(%rbx), %rdi
movq 0x18(%rbx), %rsi
movq (%rdi), %rax
callq *0xd0(%rax)
testb %al, %al
je 0x634f4
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x66504
movl %eax, %ebp
leaq 0xac35(%rip), %rsi      # 0x6df66
leaq 0x8(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x633f3
leaq 0x29226(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x633f3
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x71f8(%rip), %rsi      # 0x6a569
movl $0xd, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0xab28(%rip), %rsi      # 0x6dead
movl $0x1e, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x6fcb(%rip), %rsi      # 0x6a364
movl $0x1, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
movl $0x277, %esi            # imm = 0x277
callq 0xb9a0
movq %rax, %r12
leaq 0xabd4(%rip), %rsi      # 0x6df91
movl $0x17, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x8b2f(%rip), %rsi      # 0x6bf00
movl $0x8, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
callq 0xb250
movq (%r13), %rdi
addq $0x20, %rdi
callq 0xb3b0
testb %bpl, %bpl
je 0x635e8
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x66504
movl %eax, %ebp
jmp 0x635ea
movq 0x8(%r14), %rdx
leaq 0xaa30(%rip), %rcx      # 0x6de53
xorl %ebx, %ebx
movl $0x1b, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0xb870
leaq 0x29134(%rip), %r15     # 0x8c570
movq (%r15), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x635d7
addq $0x20, %rdi
callq 0xb7d0
movq (%r15), %rax
movq 0x8(%rax), %rbx
leaq 0x6d47(%rip), %rsi      # 0x6a1a8
movl $0xb, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0xa9fa(%rip), %rsi      # 0x6de6f
movl $0x14, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x6d53(%rip), %rsi      # 0x6a1dc
movl $0xd, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0xa676(%rip), %rsi      # 0x6db13
movl $0x2, %edx
movq %rbx, %rdi
callq 0xb5f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0xb5f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r15), %rdi
addq $0x20, %rdi
callq 0xb3b0
jmp 0x635d5
movq 0x8(%r14), %rdx
leaq 0xaa75(%rip), %rcx      # 0x6df74
movl $0x1c, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0xb870
leaq 0x2905a(%rip), %r12     # 0x8c570
movq (%r12), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x635cc
addq $0x20, %rdi
callq 0xb7d0
movq (%r12), %rax
movq 0x8(%rax), %r15
leaq 0x6c6b(%rip), %rsi      # 0x6a1a8
movl $0xb, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0xa91e(%rip), %rsi      # 0x6de6f
movl $0x14, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0x6c77(%rip), %rsi      # 0x6a1dc
movl $0xd, %edx
movq %r15, %rdi
callq 0xb5f0
leaq 0xa59a(%rip), %rsi      # 0x6db13
movl $0x2, %edx
movq %r15, %rdi
callq 0xb5f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r15, %rdi
callq 0xb5f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r14, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq 0x18(%rbx), %rdi
callq 0x5f3c4
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
leaq 0x5f63(%rip), %rsi      # 0x69554
leaq 0x8(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x636cc
leaq 0xa8d9(%rip), %rsi      # 0x6dee3
leaq 0x8(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x636cc
leaq 0x28f4d(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x636cc
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x6f1f(%rip), %rsi      # 0x6a569
movl $0xd, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0xa84f(%rip), %rsi      # 0x6dead
movl $0x1e, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x6cf2(%rip), %rsi      # 0x6a364
movl $0x1, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
movl $0x280, %esi            # imm = 0x280
callq 0xb9a0
movq %rax, %r12
leaq 0xa854(%rip), %rsi      # 0x6deea
movl $0x10, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x8856(%rip), %rsi      # 0x6bf00
movl $0x8, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
callq 0xb250
movq (%r13), %rdi
addq $0x20, %rdi
callq 0xb3b0
testb %bpl, %bpl
je 0x636ea
movq 0x18(%rbx), %rdi
leaq 0x8(%rsp), %rsi
movl $0x20, %edx
xorl %ecx, %ecx
callq 0x66504
movl %eax, %ebp
jmp 0x636ec
xorl %ebp, %ebp
leaq 0xa822(%rip), %rsi      # 0x6df15
leaq 0x8(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x637b5
leaq 0x28e64(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x637b5
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x6e36(%rip), %rsi      # 0x6a569
movl $0xd, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0xa766(%rip), %rsi      # 0x6dead
movl $0x1e, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x6c09(%rip), %rsi      # 0x6a364
movl $0x1, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
movl $0x284, %esi            # imm = 0x284
callq 0xb9a0
movq %rax, %r12
leaq 0xa79d(%rip), %rsi      # 0x6df1c
movl $0x10, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x876d(%rip), %rsi      # 0x6bf00
movl $0x8, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
callq 0xb250
movq (%r13), %rdi
addq $0x20, %rdi
callq 0xb3b0
testb %bpl, %bpl
je 0x637e3
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0x667ca
testb %al, %al
je 0x637e3
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq 0x18(%rbx), %rdi
movb $0x1, %bl
callq 0x5f3c4
jmp 0x638ad
movq 0x8(%r14), %rdx
leaq 0xa7bb(%rip), %rcx      # 0x6dfa9
movl $0x1b, %r8d
movq %r14, %rdi
xorl %esi, %esi
callq 0xb870
leaq 0x28d6b(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x63899
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x8(%rax), %r12
leaq 0x697c(%rip), %rsi      # 0x6a1a8
movl $0xb, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0xa62f(%rip), %rsi      # 0x6de6f
movl $0x14, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x6988(%rip), %rsi      # 0x6a1dc
movl $0xd, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0xa2ab(%rip), %rsi      # 0x6db13
movl $0x2, %edx
movq %r12, %rdi
callq 0xb5f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r12, %rdi
callq 0xb5f0
movq %rax, %rdi
callq 0xb250
movq (%r13), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq 0x18(%rbx), %rdi
callq 0x5f3c4
xorl %ebx, %ebx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x635d7
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
jmp 0x635d7
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x638f1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0xb510
movq %rbx, %rdi
callq 0xb9c0
nop