// File: /workspace/github_cpp_makefile_star2_O1/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 0x669f
movl %esi, %ebx
movq %r14, %rdi
callq 0x67fe
decl %ebx
jne 0x6693
leaq 0x30(%rsp), %rbx
movq %r14, -0x8(%rbx)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x77ee
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 0x670f
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 0x6de(%rip), %rax       # 0x6dfa
movq %rax, 0x18(%rsi)
leaq 0x8c3(%rip), %rax       # 0x6fea
movq %rax, 0x10(%rsi)
addq $0x54, %r14
leaq 0x50(%rsp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rdx)
movq %r14, %rdi
callq 0x129fe
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x675c
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x6773
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x678a
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
addq $0x70, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x67f5
jmp 0x67f5
jmp 0x67f5
movq %rax, %r14
movq 0x60(%rsp), %rax
testq %rax, %rax
je 0x67b6
leaq 0x50(%rsp), %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x67d6
movq %rsp, %rdi
movq %rdi, %rsi
movl $0x3, %edx
callq *%rax
jmp 0x67d6
jmp 0x67f5
jmp 0x67f5
movq %rax, %r14
movq 0x40(%rsp), %rax
testq %rax, %rax
je 0x67ed
movq %rbx, %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq *%rax
movq %r14, %rdi
callq 0x5650
movq %rax, %rdi
callq 0x792b
nop