// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x20, %rsp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x18(%rdi), %rdi
callq 0x4955c
testb %al, %al
je 0x4c90a
movq 0x18(%r14), %rdi
leaq 0x8711(%rip), %rsi      # 0x54ef6
pushq $-0x1
popq %rdx
pushq $0x20
popq %rcx
callq 0x4ed78
testb %al, %al
je 0x4c99b
movq %r15, %rdi
callq 0x4f24e
testb %al, %al
je 0x4c99b
movq 0x10(%r14), %rdi
movq 0x18(%r14), %rsi
movq (%rdi), %rax
callq *0xd0(%rax)
testb %al, %al
je 0x4c99b
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq 0x18(%r14), %rdi
movq %rsp, %rsi
pushq $0x20
popq %rdx
xorl %ecx, %ecx
callq 0x4ee36
movl %eax, %ebp
leaq 0x86aa(%rip), %rsi      # 0x54ef6
movq %rsp, %rdi
callq 0x19be0
testb %al, %al
jne 0x4c8e9
leaq 0x28d1d(%rip), %r12     # 0x75580
movq (%r12), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x4c8e9
addq $0x20, %rdi
callq 0xb800
movq (%r12), %rax
movq 0x18(%rax), %rdi
leaq 0x4cc3(%rip), %rsi      # 0x51549
callq 0xb520
leaq 0x85ab(%rip), %rsi      # 0x54e3d
movq %rax, %rdi
callq 0xb520
leaq 0x4aa3(%rip), %rsi      # 0x51344
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movl $0x277, %esi            # imm = 0x277
callq 0xb990
leaq 0x8664(%rip), %rsi      # 0x54f21
movq %rax, %rdi
callq 0xb520
leaq 0x65c4(%rip), %rsi      # 0x52e90
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3e0
testb %bpl, %bpl
je 0x4ca3d
movq 0x18(%r14), %rdi
movq %rsp, %rsi
pushq $0x20
popq %rdx
xorl %ecx, %ecx
callq 0x4ee36
movl %eax, %ebp
jmp 0x4ca3f
leaq 0x84d2(%rip), %rsi      # 0x54de3
movq %rbx, %rdi
callq 0xba40
leaq 0x28c60(%rip), %r14     # 0x75580
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x4ca2c
addq $0x20, %rdi
callq 0xb800
movq (%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x4843(%rip), %rsi      # 0x51188
callq 0xb520
leaq 0x84ae(%rip), %rsi      # 0x54dff
movq %rax, %rdi
callq 0xb520
leaq 0x485c(%rip), %rsi      # 0x511bc
movq %rax, %rdi
callq 0xb520
leaq 0x8134(%rip), %rsi      # 0x54aa3
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3e0
jmp 0x4ca2c
leaq 0x8562(%rip), %rsi      # 0x54f04
movq %rbx, %rdi
callq 0xba40
leaq 0x28bcf(%rip), %r15     # 0x75580
movq (%r15), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x4ca23
addq $0x20, %rdi
callq 0xb800
movq (%r15), %rax
movq 0x8(%rax), %rdi
leaq 0x47b6(%rip), %rsi      # 0x51188
callq 0xb520
leaq 0x8421(%rip), %rsi      # 0x54dff
movq %rax, %rdi
callq 0xb520
leaq 0x47cf(%rip), %rsi      # 0x511bc
movq %rax, %rdi
callq 0xb520
leaq 0x80a7(%rip), %rsi      # 0x54aa3
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
movq (%r15), %rdi
addq $0x20, %rdi
callq 0xb3e0
movq 0x18(%r14), %rdi
callq 0x49568
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %ebp, %ebp
leaq 0x3aee(%rip), %rsi      # 0x50534
movq %rsp, %rdi
callq 0x19be0
testb %al, %al
jne 0x4cafa
leaq 0x8416(%rip), %rsi      # 0x54e73
movq %rsp, %rdi
callq 0x19be0
testb %al, %al
jne 0x4cafa
leaq 0x28b0c(%rip), %r12     # 0x75580
movq (%r12), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x4cafa
addq $0x20, %rdi
callq 0xb800
movq (%r12), %rax
movq 0x18(%rax), %rdi
leaq 0x4ab2(%rip), %rsi      # 0x51549
callq 0xb520
leaq 0x839a(%rip), %rsi      # 0x54e3d
movq %rax, %rdi
callq 0xb520
leaq 0x4892(%rip), %rsi      # 0x51344
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movl $0x280, %esi            # imm = 0x280
callq 0xb990
leaq 0x83ac(%rip), %rsi      # 0x54e7a
movq %rax, %rdi
callq 0xb520
leaq 0x63b3(%rip), %rsi      # 0x52e90
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3e0
testb %bpl, %bpl
je 0x4cb14
movq 0x18(%r14), %rdi
movq %rsp, %rsi
pushq $0x20
popq %rdx
xorl %ecx, %ecx
callq 0x4ee36
movl %eax, %ebp
jmp 0x4cb16
xorl %ebp, %ebp
leaq 0x8388(%rip), %rsi      # 0x54ea5
movq %rsp, %rdi
callq 0x19be0
testb %al, %al
jne 0x4cbba
leaq 0x28a4c(%rip), %r12     # 0x75580
movq (%r12), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x4cbba
addq $0x20, %rdi
callq 0xb800
movq (%r12), %rax
movq 0x18(%rax), %rdi
leaq 0x49f2(%rip), %rsi      # 0x51549
callq 0xb520
leaq 0x82da(%rip), %rsi      # 0x54e3d
movq %rax, %rdi
callq 0xb520
leaq 0x47d2(%rip), %rsi      # 0x51344
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movl $0x284, %esi            # imm = 0x284
callq 0xb990
leaq 0x831e(%rip), %rsi      # 0x54eac
movq %rax, %rdi
callq 0xb520
leaq 0x62f3(%rip), %rsi      # 0x52e90
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3e0
testb %bpl, %bpl
je 0x4cbe8
movq 0x18(%r14), %rdi
movq %rbx, %rsi
callq 0x4f064
testb %al, %al
je 0x4cbe8
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq 0x18(%r14), %rdi
movb $0x1, %bl
callq 0x49568
jmp 0x4cc87
leaq 0x834a(%rip), %rsi      # 0x54f39
movq %rbx, %rdi
callq 0xba40
leaq 0x28982(%rip), %r12     # 0x75580
movq (%r12), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x4cc73
addq $0x20, %rdi
callq 0xb800
movq (%r12), %rax
movq 0x8(%rax), %rdi
leaq 0x4567(%rip), %rsi      # 0x51188
callq 0xb520
leaq 0x81d2(%rip), %rsi      # 0x54dff
movq %rax, %rdi
callq 0xb520
leaq 0x4580(%rip), %rsi      # 0x511bc
movq %rax, %rdi
callq 0xb520
leaq 0x7e58(%rip), %rsi      # 0x54aa3
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
movq %rbx, %rsi
callq 0xb490
movq %rax, %rdi
callq 0xb270
movq (%r12), %rdi
addq $0x20, %rdi
callq 0xb3e0
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq 0x18(%r14), %rdi
callq 0x49568
xorl %ebx, %ebx
movq %rsp, %rdi
callq 0xb230
jmp 0x4ca2e
movq %rax, %rbx
movq %rsp, %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0
nop