// File: /workspace/github_c_makefile_star2_O2/mrkite[P]regs/src/map.cc
// Function: Map::Map(char const*, unsigned int)
Map::Map(const char *filename, uint32_t org) : org(org) {
  mapname = filename;
  mapname += ".regs";
  usedMap = false;
  File file(mapname);
  if (!file.is_open()) {
    return;
  }

  usedMap = true;
  while (!file.eof()) {
    uint32_t ofs = file.hex();
    if (file.check('!')) {
      if (!this->org) {  // commandline overrides
        this->org = ofs;
      }
    }
    if (file.check('*')) {
      this->b = ofs >> 16;
    }
    if (file.check(':')) {
      Entry entry;
      entry.org = ofs;
      entry.flags = 0;
      uint8_t ch;
      while ((ch = file.oneOf("emx")) != 0) {
        switch (ch) {
          case 'e':
            entry.flags |= IsEmu;
            entry.flags |= IsM8;
            entry.flags |= IsX8;
            break;
          case 'm':
            entry.flags |= IsM8;
            break;
          case 'x':
            entry.flags |= IsX8;
            break;
        }
      }
      entryPoints.push_back(entry);
    }
    if (file.check('<')) {
      symbols[ofs] = file.until('>');
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movl %edx, (%rdi)
xorl %eax, %eax
movb %al, 0x4(%rdi)
leaq 0x8(%rdi), %r14
leaq 0x18(%rdi), %rcx
movq %rcx, 0x8(%rdi)
andq $0x0, 0x10(%rdi)
movb %al, 0x18(%rdi)
leaq 0x30(%rdi), %rax
movq %rax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rdi)
andq $0x0, 0x40(%rdi)
leaq 0x48(%rdi), %rax
movq %rax, 0x20(%rsp)
leaq 0x50(%rdi), %rax
andl $0x0, 0x50(%rdi)
andq $0x0, 0x58(%rdi)
movq %rax, 0x60(%rdi)
movq %rax, 0x68(%rdi)
movq %rdi, 0x8(%rsp)
andq $0x0, 0x70(%rdi)
movq %r14, %rdi
callq 0x5420
leaq 0xb6c9(%rip), %rsi      # 0x14311
movq %r14, %rdi
callq 0x5410
movq 0x8(%rsp), %rax
movb $0x0, 0x28(%rax)
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x9458
cmpq $0x0, 0x38(%rsp)
je 0x8dbe
movq 0x8(%rsp), %rax
movb $0x1, 0x28(%rax)
leaq 0x38(%rsp), %r13
leaq 0xb690(%rip), %r15      # 0x14317
leaq 0x78(%rsp), %rbp
leaq 0x7(%rsp), %rbx
movq %r13, %rdi
callq 0x8e34
testb %al, %al
jne 0x8dbe
movq %r14, %r12
movq %r13, %rdi
callq 0x8e4a
movl %eax, %r14d
movl %eax, 0x14(%rsp)
movq %r13, %rdi
pushq $0x21
popq %rsi
callq 0x8ee8
testb %al, %al
je 0x8cd4
movq 0x8(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x8cd4
movq 0x8(%rsp), %rax
movl %r14d, (%rax)
movq %r13, %rdi
pushq $0x2a
popq %rsi
callq 0x8ee8
testb %al, %al
je 0x8cf1
movl %r14d, %eax
shrl $0x10, %eax
movq 0x8(%rsp), %rcx
movb %al, 0x4(%rcx)
movq %r13, %rdi
pushq $0x3a
popq %rsi
callq 0x8ee8
testb %al, %al
je 0x8d73
movl %r14d, 0x2c(%rsp)
xorl %eax, %eax
movq %r12, %r14
movl %eax, 0x30(%rsp)
movq %rbp, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x5fd6
movq %r13, %rdi
movq %rbp, %rsi
callq 0x8f18
movl %eax, %r14d
movq %rbp, %rdi
callq 0x5140
testb %r14b, %r14b
je 0x8d64
movzbl %r14b, %eax
cmpl $0x65, %eax
je 0x8d51
cmpl $0x6d, %eax
movq %r12, %r14
je 0x8d5b
cmpl $0x78, %eax
jne 0x8d0e
pushq $0x10
jmp 0x8d5d
movl $0x130, %eax            # imm = 0x130
movq %r12, %r14
jmp 0x8d5e
pushq $0x20
popq %rax
orl 0x30(%rsp), %eax
jmp 0x8d0a
movq 0x18(%rsp), %rdi
leaq 0x2c(%rsp), %rsi
callq 0x9588
movq %r13, %rdi
pushq $0x3c
popq %rsi
callq 0x8ee8
testb %al, %al
movq %r12, %r14
je 0x8c91
movq %rbp, %rdi
movq %r13, %rsi
pushq $0x3e
popq %rdx
callq 0x8f66
movq 0x20(%rsp), %rdi
leaq 0x14(%rsp), %rsi
callq 0x95ac
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5250
movq %rbp, %rdi
callq 0x5140
jmp 0x8c91
leaq 0x58(%rsp), %rdi
callq 0x5140
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8ddc
movq %rax, %rbx
jmp 0x8e07
movq %rax, %rbx
movq %r12, %r14
jmp 0x8dfd
jmp 0x8dfa
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5140
jmp 0x8dfd
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x5140
movq 0x20(%rsp), %rdi
callq 0x6274
movq 0x18(%rsp), %rdi
callq 0x63d2
movq %r14, %rdi
callq 0x5140
movq %rbx, %rdi
callq 0x53c0
nop