// File: sundale[P]gcode/rs274ngc/interp_execute.cc
// Function: Interp::execute_binary2(double*, int, double*)
int Interp::execute_binary2(double *left,        //!< pointer to the left operand    
                           int operation,       //!< integer code for the operation 
                           double *right)       //!< pointer to the right operand   
{
  double diff;
  switch (operation) {
  case AND2:
    *left = ((*left == 0.0) || (*right == 0.0)) ? 0.0 : 1.0;
    break;
  case EXCLUSIVE_OR:
    *left = (((*left == 0.0) && (*right != 0.0))
             || ((*left != 0.0) && (*right == 0.0))) ? 1.0 : 0.0;
    break;
  case MINUS:
    *left = (*left - *right);
    break;
  case NON_EXCLUSIVE_OR:
    *left = ((*left != 0.0) || (*right != 0.0)) ? 1.0 : 0.0;
    break;
  case PLUS:
    *left = (*left + *right);
    break;

  case LT:
      *left = (*left < *right) ? 1.0 : 0.0;
      break;
  case EQ:
      diff = *left - *right;
      diff = (diff < 0) ? -diff : diff;
      *left = (diff < TOLERANCE_EQUAL) ? 1.0 : 0.0;
      break;
  case NE:
      diff = *left - *right;
      diff = (diff < 0) ? -diff : diff;
      *left = (diff >= TOLERANCE_EQUAL) ? 1.0 : 0.0;
      break;
  case LE:
      *left = (*left <= *right) ? 1.0 : 0.0;
      break;
  case GE:
      *left = (*left >= *right) ? 1.0 : 0.0;
      break;
  case GT:
      *left = (*left > *right) ? 1.0 : 0.0;
      break;

  default:
    ERS(NCE_BUG_UNKNOWN_OPERATION);
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
movl -0x1c(%rbp), %eax
addl $-0x5, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0xb, %eax
ja 0x5592e
movq -0x38(%rbp), %rax
leaq 0x272d6(%rip), %rcx     # 0x7c828
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movb $0x1, %al
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x41(%rbp)
jne 0x55575
jp 0x55575
jmp 0x5558f
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
xorps %xmm0, %xmm0
movsd 0x23873(%rip), %xmm1    # 0x78e10
movsd %xmm1, -0x58(%rbp)
testb $0x1, %al
movsd %xmm0, -0x50(%rbp)
jne 0x555b5
movsd -0x58(%rbp), %xmm0
movsd %xmm0, -0x50(%rbp)
movsd -0x50(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x555f2
jp 0x555f2
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
movb $0x1, %al
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x59(%rbp)
jne 0x5562c
jp 0x5562c
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
xorl %eax, %eax
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x5a(%rbp)
jne 0x5560c
jp 0x5560c
jmp 0x55626
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
sete %al
setnp %cl
andb %cl, %al
movb %al, -0x5a(%rbp)
movb -0x5a(%rbp), %al
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
movsd 0x237d9(%rip), %xmm0    # 0x78e10
xorps %xmm1, %xmm1
movsd %xmm1, -0x70(%rbp)
testb $0x1, %al
movsd %xmm0, -0x68(%rbp)
jne 0x55652
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
subsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movb $0x1, %al
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
movb %al, -0x71(%rbp)
jne 0x556b3
jp 0x556b3
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
setne %al
setp %cl
orb %cl, %al
movb %al, -0x71(%rbp)
movb -0x71(%rbp), %al
movsd 0x23752(%rip), %xmm0    # 0x78e10
xorps %xmm1, %xmm1
movsd %xmm1, -0x88(%rbp)
testb $0x1, %al
movsd %xmm0, -0x80(%rbp)
jne 0x556df
movsd -0x88(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
addsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movsd (%rax), %xmm1
movsd 0x236ea(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
cmpltsd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x5578f
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x90(%rbp)
jmp 0x5579c
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x90(%rbp)
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movsd 0x2365a(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
movsd 0x2308f(%rip), %xmm1    # 0x78850
cmpltsd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
subsd (%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x30(%rbp), %xmm0
jbe 0x55827
movsd -0x30(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x98(%rbp)
jmp 0x55834
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd -0x30(%rbp), %xmm1
movsd 0x235c2(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
movsd 0x22ff7(%rip), %xmm0    # 0x78850
cmplesd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x28(%rbp), %rax
movsd (%rax), %xmm1
movsd 0x2357e(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
cmplesd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x23542(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
cmplesd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
movq -0x28(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x23506(%rip), %xmm3    # 0x78e10
xorps %xmm2, %xmm2
cmpltsd %xmm1, %xmm0
movaps %xmm0, %xmm1
andpd %xmm3, %xmm1
andnpd %xmm2, %xmm0
orpd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x55a00
jmp 0x55930
leaq 0x27017(%rip), %rdi     # 0x7c94e
callq 0x10380
movq -0x40(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x3160f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x315fe(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x315f0(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26fdf(%rip), %rsi     # 0x7c964
movl $0x50, %edx
callq 0x10840
movq 0x315ca(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x315bc(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x315a4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x31594(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x31587(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x31579(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x55a07
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)