// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %eax
xorl %ebp, %ebp
cmpq $0x6, %rax
ja 0x4cecd
leaq 0x32c8e(%rip), %rcx     # 0x7f9c4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x38(%rbx), %rdi
leaq 0x32d6a(%rip), %rsi     # 0x7fab4
callq 0x3f590
cmpl $0x0, 0x60(%rbx)
jne 0x4d0f7
testl %eax, %eax
setne %r12b
movq %rbx, 0x98(%r14)
xorl %ebp, %ebp
jmp 0x4ced0
leaq 0x38(%rbx), %rdi
leaq 0x32dd0(%rip), %rsi     # 0x7fb48
callq 0x3f590
testl %eax, %eax
setne %r12b
cmpq $0x0, 0xb0(%r14)
setne %bpl
movq %rbx, 0xb0(%r14)
jmp 0x4ced0
leaq 0x38(%rbx), %rdi
leaq 0x32dac(%rip), %rsi     # 0x7fb52
callq 0x3f590
testl %eax, %eax
je 0x4ce44
xorl %ebp, %ebp
jmp 0x4ce57
leaq 0x38(%rbx), %rdi
leaq 0x32a2f(%rip), %rsi     # 0x7f7f4
callq 0x3f590
testl %eax, %eax
setne %r12b
cmpq $0x0, 0xc8(%r14)
setne %bpl
movq %rbx, 0xc8(%r14)
jmp 0x4ced0
leaq 0x38(%rbx), %rdi
leaq 0x32d5b(%rip), %rsi     # 0x7fb4e
callq 0x3f590
testl %eax, %eax
setne %r12b
cmpq $0x0, 0xa8(%r14)
setne %bpl
movq %rbx, 0xa8(%r14)
jmp 0x4ced0
leaq 0x38(%rbx), %rdi
leaq 0x32e52(%rip), %rsi     # 0x7fc73
callq 0x3f590
testl %eax, %eax
setne %r12b
cmpq $0x0, 0xb8(%r14)
setne %bpl
movq %rbx, 0xb8(%r14)
jmp 0x4ced0
cmpq $0x0, 0xc0(%r14)
setne %bpl
movq %rbx, 0xc0(%r14)
movl 0x24(%rbx), %eax
testb $0x20, %al
jne 0x4cec1
btl $0x9, %eax
jae 0x4cecd
cmpl $0x1, 0x60(%rbx)
je 0x4cecd
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x32cd1(%rip), %rsi     # 0x7fb58
leaq 0x32cee(%rip), %rdx     # 0x7fb7c
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55ffb(%rip), %rsi     # 0xa2ea8
movq 0x55d84(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4d252
movq %rbx, %rdi
callq 0x3f610
orb $0x40, 0x24(%rax)
xorl %r12d, %r12d
leaq 0x8(%r14), %r15
movq 0x8(%r14), %rax
movq 0x10(%r14), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
movslq 0x60(%rbx), %rcx
cmpq %rcx, %rdx
movq %r15, 0x50(%rsp)
ja 0x4cf0f
incl %ecx
movslq %ecx, %rsi
movq %rsp, %rdx
movq $0x0, (%rdx)
movq %r15, %rdi
callq 0x3f440
movslq 0x60(%rbx), %rcx
movq (%r15), %rax
movq (%rax,%rcx,8), %r15
movl %r12d, %eax
orb %bpl, %al
testb $0x1, %al
jne 0x4cf7f
testq %r15, %r15
jne 0x4cf7f
movl %r12d, 0x4c(%rsp)
leaq 0x38(%r14), %r12
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x38(%rbx), %rsi
movq 0x40(%rbx), %rdx
addq %rsi, %rdx
movq %rsp, %r13
movq %r13, %rdi
callq 0x3f8e0
movq %rbx, 0x20(%r13)
movq %r12, %rdi
movq %r13, %rsi
callq 0x41210
movl %edx, %ebp
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4cf76
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
xorb $0x1, %bpl
movl 0x4c(%rsp), %r12d
movl %r12d, %eax
orb %bpl, %al
testb $0x1, %al
jne 0x4cf8e
testq %r15, %r15
je 0x4cf9f
cmpl $0x0, 0x20(%rbx)
jne 0x4cf9d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebx, %ebx
testb %r12b, %r12b
jne 0x4cfe0
testb $0x1, %bpl
jne 0x4d03e
testq %r15, %r15
jne 0x4d09c
movslq 0x60(%rbx), %rax
movq 0x8(%r14), %rcx
movq %rbx, (%rcx,%rax,8)
incl 0x20(%rbx)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x404a0
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, %rbx
leaq 0x32b85(%rip), %rsi     # 0x7fb7d
leaq 0x28(%rsp), %rdi
movq %rbx, %rdx
callq 0x40510
leaq 0x32b78(%rip), %rsi     # 0x7fb84
leaq 0x28(%rsp), %rdi
callq 0x42300
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d14e
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d15a
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
addq $0x38, %rbx
leaq 0x32b27(%rip), %rsi     # 0x7fb7d
leaq 0x28(%rsp), %rdi
movq %rbx, %rdx
callq 0x40510
leaq 0x32b3b(%rip), %rsi     # 0x7fba5
leaq 0x28(%rsp), %rdi
callq 0x42300
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d19c
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d1a8
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x38(%rbx), %rdx
leaq 0x32ac9(%rip), %rsi     # 0x7fb7d
leaq 0x58(%rsp), %rdi
callq 0x40510
leaq 0x32b00(%rip), %rsi     # 0x7fbc5
leaq 0x58(%rsp), %rdi
callq 0x42300
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x4d1e7
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x4d1f4
movl $0x20, %edi
callq 0x3fb00
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x32a0f(%rip), %rsi     # 0x7fb23
leaq 0x32a2c(%rip), %rdx     # 0x7fb47
movq %rsp, %rdi
callq 0x3f8a0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55d6e(%rip), %rsi     # 0xa2ea8
movq 0x55af7(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4d252
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 0x55d20(%rip), %rsi     # 0xa2ea8
movq 0x55aa9(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4d252
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 0x55cd2(%rip), %rsi     # 0xa2ea8
movq 0x55a5b(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4d252
movq %rdx, 0x28(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x38(%rsp)
movq 0x8(%rax), %rdx
leaq 0x28(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movslq 0x60(%rbx), %rax
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq (%rcx,%rax,8), %rdx
addq $0x38, %rdx
movq %rsp, %rdi
callq 0x41650
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x3f890
xorl %ebp, %ebp
movq 0x55c65(%rip), %rsi     # 0xa2ea8
movq 0x559ee(%rip), %rdx     # 0xa2c38
movq %r14, %rdi
callq 0x41d70
jmp 0x4d259
jmp 0x4d345
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4d31a
movq 0x10(%rsp), %rsi
jmp 0x4d312
jmp 0x4d345
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d29e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4d29e
movq %rax, %rbx
movb $0x1, %bpl
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x4d2b5
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40880
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d31a
movq 0x68(%rsp), %rsi
jmp 0x4d312
movq %rax, %rbx
leaq 0x68(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d348
movq 0x68(%rsp), %rsi
jmp 0x4d337
jmp 0x4d2e6
jmp 0x4d321
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x4d2ff
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d31a
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40880
testb %bpl, %bpl
jne 0x4d348
jmp 0x4d350
movq %rax, %rbx
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4d348
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4d348
jmp 0x4d345
jmp 0x4d345
movq %rax, %rbx
movq %r14, %rdi
callq 0x40090
movq %rbx, %rdi
callq 0x41f10
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4d350
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x40880
jmp 0x4d350