// File: sundale[P]gcode/rs274ngc/interp_execute.cc
// Function: Interp::execute_unary(double*, int)
int Interp::execute_unary(double *double_ptr,    //!< pointer to the operand         
                         int operation) //!< integer code for the operation 
{
  switch (operation) {
  case ABS:
    if (*double_ptr < 0.0)
      *double_ptr = (-1.0 * *double_ptr);
    break;
  case ACOS:
    CHKS(((*double_ptr < -1.0) || (*double_ptr > 1.0)),
        NCE_ARGUMENT_TO_ACOS_OUT_OF_RANGE);
    *double_ptr = acos(*double_ptr);
    *double_ptr = ((*double_ptr * 180.0) / M_PIl);
    break;
  case ASIN:
    CHKS(((*double_ptr < -1.0) || (*double_ptr > 1.0)),
        NCE_ARGUMENT_TO_ASIN_OUT_OF_RANGE);
    *double_ptr = asin(*double_ptr);
    *double_ptr = ((*double_ptr * 180.0) / M_PIl);
    break;
  case COS:
    *double_ptr = cos((*double_ptr * M_PIl) / 180.0);
    break;
  case EXP:
    *double_ptr = exp(*double_ptr);
    break;
  case FIX:
    *double_ptr = floor(*double_ptr);
    break;
  case FUP:
    *double_ptr = ceil(*double_ptr);
    break;
  case LN:
    CHKS((*double_ptr <= 0.0), NCE_ZERO_OR_NEGATIVE_ARGUMENT_TO_LN);
    *double_ptr = log(*double_ptr);
    break;
  case ROUND:
    *double_ptr = (double)
      ((int) (*double_ptr + ((*double_ptr < 0.0) ? -0.5 : 0.5)));
    break;
  case SIN:
    *double_ptr = sin((*double_ptr * M_PIl) / 180.0);
    break;
  case SQRT:
    CHKS((*double_ptr < 0.0), NCE_NEGATIVE_ARGUMENT_TO_SQRT);
    *double_ptr = sqrt(*double_ptr);
    break;
  case TAN:
    *double_ptr = tan((*double_ptr * M_PIl) / 180.0);
    break;
  default:
    ERS(NCE_BUG_UNKNOWN_OPERATION);
  }
  return INTERP_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movl -0x1c(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0xc, %eax
ja 0x569bb
movq -0x60(%rbp), %rax
leaq 0x264bb(%rip), %rcx     # 0x7c858
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x563cb
movq -0x18(%rbp), %rax
movsd 0x224a1(%rip), %xmm0    # 0x78860
mulsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
jmp 0x563d2
movq -0x18(%rbp), %rax
movsd 0x22482(%rip), %xmm0    # 0x78860
ucomisd (%rax), %xmm0
ja 0x563fe
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x22a1c(%rip), %xmm1    # 0x78e10
ucomisd %xmm1, %xmm0
jbe 0x564d3
jmp 0x56400
leaq 0x265ca(%rip), %rdi     # 0x7c9d1
callq 0x10380
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x30b3f(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x30b2e(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30b20(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2659a(%rip), %rsi     # 0x7c9ef
movl $0x50, %edx
callq 0x10840
movq 0x30afa(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30aec(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30ad4(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30ac4(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30ab7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30aa9(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x56a94
jmp 0x564d5
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x110b0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x22956(%rip), %xmm1    # 0x78e50
mulsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
fldl -0x50(%rbp)
fldt 0x229b4(%rip)           # 0x78ec0
fdivrp %st, %st(1)
fstpl -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
jmp 0x56525
movq -0x18(%rbp), %rax
movsd 0x2232f(%rip), %xmm0    # 0x78860
ucomisd (%rax), %xmm0
ja 0x56551
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x228c9(%rip), %xmm1    # 0x78e10
ucomisd %xmm1, %xmm0
jbe 0x56626
jmp 0x56553
leaq 0x264be(%rip), %rdi     # 0x7ca18
callq 0x10380
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x309ec(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x309db(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x309cd(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26447(%rip), %rsi     # 0x7c9ef
movl $0x50, %edx
callq 0x10840
movq 0x309a7(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30999(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30981(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30971(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30964(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30956(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x56a94
jmp 0x56628
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x11d80
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movsd 0x22803(%rip), %xmm1    # 0x78e50
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
fldl -0x40(%rbp)
fldt 0x22861(%rip)           # 0x78ec0
fdivrp %st, %st(1)
fstpl -0x48(%rbp)
movsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
fldl (%rax)
fldt 0x2283e(%rip)           # 0x78ec0
fmulp %st, %st(1)
flds 0x2620e(%rip)           # 0x7c898
fdivrp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0x11230
fstpl -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x12000
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x11e50
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x10250
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
jmp 0x566fb
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jb 0x567e1
jmp 0x5670e
leaq 0x26321(%rip), %rdi     # 0x7ca36
callq 0x10380
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x30831(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x30820(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30812(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x2628c(%rip), %rsi     # 0x7c9ef
movl $0x50, %edx
callq 0x10840
movq 0x307ec(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x307de(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x307c6(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x307b6(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x307a9(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x3079b(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x56a94
jmp 0x567e3
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x10de0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
movq -0x18(%rbp), %rax
movsd (%rax), %xmm1
movsd 0x2607b(%rip), %xmm4    # 0x7c890
movsd 0x22643(%rip), %xmm3    # 0x78e60
xorps %xmm2, %xmm2
cmpltsd %xmm2, %xmm1
movaps %xmm1, %xmm2
andpd %xmm4, %xmm2
andnpd %xmm3, %xmm1
orpd %xmm2, %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
cvtsi2sd %eax, %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
fldl (%rax)
fldt 0x22667(%rip)           # 0x78ec0
fmulp %st, %st(1)
flds 0x26037(%rip)           # 0x7c898
fdivrp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0x10110
fstpl -0x30(%rbp)
movsd -0x30(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
jmp 0x56884
movq -0x18(%rbp), %rax
xorps %xmm0, %xmm0
ucomisd (%rax), %xmm0
jbe 0x5696a
jmp 0x56897
leaq 0x261b8(%rip), %rdi     # 0x7ca56
callq 0x10380
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x306a8(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x30697(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30689(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x26103(%rip), %rsi     # 0x7c9ef
movl $0x50, %edx
callq 0x10840
movq 0x30663(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30655(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x3063d(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x3062d(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x30620(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x30612(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x56a94
jmp 0x5696c
movq -0x18(%rbp), %rax
movsd (%rax), %xmm0
callq 0x10d70
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
movq -0x18(%rbp), %rax
fldl (%rax)
fldt 0x2252e(%rip)           # 0x78ec0
fmulp %st, %st(1)
flds 0x25efe(%rip)           # 0x7c898
fdivrp %st, %st(1)
movq %rsp, %rax
fstpt (%rax)
callq 0x10720
fstpl -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movq -0x18(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x56a8d
jmp 0x569bd
leaq 0x25f8a(%rip), %rdi     # 0x7c94e
callq 0x10380
movq -0x68(%rbp), %rdi
movq %rax, %rsi
movb $0x0, %al
callq 0x10df0
movq 0x30582(%rip), %rax     # 0x86f60
movl $0x0, 0xd670(%rax)
movq 0x30571(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rax
movq 0x30563(%rip), %rdi     # 0x86f60
addq $0xc6d0, %rdi           # imm = 0xC6D0
imulq $0x50, %rax, %rax
addq %rax, %rdi
leaq 0x25fdd(%rip), %rsi     # 0x7c9ef
movl $0x50, %edx
callq 0x10840
movq 0x3053d(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x3052f(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, 0x4f(%rax)
movq 0x30517(%rip), %rax     # 0x86f60
movl 0xd670(%rax), %ecx
addl $0x1, %ecx
movq 0x30507(%rip), %rax     # 0x86f60
movl %ecx, 0xd670(%rax)
movq 0x304fa(%rip), %rax     # 0x86f60
movslq 0xd670(%rax), %rcx
movq 0x304ec(%rip), %rax     # 0x86f60
addq $0xc6d0, %rax           # imm = 0xC6D0
imulq $0x50, %rcx, %rcx
addq %rcx, %rax
movb $0x0, (%rax)
movl $0x5, -0x4(%rbp)
jmp 0x56a94
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq