// File: nvanbenschoten[P]total-order-multicast/src/main.cc
// Function: GetProcessId(std::vector<net::Address, std::allocator<net::Address>> const&)
int GetProcessId(const process::ProcessList& processes) {
  int found = -1;
  auto hostname = net::GetHostname();
  for (std::size_t i = 0; i < processes.size(); ++i) {
    if (processes.at(i).hostname() == hostname) {
      if (found >= 0) {
        // Multiple processes are set to use our host.
        throw args::UsageError(
            "when running multiple processes on the same host, use the --id "
            "flag");
      }
      found = i;
    }
  }
  if (found == -1) {
    // Our process is not in the file, throw an error
    throw args::ValidationError("current hostname not found in hostfile");
  }
  return found;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
leaq -0x30(%rbp), %rdi
callq 0x2dd30
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa090
movq %rax, %rcx
movq -0xa0(%rbp), %rax
cmpq %rcx, %rax
jae 0x167df
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x15420
movq %rax, -0xa8(%rbp)
jmp 0x166c4
movq -0xa8(%rbp), %rdi
callq 0xe2e0
movq %rax, -0xb0(%rbp)
jmp 0x166d9
movq -0xb0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xe670
testb $0x1, %al
jne 0x166f2
jmp 0x167cc
cmpl $0x0, -0xc(%rbp)
jl 0x167c5
movb $0x1, -0x6a(%rbp)
movl $0x10, %edi
callq 0x6230
movq %rax, -0xc0(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x67b0
movq -0xb8(%rbp), %rdx
leaq 0x1947d(%rip), %rsi     # 0x2fbac
leaq -0x68(%rbp), %rdi
callq 0xb990
jmp 0x1673a
movq -0xc0(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x19fc0
jmp 0x1674c
movq -0xc0(%rbp), %rdi
movb $0x0, -0x6a(%rbp)
leaq 0x2eeda(%rip), %rsi     # 0x45638
leaq 0x389b(%rip), %rdx      # 0x1a000
callq 0x6770
jmp 0x168e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x168d4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x167a3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x68c8
leaq -0x69(%rbp), %rdi
callq 0x6490
testb $0x1, -0x6a(%rbp)
jne 0x167b4
jmp 0x167c0
movq -0xc0(%rbp), %rdi
callq 0x6300
jmp 0x168d4
movq -0x38(%rbp), %rax
movl %eax, -0xc(%rbp)
jmp 0x167ce
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x16687
cmpl $-0x1, -0xc(%rbp)
jne 0x168b3
movb $0x1, -0x92(%rbp)
movl $0x10, %edi
callq 0x6230
movq %rax, -0xd0(%rbp)
leaq -0x91(%rbp), %rdi
movq %rdi, -0xc8(%rbp)
callq 0x67b0
movq -0xc8(%rbp), %rdx
leaq 0x193ce(%rip), %rsi     # 0x2fbf0
leaq -0x90(%rbp), %rdi
callq 0xb990
jmp 0x16830
movq -0xd0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x1a080
jmp 0x16845
movq -0xd0(%rbp), %rdi
movb $0x0, -0x92(%rbp)
leaq 0x2edf6(%rip), %rsi     # 0x45650
leaq 0x385f(%rip), %rdx      # 0x1a0c0
callq 0x6770
jmp 0x168e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x1688e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x68c8
leaq -0x91(%rbp), %rdi
callq 0x6490
testb $0x1, -0x92(%rbp)
jne 0x168a5
jmp 0x168b1
movq -0xd0(%rbp), %rdi
callq 0x6300
jmp 0x168d4
movl -0xc(%rbp), %eax
movl %eax, -0xd4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x68c8
movl -0xd4(%rbp), %eax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x68c8
movq -0x40(%rbp), %rdi
callq 0x67a0
nopw %cs:(%rax,%rax)