// File: /workspace/github_cpp_makefile_star2_O1/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: OperatorToken::operate(unsigned short, unsigned short) const
uint16_t OperatorToken::operate(uint16_t lhs, uint16_t rhs) const {
  if (isUnary()) {
    if ("-" == _op) {
      return -rhs;
    } else if ("*" == _op) {
      throw "Dereferencing not allowed in constant expression.";
    } else if ("&" == _op) {
      throw "Address-of not allowed in constant expression.";
    } else if ("~" == _op) {
      return ~rhs;
    } else if ("!" == _op) {
      return !rhs ? 1 : 0;
    } else if ("+" == _op) {
      return +rhs;
    }
  } else if (isBinary()) {
    if ("+" == _op) {
      return lhs + rhs;
    } else if ("-" == _op) {
      return lhs - rhs;
    } else if ("*" == _op) {
      return lhs * rhs;
    } else if ("/" == _op) {
      if (0 == rhs) {
        _warn("Division by zero in expression.", _lineNum);
        return 0xffff;
      }
      return lhs / rhs;
    } else if ("%" == _op) {
      if (0 == rhs) {
        _warn("Division by zero in expression.", _lineNum);
        return 0xffff;
      }
      return lhs % rhs;
    } else if ("=" == _op) {
      throw "Assignment not allowed in constant expression.";
    } else if ("&" == _op) {
      return lhs & rhs;
    } else if ("|" == _op) {
      return lhs | rhs;
    } else if ("^" == _op) {
      return lhs ^ rhs;
    } else if ("||" == _op) {
      return lhs || rhs ? 1 : 0;
    } else if ("&&" == _op) {
      return lhs && rhs ? 1 : 0;
    } else if ("<" == _op) {
      return lhs < rhs ? 1 : 0;
    } else if ("<=" == _op) {
      return lhs <= rhs ? 1 : 0;
    } else if (">" == _op) {
      return lhs > rhs ? 1 : 0;
    } else if (">=" == _op) {
      return lhs >= rhs ? 1 : 0;
    } else if ("==" == _op) {
      return lhs == rhs ? 1 : 0;
    } else if ("!=" == _op) {
      return lhs != rhs ? 1 : 0;
    } else if ("[" == _op) {
      throw "Array indexing not yet supported.";
    } else if ("<<" == _op) {
      return lhs << rhs;
    } else if (">>" == _op) {
      return lhs >> rhs;
    }
  }
  throw "Invalid operator '" + _op + "' in expression.";
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %edx, %ebx
leaq 0x10(%rdi), %r14
cmpb $0x0, 0x30(%rdi)
je 0xe921
movl %esi, %ebp
movq %rdi, %r15
leaq 0x27e82(%rip), %rsi     # 0x365d2
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xe9fb
leaq 0x27e6d(%rip), %rsi     # 0x365d4
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea09
leaq 0x27e58(%rip), %rsi     # 0x365d6
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea19
leaq 0x27e43(%rip), %rsi     # 0x365d8
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea30
leaq 0x27e2e(%rip), %rsi     # 0x365da
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea43
leaq 0x27e2f(%rip), %rsi     # 0x365f2
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb93
leaq 0x27e0c(%rip), %rsi     # 0x365e6
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea56
leaq 0x27df2(%rip), %rsi     # 0x365e3
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea8e
leaq 0x27dd4(%rip), %rsi     # 0x365dc
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeade
leaq 0x27dc3(%rip), %rsi     # 0x365e2
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeae2
leaq 0x27daf(%rip), %rsi     # 0x365e5
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeaef
leaq 0x27daa(%rip), %rsi     # 0x365f7
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb0d
leaq 0x27d84(%rip), %rsi     # 0x365e8
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb1a
leaq 0x27d7f(%rip), %rsi     # 0x365fa
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb27
leaq 0x27d59(%rip), %rsi     # 0x365eb
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb34
leaq 0x27d45(%rip), %rsi     # 0x365ee
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb41
leaq 0x27d31(%rip), %rsi     # 0x365f1
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb4b
leaq 0x27d1d(%rip), %rsi     # 0x365f4
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeba6
leaq 0x27d08(%rip), %rsi     # 0x365f6
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb52
leaq 0x27cf4(%rip), %rsi     # 0x365f9
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
jne 0xe9ab
movzwl %bp, %eax
movl %ebx, %ecx
shrl %cl, %eax
jmp 0xea29
leaq 0x27cac(%rip), %rsi     # 0x365d4
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea02
leaq 0x27c97(%rip), %rsi     # 0x365d6
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb5b
leaq 0x27c90(%rip), %rsi     # 0x365e6
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb6e
leaq 0x27c71(%rip), %rsi     # 0x365de
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea12
leaq 0x27c5c(%rip), %rsi     # 0x365e0
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xea21
leaq 0x27c37(%rip), %rsi     # 0x365d2
movq %r14, %rdi
callq 0x70c0
testl %eax, %eax
je 0xeb00
movl $0x20, %edi
callq 0x7170
movq %rax, %r15
leaq 0x27d0f(%rip), %rsi     # 0x366ce
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0xb963
movb $0x1, %bpl
leaq 0x27d0b(%rip), %rdx     # 0x366e1
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x21f9d
xorl %ebp, %ebp
leaq 0x38634(%rip), %rsi     # 0x47020
movq 0x3956d(%rip), %rdx     # 0x47f60
movq %r15, %rdi
callq 0x74c0
addl %ebp, %ebx
jmp 0xeb00
negl %ebx
jmp 0xeb00
subl %ebx, %ebp
movl %ebp, %ebx
jmp 0xeb00
notl %ebx
jmp 0xeb00
imull %ebp, %ebx
jmp 0xeb00
xorl %eax, %eax
testw %bx, %bx
sete %al
movl %eax, %ebx
jmp 0xeb00
testw %bx, %bx
je 0xea5d
movl %ebp, %eax
xorl %edx, %edx
divw %bx
movl %eax, %ebx
jmp 0xeb00
testw %bx, %bx
je 0xea92
movl %ebp, %eax
xorl %edx, %edx
divw %bx
movl %edx, %ebx
jmp 0xeb00
andl %ebp, %ebx
jmp 0xeb00
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x27bf0(%rip), %rsi     # 0x3665d
leaq 0x27c08(%rip), %rdx     # 0x3667c
leaq 0x8(%rsp), %rdi
callq 0xc0a4
movl 0x8(%r15), %esi
leaq 0x8(%rsp), %rdi
callq 0x348b0
jmp 0xeac1
orl %ebp, %ebx
jmp 0xeb00
leaq 0x18(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x27bbb(%rip), %rsi     # 0x3665d
leaq 0x27bd3(%rip), %rdx     # 0x3667c
leaq 0x8(%rsp), %rdi
callq 0xc0a4
movl 0x8(%r15), %esi
leaq 0x8(%rsp), %rdi
callq 0x348b0
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xead8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movw $0xffff, %bx            # imm = 0xFFFF
jmp 0xeb00
xorl %ebp, %ebx
jmp 0xeb00
xorl %eax, %eax
orw %bp, %bx
setne %al
jmp 0xea29
testw %bp, %bp
setne %al
testw %bx, %bx
setne %cl
andb %al, %cl
movzbl %cl, %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
cmpw %bx, %bp
setb %al
jmp 0xea29
xorl %eax, %eax
cmpw %bx, %bp
setbe %al
jmp 0xea29
xorl %eax, %eax
cmpw %bx, %bp
seta %al
jmp 0xea29
xorl %eax, %eax
cmpw %bx, %bp
setae %al
jmp 0xea29
xorl %eax, %eax
cmpw %bx, %bp
jmp 0xea26
xorl %eax, %eax
cmpw %bx, %bp
jmp 0xeae7
movl %ebx, %ecx
shll %cl, %ebp
jmp 0xea0b
movl $0x8, %edi
callq 0x7170
leaq 0x27a90(%rip), %rcx     # 0x365fc
jmp 0xeb7f
movl $0x8, %edi
callq 0x7170
leaq 0x27aaf(%rip), %rcx     # 0x3662e
movq %rcx, (%rax)
movq 0x393df(%rip), %rsi     # 0x47f68
movq %rax, %rdi
xorl %edx, %edx
callq 0x74c0
movl $0x8, %edi
callq 0x7170
leaq 0x27ad9(%rip), %rcx     # 0x3667d
jmp 0xeb7f
movl $0x8, %edi
callq 0x7170
leaq 0x27af5(%rip), %rcx     # 0x366ac
jmp 0xeb7f
jmp 0xebbd
jmp 0xebd9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r14, %rdi
je 0xec11
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xec11
movq %rax, %rbx
jmp 0xec11
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xec04
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xec04
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0xec11
movq %r15, %rdi
callq 0x7220
movq %rbx, %rdi
callq 0x74f0
nop