// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: SleighCompile::calcContextLayout()
void SleighCompile::calcContextLayout(void)

{
  if (contextlock) return;	// Already locked
  contextlock = true;

  int4 context_offset = 0;
  int4 begin,sz;
  stable_sort(contexttable.begin(),contexttable.end());
  begin = 0;
  while(begin < contexttable.size()) { // Define the context variables
    sz = 1;
    while ((begin+sz < contexttable.size())&&(contexttable[begin+sz].sym==contexttable[begin].sym))
      sz += 1;
    context_offset = calcContextVarLayout(begin,sz,context_offset);
    begin += sz;
  } 

  //  context_size = (context_offset+8*sizeof(uintm)-1)/(8*sizeof(uintm));

  // Delete the quals
  for(int4 i=0;i<contexttable.size();++i) {
    FieldQuality *qual = contexttable[i].qual;
    delete qual;
  }

  contexttable.clear();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
testb $0x1, 0x2e0(%rax)
je 0x634e2
jmp 0x6368f
movq -0x40(%rbp), %rdi
movb $0x1, 0x2e0(%rdi)
movl $0x0, -0xc(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x6b8d0
movq -0x40(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x6b900
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6b890
movl $0x0, -0x10(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x6b930
movq %rax, %rcx
movq -0x48(%rbp), %rax
cmpq %rcx, %rax
jae 0x63606
movl $0x1, -0x14(%rbp)
movq -0x40(%rbp), %rdi
movl -0x10(%rbp), %eax
addl -0x14(%rbp), %eax
cltq
movq %rax, -0x58(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x6b930
movq -0x58(%rbp), %rcx
movq %rax, %rdx
xorl %eax, %eax
cmpq %rdx, %rcx
movb %al, -0x49(%rbp)
jae 0x635cc
movq -0x40(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
movl -0x10(%rbp), %eax
addl -0x14(%rbp), %eax
movslq %eax, %rsi
callq 0x6b520
movq -0x40(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x60(%rbp)
addq $0x240, %rdi            # imm = 0x240
movslq -0x10(%rbp), %rsi
callq 0x6b520
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq (%rcx), %rax
sete %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x635d5
jmp 0x635e3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6355b
movq -0x40(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
movl -0xc(%rbp), %ecx
callq 0x61b30
movl %eax, -0xc(%rbp)
movl -0x14(%rbp), %eax
addl -0x10(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x6352c
movl $0x0, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x2c(%rbp), %rax
movq %rax, -0x68(%rbp)
addq $0x240, %rdi            # imm = 0x240
callq 0x6b930
movq %rax, %rcx
movq -0x68(%rbp), %rax
cmpq %rcx, %rax
jae 0x6367f
movq -0x40(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
movslq -0x2c(%rbp), %rsi
callq 0x6b520
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x63672
movq -0x70(%rbp), %rdi
callq 0x6b950
movq -0x70(%rbp), %rdi
movl $0x30, %esi
callq 0x11450
jmp 0x63674
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6360d
movq -0x40(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x6b970
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)