// File: /workspace/github_cpp_makefile_star2_O2/mh0fm4[P]SCDC/src/components/compcoup/compcoup_transport.cc
// Function: scdc_compcoup_transport::serve(scdc_transport_connection_t*)
void scdc_compcoup_transport::serve(scdc_transport_connection_t *conn)
{
  handshake();

  const scdcint_t loop_max = -1;

  scdcint_t l = 0;
  string prev;

  while (conn->open && (loop_max < 0 || l < loop_max))
  {
    string head;
    bool stop_at_delim = false;

    bool ret = scdc_dataset_transport::read_delim(conn, &head, default_delim, &stop_at_delim);

    if (!ret)
    {
      SCDC_TRACE("serve_connection: read failed!");
      break;
    }

    head = prev + head;

    SCDC_TRACE("serve_connection: head: '" << head << "', stop_at_delim: '" << stop_at_delim << "'");

    prev.erase();

    if (head == "DATASET_OPEN" && stop_at_delim) on_dataset_open(conn);
    else if (head == "DATASET_CLOSE" && stop_at_delim) on_dataset_close(conn);
    else if (head == "DATASET_CMD" && stop_at_delim) on_dataset_cmd(conn);
    else if (on_cmd_handler(head.c_str(), conn->get_incoming()))
    {
      SCDC_TRACE("serve_connection: cmd_handler sccessfull");

    } else if (stop_at_delim)
    {
      SCDC_ERROR("serve_connection: unknown command '" << head << "'");

    } else prev = head;

    ++l;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x40(%rax)
leaq 0x48(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x30(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rsp), %r12
leaq 0x58(%rsp), %r15
leaq 0x38(%rsp), %rbp
cmpb $0x1, 0x8(%rbx)
jne 0x4db8d
leaq 0x28(%rsp), %rax
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
xorl %eax, %eax
movb %al, 0x28(%rsp)
movb %al, 0xf(%rsp)
movq %rbx, %rdi
movq %r12, %rsi
pushq $0x20
popq %rdx
leaq 0xf(%rsp), %rcx
callq 0x4ee36
movl %eax, %r13d
testb %al, %al
je 0x4db83
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x37f1d
movq %r12, %rdi
movq %r15, %rsi
callq 0xb690
movq %r15, %rdi
callq 0xb230
movq %rbp, %rdi
xorl %esi, %esi
pushq $-0x1
popq %rdx
callq 0xb0e0
movq %r12, %rdi
leaq 0x73d5(%rip), %rsi      # 0x54e14
callq 0x19be0
testb %al, %al
je 0x4da5f
cmpb $0x1, 0xf(%rsp)
jne 0x4da5f
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4dbc8
jmp 0x4db70
movq %r12, %rdi
leaq 0x748d(%rip), %rsi      # 0x54ef6
callq 0x19be0
testb %al, %al
je 0x4da89
cmpb $0x1, 0xf(%rsp)
jne 0x4da89
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4de18
jmp 0x4db70
movq %r12, %rdi
leaq 0x74c2(%rip), %rsi      # 0x54f55
callq 0x19be0
testb %al, %al
je 0x4dab3
cmpb $0x1, 0xf(%rsp)
jne 0x4dab3
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4df6c
jmp 0x4db70
movq 0x18(%rsp), %rsi
movq %r14, %rdi
movq 0x10(%rsp), %rdx
callq 0x4e4f2
testb %al, %al
jne 0x4db70
cmpb $0x1, 0xf(%rsp)
jne 0x4db65
leaq 0x27aa1(%rip), %rax     # 0x75580
movq (%rax), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x4db70
addq $0x20, %rdi
callq 0xb800
leaq 0x27a83(%rip), %rax     # 0x75580
movq (%rax), %rax
movq 0x18(%rax), %rdi
leaq 0x397d(%rip), %rsi      # 0x51488
callq 0xb520
movq %rax, %rdi
leaq 0x72e5(%rip), %rsi      # 0x54dff
callq 0xb520
movq %rax, %rdi
leaq 0x7516(%rip), %rsi      # 0x5503f
callq 0xb520
movq %rax, %rdi
movq %r12, %rsi
callq 0xb490
movq %rax, %rdi
leaq 0x5820(%rip), %rsi      # 0x53363
callq 0xb520
movq %rax, %rdi
callq 0xb270
leaq 0x27a29(%rip), %rax     # 0x75580
movq (%rax), %rdi
addq $0x20, %rdi
callq 0xb3e0
jmp 0x4db70
movq %rbp, %rdi
movq %r12, %rsi
callq 0xb2e0
movq %r12, %rdi
callq 0xb230
testb %r13b, %r13b
jne 0x4d9c5
jmp 0x4db8d
leaq 0x18(%rsp), %rdi
callq 0xb230
leaq 0x38(%rsp), %rdi
callq 0xb230
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4dba8
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0xb230
leaq 0x38(%rsp), %rdi
callq 0xb230
movq %rbx, %rdi
callq 0xb9a0
nop