// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/translate.cc
// Function: AddrSpaceManager::insertSpace(AddrSpace*)
void AddrSpaceManager::insertSpace(AddrSpace *spc)

{
  bool nameTypeMismatch = false;
  bool duplicateName = false;
  bool duplicateId = false;
  switch(spc->getType()) {
  case IPTR_CONSTANT:
    if (spc->getName() != "const")
      nameTypeMismatch = true;
    if (spc->index != AddrSpace::constant_space_index)
      throw LowlevelError("const space must be assigned index 0");
    constantspace = spc;
    break;
  case IPTR_INTERNAL:
    if (spc->getName() != "unique")
      nameTypeMismatch = true;
    if (uniqspace != (AddrSpace *)0)
      duplicateName = true;
    uniqspace = spc;
    break;
  case IPTR_FSPEC:
    if (spc->getName() != "fspec")
      nameTypeMismatch = true;
    if (fspecspace != (AddrSpace *)0)
      duplicateName = true;
    fspecspace = spc;
    break;
  case IPTR_JOIN:
    if (spc->getName() != "join")
      nameTypeMismatch = true;
    if (joinspace != (AddrSpace *)0)
      duplicateName = true;
    joinspace = spc;
    break;
  case IPTR_IOP:
    if (spc->getName() != "iop")
      nameTypeMismatch = true;
    if (iopspace != (AddrSpace *)0)
      duplicateName = true;
    iopspace = spc;
    break;
  case IPTR_SPACEBASE:
    if (spc->getName() == "stack") {
      if (stackspace != (AddrSpace *)0)
	duplicateName = true;
      stackspace = spc;
    }
    // fallthru
  case IPTR_PROCESSOR:
    if (spc->isOverlay()) {	// If this is a new overlay space
      OverlaySpace *ospc = (OverlaySpace *)spc;
      ospc->getBaseSpace()->setFlags(AddrSpace::overlaybase); // Mark the base as being overlayed
    }
    else if (spc->isOtherSpace()) {
      if (spc->index != AddrSpace::other_space_index)
        throw LowlevelError("OTHER space must be assigned index 1");
    }
    break;
  }

  if (baselist.size() <= spc->index)
    baselist.resize(spc->index+1, (AddrSpace *)0);

  duplicateId = baselist[spc->index] != (AddrSpace *)0;

  if (!nameTypeMismatch && !duplicateName && !duplicateId) {
    duplicateName = !name2Space.insert(pair<string,AddrSpace *>(spc->getName(),spc)).second;
  }

  if (nameTypeMismatch || duplicateName || duplicateId) {
    if (spc->refcount == 0)
      delete spc;
    spc = (AddrSpace *)0;
  }
  if (nameTypeMismatch)
    throw LowlevelError("Space "+spc->getName()+" was initialized with wrong type");
  if (duplicateName)
    throw LowlevelError("Space "+spc->getName()+" was initialized more than once");
  if (duplicateId)
    throw LowlevelError("Space "+spc->getName()+" was assigned as id duplicating: "+baselist[spc->index]->getName());
  baselist[spc->index] = spc;
  spc->refcount += 1;
  assignShortcut(spc);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x8(%rsi), %eax
xorl %ebp, %ebp
cmpq $0x6, %rax
ja 0x4cf76
leaq 0x32be8(%rip), %rcx     # 0x7f9c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x38(%r14), %rdi
leaq 0x32cc4(%rip), %rsi     # 0x7fab4
callq 0x3f590
cmpl $0x0, 0x60(%r14)
jne 0x4d1ae
testl %eax, %eax
setne %r13b
movq %r14, 0x98(%rbx)
xorl %ebp, %ebp
jmp 0x4cf79
leaq 0x38(%r14), %rdi
leaq 0x32d29(%rip), %rsi     # 0x7fb48
callq 0x3f590
testl %eax, %eax
setne %r13b
cmpq $0x0, 0xb0(%rbx)
setne %bpl
movq %r14, 0xb0(%rbx)
jmp 0x4cf79
leaq 0x38(%r14), %rdi
leaq 0x32d05(%rip), %rsi     # 0x7fb52
callq 0x3f590
testl %eax, %eax
je 0x4ceeb
xorl %ebp, %ebp
jmp 0x4cefe
leaq 0x38(%r14), %rdi
leaq 0x32988(%rip), %rsi     # 0x7f7f4
callq 0x3f590
testl %eax, %eax
setne %r13b
cmpq $0x0, 0xc8(%rbx)
setne %bpl
movq %r14, 0xc8(%rbx)
jmp 0x4cf79
leaq 0x38(%r14), %rdi
leaq 0x32cb4(%rip), %rsi     # 0x7fb4e
callq 0x3f590
testl %eax, %eax
setne %r13b
cmpq $0x0, 0xa8(%rbx)
setne %bpl
movq %r14, 0xa8(%rbx)
jmp 0x4cf79
leaq 0x38(%r14), %rdi
leaq 0x32dab(%rip), %rsi     # 0x7fc73
callq 0x3f590
testl %eax, %eax
setne %r13b
cmpq $0x0, 0xb8(%rbx)
setne %bpl
movq %r14, 0xb8(%rbx)
jmp 0x4cf79
cmpq $0x0, 0xc0(%rbx)
setne %bpl
movq %r14, 0xc0(%rbx)
movl 0x24(%r14), %eax
testb $0x20, %al
jne 0x4cf6a
btl $0x9, %eax
jae 0x4cf76
cmpl $0x1, 0x60(%r14)
je 0x4cf76
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x32c28(%rip), %rsi     # 0x7fb58
leaq 0x32c45(%rip), %rdx     # 0x7fb7c
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55f52(%rip), %rsi     # 0xa2ea8
movq 0x55cdb(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4d30a
movq %r14, %rdi
callq 0x3f610
orb $0x40, 0x24(%rax)
xorl %r13d, %r13d
movq 0x10(%rbx), %rax
subq 0x8(%rbx), %rax
leaq 0x8(%rbx), %r15
sarq $0x3, %rax
movslq 0x60(%r14), %rsi
cmpq %rsi, %rax
ja 0x4cfa7
incq %rsi
movq %rsp, %rdx
movq $0x0, (%rdx)
movq %r15, %rdi
callq 0x3f440
movslq 0x60(%r14), %rax
movq %r15, 0x50(%rsp)
movq (%r15), %rcx
movq (%rcx,%rax,8), %r15
movl %r13d, %eax
orb %bpl, %al
testb $0x1, %al
jne 0x4d023
testq %r15, %r15
jne 0x4d023
movl %r13d, 0x2c(%rsp)
leaq 0x38(%rbx), %r12
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x38(%r14), %rsi
movq 0x40(%r14), %rdx
addq %rsi, %rdx
movq %rsp, %r13
movq %r13, %rdi
callq 0x3f8e0
movq %r14, 0x20(%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x41200
movl %edx, %ebp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4d01a
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
xorb $0x1, %bpl
movl 0x2c(%rsp), %r13d
movl %r13d, %eax
orb %bpl, %al
testb $0x1, %al
jne 0x4d037
testq %r15, %r15
jne 0x4d037
movq %r14, %r12
jmp 0x4d052
xorl %r12d, %r12d
testq %r14, %r14
je 0x4d052
cmpl $0x0, 0x20(%r14)
jne 0x4d052
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
xorl %r12d, %r12d
testb %r13b, %r13b
jne 0x4d096
testb $0x1, %bpl
jne 0x4d0f4
testq %r15, %r15
jne 0x4d152
movslq 0x60(%r12), %rax
movq 0x8(%rbx), %rcx
movq %r12, (%rcx,%rax,8)
incl 0x20(%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x40490
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
addq $0x38, %r12
leaq 0x32acf(%rip), %rsi     # 0x7fb7d
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x40500
leaq 0x32ac2(%rip), %rsi     # 0x7fb84
leaq 0x30(%rsp), %rdi
callq 0x422f0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d205
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d211
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
addq $0x38, %r12
leaq 0x32a71(%rip), %rsi     # 0x7fb7d
leaq 0x30(%rsp), %rdi
movq %r12, %rdx
callq 0x40500
leaq 0x32a85(%rip), %rsi     # 0x7fba5
leaq 0x30(%rsp), %rdi
callq 0x422f0
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d253
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d25f
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x38(%r12), %rdx
leaq 0x32a12(%rip), %rsi     # 0x7fb7d
leaq 0x58(%rsp), %rdi
callq 0x40500
leaq 0x32a49(%rip), %rsi     # 0x7fbc5
leaq 0x58(%rsp), %rdi
callq 0x422f0
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d29e
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d2ab
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x32958(%rip), %rsi     # 0x7fb23
leaq 0x32975(%rip), %rdx     # 0x7fb47
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55cb7(%rip), %rsi     # 0xa2ea8
movq 0x55a40(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4d30a
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rdx
movq %rsp, %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55c69(%rip), %rsi     # 0xa2ea8
movq 0x559f2(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4d30a
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rdx
movq %rsp, %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55c1b(%rip), %rsi     # 0xa2ea8
movq 0x559a4(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4d30a
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
movq 0x8(%rax), %rdx
leaq 0x30(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movslq 0x60(%r12), %rax
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdx
addq $0x38, %rdx
movq %rsp, %rdi
callq 0x41640
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55bad(%rip), %rsi     # 0xa2ea8
movq 0x55936(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d60
jmp 0x4d311
jmp 0x4d3d0
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4d3d6
movq 0x10(%rsp), %rsi
jmp 0x4d3c2
jmp 0x4d3d0
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d356
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4d356
movq %rax, %rbx
movb $0x1, %bpl
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x4d375
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4d375
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d3d6
movq 0x68(%rsp), %rsi
jmp 0x4d3c2
jmp 0x4d38e
jmp 0x4d3a9
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4d3af
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4d3af
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d3d6
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4d3d6
jmp 0x4d3d0
jmp 0x4d3d0
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x4d3e3
movq %r14, %rdi
callq 0x40080
movq %rbx, %rdi
callq 0x41f00
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4d3e3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40870
jmp 0x4d3e3
nop