// File: nvanbenschoten[P]byzantine-agreement/src/main.cc
// Function: GetMaliciousBehavior(args::ValueFlagList<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector, args::ValueReader<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, bool)
generals::MaliciousBehavior GetMaliciousBehavior(StringFlagList& malicious,
                                                 bool is_commander) {
  // Create the MaliciousBehavior instance.
  generals::MaliciousBehavior b = generals::MaliciousBehavior::NONE;
  try {
    for (const auto mal : args::get(malicious)) {
      b |= generals::StringToMaliciousBehavior(mal);
    }
  } catch (std::invalid_argument e) {
    throw args::ValidationError(e.what());
  }

  // Validate that the malicious behavior is valid for the general type.
  if (is_commander) {
    for (auto const& not_avail : only_lieutenant_behavior) {
      if (generals::Exhibits(b, not_avail)) {
        throw args::ValidationError(
            "only a lieutenant can have the malicious behavior \"" +
            generals::MaliciousBehaviorString(not_avail) + "\"");
      }
    }
  } else {
    for (auto const& not_avail : only_commander_behavior) {
      if (generals::Exhibits(b, not_avail)) {
        throw args::ValidationError(
            "only a commander can have the malicious behavior \"" +
            generals::MaliciousBehaviorString(not_avail) + "\"");
      }
    }
  }

  return b;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xcf00
movq %rax, -0x1c8(%rbp)
jmp 0x8980
movq -0x1c8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0xcf20
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
callq 0xcf50
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0xcf80
testb $0x1, %al
jne 0x89bb
jmp 0x8b31
leaq -0x30(%rbp), %rdi
callq 0xcfc0
movq %rax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x61d0
jmp 0x89d2
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x61d0
jmp 0x89e1
leaq -0x78(%rbp), %rdi
callq 0x25e80
movl %eax, -0x1cc(%rbp)
jmp 0x89f2
movl -0x1cc(%rbp), %esi
leaq -0x10(%rbp), %rdi
callq 0xcfe0
jmp 0x8a03
leaq -0x78(%rbp), %rdi
callq 0x6878
leaq -0x58(%rbp), %rdi
callq 0x6878
leaq -0x30(%rbp), %rdi
callq 0xd000
jmp 0x89a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8a5a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8a51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x6878
leaq -0x58(%rbp), %rdi
callq 0x6878
movl -0x24(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x8efe
movq -0x20(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
callq 0x6510
movq %rax, %rsi
leaq -0x88(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0xc9e0
movq -0x1f8(%rbp), %rdi
callq 0x61a0
movb $0x1, -0xaa(%rbp)
movl $0x10, %edi
callq 0x6240
movq -0x1f0(%rbp), %rdi
movq %rax, -0x1e8(%rbp)
callq 0x6640
movq %rax, -0x1e0(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x6760
movq -0x1e0(%rbp), %rsi
movq -0x1d8(%rbp), %rdx
leaq -0xa8(%rbp), %rdi
callq 0xc850
jmp 0x8af6
movq -0x1e8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xcb20
jmp 0x8b0b
movq -0x1e8(%rbp), %rdi
movb $0x0, -0xaa(%rbp)
leaq 0x49898(%rip), %rsi     # 0x523b8
leaq 0x4039(%rip), %rdx      # 0xcb60
callq 0x6730
jmp 0x8f0f
jmp 0x8b94
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8b59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x6878
leaq -0xa9(%rbp), %rdi
callq 0x6460
testb $0x1, -0xaa(%rbp)
jne 0x8b70
jmp 0x8b7c
movq -0x1e8(%rbp), %rdi
callq 0x6300
leaq -0x88(%rbp), %rdi
callq 0x6880
callq 0x66c0
jmp 0x8b8f
jmp 0x8efe
testb $0x1, -0x9(%rbp)
je 0x8d4b
leaq 0x4aa5b(%rip), %rax     # 0x53600
movq %rax, -0xb8(%rbp)
leaq 0x4aa4d(%rip), %rdi     # 0x53600
callq 0xd020
movq %rax, -0xc0(%rbp)
leaq 0x4aa3a(%rip), %rdi     # 0x53600
callq 0xd050
movq %rax, -0xc8(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0xd080
testb $0x1, %al
jne 0x8bee
jmp 0x8d46
leaq -0xc0(%rbp), %rdi
callq 0xd0b0
movq %rax, -0xd0(%rbp)
movl -0x10(%rbp), %edi
movq -0xd0(%rbp), %rax
movl (%rax), %esi
callq 0xd0d0
testb $0x1, %al
jne 0x8c1b
jmp 0x8d33
movb $0x1, -0x131(%rbp)
movl $0x10, %edi
callq 0x6240
movq %rax, -0x200(%rbp)
movq -0xd0(%rbp), %rax
movl (%rax), %esi
leaq -0x130(%rbp), %rdi
callq 0x25f70
jmp 0x8c4a
leaq 0x2dde6(%rip), %rsi     # 0x36a37
leaq -0x110(%rbp), %rdi
leaq -0x130(%rbp), %rdx
callq 0xd150
jmp 0x8c66
leaq 0x2de2f(%rip), %rdx     # 0x36a9c
leaq -0xf0(%rbp), %rdi
leaq -0x110(%rbp), %rsi
callq 0xd100
jmp 0x8c82
movq -0x200(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xcb20
jmp 0x8c97
movq -0x200(%rbp), %rdi
movb $0x0, -0x131(%rbp)
leaq 0x4970c(%rip), %rsi     # 0x523b8
leaq 0x3ead(%rip), %rdx      # 0xcb60
callq 0x6730
jmp 0x8f0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8d17
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8d0b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8cff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x6878
leaq -0x110(%rbp), %rdi
callq 0x6878
leaq -0x130(%rbp), %rdi
callq 0x6878
testb $0x1, -0x131(%rbp)
jne 0x8d22
jmp 0x8d2e
movq -0x200(%rbp), %rdi
callq 0x6300
jmp 0x8efe
jmp 0x8d35
leaq -0xc0(%rbp), %rdi
callq 0xd1a0
jmp 0x8bd2
jmp 0x8ef2
leaq 0x4a8de(%rip), %rax     # 0x53630
movq %rax, -0x140(%rbp)
leaq 0x4a8d0(%rip), %rdi     # 0x53630
callq 0xd020
movq %rax, -0x148(%rbp)
leaq 0x4a8bd(%rip), %rdi     # 0x53630
callq 0xd050
movq %rax, -0x150(%rbp)
leaq -0x148(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xd080
testb $0x1, %al
jne 0x8d9b
jmp 0x8ef0
leaq -0x148(%rbp), %rdi
callq 0xd0b0
movq %rax, -0x158(%rbp)
movl -0x10(%rbp), %edi
movq -0x158(%rbp), %rax
movl (%rax), %esi
callq 0xd0d0
testb $0x1, %al
jne 0x8dc8
jmp 0x8edd
movb $0x1, -0x1b9(%rbp)
movl $0x10, %edi
callq 0x6240
movq %rax, -0x208(%rbp)
movq -0x158(%rbp), %rax
movl (%rax), %esi
leaq -0x1b8(%rbp), %rdi
callq 0x25f70
jmp 0x8df7
leaq 0x2dc6d(%rip), %rsi     # 0x36a6b
leaq -0x198(%rbp), %rdi
leaq -0x1b8(%rbp), %rdx
callq 0xd150
jmp 0x8e13
leaq 0x2dc82(%rip), %rdx     # 0x36a9c
leaq -0x178(%rbp), %rdi
leaq -0x198(%rbp), %rsi
callq 0xd100
jmp 0x8e2f
movq -0x208(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0xcb20
jmp 0x8e44
movq -0x208(%rbp), %rdi
movb $0x0, -0x1b9(%rbp)
leaq 0x4955f(%rip), %rsi     # 0x523b8
leaq 0x3d00(%rip), %rdx      # 0xcb60
callq 0x6730
jmp 0x8f0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8ec4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8eb8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x8eac
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x6878
leaq -0x198(%rbp), %rdi
callq 0x6878
leaq -0x1b8(%rbp), %rdi
callq 0x6878
testb $0x1, -0x1b9(%rbp)
jne 0x8ecf
jmp 0x8edb
movq -0x208(%rbp), %rdi
callq 0x6300
jmp 0x8efe
jmp 0x8edf
leaq -0x148(%rbp), %rdi
callq 0xd1a0
jmp 0x8d7f
jmp 0x8ef2
movl -0x10(%rbp), %eax
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x6750
movq %rax, %rdi
callq 0xca80
nop