// File: /workspace/github_cpp_makefile_star2_O3/nvanbenschoten[P]total-order-multicast/src/process.cc
// Function: process::Process::TotalOrder(unsigned int, std::function<void (msg::SeqMessage&)>)
void Process::TotalOrder(unsigned int send_count, deliverMsgFn deliver) {
  // Launch a multicast sender for each message.
  for (unsigned int i = 0; i < send_count; ++i) {
    LaunchMulticastSender();
  }

  // Launch a server, which will block indefinitely.
  server_.Listen(
      // Called on all incoming Data Messages.
      [this, deliver](udp::ClientPtr client, char* buf, size_t n) {
        auto data_type = MessageTypeFromBuf(buf, n);
        if (!data_type) {
          // We didn't even get a full data type message. Drop it on the floor.
          logging::out << "Received message with incomplete type\n";
          return udp::ServerAction::Continue;
        }

        // Delegate message handling based on the message type.
        switch (*data_type) {
          case msg::kDataMessageType:
            HandleDataMsg(client, buf, n);
            break;
          case msg::kSeqMessageType:
            HandleSeqMsg(client, buf, n, deliver);
            break;
          case msg::kAckMessageType:
          case msg::kSeqAckMessageType:
            logging::out << "Received ack message when one was not expected\n";
            break;
          default:
            logging::out << "Received message with unknown type: " << *data_type
                         << "\n";
            break;
        }
        return udp::ServerAction::Continue;
      });
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x70, %rsp
movq %rdx, %r15
movq %rdi, %r14
testl %esi, %esi
je 0x66d7
movl %esi, %ebx
movq %r14, %rdi
callq 0x6836
decl %ebx
jne 0x66cb
leaq 0x30(%rsp), %rbx
movq %r14, -0x8(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x77e6
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movaps %xmm0, (%rsp)
movl $0x28, %edi
callq 0x5360
movq 0x28(%rsp), %rcx
movq %rcx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
movq $0x0, 0x18(%rax)
movq 0x48(%rsp), %rcx
movq %rcx, 0x20(%rax)
movq 0x40(%rsp), %rcx
testq %rcx, %rcx
je 0x6747
movq %rax, %rdx
addq $0x8, %rdx
leaq 0x40(%rsp), %rsi
movups (%rbx), %xmm0
movups %xmm0, (%rdx)
movq %rcx, 0x18(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rsi)
movq %rsp, %rsi
movq %rax, (%rsi)
leaq 0x6ba(%rip), %rax       # 0x6e0e
movq %rax, 0x18(%rsi)
leaq 0x88f(%rip), %rax       # 0x6fee
movq %rax, 0x10(%rsi)
addq $0x54, %r14
leaq 0x50(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movq %r14, %rdi
callq 0x1281c
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x6794
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x67ab
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x67c2
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x682d
jmp 0x682d
jmp 0x682d
movq %rax, %r14
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x67ee
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x680e
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x680e
jmp 0x682d
jmp 0x682d
movq %rax, %r14
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x6825
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq %r14, %rdi
callq 0x5650
movq %rax, %rdi
callq 0x791b
nop