// File: tomfunkhouser[P]gaps/pkgs/RNMath/RNAlgebraic.cpp
// Function: gaps::RNAlgebraic::Divide(gaps::RNPolynomial const&)
void RNAlgebraic::
Divide(const RNPolynomial& value)
{
  // Just checking
  assert(IsValid());

  // Check value
  if (value.IsZero()) {
    if (IsZero()) {
      Empty();
    }
    else {
      Empty();
      operation = RN_POLYNOMIAL_OPERATION;
      polynomial = new RNPolynomial(RN_INFINITY, 0);
    }
  }
  else if (!value.IsOne()){
    switch(operation) {
    case RN_ZERO_OPERATION: 
      return;
      
    case RN_POLYNOMIAL_OPERATION:
      operation = RN_DIVIDE_OPERATION;
      operands[0] = new RNAlgebraic(polynomial);
      operands[1] = new RNAlgebraic(value, 0);
      polynomial = NULL;
      return;
    
    default: {
      RNAlgebraic *e = new RNAlgebraic(operation, operands[0], operands[1]);
      operation = RN_DIVIDE_OPERATION;
      operands[0] = new RNAlgebraic(value, 0);
      operands[1] = e;
      return; }
    }
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x58(%rsp), %rdi
callq 0x3cf90
cmpl $0x0, %eax
je 0x45286
movq 0x38(%rsp), %rdi
callq 0x3fa70
cmpl $0x0, %eax
je 0x45206
movq 0x38(%rsp), %rdi
callq 0x444e0
jmp 0x45281
movq 0x38(%rsp), %rdi
callq 0x444e0
movq 0x38(%rsp), %rax
movl $0x1, 0x8(%rax)
movl $0x10, %edi
callq 0x4280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x30(%rsp)
leaq 0x850b0(%rip), %rax     # 0xca2e8
movsd (%rax), %xmm0
xorl %r8d, %r8d
movl %r8d, %ecx
movl %r8d, %esi
movq %rcx, %rdx
callq 0x3c6e0
jmp 0x4524f
movq 0x38(%rsp), %rax
movq 0x30(%rsp), %rcx
movq %rcx, 0x20(%rax)
jmp 0x45281
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x10, %esi
callq 0x4290
jmp 0x45442
jmp 0x4543d
movq 0x58(%rsp), %rdi
callq 0x3cfd0
cmpl $0x0, %eax
jne 0x4543b
movq 0x38(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0x452b9
jmp 0x452ab
movl 0x2c(%rsp), %eax
subl $0x1, %eax
je 0x452be
jmp 0x4537f
jmp 0x4543d
movq 0x38(%rsp), %rax
movl $0x5, 0x8(%rax)
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq 0x38(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x20(%rsp)
movq 0x20(%rax), %rsi
callq 0x3f8b0
jmp 0x452ef
movq 0x38(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
movq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0x3fda0
jmp 0x45320
movq 0x38(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x18(%rax)
movq $0x0, 0x20(%rax)
jmp 0x4543d
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45442
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45442
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq 0x38(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x10(%rsp)
movl 0x8(%rax), %esi
movq 0x10(%rax), %rdx
movq 0x18(%rax), %rcx
callq 0x42ac0
jmp 0x453ab
movq 0x38(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x40(%rsp)
movl $0x5, 0x8(%rax)
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rsi
xorl %edx, %edx
callq 0x3fda0
jmp 0x453e4
movq 0x38(%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x40(%rsp), %rcx
movq %rcx, 0x18(%rax)
jmp 0x4543d
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45442
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45442
jmp 0x4543d
addq $0x68, %rsp
retq
movq 0x50(%rsp), %rdi
callq 0x44b0
nopl (%rax)