// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
movl -0x14(%rbp), %eax
movl %eax, (%rdi)
movb $0x0, 0x4(%rdi)
addq $0x8, %rdi
movq %rdi, -0xd0(%rbp)
callq 0x6420
movq -0xe0(%rbp), %rdi
addq $0x30, %rdi
movq %rdi, -0xe8(%rbp)
callq 0x13db0
movq -0xe0(%rbp), %rdi
addq $0x48, %rdi
movq %rdi, -0xd8(%rbp)
callq 0x13dd0
movq -0xd0(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6410
jmp 0x12a5a
movq -0xe0(%rbp), %rdi
addq $0x8, %rdi
leaq 0x27869(%rip), %rsi     # 0x3a2d5
callq 0x62e0
jmp 0x12a73
movq -0xe0(%rbp), %rsi
movb $0x0, 0x28(%rsi)
addq $0x8, %rsi
leaq -0x68(%rbp), %rdi
callq 0x13a70
jmp 0x12a8d
leaq -0x68(%rbp), %rdi
callq 0x12de0
movb %al, -0xe9(%rbp)
jmp 0x12a9e
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x12ad8
jmp 0x12aaa
movl $0x1, -0x6c(%rbp)
jmp 0x12d8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x12da9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x12da0
movq -0xe0(%rbp), %rax
movb $0x1, 0x28(%rax)
leaq -0x68(%rbp), %rdi
callq 0x12e00
movb %al, -0xea(%rbp)
jmp 0x12af4
movb -0xea(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x12b05
jmp 0x12d87
leaq -0x68(%rbp), %rdi
callq 0x12e30
movl %eax, -0xf0(%rbp)
jmp 0x12b16
movl -0xf0(%rbp), %eax
movl %eax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
movl $0x21, %esi
callq 0x12fb0
movb %al, -0xf1(%rbp)
jmp 0x12b35
movb -0xf1(%rbp), %al
testb $0x1, %al
jne 0x12b41
jmp 0x12b5b
movq -0xe0(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x12b59
movq -0xe0(%rbp), %rax
movl -0x70(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x12b5b
leaq -0x68(%rbp), %rdi
movl $0x2a, %esi
callq 0x12fb0
movb %al, -0xf2(%rbp)
jmp 0x12b71
movb -0xf2(%rbp), %al
testb $0x1, %al
jne 0x12b7d
jmp 0x12b8d
movq -0xe0(%rbp), %rax
movl -0x70(%rbp), %ecx
shrl $0x10, %ecx
movb %cl, 0x4(%rax)
leaq -0x68(%rbp), %rdi
movl $0x3a, %esi
callq 0x12fb0
movb %al, -0xf3(%rbp)
jmp 0x12ba3
movb -0xf3(%rbp), %al
testb $0x1, %al
jne 0x12bb2
jmp 0x12cf1
movl -0x70(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x78(%rbp)
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x6560
movq -0x100(%rbp), %rdx
leaq 0x276fb(%rip), %rsi     # 0x3a2db
leaq -0xa0(%rbp), %rdi
callq 0x7c00
jmp 0x12bee
leaq -0x68(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x13020
movb %al, -0x101(%rbp)
jmp 0x12c06
movb -0x101(%rbp), %al
movb %al, -0x7d(%rbp)
movzbl %al, %eax
movl %eax, -0x108(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x61e0
leaq -0xa1(%rbp), %rdi
callq 0x6350
movl -0x108(%rbp), %eax
cmpl $0x0, %eax
je 0x12cd9
movzbl -0x7d(%rbp), %eax
movl %eax, -0x10c(%rbp)
subl $0x65, %eax
je 0x12ca1
jmp 0x12c50
movl -0x10c(%rbp), %eax
subl $0x6d, %eax
je 0x12cc0
jmp 0x12c5d
movl -0x10c(%rbp), %eax
subl $0x78, %eax
je 0x12ccb
jmp 0x12cd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x12c90
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x61e0
leaq -0xa1(%rbp), %rdi
callq 0x6350
jmp 0x12da0
movl -0x78(%rbp), %eax
orl $0x100, %eax            # imm = 0x100
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x78(%rbp)
movl -0x78(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x78(%rbp)
jmp 0x12cd4
movl -0x78(%rbp), %eax
orl $0x20, %eax
movl %eax, -0x78(%rbp)
jmp 0x12cd4
movl -0x78(%rbp), %eax
orl $0x10, %eax
movl %eax, -0x78(%rbp)
jmp 0x12bbf
movq -0xe0(%rbp), %rdi
addq $0x30, %rdi
leaq -0x7c(%rbp), %rsi
callq 0x13df0
jmp 0x12cef
jmp 0x12cf1
leaq -0x68(%rbp), %rdi
movl $0x3c, %esi
callq 0x12fb0
movb %al, -0x10d(%rbp)
jmp 0x12d07
movb -0x10d(%rbp), %al
testb $0x1, %al
jne 0x12d13
jmp 0x12d82
leaq -0xc8(%rbp), %rdi
leaq -0x68(%rbp), %rsi
movl $0x3e, %edx
callq 0x13090
jmp 0x12d2a
movq -0xe0(%rbp), %rdi
addq $0x48, %rdi
leaq -0x70(%rbp), %rsi
callq 0x13e60
movq %rax, -0x118(%rbp)
jmp 0x12d47
movq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x6390
leaq -0xc8(%rbp), %rdi
callq 0x61e0
jmp 0x12d82
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x61e0
jmp 0x12da0
jmp 0x12ae3
movl $0x0, -0x6c(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x13f40
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x68(%rbp), %rdi
callq 0x13f40
movq -0xd8(%rbp), %rdi
callq 0x81d0
movq -0xe8(%rbp), %rdi
callq 0x8300
movq -0xd0(%rbp), %rdi
callq 0x61e0
movq -0x20(%rbp), %rdi
callq 0x6540
nopw %cs:(%rax,%rax)