LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/nes.cpp
// Function: Rnes::Nes::mapRom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
int Nes::mapRom(const std::string &filename) {
  struct stat stats;
  int fd;
  int result = open(filename.c_str(), O_RDWR);
  if (result == -1) {
    return result;
  }
  fd = result;

  result = fstat(fd, &stats);
  if (result == -1) {
    perror(nullptr);
    return result;
  }

  rom = mmap(nullptr, stats.st_size, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0);
  if (rom == MAP_FAILED) {
    perror(nullptr);
    return -1;
  }
  romSize = stats.st_size;

  close(fd);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x90, %rsp
movq %rdi, %r14
movq (%rsi), %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0xb390
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %eax
je 0x21d6b
movl %eax, %r15d
leaq -0xb0(%rbp), %rsi
movl %eax, %edi
callq 0xb6a0
cmpl $-0x1, %eax
je 0x21d7d
movq -0x80(%rbp), %r12
xorl %edi, %edi
movq %r12, %rsi
movl $0x1, %edx
movl $0x2, %ecx
movl %r15d, %r8d
xorl %r9d, %r9d
callq 0xb760
movq %rax, (%r14)
cmpq $-0x1, %rax
je 0x21d7d
movq %r12, 0x8(%r14)
movl %r15d, %edi
callq 0xb1c0
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x90, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0xb240
jmp 0x21d6b
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/sdl.cpp
// Function: Rnes::Sdl::initDisplay()
int Sdl::initDisplay() {
  window = SDL_CreateWindow("rnes", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, displayWidth,
                            displayHeight, 0);
  renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED);
  texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING,
                              renderWidth, renderHeight);
  SDL_RenderSetLogicalSize(renderer, renderWidth, renderHeight);
  SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
  image = new uint32_t[renderWidth * renderHeight];

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1175a(%rip), %rdi     # 0x34038
movl $0x2fff0000, %esi       # imm = 0x2FFF0000
movl $0x2fff0000, %edx       # imm = 0x2FFF0000
movl $0x400, %ecx            # imm = 0x400
movl $0x3c0, %r8d            # imm = 0x3C0
xorl %r9d, %r9d
callq 0xb340
movq %rax, 0x8(%rbx)
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0x6, %edx
callq 0xb320
movq %rax, 0x10(%rbx)
movq %rax, %rdi
movl $0x16362004, %esi       # imm = 0x16362004
movl $0x1, %edx
movl $0x100, %ecx            # imm = 0x100
movl $0xf0, %r8d
callq 0xb2f0
movq %rax, 0x18(%rbx)
movq 0x10(%rbx), %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xf0, %edx
callq 0xb6c0
leaq 0x12d18(%rip), %rdi     # 0x35668
leaq 0x12d2a(%rip), %rsi     # 0x35681
callq 0xb5d0
movl $0x3c000, %edi          # imm = 0x3C000
callq 0xb3b0
movq %rax, 0x20(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/sdl.cpp
// Function: Rnes::Sdl::initAudio()
int Sdl::initAudio() {
  SDL_AudioSpec desired, obtained;

  desired.freq = 44100;
  desired.format = AUDIO_S16SYS;
  desired.channels = 1;
  desired.samples = 2048;
  desired.callback = callback;
  desired.userdata = this;

  if (SDL_OpenAudio(&desired, &obtained) < 0) {
    printf("Fail\n");
    return 1;
  }

  audioFreq = obtained.freq;
  audioBufferSize = obtained.samples;

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq -0x48(%rbp), %rdi
movl $0xac44, (%rdi)         # imm = 0xAC44
movw $0x8010, 0x4(%rdi)      # imm = 0x8010
movb $0x1, 0x6(%rdi)
movw $0x800, 0x8(%rdi)       # imm = 0x800
leaq -0x149(%rip), %rax      # 0x22858
movq %rax, 0x10(%rdi)
movq %rbx, 0x18(%rdi)
leaq -0x28(%rbp), %rsi
callq 0xb150
testl %eax, %eax
js 0x229c7
movl -0x28(%rbp), %eax
movl %eax, 0x48(%rbx)
movzwl -0x20(%rbp), %eax
movl %eax, 0x4c(%rbx)
xorl %eax, %eax
jmp 0x229d8
leaq 0x12cba(%rip), %rdi     # 0x35688
callq 0xb820
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/sdl.cpp
// Function: Rnes::Sdl::Sdl()
Sdl::Sdl() {
  int ret;

  ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
  if (ret < 0) {
    return;
  }

  if (initDisplay() < 0) {
    return;
  }

  if (initAudio() < 0) {
    return;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
movq %rax, (%rdi)
movq %rax, 0x28(%rdi)
movw $0x0, 0x30(%rdi)
movl $0x30, %edi
callq 0xb970
testl %eax, %eax
js 0x22a1c
movq %rbx, %rdi
callq 0x228ce
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x22974
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/sdl.cpp
// Function: Rnes::Sdl::setPixel(int, int, unsigned char, unsigned char, unsigned char)
void Sdl::setPixel(int x, int y, uint8_t r, uint8_t g, uint8_t b) {
  uint32_t pixel = 0;
  pixel |= 255 << 24;
  pixel |= (uint32_t)r << 16;
  pixel |= (uint32_t)g << 8;
  pixel |= (uint32_t)b << 0;
  image[x + y * renderWidth] = pixel;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
shll $0x10, %ecx
shll $0x8, %r8d
orl %ecx, %r8d
leal (%r9,%r8), %eax
addl $0xff000000, %eax       # imm = 0xFF000000
movq 0x20(%rdi), %rcx
shll $0x8, %edx
addl %esi, %edx
movslq %edx, %rdx
movl %eax, (%rcx,%rdx,4)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/sdl.cpp
// Function: Rnes::Sdl::parseInput()
void Sdl::parseInput() {
  SDL_Event event;
  int button;

  while (SDL_PollEvent(&event)) {
    switch (event.type) {
    case SDL_KEYDOWN:
    case SDL_KEYUP:
      switch (event.key.keysym.sym) {
      case SDLK_UP:
      case SDLK_w:
        button = BUTTON_UP;
        break;
      case SDLK_DOWN:
      case SDLK_s:
        button = BUTTON_DOWN;
        break;
      case SDLK_LEFT:
      case SDLK_a:
        button = BUTTON_LEFT;
        break;
      case SDLK_RIGHT:
      case SDLK_d:
        button = BUTTON_RIGHT;
        break;
      case SDLK_RETURN:
      case SDLK_KP_ENTER:
        button = BUTTON_START;
        break;
      case SDLK_RSHIFT:
      case SDLK_LSHIFT:
        button = BUTTON_SELECT;
        break;
      case SDLK_z:
      case SDLK_n:
        button = BUTTON_A;
        break;
      case SDLK_x:
      case SDLK_m:
        button = BUTTON_B;
        break;
      case SDLK_k:
        button = BUTTON_SAVE;
        break;
      case SDLK_l:
        button = BUTTON_RESTORE;
        break;
      default:
        continue;
      }
      if (event.type == SDL_KEYDOWN) {
        buttonState[button] = true;
      } else {
        buttonState[button] = false;
      }
      break;
    case SDL_QUIT:
      exit(1);
      break;
    default:
      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq -0x60(%rbp), %rdi
callq 0xb8b0
testl %eax, %eax
je 0x22bb5
leaq 0x12b4e(%rip), %r15     # 0x35620
leaq 0x12b0f(%rip), %r12     # 0x355e8
leaq 0x12b60(%rip), %r13     # 0x35640
leaq -0x60(%rbp), %r14
movl -0x60(%rbp), %eax
leal -0x300(%rax), %ecx
cmpl $0x2, %ecx
jae 0x22b1a
xorl %ecx, %ecx
movl -0x4c(%rbp), %edx
cmpl $0x4000004e, %edx       # imm = 0x4000004E
jg 0x22b2a
leal -0x61(%rdx), %esi
cmpl $0xd, %esi
ja 0x22b46
movslq (%r12,%rsi,4), %rcx
addq %r12, %rcx
jmpq *%rcx
movl $0x8, %ecx
jmp 0x22b9b
cmpl $0x100, %eax            # imm = 0x100
jne 0x22ba5
jmp 0x22bc4
leal -0x4000004f(%rdx), %esi
cmpl $0x9, %esi
ja 0x22b5e
movslq (%r13,%rsi,4), %rdx
addq %r13, %rdx
jmpq *%rdx
movl $0x3, %ecx
jmp 0x22b9b
leal -0x73(%rdx), %esi
cmpl $0x7, %esi
ja 0x22b8a
movslq (%r15,%rsi,4), %rdx
addq %r15, %rdx
jmpq *%rdx
movl $0x1, %ecx
jmp 0x22b9b
cmpl $0x400000e1, %edx       # imm = 0x400000E1
je 0x22b6e
cmpl $0x400000e5, %edx       # imm = 0x400000E5
jne 0x22ba5
movl $0x5, %ecx
jmp 0x22b9b
movl $0x2, %ecx
jmp 0x22b9b
movl $0x6, %ecx
jmp 0x22b9b
movl $0x7, %ecx
jmp 0x22b9b
cmpl $0xd, %edx
jne 0x22ba5
movl $0x4, %ecx
jmp 0x22b9b
movl $0x9, %ecx
cmpl $0x300, %eax            # imm = 0x300
sete 0x28(%rbx,%rcx)
movq %r14, %rdi
callq 0xb8b0
testl %eax, %eax
jne 0x22ae4
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %edi
callq 0xb4f0
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::MmcNone::MmcNone(std::vector<unsigned char*, std::allocator<unsigned char*>> const&, std::vector<unsigned char*, std::allocator<unsigned char*>> const&, unsigned int, bool)
MmcNone::MmcNone(const std::vector<uint8_t *> &prgRoms, const std::vector<uint8_t *> &chrRoms,
                 uint32_t prgRam, bool vertMirror)
    : progRoms{prgRoms}, charRoms{chrRoms}, numPrgRam{prgRam}, verticalMirror{vertMirror} {
  assert(numPrgRam == 0 || numPrgRam == 1);
  assert(prgRoms.size() <= 2);
  assert(chrRoms.size() <= 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, -0x2c(%rbp)
movl %ecx, %r12d
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
leaq 0x24197(%rip), %rax     # 0x46d98
movq %rax, (%rdi)
leaq 0x8(%rdi), %r13
movq %r13, %rdi
callq 0x23b66
leaq 0x20(%r14), %rdi
movq %rbx, %rsi
callq 0x23b66
movl %r12d, 0x38(%r14)
movl -0x2c(%rbp), %eax
movb %al, 0x3c(%r14)
cmpl $0x2, %r12d
jae 0x22c56
movq 0x8(%r15), %rax
subq (%r15), %rax
cmpq $0x11, %rax
jae 0x22c75
movq 0x8(%rbx), %rax
subq (%rbx), %rax
cmpq $0x9, %rax
jae 0x22c94
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x12a8d(%rip), %rdi     # 0x356ea
leaq 0x12aa7(%rip), %rsi     # 0x3570b
leaq 0x12aa8(%rip), %rcx     # 0x35713
movl $0x3a, %edx
callq 0xb160
leaq 0x12afe(%rip), %rdi     # 0x3577a
leaq 0x12a88(%rip), %rsi     # 0x3570b
leaq 0x12a89(%rip), %rcx     # 0x35713
movl $0x3b, %edx
callq 0xb160
leaq 0x12af3(%rip), %rdi     # 0x3578e
leaq 0x12a69(%rip), %rsi     # 0x3570b
leaq 0x12a6a(%rip), %rcx     # 0x35713
movl $0x3c, %edx
callq 0xb160
movq %rax, %rbx
movq (%r13), %rdi
testq %rdi, %rdi
je 0x22ccb
movq 0x18(%r14), %rsi
subq %rdi, %rsi
callq 0xb0e0
movq %rbx, %rdi
callq 0xb4d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::MmcNone::cpuMemRead(unsigned short)
uint8_t MmcNone::cpuMemRead(uint16_t addr) {
  assert(addr >= mmcCpuAddrBase);
  // prg rom 1
  if ((addr >= 0x8000) and (addr < 0x8000 + 0x4000) and (progRoms.size() == 2)) {
    return *(progRoms[0] + addr - 0x8000);
  }
  // prg rom 2
  if ((addr >= 0xc000) and (progRoms.size() >= 1)) {
    if (progRoms.size() == 1) {
      return *(progRoms[0] + addr - 0xc000);
    } else {
      return *(progRoms[1] + addr - 0xc000);
    }
  }
  return 0;
}

// Assembly:
cmpl $0x5fff, %esi           # imm = 0x5FFF
jbe 0x22dcd
movswl %si, %ecx
movzwl %cx, %eax
cmpl $0xffffbfff, %ecx       # imm = 0xFFFFBFFF
jg 0x22d9a
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rsi
subq %rcx, %rsi
movq $-0x8000, %rdx          # imm = 0x8000
cmpq $0x10, %rsi
je 0x22dc3
cmpl $0xc000, %eax           # imm = 0xC000
jb 0x22dca
movq 0x8(%rdi), %rcx
movq 0x10(%rdi), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
je 0x22dca
movq $-0xc000, %rdx          # imm = 0xFFFF4000
cmpq $0x1, %rsi
je 0x22dc3
addq $0x8, %rcx
addq (%rcx), %rax
movb (%rdx,%rax), %al
retq
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x129ca(%rip), %rdi     # 0x357a2
leaq 0x1292c(%rip), %rsi     # 0x3570b
leaq 0x12a0e(%rip), %rcx     # 0x357f4
movl $0x44, %edx
callq 0xb160
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::cpuMemWrite(unsigned short, unsigned char)
void Mmc1::cpuMemWrite(uint16_t addr, uint8_t val) {
  // shift register writes
  if ((addr >= shiftWriteAddr) and (addr <= shiftWriteAddrLimit)) {
    // initialize shift register when 7th bit is set.
    if (val & (1 << 7)) {
      shiftRegister = shiftInit;
      controlReg |= 0x3 << 2;
      if (debug) {
        std::cerr << "mmc1: control reg reset: " << std::hex << (int)controlReg << std::endl;
      }
    } else {
      uint8_t oldShiftRegister = shiftRegister;
      shiftRegister >>= 1;
      shiftRegister |= (val & 0x1) << 4;
      // lowest bit is set on last write.
      if (oldShiftRegister & 0x1) {
        updateMmcRegister(addr, shiftRegister);
        shiftRegister = shiftInit;
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testw %si, %si
js 0x22fd7
popq %rbp
retq
testb %dl, %dl
js 0x23014
movb 0x54(%rdi), %al
movl %eax, %ecx
shrb %cl
shlb $0x4, %dl
andb $0x10, %dl
orb %cl, %dl
movb %dl, 0x54(%rdi)
testb $0x1, %al
je 0x22fd5
movzwl %si, %eax
shrl $0xd, %eax
addl $-0x4, %eax
cmpl $0x3, %eax
ja 0x2302b
leaq 0x1269a(%rip), %rcx     # 0x356a0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb %dl, 0x50(%rdi)
jmp 0x2302b
movb $0x10, 0x54(%rdi)
orb $0xc, 0x50(%rdi)
jmp 0x22fd5
movb %dl, 0x52(%rdi)
jmp 0x2302b
movb %dl, 0x53(%rdi)
jmp 0x2302b
movb %dl, 0x51(%rdi)
movb $0x10, 0x54(%rdi)
jmp 0x22fd5
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::cpuMemRead(unsigned short)
uint8_t Mmc1::cpuMemRead(uint16_t addr) {
  assert(addr >= mmcCpuAddrBase);
  // prg rom @ 0x8000
  uint32_t prgRomMode = getPrgRomMode();
  uint8_t bank = prgBank & 0xf;
  if ((addr >= 0x8000) and (addr < 0x8000 + 0x4000)) {
    switch (prgRomMode) {
    case 0:
    case 1:
      return *(progRoms[bank & ~0x1] + addr - 0x8000);
      break;
    case 2:
      return *(progRoms[0] + addr - 0x8000);
      break;
    case 3:
      return *(progRoms[bank] + addr - 0x8000);
      break;
    default:
      assert(0);
      break;
    }
  }
  // prg rom @ 0xc000
  if (addr >= 0xc000) {
    switch (prgRomMode) {
    case 0:
    case 1:
      return *(progRoms[(bank & ~0x1) + 1] + addr - 0xc000);
      break;
    case 2:
      return *(progRoms[bank] + addr - 0xc000);
      break;
    case 3:
      return *(progRoms[progRoms.size() - 1] + addr - 0xc000);
      break;
    default:
      assert(0);
      break;
    }
  }
  return 0;
}

// Assembly:
cmpl $0x5fff, %esi           # imm = 0x5FFF
jbe 0x230df
movl 0x50(%rdi), %r8d
shrl $0x2, %r8d
andl $0x3, %r8d
movzbl 0x53(%rdi), %ecx
movl %ecx, %edx
andl $0xf, %edx
movswl %si, %esi
movzwl %si, %eax
cmpl $0xffffbfff, %esi       # imm = 0xFFFFBFFF
jg 0x23073
cmpl $0x2, %r8d
jae 0x2308f
andl $0xe, %ecx
shll $0x3, %ecx
addq 0x8(%rdi), %rcx
jmp 0x23095
cmpl $0xc000, %eax           # imm = 0xC000
jb 0x2309e
cmpb $0x2, %r8b
jae 0x230a1
andb $0xe, %cl
movzbl %cl, %ecx
leal 0x8(,%rcx,8), %ecx
jmp 0x230b0
jne 0x230b6
movq 0x8(%rdi), %rcx
movq $-0x8000, %rsi          # imm = 0x8000
jmp 0x230d8
xorl %eax, %eax
retq
movzbl %r8b, %ecx
cmpl $0x2, %ecx
jne 0x230c9
movzbl %dl, %ecx
shll $0x3, %ecx
addq 0x8(%rdi), %rcx
jmp 0x230d1
shll $0x3, %edx
addq 0x8(%rdi), %rdx
movq $-0x8000, %rsi          # imm = 0x8000
movq %rdx, %rcx
jmp 0x230d8
movq 0x10(%rdi), %rcx
addq $-0x8, %rcx
movq $-0xc000, %rsi          # imm = 0xFFFF4000
addq (%rcx), %rax
movb (%rsi,%rax), %al
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x126b8(%rip), %rdi     # 0x357a2
leaq 0x1261a(%rip), %rsi     # 0x3570b
leaq 0x127ad(%rip), %rcx     # 0x358a5
movl $0xb1, %edx
callq 0xb160
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::vidMemWrite(unsigned short, unsigned char)
void Mmc1::vidMemWrite(uint16_t addr, uint8_t val) {
  addr = vidAddrTranslate(addr);
  bool chr8kMode = getChrRomMode() == 0;
  if ((charRoms.size() == 0) and (addr < 0x1000)) {
    if (chr8kMode) {
      videoMemory->patternTableMemory[addr] = val;
    } else {
      videoMemory->patternTableMemory[addr + ((chr0Bank & 0x1) ? 0x1000 : 0)] = val;
    }
  } else if ((charRoms.size() == 0) and (addr >= 0x1000) and (addr <= 0x1fff)) {
    if (chr8kMode) {
      videoMemory->patternTableMemory[addr] = val;
    } else {
      videoMemory->patternTableMemory[addr - 0x1000 + ((chr1Bank & 0x1) ? 0x1000 : 0)] = val;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rdi, %r14
movq (%rdi), %rax
callq *0x50(%rax)
movb 0x50(%r14), %dl
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdi
cmpq %rsi, %rdi
setne %r8b
movzwl %ax, %ecx
cmpl $0x1000, %ecx           # imm = 0x1000
setae %al
orb %r8b, %al
jne 0x2314c
movq 0x48(%r14), %rax
addq $0x8, %rax
testb $0x10, %dl
je 0x23176
movzbl 0x51(%r14), %edx
jmp 0x23188
cmpq %rsi, %rdi
setne %al
movl %ecx, %esi
andl $0xf000, %esi           # imm = 0xF000
cmpl $0x1000, %esi           # imm = 0x1000
setne %sil
orb %al, %sil
jne 0x23195
movq 0x48(%r14), %rax
addq $0x8, %rax
testb $0x10, %dl
jne 0x2317d
movl %ecx, %ecx
addq %rcx, %rax
jmp 0x23193
addl $0xfffff000, %ecx       # imm = 0xFFFFF000
movzbl 0x52(%r14), %edx
andl $0x1, %edx
shll $0xc, %edx
orl %ecx, %edx
addq %rdx, %rax
movb %bl, (%rax)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::vidMemRead(unsigned short)
uint8_t Mmc1::vidMemRead(uint16_t addr) {
  bool chr8kMode = getChrRomMode() == 0;
  if (charRoms.size() > 0) {
    // chr rom @ 0x0
    if (addr < 0x1000) {
      if (chr8kMode) {
        return *(charRoms[chr0Bank >> 1] + addr);
      } else {
        return *(charRoms[chr0Bank >> 1] + addr + ((chr0Bank & 0x1) ? 0x1000 : 0));
      }
    }
    // chr rom @ 0x1000
    if ((addr >= 0x1000) and (addr <= 0x1fff)) {
      if (chr8kMode) {
        return *(charRoms[chr0Bank >> 1] + addr);
      } else {
        return *(charRoms[chr1Bank >> 1] + addr + ((chr1Bank & 0x1) ? 0x1000 : 0) - 0x1000);
      }
    }
  } else {
    if (chr8kMode) {
      if (addr < 0x2000) {
        return videoMemory->patternTableMemory[addr];
      }
    } else {
      if (addr < 0x1000) {
        return videoMemory->patternTableMemory[addr + (chr0Bank & 0x1) ? 0x1000 : 0];
      }
      if ((addr >= 0x1000) and (addr <= 0x1fff)) {
        return videoMemory->patternTableMemory[addr - 0x1000 + (chr1Bank & 0x1) ? 0x1000 : 0];
      }
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x50(%rdi), %dl
movq 0x20(%rdi), %rcx
cmpq %rcx, 0x28(%rdi)
je 0x231d9
movzwl %si, %eax
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0x231f5
movzbl 0x51(%rdi), %esi
movl %esi, %edi
andl $-0x2, %edi
addq (%rcx,%rdi,4), %rax
testb $0x10, %dl
je 0x2326e
andl $0x1, %esi
shll $0xc, %esi
addq %rsi, %rax
jmp 0x2326e
testb $0x10, %dl
jne 0x2320e
movzwl %si, %eax
cmpl $0x1fff, %eax           # imm = 0x1FFF
ja 0x2324e
movq 0x48(%rdi), %rcx
addq %rcx, %rax
addq $0x8, %rax
jmp 0x2326e
cmpl $0x1fff, %eax           # imm = 0x1FFF
ja 0x2324e
testb $0x10, %dl
jne 0x23252
movzbl 0x51(%rdi), %edx
andl $-0x2, %edx
addq (%rcx,%rdx,4), %rax
jmp 0x2326e
movzwl %si, %eax
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0x23222
movq 0x48(%rdi), %rcx
movzbl 0x51(%rdi), %edx
jmp 0x23236
cmpl $0x1fff, %eax           # imm = 0x1FFF
ja 0x2324e
movq 0x48(%rdi), %rcx
addl $0xfffff000, %eax       # imm = 0xFFFFF000
movzbl 0x52(%rdi), %edx
andl $0x1, %edx
xorl %esi, %esi
orl %eax, %edx
setne %sil
shll $0xc, %esi
leaq (%rcx,%rsi), %rax
addq $0x8, %rax
jmp 0x2326e
xorl %eax, %eax
jmp 0x23270
movzbl 0x52(%rdi), %edx
movl %edx, %esi
andl $-0x2, %esi
addq (%rcx,%rsi,4), %rax
andl $0x1, %edx
shll $0xc, %edx
addq %rdx, %rax
addq $-0x1000, %rax          # imm = 0xF000
movb (%rax), %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::vidAddrTranslate(unsigned short)
uint16_t Mmc1::vidAddrTranslate(uint16_t addr) {
  uint32_t mirrorMode = getMirroringMode();
  switch (mirrorMode) {
  case 0:
    return translateSingleMirror(addr);
  case 1:
    return translateSingleMirror(addr) + nameTableSize;
  case 2:
    return translateVerticalMirror(addr);
  case 3:
    return translateHorizMirror(addr);
  default:
    assert(0);
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl 0x50(%rdi), %eax
andl $0x3, %eax
leaq 0x1242c(%rip), %rcx     # 0x356b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl %esi, %ecx
andl $0xf000, %ecx           # imm = 0xF000
movl %esi, %eax
andl $0x23ff, %eax           # imm = 0x23FF
cmpl $0x2000, %ecx           # imm = 0x2000
cmovnel %esi, %eax
jmp 0x23317
movl %esi, %ecx
andl $0xfc00, %ecx           # imm = 0xFC00
movl %esi, %edx
andl $0x27ff, %edx           # imm = 0x27FF
movl %esi, %eax
andl $0x23ff, %eax           # imm = 0x23FF
cmpl $0x2800, %ecx           # imm = 0x2800
cmovnel %esi, %eax
cmpl $0x2c00, %ecx           # imm = 0x2C00
jmp 0x232f5
movl %esi, %ecx
andl $0xfc00, %ecx           # imm = 0xFC00
movl %esi, %edx
andl $0x23ff, %edx           # imm = 0x23FF
movl %esi, %eax
andl $0x2bff, %eax           # imm = 0x2BFF
cmpl $0x2c00, %ecx           # imm = 0x2C00
cmovnel %esi, %eax
cmpl $0x2400, %ecx           # imm = 0x2400
cmovel %edx, %eax
jmp 0x23317
movl %esi, %ecx
andl $0xf000, %ecx           # imm = 0xF000
movl %esi, %eax
andl $0x23ff, %eax           # imm = 0x23FF
cmpl $0x2000, %ecx           # imm = 0x2000
cmovnel %esi, %eax
addl $0x400, %eax            # imm = 0x400
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::save(Rnes::MmcState&)
void Mmc1::save(MmcState &pb) {
  MmcState_Mmc1State *mmc1 = pb.mutable_mmc1();
  mmc1->set_controlreg(controlReg);
  mmc1->set_chr0bank(chr0Bank);
  mmc1->set_chr1bank(chr1Bank);
  mmc1->set_prgbank(prgBank);
  mmc1->set_shiftregister(shiftRegister);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
orb $0x2, 0x10(%rsi)
movq %rdi, %rbx
cmpq $0x0, 0x20(%rsi)
jne 0x23345
movq 0x8(%r14), %rdi
testb $0x1, %dil
jne 0x2339a
callq 0x31fb8
movq %rax, 0x20(%r14)
movq 0x20(%r14), %rax
movzbl 0x50(%rbx), %ecx
movl 0x10(%rax), %edx
movl %edx, %esi
orl $0x1, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x18(%rax)
movzbl 0x51(%rbx), %ecx
movl %edx, %esi
orl $0x3, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x1c(%rax)
movzbl 0x52(%rbx), %ecx
movl %edx, %esi
orl $0x7, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x20(%rax)
movzbl 0x53(%rbx), %ecx
movl %edx, %esi
orl $0xf, %esi
movl %esi, 0x10(%rax)
movl %ecx, 0x24(%rax)
movzbl 0x54(%rbx), %ecx
orl $0x1f, %edx
movl %edx, 0x10(%rax)
movl %ecx, 0x28(%rax)
popq %rbx
popq %r14
popq %rbp
retq
andq $-0x2, %rdi
movq (%rdi), %rdi
jmp 0x2333c
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc1::restore(Rnes::MmcState&)
void Mmc1::restore(MmcState &pb) {
  const MmcState_Mmc1State &mmc1 = pb.mmc1();
  controlReg = mmc1.controlreg();
  chr0Bank = mmc1.chr0bank();
  chr1Bank = mmc1.chr1bank();
  prgBank = mmc1.prgbank();
  shiftRegister = mmc1.shiftregister();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x20(%rsi), %rax
testq %rax, %rax
jne 0x233b8
leaq 0x25650(%rip), %rax     # 0x48a08
movb 0x18(%rax), %cl
movb %cl, 0x50(%rdi)
movb 0x1c(%rax), %cl
movb %cl, 0x51(%rdi)
movb 0x20(%rax), %cl
movb %cl, 0x52(%rdi)
movb 0x24(%rax), %cl
movb %cl, 0x53(%rdi)
movb 0x28(%rax), %al
movb %al, 0x54(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc3::get1kChrBank(unsigned int)
uint8_t *Mmc3::get1kChrBank(uint32_t bank) {
  if (charRoms.size() == 0) {
    return &videoMemory->patternTableMemory[bank * 1024];
  } else {
    return charRoms[bank >> 3] + (bank & 0x7) * 1024;
  }
}

// Assembly:
movl %esi, %eax
movq 0x20(%rdi), %rcx
cmpq %rcx, 0x28(%rdi)
je 0x23531
pushq %rbp
movq %rsp, %rbp
movl %eax, %edx
andl $-0x8, %edx
andl $0x7, %eax
shll $0xa, %eax
addq (%rcx,%rdx), %rax
popq %rbp
retq
movq 0x48(%rdi), %rcx
shll $0xa, %eax
addq %rcx, %rax
addq $0x8, %rax
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc3::cpuMemWrite(unsigned short, unsigned char)
void Mmc3::cpuMemWrite(uint16_t addr, uint8_t val) {
  assert(addr >= mmcCpuAddrBase);

  // mmc control register writes
  if (addr >= 0x8000 and addr <= 0x9fff) {
    if (addr & 0x1) {
      updateBankRegister(val);
    } else {
      bankSelectReg = val;
    }
  } else if (addr >= 0xa000 and addr <= 0xbfff) {
    if (addr & 0x1) {
      prgRamReg = val;
    } else {
      mirrorReg = val;
    }
  } else if (addr >= 0xc000 and addr <= 0xdfff) {
    if (addr & 0x1) {
      irqCounterReg = 0;
    } else {
      irqReloadReg = val;
    }
  } else if (addr >= 0xe000 and addr <= 0xffff) {
    if (addr & 0x1) {
      irqEnabled = true;
    } else {
      irqEnabled = false;
      irqPending = false;
    }
  }
}

// Assembly:
cmpl $0x5fff, %esi           # imm = 0x5FFF
jbe 0x2360e
movswl %si, %eax
cmpl $0xffff9fff, %eax       # imm = 0xFFFF9FFF
jg 0x235b4
testb $0x1, %sil
jne 0x235d3
movb %dl, 0x50(%rdi)
retq
movl %esi, %eax
andl $0xe000, %eax           # imm = 0xE000
cmpl $0xc000, %eax           # imm = 0xC000
je 0x235df
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x235e9
testb $0x1, %sil
jne 0x23600
movb %dl, 0x51(%rdi)
retq
movzbl 0x50(%rdi), %eax
andl $0x7, %eax
movb %dl, 0x53(%rdi,%rax)
retq
testb $0x1, %sil
jne 0x23604
movb %dl, 0x5b(%rdi)
retq
movzwl %si, %eax
cmpl $0xe000, %eax           # imm = 0xE000
jb 0x235ff
testb $0x1, %sil
jne 0x23609
movw $0x0, 0x5d(%rdi)
retq
movb %dl, 0x52(%rdi)
retq
movb $0x0, 0x5c(%rdi)
retq
movb $0x1, 0x5d(%rdi)
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x12189(%rip), %rdi     # 0x357a2
leaq 0x120eb(%rip), %rsi     # 0x3570b
leaq 0x1232c(%rip), %rcx     # 0x35953
movl $0x15b, %edx            # imm = 0x15B
callq 0xb160
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc3::cpuMemRead(unsigned short)
uint8_t Mmc3::cpuMemRead(uint16_t addr) {
  assert(addr >= mmcCpuAddrBase);

  // prg rom @ 0x8000
  if ((addr >= 0x8000) and (addr < 0x8000 + 0x2000)) {
    uint8_t bank;
    if (isLowerPrgRomSwappable())
      bank = bankRegister[6];
    else
      bank = get8kPrgBankCount() - 2;
    return *(get8kPrgBank(bank) + addr - 0x8000);
  }
  // prg rom @ 0xa000
  if ((addr >= 0xa000) and (addr < 0xa000 + 0x2000)) {
    uint8_t bank = bankRegister[7];
    return *(get8kPrgBank(bank) + addr - 0xa000);
  }

  // prg rom @ 0xc000
  if ((addr >= 0xc000) and (addr <= 0xdfff)) {
    uint8_t bank;
    if (isLowerPrgRomSwappable())
      bank = get8kPrgBankCount() - 2;
    else
      bank = bankRegister[6];
    return *(get8kPrgBank(bank) + addr - 0xc000);
  }
  // prg rom @ 0xe000
  if ((addr >= 0xe000) and (addr <= 0xffff)) {
    return *(get8kPrgBank(get8kPrgBankCount() - 1) + addr - 0xe000);
  }
  return 0;
}

// Assembly:
cmpl $0x5fff, %esi           # imm = 0x5FFF
jbe 0x23731
movswl %si, %ecx
movzwl %si, %eax
cmpl $0xffff9fff, %ecx       # imm = 0xFFFF9FFF
jg 0x23657
testb $0x40, 0x50(%rdi)
jne 0x23690
movb 0x59(%rdi), %cl
jmp 0x2369f
andl $0xe000, %esi           # imm = 0xE000
cmpl $0xc000, %esi           # imm = 0xC000
je 0x236be
cmpl $0xa000, %esi           # imm = 0xA000
jne 0x236d5
movzbl 0x5a(%rdi), %ecx
movq 0x8(%rdi), %rdx
movl %ecx, %esi
andl $0x3e, %esi
andl $0x1, %ecx
shll $0xd, %ecx
addq (%rdx,%rsi,4), %rcx
movq $-0xa000, %rdx          # imm = 0xFFFF6000
jmp 0x23727
movl 0x10(%rdi), %ecx
subl 0x8(%rdi), %ecx
shrl $0x2, %ecx
andb $-0x2, %cl
addb $-0x2, %cl
movzbl %cl, %ecx
movq 0x8(%rdi), %rdx
movl %ecx, %esi
andl $0x3e, %esi
andl $0x1, %ecx
shll $0xd, %ecx
addq (%rdx,%rsi,4), %rcx
movq $-0x8000, %rdx          # imm = 0x8000
jmp 0x23727
testb $0x40, 0x50(%rdi)
jne 0x23707
movl 0x10(%rdi), %ecx
subl 0x8(%rdi), %ecx
shrl $0x2, %ecx
andb $-0x2, %cl
addb $-0x2, %cl
jmp 0x2370a
cmpl $0xe000, %eax           # imm = 0xE000
jb 0x2372e
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rsi
subq %rdx, %rsi
shrq $0x2, %rsi
andl $-0x2, %esi
decl %esi
shrl %esi
andl $-0x61, %esi
movl $0x2000, %ecx           # imm = 0x2000
addq (%rdx,%rsi,8), %rcx
movq $-0xe000, %rdx          # imm = 0xFFFF2000
jmp 0x23727
movb 0x59(%rdi), %cl
movzbl %cl, %ecx
movq 0x8(%rdi), %rdx
movl %ecx, %esi
andl $0x3e, %esi
andl $0x1, %ecx
shll $0xd, %ecx
addq (%rdx,%rsi,4), %rcx
movq $-0xc000, %rdx          # imm = 0xFFFF4000
addq %rcx, %rax
movb (%rdx,%rax), %al
retq
xorl %eax, %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x12066(%rip), %rdi     # 0x357a2
leaq 0x11fc8(%rip), %rsi     # 0x3570b
leaq 0x12241(%rip), %rcx     # 0x3598b
movl $0x17b, %edx            # imm = 0x17B
callq 0xb160
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc3::notifyScanlineComplete()
void Mmc3::notifyScanlineComplete() {
  if (irqCounterReg == 0) {
    irqCounterReg = irqReloadReg;
  } else {
    irqCounterReg--;
    if (irqCounterReg == 0 and irqEnabled) {
      irqPending = true;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x5c(%rdi), %al
testb %al, %al
je 0x2398c
decb %al
movb %al, 0x5c(%rdi)
jne 0x23992
cmpb $0x1, 0x5d(%rdi)
jne 0x23992
movb $0x1, 0x5e(%rdi)
jmp 0x23992
movb 0x5b(%rdi), %al
movb %al, 0x5c(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/mmc.cpp
// Function: Rnes::Mmc3::save(Rnes::MmcState&)
void Mmc3::save(MmcState &pb) {
  /*
  // internal control registers
  uint8_t bankSelectReg = 1 << 6;
  uint8_t mirrorReg = 0;
  uint8_t prgRamReg = 0;
  uint8_t bankRegister[8] = {0};
  uint8_t irqReloadReg = 0;
  uint8_t irqCounterReg = 0;
  bool irqEnabled = false;
  bool irqPending = false;
  */

  MmcState_Mmc3State *mmc3 = pb.mutable_mmc3();
  mmc3->set_bankselectreg(bankSelectReg);
  mmc3->set_mirrorreg(mirrorReg);
  mmc3->set_prgramreg(prgRamReg);
  mmc3->set_bankregister(bankRegister, bankRegisterCount);
  mmc3->set_irqreloadreg(irqReloadReg);
  mmc3->set_irqcounterreg(irqCounterReg);
  mmc3->set_irqenabled(irqEnabled);
  mmc3->set_irqpending(irqPending);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movq %rsi, %r14
orb $0x4, 0x10(%rsi)
movq %rdi, %rbx
cmpq $0x0, 0x28(%rsi)
jne 0x239d5
movq 0x8(%r14), %rdi
testb $0x1, %dil
jne 0x23ad2
callq 0x3201e
movq %rax, 0x28(%r14)
movq 0x28(%r14), %r14
movzbl 0x50(%rbx), %eax
movl 0x10(%r14), %ecx
movl %ecx, %edx
orl $0x2, %edx
movl %edx, 0x10(%r14)
movl %eax, 0x20(%r14)
movzbl 0x51(%rbx), %eax
movl %ecx, %edx
orl $0x6, %edx
movl %edx, 0x10(%r14)
movl %eax, 0x24(%r14)
movzbl 0x52(%rbx), %eax
movl %eax, 0x28(%r14)
orl $0xf, %ecx
movl %ecx, 0x10(%r14)
leaq 0x18(%r14), %rdi
leaq -0x28(%rbp), %r15
movq %r15, -0x10(%r15)
movq 0x53(%rbx), %rax
movq %rax, (%r15)
movq $0x8, -0x8(%r15)
movb $0x0, 0x8(%r15)
movq 0x8(%r14), %rsi
testb $0x1, %sil
jne 0x23ac6
movq (%rdi), %rax
cmpq 0x2457a(%rip), %rax     # 0x47fc0
je 0x23a56
leaq -0x38(%rbp), %rsi
movq %rax, %rdi
callq 0xb900
jmp 0x23a5f
leaq -0x38(%rbp), %rdx
callq 0x23c3e
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x23a74
movq -0x28(%rbp), %rsi
incq %rsi
callq 0xb0e0
movzbl 0x5b(%rbx), %eax
movl 0x10(%r14), %ecx
movl %ecx, %edx
orl $0x10, %edx
movl %edx, 0x10(%r14)
movl %eax, 0x2c(%r14)
movzbl 0x5c(%rbx), %eax
movl %ecx, %edx
orl $0x30, %edx
movl %edx, 0x10(%r14)
movl %eax, 0x30(%r14)
movb 0x5d(%rbx), %al
movl %ecx, %edx
orl $0x70, %edx
movl %edx, 0x10(%r14)
movb %al, 0x34(%r14)
movb 0x5e(%rbx), %al
orl $0xf0, %ecx
movl %ecx, 0x10(%r14)
movb %al, 0x35(%r14)
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
andq $-0x2, %rsi
movq (%rsi), %rsi
jmp 0x23a3c
andq $-0x2, %rdi
movq (%rdi), %rdi
jmp 0x239cc
movq %rax, %rbx
movq -0x38(%rbp), %rdi
cmpq %r15, %rdi
je 0x23af6
movq -0x28(%rbp), %rsi
incq %rsi
callq 0xb0e0
movq %rbx, %rdi
callq 0xb4d0
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::CpuMemory::load(unsigned short) const
uint8_t CpuMemory::load(uint16_t addr) const {
  if (addr < cpuSramSize) {
    return cpuSram[addr];
  } else if ((addr >= prgSramBase) and (addr < prgSramBase + prgSramSize) and
             mmc->isPrgSramEnabled()) {
    return prgSram[addr - prgSramBase];
  } else {
    return mmc->cpuMemRead(addr);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
cmpl $0x7ff, %esi            # imm = 0x7FF
ja 0x23d96
movzwl %r14w, %eax
movb 0x8(%rbx,%rax), %al
popq %rbx
popq %r14
popq %rbp
retq
movswl %r14w, %eax
cmpl $0x6000, %eax           # imm = 0x6000
jl 0x23dc0
movq (%rbx), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
testb %al, %al
je 0x23dc0
movzwl %r14w, %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movb 0x808(%rbx,%rax), %al
jmp 0x23d91
movq (%rbx), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movzwl %r14w, %esi
popq %rbx
popq %r14
popq %rbp
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::CpuMemory::store(unsigned short, unsigned char)
void CpuMemory::store(uint16_t addr, uint8_t data) {
  if (addr < cpuSramSize) {
    cpuSram[addr] = data;
  } else if ((addr >= prgSramBase) and (addr < prgSramBase + prgSramSize) and
             mmc->isPrgSramWriteable()) {
    prgSram[addr - prgSramBase] = data;
  } else {
    mmc->cpuMemWrite(addr, data);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %r15d
movq %rdi, %r14
cmpl $0x7ff, %esi            # imm = 0x7FF
ja 0x23e02
movzwl %r15w, %eax
movb %bl, 0x8(%r14,%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movswl %r15w, %eax
cmpl $0x6000, %eax           # imm = 0x6000
jl 0x23e2d
movq (%r14), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
testb %al, %al
je 0x23e2d
movzwl %r15w, %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movb %bl, 0x808(%r14,%rax)
jmp 0x23df7
movq (%r14), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
movzwl %r15w, %esi
movzbl %bl, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::CpuMemory::restore(Rnes::CpuMemoryState const&)
void CpuMemory::restore(const CpuMemoryState &pb) {
  const std::string &bytes = pb.cpusram();
  for (unsigned i = 0; i < bytes.size(); i++) {
    cpuSram[i] = bytes[i];
  }

  const std::string &prgBytes = pb.prgsram();
  for (unsigned i = 0; i < prgBytes.size(); i++) {
    prgSram[i] = prgBytes[i];
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x18(%rsi), %rax
cmpq $0x0, 0x8(%rax)
je 0x23fa6
movl $0x1, %ecx
xorl %edx, %edx
movq (%rax), %r8
movb (%r8,%rdx), %r8b
movb %r8b, 0x8(%rdi,%rdx)
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x8(%rax)
ja 0x23f90
movq 0x20(%rsi), %rax
cmpq $0x0, 0x8(%rax)
je 0x23fd1
movl $0x1, %ecx
xorl %edx, %edx
movq (%rax), %rsi
movb (%rsi,%rdx), %sil
movb %sil, 0x808(%rdi,%rdx)
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x8(%rax)
ja 0x23fb8
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::VideoMemory::load(unsigned short) const
uint8_t VideoMemory::load(uint16_t addr) const {
  if (addr >= 0x2000 and addr < 0x2000 + 0x1000) {
    addr = mmc->vidAddrTranslate(addr);
    return nameTableMemory[addr - 0x2000];
  } else if (addr >= 0x3f00 and addr <= 0x3f1f) {
    return paletteMemory[addr - 0x3f00];
  } else {
    return mmc->vidMemRead(addr);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl %esi, %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x2000, %eax           # imm = 0x2000
jne 0x24000
movq (%rbx), %rdi
movq (%rdi), %rax
movzwl %si, %esi
callq *0x50(%rax)
movzwl %ax, %eax
movb 0x8(%rax,%rbx), %al
jmp 0x2401b
movl %esi, %eax
andl $0xffe0, %eax           # imm = 0xFFE0
cmpl $0x3f00, %eax           # imm = 0x3F00
jne 0x24022
movzwl %si, %eax
andl $0x1f, %eax
movb 0x3008(%rbx,%rax), %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq (%rbx), %rdi
movq (%rdi), %rax
movq 0x28(%rax), %rax
movzwl %si, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::VideoMemory::store(unsigned short, unsigned char)
void VideoMemory::store(uint16_t addr, uint8_t data) {
  if (addr >= 0x2000 and addr < 0x2000 + 0x1000) {
    nameTableMemory[addr - 0x2000] = data;
  } else if (addr >= 0x3f00 and addr <= 0x3f1f) {
    paletteMemory[addr - 0x3f00] = data;
  } else {
    mmc->vidMemWrite(addr, data);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %eax
andl $0xf000, %eax           # imm = 0xF000
cmpl $0x2000, %eax           # imm = 0x2000
jne 0x24059
addl $0xffffe000, %esi       # imm = 0xFFFFE000
movb %dl, 0x2008(%rdi,%rsi)
jmp 0x24074
movl %esi, %eax
andl $0xffe0, %eax           # imm = 0xFFE0
cmpl $0x3f00, %eax           # imm = 0x3F00
jne 0x24076
addl $0xffffc100, %esi       # imm = 0xFFFFC100
movb %dl, 0x3008(%rdi,%rsi)
popq %rbp
retq
movq (%rdi), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
movzwl %si, %esi
movzbl %dl, %edx
popq %rbp
jmpq *%rax
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/memory.cpp
// Function: Rnes::VideoMemory::restore(Rnes::VideoMemoryState const&)
void VideoMemory::restore(const VideoMemoryState &pb) {
  {
    const std::string &bytes = pb.patterntablememory();
    for (unsigned i = 0; i < bytes.size(); i++) {
      patternTableMemory[i] = bytes[i];
    }
  }
  {
    const std::string &bytes = pb.nametablememory();
    for (unsigned i = 0; i < bytes.size(); i++) {
      nameTableMemory[i] = bytes[i];
    }
  }
  {
    const std::string &bytes = pb.palettememory();
    for (unsigned i = 0; i < bytes.size(); i++) {
      paletteMemory[i] = bytes[i];
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x18(%rsi), %rax
cmpq $0x0, 0x8(%rax)
je 0x24272
movl $0x1, %ecx
xorl %edx, %edx
movq (%rax), %r8
movb (%r8,%rdx), %r8b
movb %r8b, 0x8(%rdi,%rdx)
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x8(%rax)
ja 0x2425c
movq 0x20(%rsi), %rax
cmpq $0x0, 0x8(%rax)
je 0x2429d
movl $0x1, %ecx
xorl %edx, %edx
movq (%rax), %r8
movb (%r8,%rdx), %r8b
movb %r8b, 0x2008(%rdi,%rdx)
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x8(%rax)
ja 0x24284
movq 0x28(%rsi), %rax
cmpq $0x0, 0x8(%rax)
je 0x242c8
movl $0x1, %ecx
xorl %edx, %edx
movq (%rax), %rsi
movb (%rsi,%rdx), %sil
movb %sil, 0x3008(%rdi,%rdx)
movl %ecx, %edx
incl %ecx
cmpq %rdx, 0x8(%rax)
ja 0x242af
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_ApuState_save_2eproto()
static void InitDefaultsscc_info_ApuState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_ApuState_default_instance_;
    new (ptr) ::Rnes::ApuState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::ApuState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x129b8(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x245f1(%rip), %rbx     # 0x488e0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27b4e
movq 0x23ca0(%rip), %rdi     # 0x47fa0
movq %rbx, %rsi
callq 0xb870
leaq 0x24531(%rip), %rax     # 0x48840
movq %rax, 0x245f2(%rip)     # 0x48908
movq %rax, 0x245f3(%rip)     # 0x48910
leaq 0x24554(%rip), %rax     # 0x48878
movq %rax, 0x245ed(%rip)     # 0x48918
leaq 0x24576(%rip), %rax     # 0x488a8
movq %rax, 0x245e7(%rip)     # 0x48920
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_ControllerState_save_2eproto()
static void InitDefaultsscc_info_ControllerState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_ControllerState_default_instance_;
    new (ptr) ::Rnes::ControllerState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::ControllerState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12946(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x2473f(%rip), %rsi     # 0x48aa0
movq $0x0, 0x2473c(%rip) # 0x48aa8
leaq 0x2348d(%rip), %rax     # 0x47800
movq %rax, 0x24726(%rip)     # 0x48aa0
xorps %xmm0, %xmm0
movups %xmm0, 0x2472c(%rip)    # 0x48ab0
movq 0x23c15(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_CpuMemoryState_save_2eproto()
static void InitDefaultsscc_info_CpuMemoryState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_CpuMemoryState_default_instance_;
    new (ptr) ::Rnes::CpuMemoryState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::CpuMemoryState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x128f5(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
xorps %xmm0, %xmm0
movups %xmm0, 0x24713(%rip)    # 0x48ac8
leaq 0x234f4(%rip), %rax     # 0x478b0
movq %rax, 0x246fd(%rip)     # 0x48ac0
movl 0x2418f(%rip), %eax     # 0x48558
testl %eax, %eax
jne 0x243f6
movq 0x23bec(%rip), %rax     # 0x47fc0
movq %rax, 0x246fd(%rip)     # 0x48ad8
leaq 0x246de(%rip), %rsi     # 0x48ac0
movq %rax, 0x246f7(%rip)     # 0x48ae0
movq 0x23bb0(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
leaq 0x2415b(%rip), %rdi     # 0x48558
callq 0xb520
jmp 0x243cd
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_CpuState_save_2eproto()
static void InitDefaultsscc_info_CpuState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_CpuState_default_instance_;
    new (ptr) ::Rnes::CpuState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::CpuState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12882(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x243e3(%rip), %rsi     # 0x48808
xorl %eax, %eax
movq %rax, 0x243e2(%rip)     # 0x48810
leaq 0x22c3b(%rip), %rcx     # 0x47070
movq %rcx, 0x243cc(%rip)     # 0x48808
xorps %xmm0, %xmm0
movups %xmm0, 0x243d2(%rip)    # 0x48818
movups %xmm0, 0x243db(%rip)    # 0x48828
movq %rax, 0x243e4(%rip)     # 0x48838
movq 0x23b45(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_DmaState_save_2eproto()
static void InitDefaultsscc_info_DmaState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_DmaState_default_instance_;
    new (ptr) ::Rnes::DmaState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::DmaState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12825(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x24696(%rip), %rsi     # 0x48b18
movq $0x0, 0x24693(%rip) # 0x48b20
leaq 0x2357c(%rip), %rax     # 0x47a10
movq %rax, 0x2467d(%rip)     # 0x48b18
xorps %xmm0, %xmm0
movups %xmm0, 0x24683(%rip)    # 0x48b28
movl $0x0, 0x24689(%rip)     # 0x48b38
movq 0x23aea(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_MmcState_save_2eproto()
static void InitDefaultsscc_info_MmcState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_MmcState_default_instance_;
    new (ptr) ::Rnes::MmcState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::MmcState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x127ca(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
xorps %xmm0, %xmm0
movups %xmm0, 0x24598(%rip)    # 0x48a78
leaq 0x23269(%rip), %rax     # 0x47750
movq %rax, 0x24582(%rip)     # 0x48a70
movl 0x240ac(%rip), %eax     # 0x485a0
testl %eax, %eax
jne 0x24549
movups %xmm0, 0x24589(%rip)    # 0x48a88
movq $0x0, 0x2458e(%rip) # 0x48a98
leaq 0x2455f(%rip), %rsi     # 0x48a70
movq 0x23a88(%rip), %rdi     # 0x47fa0
callq 0xb870
leaq 0x244cc(%rip), %rax     # 0x489f0
movq %rax, 0x2455d(%rip)     # 0x48a88
leaq 0x244d6(%rip), %rax     # 0x48a08
movq %rax, 0x24557(%rip)     # 0x48a90
leaq 0x244f8(%rip), %rax     # 0x48a38
movq %rax, 0x24551(%rip)     # 0x48a98
popq %rbp
retq
leaq 0x24050(%rip), %rdi     # 0x485a0
callq 0xb520
xorps %xmm0, %xmm0
jmp 0x244f8
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_MmcState_Mmc1State_save_2eproto()
static void InitDefaultsscc_info_MmcState_Mmc1State_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_MmcState_Mmc1State_default_instance_;
    new (ptr) ::Rnes::MmcState_Mmc1State();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::MmcState_Mmc1State::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x1272c(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x2448d(%rip), %rsi     # 0x48a08
movq $0x0, 0x2448a(%rip) # 0x48a10
leaq 0x23063(%rip), %rax     # 0x475f0
movq %rax, 0x24474(%rip)     # 0x48a08
xorps %xmm0, %xmm0
movups %xmm0, 0x2447a(%rip)    # 0x48a18
movups %xmm0, 0x2447f(%rip)    # 0x48a24
movq 0x239f4(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_MmcState_Mmc3State_save_2eproto()
static void InitDefaultsscc_info_MmcState_Mmc3State_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_MmcState_Mmc3State_default_instance_;
    new (ptr) ::Rnes::MmcState_Mmc3State();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::MmcState_Mmc3State::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x126d4(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
xorps %xmm0, %xmm0
movups %xmm0, 0x2446a(%rip)    # 0x48a40
leaq 0x230c3(%rip), %rax     # 0x476a0
movq %rax, 0x24454(%rip)     # 0x48a38
movl 0x23ffe(%rip), %eax     # 0x485e8
testl %eax, %eax
jne 0x24622
movq 0x239cb(%rip), %rax     # 0x47fc0
movq %rax, 0x24454(%rip)     # 0x48a50
leaq 0x24435(%rip), %rsi     # 0x48a38
movups %xmm0, 0x2444e(%rip)    # 0x48a58
movq $0x0, 0x24451(%rip) # 0x48a66
movq 0x23984(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
leaq 0x23fbf(%rip), %rdi     # 0x485e8
callq 0xb520
xorps %xmm0, %xmm0
jmp 0x245ee
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_MmcState_MmcNoneState_save_2eproto()
static void InitDefaultsscc_info_MmcState_MmcNoneState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_MmcState_MmcNoneState_default_instance_;
    new (ptr) ::Rnes::MmcState_MmcNoneState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::MmcState_MmcNoneState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12653(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x2439c(%rip), %rsi     # 0x489f0
movq $0x0, 0x24399(%rip) # 0x489f8
leaq 0x22eda(%rip), %rax     # 0x47540
movq %rax, 0x24383(%rip)     # 0x489f0
movl $0x0, 0x24389(%rip)     # 0x48a00
movq 0x23922(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/bin/save.pb.cc
// Function: InitDefaultsscc_info_NoiseState_save_2eproto()
static void InitDefaultsscc_info_NoiseState_save_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::Rnes::_NoiseState_default_instance_;
    new (ptr) ::Rnes::NoiseState();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::Rnes::NoiseState::InitAsDefaultInstance();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x12602(%rip), %rdx     # 0x36c91
movl $0x2df5a4, %edi         # imm = 0x2DF5A4
movl $0x2df5a0, %esi         # imm = 0x2DF5A0
callq 0xb100
leaq 0x24203(%rip), %rsi     # 0x488a8
movq $0x0, 0x24200(%rip) # 0x488b0
leaq 0x22bc9(%rip), %rax     # 0x47280
movq %rax, 0x241ea(%rip)     # 0x488a8
xorps %xmm0, %xmm0
movups %xmm0, 0x241f0(%rip)    # 0x488b8
movups %xmm0, 0x241f9(%rip)    # 0x488c8
movl $0x0, 0x241ff(%rip)     # 0x488d8
movq 0x238c0(%rip), %rdi     # 0x47fa0
popq %rbp
jmp 0xb870