// File: jstaursky[P]hutch/src/Sleigh/slgh_compile.cc
// Function: ConsistencyChecker::checkSubtable(SubtableSymbol*)
bool ConsistencyChecker::checkSubtable(SubtableSymbol *sym)

{
  int4 tablesize = 0;
  int4 numconstruct = sym->getNumConstructors();
  Constructor *ct;
  bool testresult = true;
  bool seenemptyexport = false;
  bool seennonemptyexport = false;

  for(int4 i=0;i<numconstruct;++i) {
    ct = sym->getConstructor(i);
    if (!checkConstructorSection(ct,ct->getTempl()))
      testresult = false;
    int4 numsection = ct->getNumSections();
    for(int4 j=0;j<numsection;++j) {
      if (!checkConstructorSection(ct,ct->getNamedTempl(j)))
	testresult = false;
    }

    if (ct->getTempl() == (ConstructTpl *)0) continue;	// Unimplemented
    HandleTpl *exportres = ct->getTempl()->getResult();
    if (exportres != (HandleTpl *)0) {
      if (seenemptyexport && (!seennonemptyexport)) {
	cerr << "Table " << sym->getName() << " exports inconsistently" << endl;
	cerr << "Constructor starting at line " << dec << ct->getLineno() << " is first inconsistency" << endl;
	testresult = false;
      }
      seennonemptyexport = true;
      int4 exsize = recoverSize(exportres->getSize(),ct);
      if (tablesize == 0)
	tablesize = exsize;
      if ((exsize!=0)&&(exsize != tablesize)) {
	cerr << "Table " << sym->getName() << " has inconsistent export size." << endl;
	cerr << "Constructor starting at line " << dec << ct->getLineno() << " is first conflict" << endl;
	testresult = false;
      }
    }
    else {
      if (seennonemptyexport && (!seenemptyexport)) {
	cerr << "Table " << sym->getName() << " exports inconsistently" << endl;
	cerr << "Constructor starting at line " << dec << ct->getLineno() << " is first inconsistency" << endl;
	testresult = false;
      }
      seenemptyexport = true;
    }
  }
  if (seennonemptyexport) {
    if (tablesize == 0)
      cerr << "Warning: Table " << sym->getName() << " exports size 0" << endl;
    sizemap[sym] = tablesize;	// Remember recovered size
  }
  else
    sizemap[sym] = -1;
  
  return testresult;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rdi
callq 0x6a660
movl %eax, -0x18(%rbp)
movb $0x1, -0x21(%rbp)
movb $0x0, -0x22(%rbp)
movb $0x0, -0x23(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x5e959
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x6a680
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0x52880
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %rax, %rdx
callq 0x5e000
testb $0x1, %al
jne 0x5e656
movb $0x0, -0x21(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6a6b0
movl %eax, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5e6aa
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
movl -0x30(%rbp), %esi
callq 0xaa8d0
movq -0x48(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %rax, %rdx
callq 0x5e000
testb $0x1, %al
jne 0x5e69d
movb $0x0, -0x21(%rbp)
jmp 0x5e69f
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5e669
movq -0x20(%rbp), %rdi
callq 0x52880
cmpq $0x0, %rax
jne 0x5e6be
jmp 0x5e94b
movq -0x20(%rbp), %rdi
callq 0x52880
movq %rax, %rdi
callq 0x52ef0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x5e885
testb $0x1, -0x22(%rbp)
je 0x5e798
testb $0x1, -0x23(%rbp)
jne 0x5e798
movq 0xd38ef(%rip), %rdi     # 0x131fe8
leaq 0x7ab1b(%rip), %rsi     # 0xd921b
callq 0x11420
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x401a0
movq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0x113e0
movq %rax, %rdi
leaq 0x7aa6a(%rip), %rsi     # 0xd9192
callq 0x11420
movq %rax, %rdi
movq 0xd3869(%rip), %rsi     # 0x131fa0
callq 0x114a0
movq 0xd38a5(%rip), %rdi     # 0x131fe8
leaq 0x7aa60(%rip), %rsi     # 0xd91aa
callq 0x11420
movq %rax, %rdi
leaq -0x390e9(%rip), %rsi    # 0x25670
callq 0x11180
movq %rax, -0x60(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6a600
movq -0x60(%rbp), %rdi
movl %eax, %esi
callq 0x11880
movq %rax, %rdi
leaq 0x7aa48(%rip), %rsi     # 0xd91c8
callq 0x11420
movq %rax, %rdi
movq 0xd3811(%rip), %rsi     # 0x131fa0
callq 0x114a0
movb $0x0, -0x21(%rbp)
movb $0x1, -0x23(%rbp)
movq -0x38(%rbp), %rdi
callq 0x4e1d0
movq -0x48(%rbp), %rdi
movq %rax, %rsi
movq -0x20(%rbp), %rdx
callq 0x5ac50
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x5e7c4
movl -0x3c(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x5e880
movl -0x3c(%rbp), %eax
cmpl -0x14(%rbp), %eax
je 0x5e880
movq 0xd3807(%rip), %rdi     # 0x131fe8
leaq 0x7aa33(%rip), %rsi     # 0xd921b
callq 0x11420
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rdi
callq 0x401a0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x113e0
movq %rax, %rdi
leaq 0x7a9d0(%rip), %rsi     # 0xd91e0
callq 0x11420
movq %rax, %rdi
movq 0xd3781(%rip), %rsi     # 0x131fa0
callq 0x114a0
movq 0xd37bd(%rip), %rdi     # 0x131fe8
leaq 0x7a978(%rip), %rsi     # 0xd91aa
callq 0x11420
movq %rax, %rdi
leaq -0x391d1(%rip), %rsi    # 0x25670
callq 0x11180
movq %rax, -0x70(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6a600
movq -0x70(%rbp), %rdi
movl %eax, %esi
callq 0x11880
movq %rax, %rdi
leaq 0x7a997(%rip), %rsi     # 0xd91ff
callq 0x11420
movq %rax, %rdi
movq 0xd3729(%rip), %rsi     # 0x131fa0
callq 0x114a0
movb $0x0, -0x21(%rbp)
jmp 0x5e949
testb $0x1, -0x23(%rbp)
je 0x5e945
testb $0x1, -0x22(%rbp)
jne 0x5e945
movq 0xd3748(%rip), %rdi     # 0x131fe8
leaq 0x7a974(%rip), %rsi     # 0xd921b
callq 0x11420
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
callq 0x401a0
movq -0x88(%rbp), %rdi
movq %rax, %rsi
callq 0x113e0
movq %rax, %rdi
leaq 0x7a8bd(%rip), %rsi     # 0xd9192
callq 0x11420
movq %rax, %rdi
movq 0xd36bc(%rip), %rsi     # 0x131fa0
callq 0x114a0
movq 0xd36f8(%rip), %rdi     # 0x131fe8
leaq 0x7a8b3(%rip), %rsi     # 0xd91aa
callq 0x11420
movq %rax, %rdi
leaq -0x39296(%rip), %rsi    # 0x25670
callq 0x11180
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
callq 0x6a600
movq -0x80(%rbp), %rdi
movl %eax, %esi
callq 0x11880
movq %rax, %rdi
leaq 0x7a89b(%rip), %rsi     # 0xd91c8
callq 0x11420
movq %rax, %rdi
movq 0xd3664(%rip), %rsi     # 0x131fa0
callq 0x114a0
movb $0x0, -0x21(%rbp)
movb $0x1, -0x22(%rbp)
jmp 0x5e94b
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x5e611
testb $0x1, -0x23(%rbp)
je 0x5e9d9
cmpl $0x0, -0x14(%rbp)
jne 0x5e9b5
movq 0xd367c(%rip), %rdi     # 0x131fe8
leaq 0x7a89f(%rip), %rsi     # 0xd9212
callq 0x11420
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rdi
callq 0x401a0
movq -0x90(%rbp), %rdi
movq %rax, %rsi
callq 0x113e0
movq %rax, %rdi
leaq 0x7a881(%rip), %rsi     # 0xd9222
callq 0x11420
movq %rax, %rdi
movq 0xd35f0(%rip), %rsi     # 0x131fa0
callq 0x114a0
movq -0x48(%rbp), %rdi
movl -0x14(%rbp), %eax
movl %eax, -0x94(%rbp)
addq $0x30, %rdi
leaq -0x10(%rbp), %rsi
callq 0x6a6d0
movl -0x94(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x5e9f0
movq -0x48(%rbp), %rdi
addq $0x30, %rdi
leaq -0x10(%rbp), %rsi
callq 0x6a6d0
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movb -0x21(%rbp), %al
andb $0x1, %al
addq $0xa0, %rsp
popq %rbp
retq
nop