// File: /workspace/github_cpp_makefile_star2_O2/jstaursky[P]hutch/src/Sleigh/slghsymbol.cc
// Function: Constructor::orderOperands()
void Constructor::orderOperands(void)

{
  OperandSymbol *sym;
  vector<OperandSymbol *> patternorder;
  vector<OperandSymbol *> newops; // New order of the operands
  int4 lastsize;

  pateq->operandOrder(this,patternorder);
  for(int4 i=0;i<operands.size();++i) { // Make sure patternorder contains all operands
    sym = operands[i];
    if (!sym->isMarked()) {
      patternorder.push_back(sym);
      sym->setMark();		// Make sure all operands are marked
    }
  }
  do {
    lastsize = newops.size();
    for(int4 i=0;i<patternorder.size();++i) {
      sym = patternorder[i];
      if (!sym->isMarked()) continue; // "unmarked" means it is already in newops
      if (sym->isOffsetIrrelevant()) continue; // expression Operands come last
      if ((sym->offsetbase == -1)||(!operands[sym->offsetbase]->isMarked())) {
	newops.push_back(sym);
	sym->clearMark();
      }
    }
  } while(newops.size() != lastsize);
  for(int4 i=0;i<patternorder.size();++i) { // Tack on expression Operands
    sym = patternorder[i];
    if (sym->isOffsetIrrelevant()) {
      newops.push_back(sym);
      sym->clearMark();
    }
  }

  if (newops.size() != operands.size())
    throw SleighError("Circular offset dependency between operands");


  for(int4 i=0;i<newops.size();++i) { // Fix up operand indices
    newops[i]->hand = i;
    newops[i]->localexp->changeIndex(i);
  }
  vector<int4> handmap;		// Create index translation map
  for(int4 i=0;i<operands.size();++i)
    handmap.push_back(operands[i]->hand);

				// Fix up offsetbase
  for(int4 i=0;i<newops.size();++i) {
    sym = newops[i];
    if (sym->offsetbase == -1) continue;
    sym->offsetbase = handmap[sym->offsetbase];
  }

  if (templ != (ConstructTpl *)0) // Fix up templates
    templ->changeHandleIndex(handmap);
  for(int4 i=0;i<namedtempl.size();++i) {
    ConstructTpl *ntempl = namedtempl[i];
    if (ntempl != (ConstructTpl *)0)
      ntempl->changeHandleIndex(handmap);
  }

				// Fix up printpiece operand refs
  for(int4 i=0;i<printpiece.size();++i) {
    if (printpiece[i][0] == '\n') {
      int4 index = printpiece[i][1]-'A';
      index = handmap[index];
      printpiece[i][1] = 'A'+index;
    }
  }
  operands = newops;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rdi, %rbx
leaq 0x30(%rsp), %rdx
andq $0x0, 0x10(%rdx)
xorps %xmm0, %xmm0
andq $0x0, 0x20(%rsp)
movaps %xmm0, (%rdx)
movaps %xmm0, 0x10(%rsp)
movq 0x10(%rdi), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
callq *0x20(%rax)
leaq 0x18(%rbx), %r14
xorl %r13d, %r13d
leaq 0x30(%rsp), %r15
movq %rsp, %r12
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r13, %rcx
jbe 0x737ca
movq (%rax,%r13,8), %rax
movq %rax, (%rsp)
testb $0x8, 0x58(%rax)
jne 0x737c5
movq %r15, %rdi
movq %r12, %rsi
callq 0x509f0
movq (%rsp), %rax
orl $0x8, 0x58(%rax)
incq %r13
jmp 0x73790
leaq 0x10(%rsp), %r15
movq (%r15), %rdx
movq 0x8(%r15), %r13
movq %rsp, %r12
subq %rdx, %r13
xorl %ebp, %ebp
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %rbp, %rdx
jbe 0x73839
movq (%rax,%rbp,8), %rax
movq %rax, (%rsp)
movl 0x58(%rax), %ecx
andl $0xa, %ecx
cmpl $0x8, %ecx
jne 0x73834
movslq 0x34(%rax), %rax
cmpq $-0x1, %rax
je 0x73821
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
testb $0x8, 0x58(%rax)
jne 0x73834
movq %r15, %rdi
movq %r12, %rsi
callq 0x509f0
movq (%rsp), %rax
andl $-0x9, 0x58(%rax)
incq %rbp
jmp 0x737de
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
shrq $0x3, %r13
movslq %r13d, %rdi
movq %rsi, %r13
subq %rdx, %rsi
sarq $0x3, %rsi
cmpq %rdi, %rsi
jne 0x737d9
xorl %r13d, %r13d
leaq 0x10(%rsp), %r15
movq %rsp, %r12
movq %rcx, %rdx
subq %rax, %rdx
sarq $0x3, %rdx
cmpq %r13, %rdx
jbe 0x738a3
movq (%rax,%r13,8), %rdx
movq %rdx, (%rsp)
testb $0x2, 0x58(%rdx)
je 0x7389e
movq %r15, %rdi
movq %r12, %rsi
callq 0x509f0
movq (%rsp), %rax
andl $-0x9, 0x58(%rax)
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
incq %r13
jmp 0x73864
movq 0x10(%rsp), %rdx
movq 0x18(%rsp), %rsi
subq %rdx, %rsi
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
movq %rcx, %rdi
subq %rax, %rdi
cmpq %rdi, %rsi
jne 0x73a23
sarq $0x3, %rsi
xorl %edi, %edi
cmpq %rdi, %rsi
je 0x738e7
movq (%rdx,%rdi,8), %r8
movl %edi, 0x3c(%r8)
movq 0x40(%r8), %r8
movl %edi, 0xc(%r8)
incq %rdi
jmp 0x738cd
xorps %xmm0, %xmm0
leaq 0x50(%rsp), %r15
movaps %xmm0, (%r15)
andq $0x0, 0x10(%r15)
xorl %r12d, %r12d
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x73924
movq (%rax,%r12,8), %rsi
addq $0x3c, %rsi
movq %r15, %rdi
callq 0x4d4e0
incq %r12
movq 0x18(%rbx), %rax
movq 0x20(%rbx), %rcx
jmp 0x738fb
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq 0x50(%rsp), %rdx
xorl %esi, %esi
cmpq %rsi, %rcx
je 0x73960
movq (%rax,%rsi,8), %rdi
movq %rdi, (%rsp)
movslq 0x34(%rdi), %r8
cmpq $-0x1, %r8
je 0x7395b
movl (%rdx,%r8,4), %r8d
movl %r8d, 0x34(%rdi)
incq %rsi
jmp 0x7393c
movq 0x60(%rbx), %rdi
testq %rdi, %rdi
je 0x73973
leaq 0x50(%rsp), %rsi
callq 0x50490
xorl %r12d, %r12d
leaq 0x50(%rsp), %r15
movq 0x68(%rbx), %rax
movq 0x70(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r12, %rcx
jbe 0x739a5
movq (%rax,%r12,8), %rdi
testq %rdi, %rdi
je 0x739a0
movq %r15, %rsi
callq 0x50490
incq %r12
jmp 0x7397b
xorl %eax, %eax
xorl %ecx, %ecx
movq 0x30(%rbx), %rdx
movq 0x38(%rbx), %rsi
subq %rdx, %rsi
sarq $0x5, %rsi
cmpq %rcx, %rsi
jbe 0x739e9
movq (%rdx,%rax), %rdx
cmpb $0xa, (%rdx)
jne 0x739e0
movsbq 0x1(%rdx), %rsi
movq 0x50(%rsp), %rdi
movb -0x104(%rdi,%rsi,4), %sil
addb $0x41, %sil
movb %sil, 0x1(%rdx)
incq %rcx
addq $0x20, %rax
jmp 0x739a9
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x4eef0
leaq 0x50(%rsp), %rdi
callq 0x4fab0
leaq 0x10(%rsp), %rdi
callq 0x513f0
leaq 0x30(%rsp), %rdi
callq 0x513f0
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x20
popq %rdi
callq 0x4e180
movq %rax, %r14
leaq 0x14ae6(%rip), %rsi     # 0x8851b
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x515e0
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x4ddf0
xorl %ebp, %ebp
movq 0x3b42b(%rip), %rsi     # 0xaee88
movq 0x3b1d4(%rip), %rdx     # 0xaec38
movq %r14, %rdi
callq 0x51630
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4e020
testb %bpl, %bpl
jne 0x73a83
jmp 0x73aa9
movq %rax, %rbx
movq %r14, %rdi
callq 0x4ea60
jmp 0x73aa9
jmp 0x73aa6
jmp 0x73a97
jmp 0x73aa6
jmp 0x73aa6
jmp 0x73a97
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x4fab0
jmp 0x73aa9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x513f0
leaq 0x30(%rsp), %rdi
callq 0x513f0
movq %rbx, %rdi
callq 0x518c0
nop