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

  // Check factor 
  if (value.IsZero()) {
    Empty();
  }
  else if (!value.IsOne()) {
    switch(operation) {
    case RN_ZERO_OPERATION: 
      return;
      
    case RN_POLYNOMIAL_OPERATION:
      if (value.operation == RN_POLYNOMIAL_OPERATION) {
        if (TRUE || (polynomial->NTerms() == 1) || (value.polynomial->NTerms() == 1)) {
          polynomial->Multiply(*(value.polynomial));
        }
        else {
          operands[1] = new RNAlgebraic(value);
          operands[0] = new RNAlgebraic(polynomial);
          operation = RN_MULTIPLY_OPERATION;
          polynomial = NULL;
        }
      }
      else {
        operands[1] = new RNAlgebraic(value);
        operands[0] = new RNAlgebraic(polynomial);
        operation = RN_MULTIPLY_OPERATION;
        polynomial = NULL;
      }
      return;
    
    default: {
      RNAlgebraic *e = new RNAlgebraic(operation, operands[0], operands[1]);
      operands[0] = new RNAlgebraic(value);
      operands[1] = e;
      operation = RN_MULTIPLY_OPERATION;
      return; }
    }
  }
}

// Assembly:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x48(%rsp), %rdi
callq 0x3fa70
cmpl $0x0, %eax
je 0x45a06
movq 0x28(%rsp), %rdi
callq 0x444e0
jmp 0x45bd5
movq 0x48(%rsp), %rdi
callq 0x43990
cmpl $0x0, %eax
jne 0x45bd3
movq 0x28(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x24(%rsp)
testl %eax, %eax
je 0x45a39
jmp 0x45a2b
movl 0x24(%rsp), %eax
subl $0x1, %eax
je 0x45a3e
jmp 0x45b21
jmp 0x45bd5
movq 0x48(%rsp), %rax
cmpl $0x1, 0x8(%rax)
jne 0x45a65
movq 0x28(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rsi
callq 0x3d780
jmp 0x45b1c
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x18(%rsp)
movq 0x48(%rsp), %rsi
callq 0x3fe60
jmp 0x45a86
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, 0x18(%rax)
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq 0x28(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x10(%rsp)
movq 0x20(%rax), %rsi
callq 0x3f8b0
jmp 0x45ab9
movq 0x28(%rsp), %rax
movq 0x10(%rsp), %rcx
movq %rcx, 0x10(%rax)
movl $0x4, 0x8(%rax)
movq $0x0, 0x20(%rax)
jmp 0x45b1c
movq 0x18(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45bda
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45bda
jmp 0x45bd5
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq 0x28(%rsp), %rax
movq %rdi, %rcx
movq %rcx, 0x8(%rsp)
movl 0x8(%rax), %esi
movq 0x10(%rax), %rdx
movq 0x18(%rax), %rcx
callq 0x42ac0
jmp 0x45b4d
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rsp)
movl $0x28, %edi
callq 0x4280
movq %rax, %rdi
movq %rdi, %rax
movq %rax, (%rsp)
movq 0x48(%rsp), %rsi
callq 0x3fe60
jmp 0x45b77
movq 0x28(%rsp), %rax
movq (%rsp), %rcx
movq %rcx, 0x10(%rax)
movq 0x30(%rsp), %rcx
movq %rcx, 0x18(%rax)
movl $0x4, 0x8(%rax)
jmp 0x45bd5
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45bda
movq (%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x40(%rsp)
movl %eax, 0x3c(%rsp)
movl $0x28, %esi
callq 0x4290
jmp 0x45bda
jmp 0x45bd5
addq $0x58, %rsp
retq
movq 0x40(%rsp), %rdi
callq 0x44b0
nopw %cs:(%rax,%rax)