// File: nvanbenschoten[P]total-order-multicast/src/process.cc
// Function: process::Process::HandleSeqMsg(std::shared_ptr<udp::Client>, char*, unsigned long, std::function<void (msg::SeqMessage&)>)
void Process::HandleSeqMsg(const udp::ClientPtr client, char* buf, size_t n,
                           const deliverMsgFn deliver) {
  auto seq_msg = SeqMsgFromBuf(buf, n);
  if (!seq_msg || !ValidSeqMsg(*seq_msg, processes_.size())) {
    // If the seq message was not valid, return without trying to use it.
    return;
  }
  logging::out << "Received message " << *seq_msg << "\n";

  // Forward our sequence number so that it is always larger than any other
  // we have seen.
  ForwardSeqNum(seq_msg->final_seq);

  // Respond to the sender.
  msg::SeqAckMessage seqack_msg;
  seqack_msg.sender = seq_msg->sender;
  seqack_msg.msg_id = seq_msg->msg_id;
  SendSeqAckMsg(client, seqack_msg);

  // Set the message as deliverable in the HoldBackQueue. This may result in one
  // or more messages being delivered.
  hold_back_queue_.SetDeliverable(*seq_msg, deliver);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rsi, -0xc8(%rbp)
movq %r8, -0xc0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x7550
leaq -0x40(%rbp), %rdi
callq 0xaf70
testb $0x1, %al
jne 0x8578
jmp 0x85a7
leaq -0x40(%rbp), %rdi
callq 0xaf90
movq -0xb8(%rbp), %rdi
movq %rax, -0xd0(%rbp)
callq 0xa090
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x7ab0
testb $0x1, %al
jne 0x85ac
jmp 0x86e8
leaq 0x3e045(%rip), %rdi     # 0x465f8
leaq 0x26cf9(%rip), %rsi     # 0x2f2b3
callq 0xadd0
movq %rax, -0xe8(%rbp)
leaq -0x40(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0xaf90
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0xaa40
movq %rax, %rdi
leaq 0x2769b(%rip), %rsi     # 0x2fc8a
callq 0xae70
movq -0xe0(%rbp), %rdi
callq 0xafb0
movq -0xb8(%rbp), %rdi
movl 0xc(%rax), %esi
callq 0x8740
movq -0xe0(%rbp), %rdi
callq 0xafb0
movq -0xe0(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0x48(%rbp)
callq 0xafb0
movq -0xc8(%rbp), %rsi
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0xaf40
movq -0xd8(%rbp), %rdi
movl -0x44(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x4c(%rbp), %rax
movq %rax, -0x70(%rbp)
movl -0x68(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rsi
movl -0x78(%rbp), %edx
callq 0x7990
jmp 0x867b
leaq -0x60(%rbp), %rdi
callq 0xa2d0
movq -0xb8(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x100(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xaf90
movq -0xc0(%rbp), %rsi
movq %rax, -0xf8(%rbp)
leaq -0xb0(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0xac80
movq -0x100(%rbp), %rdi
movq -0xf8(%rbp), %rsi
movq -0xf0(%rbp), %rdx
callq 0x7e60
jmp 0x86dc
leaq -0xb0(%rbp), %rdi
callq 0xafd0
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0xa2d0
jmp 0x872c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0xafd0
movq -0x88(%rbp), %rdi
callq 0x67a0
nopl (%rax,%rax)