// File: /workspace/github_cpp_makefile_star2_O1/mh0fm4[P]SCDC/src/components/compcoup/compcoup_transport.cc
// Function: scdc_compcoup_transport::dataset_output_incoming_recv(scdc_transport_connection_t*, _scdc_dataset_inout_t*, bool*)
bool scdc_compcoup_transport::dataset_output_incoming_recv(scdc_transport_connection_t *conn, scdc_dataset_output_t *output, bool *next)
{
  SCDC_TRACE("dataset_output_incoming_recv:");

  SCDC_ASSERT(conn->current_incoming_output_size >= 0);

  /* empty output */
  SCDC_DATASET_INOUT_BUF_CURRENT(output) = 0;

  bool cont_recv = true;

  do
  {
    if (conn->current_incoming_output_size <= 0)
    {
      if (!scdc_dataset_transport::read_output_info(conn, &conn->current_incoming_output, conn->current_incoming_output_next))
      {
        SCDC_FAIL("dataset_output_incoming_recv: read output info failed");
        return false;
      }

      conn->current_incoming_output_size = SCDC_DATASET_INOUT_BUF_CURRENT(&conn->current_incoming_output);

      SCDC_TRACE("dataset_output_incoming_recv: current_incoming_output_next/size: " << conn->current_incoming_output_next << " / " << conn->current_incoming_output_size);
    }

    strncpy(output->format, conn->current_incoming_output.format, SCDC_FORMAT_MAX_SIZE);
    output->total_size = conn->current_incoming_output.total_size;
    output->total_size_given = conn->current_incoming_output.total_size_given;

    scdcint_t prev_current = SCDC_DATASET_INOUT_BUF_CURRENT(output);

    if (!conn->transport->recv_incoming_dataset_output(conn, output, conn->current_incoming_output_size, cont_recv))
    {
      SCDC_FAIL("dataset_output_incoming_recv: receive dataset output failed");
      return false;
    }

    conn->current_incoming_output_size -= SCDC_DATASET_INOUT_BUF_CURRENT(output) - prev_current;

    *next = (conn->current_incoming_output_next || conn->current_incoming_output_size > 0);

    SCDC_TRACE("dataset_output_incoming_recv: cont: '" << cont_recv << "', next: '" << *next << "', buf: " << SCDC_DATASET_INOUT_BUF_CURRENT(output) << " of " << SCDC_DATASET_INOUT_BUF_SIZE(output));
 
  } while (cont_recv && *next && SCDC_DATASET_INOUT_BUF_CURRENT(output) < SCDC_DATASET_INOUT_BUF_SIZE(output));

  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpq $0x0, 0x2c8(%rdi)
jns 0x6624f
leaq 0x263ea(%rip), %r13     # 0x8c570
movq (%r13), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x6624f
addq $0x20, %rdi
callq 0xb7d0
movq (%r13), %rax
movq 0x18(%rax), %r12
leaq 0x439c(%rip), %rsi      # 0x6a549
movl $0xd, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x7c7c(%rip), %rsi      # 0x6de3d
movl $0x1e, %edx
movq %r12, %rdi
callq 0xb5f0
leaq 0x416f(%rip), %rsi      # 0x6a344
movl $0x1, %edx
movq %r12, %rdi
callq 0xb5f0
movq %r12, %rdi
movl $0x3f0, %esi            # imm = 0x3F0
callq 0xb9a0
movq %rax, %r12
leaq 0x7f6e(%rip), %rsi      # 0x6e167
movl $0x2a, %edx
movq %rax, %rdi
callq 0xb5f0
leaq 0x5c7b(%rip), %rsi      # 0x6be88
movl $0x8, %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
movq $0x0, 0x20(%r14)
leaq 0x7(%rsp), %r13
movb $0x1, (%r13)
leaq 0x268(%r15), %rax
movq %rax, 0x8(%rsp)
leaq 0x2d1(%r15), %rax
movq %rax, 0x10(%rsp)
cmpq $0x0, 0x2c8(%r15)
jg 0x662ab
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
callq 0x676fc
testb %al, %al
je 0x663f6
movq 0x288(%r15), %rax
movq %rax, 0x2c8(%r15)
movl $0x10, %edx
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0xb2a0
movq 0x290(%r15), %rax
movq %rax, 0x28(%r14)
movb 0x298(%r15), %al
movb %al, 0x30(%r14)
movq 0x20(%r14), %r12
movq (%r15), %rdi
movq 0x2c8(%r15), %rcx
movq (%rdi), %rax
movq %r15, %rsi
movq %r14, %rdx
movq %r13, %r8
callq *0xb0(%rax)
movl %eax, %ebp
testb %al, %al
je 0x6631f
subq 0x20(%r14), %r12
addq 0x2c8(%r15), %r12
movq %r12, 0x2c8(%r15)
testq %r12, %r12
setg %al
orb 0x2d1(%r15), %al
movb %al, (%rbx)
jmp 0x663c6
leaq 0x2624a(%rip), %rax     # 0x8c570
movq (%rax), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x663c6
addq $0x20, %rdi
callq 0xb7d0
movq %rbx, %r13
leaq 0x26229(%rip), %rbx     # 0x8c570
movq (%rbx), %rax
movq 0x8(%rax), %r12
movl $0xb, %edx
movq %r12, %rdi
leaq 0x3e2b(%rip), %rsi      # 0x6a188
callq 0xb5f0
movl $0x14, %edx
movq %r12, %rdi
leaq 0x7a8e(%rip), %rsi      # 0x6ddff
callq 0xb5f0
movl $0x3b, %edx
movq %r12, %rdi
leaq 0x7e43(%rip), %rsi      # 0x6e1c8
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 (%rbx), %rdi
movq %r13, %rbx
leaq 0x7(%rsp), %r13
addq $0x20, %rdi
callq 0xb3b0
testb %bpl, %bpl
je 0x66488
cmpb $0x1, 0x7(%rsp)
jne 0x66488
cmpb $0x1, (%rbx)
jne 0x66488
movq 0x20(%r14), %rax
cmpq 0x18(%r14), %rax
jl 0x66279
jmp 0x66488
leaq 0x26173(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x66486
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x8(%rax), %rbx
leaq 0x3d6a(%rip), %rsi      # 0x6a188
movl $0xb, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x79cd(%rip), %rsi      # 0x6ddff
movl $0x14, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x7d4c(%rip), %rsi      # 0x6e192
movl $0x35, %edx
movq %rbx, %rdi
callq 0xb5f0
movq (%rbx), %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 (%r14), %rdi
addq $0x20, %rdi
callq 0xb3b0
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop