// File: mh0fm4[P]SCDC/src/components/compcoup/compcoup_transport.cc
// Function: scdc_compcoup_transport::dataset_input_incoming_recv(scdc_transport_connection_t*, _scdc_dataset_inout_t*, bool*)
bool scdc_compcoup_transport::dataset_input_incoming_recv(scdc_transport_connection_t *conn, scdc_dataset_input_t *input, bool *next)
{
  SCDC_TRACE("dataset_input_incoming_recv:");

  SCDC_ASSERT(conn->current_incoming_input_size >= 0);

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

  bool cont_recv = true;

  do
  {
    if (conn->current_incoming_input_size <= 0)
    {
      SCDC_TRACE("dataset_input_incoming_recv: read_input_info");
      if (!scdc_dataset_transport::read_input_info(conn, &conn->current_incoming_input, conn->current_incoming_input_next))
      {
        SCDC_FAIL("dataset_input_incoming_recv: read input info failed");
        return false;
      }

      conn->current_incoming_input_size = SCDC_DATASET_INOUT_BUF_CURRENT(&conn->current_incoming_input);
    }

    strncpy(input->format, conn->current_incoming_input.format, SCDC_FORMAT_MAX_SIZE);
    input->total_size = conn->current_incoming_input.total_size;
    input->total_size_given = conn->current_incoming_input.total_size_given;

    scdcint_t prev_current = SCDC_DATASET_INOUT_BUF_CURRENT(input);

    if (!conn->transport->recv_incoming_dataset_input(conn, input, conn->current_incoming_input_size, cont_recv))
    {
      SCDC_FAIL("dataset_input_incoming_recv: receive dataset input failed");
      return false;
    }

    conn->current_incoming_input_size -= SCDC_DATASET_INOUT_BUF_CURRENT(input) - prev_current;

    *next = (conn->current_incoming_input_next || conn->current_incoming_input_size > 0);

    SCDC_TRACE("dataset_input_incoming_recv: cont: '" << cont_recv << "', next: '" << *next << "', buf: " << SCDC_DATASET_INOUT_BUF_CURRENT(input) << " of " << SCDC_DATASET_INOUT_BUF_SIZE(input));

  } while (cont_recv && *next && SCDC_DATASET_INOUT_BUF_CURRENT(input) < SCDC_DATASET_INOUT_BUF_SIZE(input));

  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
jmp 0xa1e56
jmp 0xa1e58
movq -0x10(%rbp), %rax
cmpq $0x0, 0x2c0(%rax)
jge 0xa1f1d
jmp 0xa1e6c
leaq 0x32835(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
cmpq $0x0, %rax
je 0xa1f19
leaq 0x3281c(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e900
leaq 0x3280d(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e8e0
movq %rax, %rdi
leaq 0x46bc(%rip), %rsi      # 0xa6569
callq 0xc670
movq %rax, %rdi
leaq 0x7fc9(%rip), %rsi      # 0xa9e85
callq 0xc670
movq %rax, %rdi
leaq 0x4499(%rip), %rsi      # 0xa6364
callq 0xc670
movq %rax, %rdi
movl $0x3a8, %esi            # imm = 0x3A8
callq 0xcb80
movq %rax, %rdi
leaq 0x81c4(%rip), %rsi      # 0xaa0ab
callq 0xc670
movq %rax, %rdi
leaq 0x6016(%rip), %rsi      # 0xa7f0c
callq 0xc670
movq %rax, %rdi
movq 0x320bb(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x32797(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x2e920
jmp 0xa1f1b
jmp 0xa1f1d
jmp 0xa1f1f
movq -0x18(%rbp), %rax
movq $0x0, 0x20(%rax)
movb $0x1, -0x21(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x2c0(%rax)
jg 0xa200d
jmp 0xa1f43
jmp 0xa1f45
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x210, %rsi            # imm = 0x210
movq -0x10(%rbp), %rdx
addq $0x2d0, %rdx            # imm = 0x2D0
callq 0xa3670
testb $0x1, %al
jne 0xa1ff7
jmp 0xa1f6e
leaq 0x32733(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
cmpq $0x0, %rax
je 0xa1fec
leaq 0x3271e(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25800
leaq 0x3270f(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, %rdi
leaq 0x4205(%rip), %rsi      # 0xa61b0
callq 0xc670
movq %rax, %rdi
leaq 0x7e8d(%rip), %rsi      # 0xa9e47
callq 0xc670
movq %rax, %rdi
leaq 0x810c(%rip), %rsi      # 0xaa0d5
callq 0xc670
movq %rax, %rdi
movq 0x31fe8(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x326c4(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0xa1fee
movb $0x0, -0x1(%rbp)
jmp 0xa21a3
movq -0x10(%rbp), %rax
movq 0x230(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2c0(%rax)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x210, %rsi            # imm = 0x210
movl $0x10, %edx
callq 0xc320
movq -0x10(%rbp), %rax
movq 0x238(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movb 0x240(%rax), %cl
movq -0x18(%rbp), %rax
movb %cl, 0x30(%rax)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x2c0(%rax), %rcx
movq (%rdi), %rax
leaq -0x21(%rbp), %r8
callq *0xa8(%rax)
testb $0x1, %al
jne 0xa2110
jmp 0xa2087
leaq 0x3261a(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
cmpq $0x0, %rax
je 0xa2105
leaq 0x32605(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25800
leaq 0x325f6(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x257e0
movq %rax, %rdi
leaq 0x40ec(%rip), %rsi      # 0xa61b0
callq 0xc670
movq %rax, %rdi
leaq 0x7d74(%rip), %rsi      # 0xa9e47
callq 0xc670
movq %rax, %rdi
leaq 0x8027(%rip), %rsi      # 0xaa109
callq 0xc670
movq %rax, %rdi
movq 0x31ecf(%rip), %rsi     # 0xd3fc0
callq 0xc6d0
leaq 0x325ab(%rip), %rax     # 0xd46a8
movq (%rax), %rdi
callq 0x25820
jmp 0xa2107
movb $0x0, -0x1(%rbp)
jmp 0xa21a3
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdx
subq -0x30(%rbp), %rdx
movq -0x10(%rbp), %rax
movq 0x2c0(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x2c0(%rax)
movq -0x10(%rbp), %rcx
movb $0x1, %al
testb $0x1, 0x2d0(%rcx)
movb %al, -0x31(%rbp)
jne 0xa2155
movq -0x10(%rbp), %rax
cmpq $0x0, 0x2c0(%rax)
setg %al
movb %al, -0x31(%rbp)
movb -0x31(%rbp), %cl
movq -0x20(%rbp), %rax
andb $0x1, %cl
movb %cl, (%rax)
jmp 0xa2163
jmp 0xa2165
xorl %eax, %eax
testb $0x1, -0x21(%rbp)
movb %al, -0x32(%rbp)
je 0xa2194
movq -0x20(%rbp), %rcx
xorl %eax, %eax
testb $0x1, (%rcx)
movb %al, -0x32(%rbp)
je 0xa2194
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x18(%rcx), %rax
setl %al
movb %al, -0x32(%rbp)
movb -0x32(%rbp), %al
testb $0x1, %al
jne 0xa1f2f
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nop