LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: mindbeast[P]rnes/main.cpp
// Function: Rnes::loadNesState(Rnes::Nes*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void loadNesState(Nes *nes, std::string saveFile) {
  namespace io = boost::iostreams;
  namespace fs = boost::filesystem;
  using namespace std;

  try {
    io::stream<io::mapped_file_source> stream(saveFile);
    unique_ptr<SaveState> gameState{new SaveState{}};

    // Read out state from save file.
    gameState->ParseFromIstream(&stream);

    // Restore nes state.
    nes->restore(*gameState.get());

    cerr << "State restored" << endl;
  } catch (const std::ios_base::failure &exception) {
    cerr << "Exception: " << exception.what() << endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x1b0(%rbp), %rdi
callq 0x19c40
jmp 0x189a5
movl $0x60, %edi
callq 0xe200
movq %rax, -0x1d8(%rbp)
jmp 0x189b8
movq -0x1d8(%rbp), %rdi
callq 0x1a040
jmp 0x189c6
movq -0x1d8(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x1a060
movq -0x1e0(%rbp), %rdi
callq 0x1a090
movq %rax, %rdi
leaq -0x1b0(%rbp), %rsi
callq 0xe070
jmp 0x189fd
movq -0x8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x1a0b0
movq -0x1e8(%rbp), %rdi
movq %rax, %rsi
callq 0x3cb20
jmp 0x18a25
movq 0x795bc(%rip), %rdi     # 0x91fe8
leaq 0x4f65d(%rip), %rsi     # 0x68090
callq 0xe680
movq %rax, -0x1f0(%rbp)
jmp 0x18a41
movq -0x1f0(%rbp), %rdi
movq 0x79589(%rip), %rsi     # 0x91fd8
callq 0xeae0
jmp 0x18a56
leaq -0x1c8(%rbp), %rdi
callq 0x1a0e0
leaq -0x1b0(%rbp), %rdi
callq 0x19da0
jmp 0x18b6e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
jmp 0x18aea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
jmp 0x18ade
movq -0x1d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
movl $0x60, %esi
callq 0xe170
jmp 0x18ade
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
leaq -0x1c8(%rbp), %rdi
callq 0x1a0e0
leaq -0x1b0(%rbp), %rdi
callq 0x19da0
movl -0x1bc(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18b92
movq -0x1b8(%rbp), %rdi
callq 0xe080
movq %rax, -0x1d0(%rbp)
movq 0x794d1(%rip), %rdi     # 0x91fe8
leaq 0x4f581(%rip), %rsi     # 0x6809f
callq 0xe680
movq %rax, -0x1f8(%rbp)
jmp 0x18b2c
movq -0x1d0(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x1f8(%rbp), %rdi
movq %rax, %rsi
callq 0xe680
movq %rax, -0x200(%rbp)
jmp 0x18b54
movq -0x200(%rbp), %rdi
movq 0x79476(%rip), %rsi     # 0x91fd8
callq 0xeae0
jmp 0x18b69
callq 0xe800
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b8(%rbp)
movl %eax, -0x1bc(%rbp)
callq 0xe800
jmp 0x18b90
jmp 0x18b92
movq -0x1b8(%rbp), %rdi
callq 0xe700
movq %rax, %rdi
callq 0x199b0
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/main.cpp
// Function: Rnes::saveNesState(Rnes::Nes*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void saveNesState(Nes *nes, std::string saveFile) {
  namespace io = boost::iostreams;
  namespace fs = boost::filesystem;
  using namespace std;

  // Useless comment.

  try {
    io::stream<io::file_sink> stream(saveFile);
    unique_ptr<SaveState> gameState{new SaveState{}};

    // Save nes state.
    nes->save(*gameState.get());

    // Serialize save to file.
    gameState->SerializeToOstream(&stream);

    cerr << "state saved." << endl;
  } catch (const std::ios_base::failure &exception) {
    cerr << "Exception: " << exception.what() << endl;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
xorl %eax, %eax
movl %eax, %edx
leaq -0x1a8(%rbp), %rdi
callq 0x1a140
jmp 0x18bd5
movl $0x60, %edi
callq 0xe200
movq %rax, -0x1d0(%rbp)
jmp 0x18be8
movq -0x1d0(%rbp), %rdi
callq 0x1a040
jmp 0x18bf6
movq -0x1d0(%rbp), %rsi
leaq -0x1c0(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x1a060
movq -0x1e0(%rbp), %rdi
movq -0x8(%rbp), %rax
movq %rax, -0x1d8(%rbp)
callq 0x1a0b0
movq -0x1d8(%rbp), %rdi
movq %rax, %rsi
callq 0x3c9d0
jmp 0x18c38
leaq -0x1c0(%rbp), %rdi
callq 0x1a090
movq %rax, %rdi
leaq -0x1a8(%rbp), %rsi
callq 0xeb70
jmp 0x18c55
movq 0x7938c(%rip), %rdi     # 0x91fe8
leaq 0x4f448(%rip), %rsi     # 0x680ab
callq 0xe680
movq %rax, -0x1e8(%rbp)
jmp 0x18c71
movq -0x1e8(%rbp), %rdi
movq 0x79359(%rip), %rsi     # 0x91fd8
callq 0xeae0
jmp 0x18c86
leaq -0x1c0(%rbp), %rdi
callq 0x1a0e0
leaq -0x1a8(%rbp), %rdi
callq 0x1a230
jmp 0x18d9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x18d1a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
jmp 0x18d0e
movq -0x1d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
movl $0x60, %esi
callq 0xe170
jmp 0x18d0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x1a0e0
leaq -0x1a8(%rbp), %rdi
callq 0x1a230
movl -0x1b4(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x18dc2
movq -0x1b0(%rbp), %rdi
callq 0xe080
movq %rax, -0x1c8(%rbp)
movq 0x792a1(%rip), %rdi     # 0x91fe8
leaq 0x4f351(%rip), %rsi     # 0x6809f
callq 0xe680
movq %rax, -0x1f0(%rbp)
jmp 0x18d5c
movq -0x1c8(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x1f0(%rbp), %rdi
movq %rax, %rsi
callq 0xe680
movq %rax, -0x1f8(%rbp)
jmp 0x18d84
movq -0x1f8(%rbp), %rdi
movq 0x79246(%rip), %rsi     # 0x91fd8
callq 0xeae0
jmp 0x18d99
callq 0xe800
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x1b0(%rbp)
movl %eax, -0x1b4(%rbp)
callq 0xe800
jmp 0x18dc0
jmp 0x18dc2
movq -0x1b0(%rbp), %rdi
callq 0xe700
movq %rax, %rdi
callq 0x199b0
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::getBgColor()
uint32_t Ppu::getBgColor() {
  uint8_t memColor = load(backColorAddr);
  assert(memColor < sizeof(nesPaletteLut) / sizeof(nesPaletteLut[0]));
  if (isMonochromeMode()) {
    memColor &= 0x30;
  } else {
    memColor &= 0x3f;
  }
  return nesPaletteLut[memColor];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
movl $0x3f00, %esi           # imm = 0x3F00
callq 0x23410
movb %al, -0x9(%rbp)
movzbl -0x9(%rbp), %eax
cmpq $0x40, %rax
jae 0x233ad
jmp 0x233cc
leaq 0x45d8c(%rip), %rdi     # 0x69140
leaq 0x45dc1(%rip), %rsi     # 0x6917c
movl $0x3a, %edx
leaq 0x45dbd(%rip), %rcx     # 0x69184
callq 0xe240
movq -0x18(%rbp), %rdi
callq 0x24980
testb $0x1, %al
jne 0x233db
jmp 0x233e7
movzbl -0x9(%rbp), %eax
andl $0x30, %eax
movb %al, -0x9(%rbp)
jmp 0x233f1
movzbl -0x9(%rbp), %eax
andl $0x3f, %eax
movb %al, -0x9(%rbp)
movzbl -0x9(%rbp), %eax
movl %eax, %ecx
leaq 0x45c42(%rip), %rax     # 0x69040
movl (%rax,%rcx,4), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::getColor(unsigned int, unsigned int, bool)
uint32_t Ppu::getColor(uint32_t palette, uint32_t color, bool sprite) {
  uint8_t memColor;
  assert(color >= 0 && color <= 3);
  if (color == 0) {
    memColor = load(backColorAddr);
  } else {
    uint16_t paletteOffset = sprite ? 0x10 : 0;
    memColor = load(backColorAddr + paletteOffset + 4 * palette + color);
  }
  if (isMonochromeMode()) {
    memColor &= 0x30;
  } else {
    memColor &= 0x3f;
  }
  assert(memColor < sizeof(nesPaletteLut) / sizeof(nesPaletteLut[0]));
  return nesPaletteLut[memColor];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x10(%rbp)
movb %al, -0x15(%rbp)
jb 0x23476
cmpl $0x3, -0x10(%rbp)
setbe %al
movb %al, -0x15(%rbp)
movb -0x15(%rbp), %al
testb $0x1, %al
jne 0x2347f
jmp 0x23481
jmp 0x234a0
leaq 0x45d1d(%rip), %rdi     # 0x691a5
leaq 0x45ced(%rip), %rsi     # 0x6917c
movl $0x45, %edx
leaq 0x45d23(%rip), %rcx     # 0x691be
callq 0xe240
cmpl $0x0, -0x10(%rbp)
jne 0x234b9
movq -0x20(%rbp), %rdi
movl $0x3f00, %esi           # imm = 0x3F00
callq 0x23410
movb %al, -0x12(%rbp)
jmp 0x234f0
movq -0x20(%rbp), %rdi
movb -0x11(%rbp), %dl
xorl %eax, %eax
movl $0x10, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movw %ax, -0x14(%rbp)
movzwl -0x14(%rbp), %eax
addl $0x3f00, %eax           # imm = 0x3F00
movl -0xc(%rbp), %ecx
shll $0x2, %ecx
addl %ecx, %eax
addl -0x10(%rbp), %eax
movzwl %ax, %esi
callq 0x23410
movb %al, -0x12(%rbp)
movq -0x20(%rbp), %rdi
callq 0x24980
testb $0x1, %al
jne 0x234ff
jmp 0x2350b
movzbl -0x12(%rbp), %eax
andl $0x30, %eax
movb %al, -0x12(%rbp)
jmp 0x23515
movzbl -0x12(%rbp), %eax
andl $0x3f, %eax
movb %al, -0x12(%rbp)
movzbl -0x12(%rbp), %eax
cmpq $0x40, %rax
jae 0x23521
jmp 0x23540
leaq 0x45c18(%rip), %rdi     # 0x69140
leaq 0x45c4d(%rip), %rsi     # 0x6917c
movl $0x51, %edx
leaq 0x45c83(%rip), %rcx     # 0x691be
callq 0xe240
movzbl -0x12(%rbp), %eax
movl %eax, %ecx
leaq 0x45af3(%rip), %rax     # 0x69040
movl (%rax,%rcx,4), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::vramCoarseXInc()
void Ppu::vramCoarseXInc() {
  if ((vramCurrentAddr & 0x1f) == 31) {
    // coarse x = 0
    vramCurrentAddr &= ~0x001f;
    // switch horizontal nametable
    vramCurrentAddr ^= 0x0400;
  } else {
    // increment coarse x
    vramCurrentAddr += 1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movzwl 0x138(%rax), %eax
andl $0x1f, %eax
cmpl $0x1f, %eax
jne 0x235aa
movq -0x10(%rbp), %rax
movzwl 0x138(%rax), %ecx
andl $-0x20, %ecx
movw %cx, 0x138(%rax)
movzwl 0x138(%rax), %ecx
xorl $0x400, %ecx            # imm = 0x400
movw %cx, 0x138(%rax)
jmp 0x235bf
movq -0x10(%rbp), %rax
movzwl 0x138(%rax), %ecx
addl $0x1, %ecx
movw %cx, 0x138(%rax)
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::vramYInc()
void Ppu::vramYInc() {
  if ((vramCurrentAddr & 0x7000) != 0x7000) {
    vramCurrentAddr += 0x1000;
  } else {
    vramCurrentAddr &= ~0x7000;
    int y = (vramCurrentAddr & 0x03e0) >> 5;
    if (y == 29) {
      y = 0;
      vramCurrentAddr ^= 0x0800;
    } else if (y == 31) {
      y = 0;
    } else {
      y += 1;
    }
    vramCurrentAddr = (vramCurrentAddr & ~0x03e0) | (y << 5);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movzwl 0x138(%rax), %eax
andl $0x7000, %eax           # imm = 0x7000
cmpl $0x7000, %eax           # imm = 0x7000
je 0x23610
movq -0x18(%rbp), %rax
movzwl 0x138(%rax), %ecx
addl $0x1000, %ecx           # imm = 0x1000
movw %cx, 0x138(%rax)
jmp 0x2369b
movq -0x18(%rbp), %rax
movzwl 0x138(%rax), %ecx
andl $0xffff8fff, %ecx       # imm = 0xFFFF8FFF
movw %cx, 0x138(%rax)
movzwl 0x138(%rax), %eax
andl $0x3e0, %eax            # imm = 0x3E0
sarl $0x5, %eax
movl %eax, -0xc(%rbp)
cmpl $0x1d, -0xc(%rbp)
jne 0x23661
movq -0x18(%rbp), %rax
movl $0x0, -0xc(%rbp)
movzwl 0x138(%rax), %ecx
xorl $0x800, %ecx            # imm = 0x800
movw %cx, 0x138(%rax)
jmp 0x2367b
cmpl $0x1f, -0xc(%rbp)
jne 0x23670
movl $0x0, -0xc(%rbp)
jmp 0x23679
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2367b
movq -0x18(%rbp), %rax
movzwl 0x138(%rax), %ecx
andl $0xfffffc1f, %ecx       # imm = 0xFFFFFC1F
movl -0xc(%rbp), %edx
shll $0x5, %edx
orl %edx, %ecx
movw %cx, 0x138(%rax)
popq %rbp
retq
nopl (%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::loadPatternTile(unsigned short)
uint16_t Ppu::loadPatternTile(uint16_t addr) {
  uint16_t ret = 0;
  uint16_t a = load(addr);
  uint16_t b = load(addr + 8);
  for (uint32_t i = 0; i < 8; i++) {
    ret |= ((1u << i) & a) << i;
    ret |= ((1u << i) & b) << (i + 1);
  }
  return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movw $0x0, -0xc(%rbp)
movzwl -0xa(%rbp), %esi
callq 0x23410
movq -0x20(%rbp), %rdi
movzbl %al, %eax
movw %ax, -0xe(%rbp)
movzwl -0xa(%rbp), %eax
addl $0x8, %eax
movzwl %ax, %esi
callq 0x23410
movzbl %al, %eax
movw %ax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jae 0x237c8
movl -0x14(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movzwl -0xe(%rbp), %ecx
andl %ecx, %eax
movl -0x14(%rbp), %ecx
shll %cl, %eax
movl %eax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
movl -0x14(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movzwl -0x10(%rbp), %ecx
andl %ecx, %eax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
shll %cl, %eax
movl %eax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x23772
movw -0xc(%rbp), %ax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::save(Rnes::PpuState&)
void Ppu::save(PpuState &pb) {
  pb.set_cycle(cycle);
  pb.set_frame(frame);

  for (int i = 0; i < REG_COUNT; i++) {
    pb.add_regs(regs[i]);
  }

  for (int i = 0; i < spriteRamSize; i++) {
    PpuState_SpriteState *sprite = pb.add_spriteram();
    sprite->set_ycoordminus1(spriteRam[i].yCoordMinus1);
    sprite->set_tileindex(spriteRam[i].tileIndex);
    sprite->set_attr(spriteRam[i].attr);
    sprite->set_xcoord(spriteRam[i].xCoord);
  }

  pb.set_vramtoggle(vramToggle);
  pb.set_vramfinexscroll(vramFineXScroll);
  pb.set_vramcurrentaddr(vramCurrentAddr);
  pb.set_vramtempaddr(vramTempAddr);
  pb.set_vrammachineaddr(vramMachineAddr);
  pb.set_vramreadlatch(vramReadLatch);
  pb.set_scrollingmachinestate(scrollingMachineState);
  pb.set_xscrollorigin(xScrollOrigin);
  pb.set_yscrollorigin(yScrollOrigin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
movq 0x18(%rax), %rsi
callq 0x249a0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0x20(%rax), %rsi
callq 0x249d0
movl $0x0, -0x14(%rbp)
cmpl $0x8, -0x14(%rbp)
jge 0x23844
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movslq -0x14(%rbp), %rcx
movzbl 0x28(%rax,%rcx), %esi
callq 0x24a00
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2381d
movl $0x0, -0x18(%rbp)
cmpl $0x40, -0x18(%rbp)
jge 0x238c4
movq -0x10(%rbp), %rdi
callq 0x24a30
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rcx
movzbl 0x30(%rax,%rcx,4), %esi
callq 0x24a50
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rcx
movzbl 0x31(%rax,%rcx,4), %esi
callq 0x24a80
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rcx
movzbl 0x32(%rax,%rcx,4), %esi
callq 0x24ab0
movq -0x28(%rbp), %rax
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rcx
movzbl 0x33(%rax,%rcx,4), %esi
callq 0x24ae0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x2384b
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x130(%rax), %esi
callq 0x24b10
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x134(%rax), %esi
callq 0x24b40
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzwl 0x138(%rax), %esi
callq 0x24b70
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzwl 0x13a(%rax), %esi
callq 0x24ba0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzwl 0x13c(%rax), %esi
callq 0x24bd0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x13e(%rax), %esi
callq 0x24c00
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x140(%rax), %esi
callq 0x24c30
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x144(%rax), %esi
callq 0x24c60
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x145(%rax), %esi
callq 0x24c90
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::getVramAddrInc() const
uint16_t Ppu::getVramAddrInc() const {
  if (regs[CONTROL1_REG] & CONTROL_VRAM_ADDR_INC) {
    return 32;
  } else {
    return 1;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x28(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x241b0
movw $0x20, -0x2(%rbp)
jmp 0x241b6
movw $0x1, -0x2(%rbp)
movw -0x2(%rbp), %ax
popq %rbp
retq
nopl (%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::readReg(unsigned int)
uint8_t Ppu::readReg(uint32_t reg) {
  uint8_t ret;
  switch (reg) {
  case CONTROL1_REG:
    assert(0);
    // GUESS: Write only registers.
    return regs[reg];
    break;
  case CONTROL2_REG:
    assert(0);
    // GUESS: Write only registers.
    return regs[reg];
    break;
  case STATUS_REG:
    ret = regs[reg];
    // vblank status bit is clear on read
    clearVblankFlag();
    // reset the scroll/vram machine flip flops
    vramToggle = 0;
    // and return the reg value
    return ret;
    break;
  case SPR_ADDR_REG:
  case SPR_DATA_REG:
    // Write only registers.
    assert(0);
    return 0;
    break;
  case VRAM_ADDR_REG1:
    // assert(0);
    // This is a guess, we aren't expecting reads here.
    return vramCurrentAddr;
    break;
  case VRAM_ADDR_REG2:
    assert(0);
    // This is a guess, we aren't expecting reads here.
    return vramTempAddr;
    break;
  case VRAM_DATA_REG:
    ret = vramReadLatch;
    vramReadLatch = nes->vidMemRead(vramCurrentAddr);
    vramCurrentAddr += getVramAddrInc();
    return ret;
    break;
  default:
    assert(0);
    break;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movl -0x14(%rbp), %eax
movq %rax, -0x20(%rbp)
subq $0x7, %rax
ja 0x24305
movq -0x20(%rbp), %rax
leaq 0x44e2d(%rip), %rcx     # 0x69020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x442c6(%rip), %rdi     # 0x684c9
leaq 0x44f72(%rip), %rsi     # 0x6917c
movl $0x105, %edx            # imm = 0x105
leaq 0x4500b(%rip), %rcx     # 0x69221
callq 0xe240
leaq 0x442a7(%rip), %rdi     # 0x684c9
leaq 0x44f53(%rip), %rsi     # 0x6917c
movl $0x10a, %edx            # imm = 0x10A
leaq 0x44fec(%rip), %rcx     # 0x69221
callq 0xe240
movq -0x28(%rbp), %rdi
movl -0x14(%rbp), %eax
movb 0x28(%rdi,%rax), %al
movb %al, -0x15(%rbp)
callq 0x24f40
movq -0x28(%rbp), %rax
movl $0x0, 0x130(%rax)
movb -0x15(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x24324
leaq 0x4425c(%rip), %rdi     # 0x684c9
leaq 0x44f08(%rip), %rsi     # 0x6917c
movl $0x11a, %edx            # imm = 0x11A
leaq 0x44fa1(%rip), %rcx     # 0x69221
callq 0xe240
movq -0x28(%rbp), %rax
movw 0x138(%rax), %ax
movb %al, -0x1(%rbp)
jmp 0x24324
leaq 0x4422a(%rip), %rdi     # 0x684c9
leaq 0x44ed6(%rip), %rsi     # 0x6917c
movl $0x123, %edx            # imm = 0x123
leaq 0x44f6f(%rip), %rcx     # 0x69221
callq 0xe240
movq -0x28(%rbp), %rax
movb 0x13e(%rax), %cl
movb %cl, -0x15(%rbp)
movq 0x8(%rax), %rdi
movzwl 0x138(%rax), %esi
callq 0x3c6e0
movq -0x28(%rbp), %rdi
movb %al, 0x13e(%rdi)
callq 0x24190
movw %ax, %cx
movq -0x28(%rbp), %rax
movzwl %cx, %edx
movzwl 0x138(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x138(%rax)
movb -0x15(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x24324
leaq 0x441bd(%rip), %rdi     # 0x684c9
leaq 0x44e69(%rip), %rsi     # 0x6917c
movl $0x12e, %edx            # imm = 0x12E
leaq 0x44f02(%rip), %rcx     # 0x69221
callq 0xe240
movb -0x1(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::setPixel(int, int, unsigned int)
void Ppu::setPixel(int x, int y, uint32_t color) {
  uint8_t r = 0xff & (color >> 16);
  uint8_t g = 0xff & (color >> 8);
  uint8_t b = 0xff & (color);
  sdl->setPixel(x, y, r, g, b);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl -0x14(%rbp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movb %cl, -0x15(%rbp)
movl -0x14(%rbp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movb %cl, -0x16(%rbp)
movl -0x14(%rbp), %ecx
andl $0xff, %ecx
movb %cl, -0x17(%rbp)
movq 0x10(%rax), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movb -0x15(%rbp), %cl
movb -0x16(%rbp), %al
movzbl %cl, %ecx
movzbl %al, %r8d
movzbl -0x17(%rbp), %r9d
callq 0x41710
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: mindbeast[P]rnes/ppu.cpp
// Function: unsigned char Rnes::Ppu::getColorFromPatternTable<false>(unsigned short, int, unsigned int, unsigned int)
uint8_t Ppu::getColorFromPatternTable(uint16_t patternTable, int offset, uint32_t x, uint32_t y) {
  assert(x < 8);
  if (!is8x8) {
    assert(y < 16);
    if ((offset % 2) == 0) {
      patternTable = 0x0000;
    } else {
      patternTable = 0x1000;
      offset--;
    }
    if (y >= 8) {
      offset++;
      y -= 8;
    }
  } else {
    assert(y < 8);
  }
  x = 8 - 1 - x;
  uint16_t byteAddrLower = patternTable + 16 * offset + y;
  uint16_t byteAddrUpper = patternTable + 16 * offset + y + 8;
  uint8_t color = ((load(byteAddrLower) >> x) & 0x1) | (((load(byteAddrUpper) >> (x)) & 0x1) << 1);
  return color;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpl $0x8, -0x14(%rbp)
jae 0x251cd
jmp 0x251ec
leaq 0x44183(%rip), %rdi     # 0x69357
leaq 0x43fa1(%rip), %rsi     # 0x6917c
movl $0x136, %edx            # imm = 0x136
leaq 0x441da(%rip), %rcx     # 0x693c1
callq 0xe240
cmpl $0x10, -0x18(%rbp)
jae 0x251f4
jmp 0x25213
leaq 0x44225(%rip), %rdi     # 0x69420
leaq 0x43f7a(%rip), %rsi     # 0x6917c
movl $0x138, %edx            # imm = 0x138
leaq 0x441b3(%rip), %rcx     # 0x693c1
callq 0xe240
movl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x2522b
movw $0x0, -0xa(%rbp)
jmp 0x2523a
movw $0x1000, -0xa(%rbp)     # imm = 0x1000
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
cmpl $0x8, -0x18(%rbp)
jb 0x25252
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x18(%rbp), %eax
subl $0x8, %eax
movl %eax, -0x18(%rbp)
movq -0x28(%rbp), %rdi
movl $0x7, %eax
subl -0x14(%rbp), %eax
movl %eax, -0x14(%rbp)
movzwl -0xa(%rbp), %eax
movl -0x10(%rbp), %ecx
shll $0x4, %ecx
addl %ecx, %eax
addl -0x18(%rbp), %eax
movw %ax, -0x1a(%rbp)
movzwl -0xa(%rbp), %eax
movl -0x10(%rbp), %ecx
shll $0x4, %ecx
addl %ecx, %eax
addl -0x18(%rbp), %eax
addl $0x8, %eax
movw %ax, -0x1c(%rbp)
movzwl -0x1a(%rbp), %esi
callq 0x23410
movq -0x28(%rbp), %rdi
movzbl %al, %eax
movl -0x14(%rbp), %ecx
sarl %cl, %eax
andl $0x1, %eax
movl %eax, -0x2c(%rbp)
movzwl -0x1c(%rbp), %esi
callq 0x23410
movb %al, %cl
movl -0x2c(%rbp), %eax
movzbl %cl, %edx
movl -0x14(%rbp), %ecx
sarl %cl, %edx
movl %edx, %ecx
andl $0x1, %ecx
shll %ecx
orl %ecx, %eax
movb %al, -0x1d(%rbp)
movb -0x1d(%rbp), %al
addq $0x30, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::apuSdlCallback(void*, unsigned char*, int)
void apuSdlCallback(void *data, uint8_t *stream, int len) {
  RingBuffer<int16_t> *rb = (RingBuffer<int16_t> *)data;
  uint32_t items = len / sizeof(int16_t);
  int16_t *outData = (int16_t *)stream;

  rb->getData(outData, items);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movslq -0x14(%rbp), %rax
shrq %rax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x24(%rbp), %edx
callq 0x27270
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::clockLengthAndSweep()
void Apu::clockLengthAndSweep() {
  pulseA->clockLengthAndSweep();
  pulseB->clockLengthAndSweep();
  triangle->clockLength();
  noise->clockLength();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
addq $0xe8, %rdi
callq 0x27370
movq %rax, %rdi
callq 0x2c230
movq -0x10(%rbp), %rdi
addq $0xf0, %rdi
callq 0x27370
movq %rax, %rdi
callq 0x2c230
movq -0x10(%rbp), %rdi
addq $0xf8, %rdi
callq 0x27390
movq %rax, %rdi
callq 0x2c4b0
movq -0x10(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x273b0
movq %rax, %rdi
callq 0x2c910
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::resetFrameCounter()
void Apu::resetFrameCounter() {
  frameDivider = 0;
  step = 0;
  if (!isFourStepFrame()) {
    stepAdvance();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
movl $0x0, 0x10(%rdi)
movl $0x0, 0x14(%rdi)
callq 0x273d0
testb $0x1, %al
jne 0x25f14
movq -0x10(%rbp), %rdi
callq 0x25f20
addq $0x10, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::stepAdvance()
void Apu::stepAdvance() {
  uint32_t frameSteps = isFourStepFrame() ? 4 : 5;

  if (isFourStepFrame()) {
    if (step % 2) {
      clockLengthAndSweep();
    }
    clockEnvAndTriangle();
    if ((step == 3) and isFrameIntEnabled()) {
      setRequestFrameIrq();
    }
  } else {
    if (step < 4) {
      clockEnvAndTriangle();
    }
    if (step == 0 or step == 2) {
      clockLengthAndSweep();
    }
  }
  step += 1;
  if (step == frameSteps) {
    step = 0;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
callq 0x273d0
movq -0x18(%rbp), %rdi
movb %al, %dl
movl $0x5, %eax
movl $0x4, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0xc(%rbp)
callq 0x273d0
testb $0x1, %al
jne 0x25f5d
jmp 0x25fa2
movq -0x18(%rbp), %rax
movl 0x14(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x25f75
movq -0x18(%rbp), %rdi
callq 0x25e00
movq -0x18(%rbp), %rdi
callq 0x25e80
movq -0x18(%rbp), %rax
cmpl $0x3, 0x14(%rax)
jne 0x25fa0
movq -0x18(%rbp), %rdi
callq 0x27400
testb $0x1, %al
jne 0x25f97
jmp 0x25fa0
movq -0x18(%rbp), %rdi
callq 0x27420
jmp 0x25fd4
movq -0x18(%rbp), %rax
cmpl $0x4, 0x14(%rax)
jae 0x25fb5
movq -0x18(%rbp), %rdi
callq 0x25e80
movq -0x18(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x25fc9
movq -0x18(%rbp), %rax
cmpl $0x2, 0x14(%rax)
jne 0x25fd2
movq -0x18(%rbp), %rdi
callq 0x25e00
jmp 0x25fd4
movq -0x18(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
movl 0x14(%rax), %eax
cmpl -0xc(%rbp), %eax
jne 0x25ff4
movq -0x18(%rbp), %rax
movl $0x0, 0x14(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::readReg(unsigned int)
uint8_t Apu::readReg(uint32_t reg) {
  uint8_t result = regs[reg];
  if (reg == CONTROL_STATUS) {
    clearRequestFrameIrq();
    result = result & (STATUS_FRAME_IRQ_REQUESTED | STATUS_DMC_IRQ_REQUESTED);
    result |= pulseA->isNonZeroLength() ? STATUS_CHANNEL1_LENGTH : 0;
    result |= pulseB->isNonZeroLength() ? STATUS_CHANNEL2_LENGTH : 0;
    result |= triangle->isNonZeroLength() ? STATUS_CHANNEL3_LENGTH : 0;
    result |= noise->isNonZeroLength() ? STATUS_CHANNEL4_LENGTH : 0;
  }
  return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl -0xc(%rbp), %ecx
movb 0xb8(%rax,%rcx), %al
movb %al, -0xd(%rbp)
cmpl $0x15, -0xc(%rbp)
jne 0x26843
movq -0x18(%rbp), %rdi
callq 0x277f0
movq -0x18(%rbp), %rdi
movzbl -0xd(%rbp), %eax
andl $0xc0, %eax
movb %al, -0xd(%rbp)
addq $0xe8, %rdi
callq 0x27370
movq %rax, %rdi
callq 0x27810
movq -0x18(%rbp), %rdi
movb %al, %dl
xorl %ecx, %ecx
movl $0x1, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movzbl -0xd(%rbp), %eax
orl %ecx, %eax
movb %al, -0xd(%rbp)
addq $0xf0, %rdi
callq 0x27370
movq %rax, %rdi
callq 0x27810
movq -0x18(%rbp), %rdi
movb %al, %dl
xorl %ecx, %ecx
movl $0x2, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movzbl -0xd(%rbp), %eax
orl %ecx, %eax
movb %al, -0xd(%rbp)
addq $0xf8, %rdi
callq 0x27390
movq %rax, %rdi
callq 0x27830
movq -0x18(%rbp), %rdi
movb %al, %dl
xorl %ecx, %ecx
movl $0x4, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movzbl -0xd(%rbp), %eax
orl %ecx, %eax
movb %al, -0xd(%rbp)
addq $0x100, %rdi            # imm = 0x100
callq 0x273b0
movq %rax, %rdi
callq 0x27850
movb %al, %dl
xorl %ecx, %ecx
movl $0x8, %eax
testb $0x1, %dl
cmovnel %eax, %ecx
movzbl -0xd(%rbp), %eax
orl %ecx, %eax
movb %al, -0xd(%rbp)
movb -0xd(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::save(Rnes::ApuState&)
void Apu::save(ApuState &pb) {
  // Save sub-units.
  pulseA->save(*pb.mutable_pulsea());
  pulseB->save(*pb.mutable_pulseb());
  triangle->save(*pb.mutable_triangle());
  noise->save(*pb.mutable_noise());

  /*
  // Apu register file.
  repeated uint32 reg = 1;
  optional uint32 sampleRate = 2;
  optional uint32 fourFrameCount = 3;
  optional uint32 fiveFrameCount = 4;
  optional uint32 frameDivider = 5;
  optional uint32 step = 6;
  optional uint32 halfTimerDivider = 7;
  optional uint32 samplerDivider = 8;
  optional float clksPerSample = 9;
  optional float currentSampleClk = 10;
  optional uint32 nextSampleCountdown = 11;
  */

  for (unsigned i = 0; i < REG_COUNT; i++) {
    pb.add_reg(regs[i]);
  }
  pb.set_samplerate(sampleRate);
  pb.set_fourframecount(fourFrameCount);
  pb.set_fiveframecount(fiveFrameCount);
  pb.set_framedivider(frameDivider);
  pb.set_step(step);
  pb.set_halftimerdivider(halfTimerDivider);
  pb.set_samplerdivider(samplerDivider);
  pb.set_clkspersample(clksPerSample);
  pb.set_currentsampleclk(currentSampleClk);
  pb.set_nextsamplecountdown(nextSampleCountdown);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
addq $0xe8, %rdi
callq 0x27370
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x27870
movq -0x40(%rbp), %rdi
movq %rax, %rsi
callq 0x2bf90
movq -0x28(%rbp), %rdi
addq $0xf0, %rdi
callq 0x27370
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
callq 0x27890
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x2bf90
movq -0x28(%rbp), %rdi
addq $0xf8, %rdi
callq 0x27390
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x278b0
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x2c390
movq -0x28(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
callq 0x273b0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x278d0
movq -0x20(%rbp), %rdi
movq %rax, %rsi
callq 0x2c750
movl $0x0, -0x14(%rbp)
cmpl $0x18, -0x14(%rbp)
jae 0x26938
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %ecx
movzbl 0xb8(%rax,%rcx), %esi
callq 0x278f0
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x2690f
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0xd0(%rax), %esi
callq 0x27920
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0xd8(%rax), %rax
movl %eax, %esi
callq 0x27950
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movq 0xe0(%rax), %rax
movl %eax, %esi
callq 0x27980
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x10(%rax), %esi
callq 0x279b0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x14(%rax), %esi
callq 0x279e0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x18(%rax), %esi
callq 0x27a10
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x1c(%rax), %esi
callq 0x27a40
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movss 0x20(%rax), %xmm0
callq 0x27a70
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movss 0x24(%rax), %xmm0
callq 0x27aa0
movq -0x28(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x28(%rax), %esi
callq 0x27ad0
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/./ringbuffer.h
// Function: Rnes::RingBuffer<short>::getData(short*, unsigned int)
void getData(T *out, uint32_t count) {
    {
      std::unique_lock<std::mutex> lock(mutex);
      if (!hasData(count)) {
        consumeCv.wait(lock, [&] { return this->hasData(count); });
      }
      for (uint32_t i = 0; i < count; i++) {
        out[i] = buffer[get & (size - 1)];
        get += 1;
      }
    }
    produceCv.notify_one();
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x58(%rbp)
addq $0x30, %rsi
leaq -0x28(%rbp), %rdi
callq 0x29a10
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x29a50
movb %al, -0x4d(%rbp)
jmp 0x272a9
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x272f5
jmp 0x272b2
movq -0x58(%rbp), %rax
movq %rax, %rdi
addq $0x58, %rdi
movq %rax, -0x48(%rbp)
leaq -0x14(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq -0x28(%rbp), %rsi
callq 0x29a80
jmp 0x272dc
jmp 0x272f5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x29af0
jmp 0x27367
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x27348
movq -0x58(%rbp), %rdi
movq 0x20(%rdi), %rsi
movl 0x18(%rdi), %eax
subl $0x1, %eax
movl %eax, %eax
andq %rax, %rsi
callq 0x29ad0
movq %rax, %rcx
movq -0x58(%rbp), %rax
movw (%rcx), %si
movq -0x10(%rbp), %rcx
movl -0x4c(%rbp), %edx
movw %si, (%rcx,%rdx,2)
movq 0x20(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x20(%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x272fc
leaq -0x28(%rbp), %rdi
callq 0x29af0
movq -0x58(%rbp), %rdi
addq $0x88, %rdi
callq 0xe6a0
addq $0x60, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0xe700
// File: mindbeast[P]rnes/./ringbuffer.h
// Function: Rnes::RingBuffer<unsigned short>::putData(unsigned short const*, unsigned int)
void putData(const T *in, uint32_t count) {
    {
      std::unique_lock<std::mutex> lock(mutex);
      if (!hasEmptySpace(count)) {
        produceCv.wait(lock, [&] { return this->hasEmptySpace(count); });
      }
      for (uint32_t i = 0; i < count; i++) {
        buffer[put & (size - 1)] = in[i];
        put += 1;
      }
    }
    consumeCv.notify_one();
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x58(%rbp)
addq $0x30, %rsi
leaq -0x28(%rbp), %rdi
callq 0x29a10
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2a760
movb %al, -0x4d(%rbp)
jmp 0x274e9
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x27538
jmp 0x274f2
movq -0x58(%rbp), %rax
movq %rax, %rdi
addq $0x88, %rdi
movq %rax, -0x48(%rbp)
leaq -0x14(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
leaq -0x28(%rbp), %rsi
callq 0x2a790
jmp 0x2751f
jmp 0x27538
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x29af0
jmp 0x275af
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x27593
movq -0x58(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x4c(%rbp), %ecx
movw (%rax,%rcx,2), %ax
movw %ax, -0x5a(%rbp)
movq 0x28(%rdi), %rsi
movl 0x18(%rdi), %eax
subl $0x1, %eax
movl %eax, %eax
andq %rax, %rsi
callq 0x2a7e0
movw -0x5a(%rbp), %dx
movq %rax, %rcx
movq -0x58(%rbp), %rax
movw %dx, (%rcx)
movq 0x28(%rax), %rcx
addq $0x1, %rcx
movq %rcx, 0x28(%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x2753f
leaq -0x28(%rbp), %rdi
callq 0x29af0
movq -0x58(%rbp), %rdi
addq $0x58, %rdi
callq 0xe6a0
addq $0x60, %rsp
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0xe700
nopl (%rax,%rax)
// File: mindbeast[P]rnes/./bin/save.pb.h
// Function: Rnes::ApuState::_internal_mutable_pulsea()
inline ::Rnes::PulseState* ApuState::_internal_mutable_pulsea() {
  _has_bits_[0] |= 0x00000001u;
  if (pulsea_ == nullptr) {
    auto* p = CreateMaybeMessage<::Rnes::PulseState>(GetArena());
    pulsea_ = p;
  }
  return pulsea_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
orl $0x1, %esi
movl %esi, (%rcx,%rdx,4)
cmpq $0x0, 0x28(%rax)
jne 0x284a2
movq -0x28(%rbp), %rdi
callq 0x284d0
movq %rax, %rdi
callq 0x284b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/./bin/save.pb.h
// Function: Rnes::ApuState::_internal_mutable_pulseb()
inline ::Rnes::PulseState* ApuState::_internal_mutable_pulseb() {
  _has_bits_[0] |= 0x00000002u;
  if (pulseb_ == nullptr) {
    auto* p = CreateMaybeMessage<::Rnes::PulseState>(GetArena());
    pulseb_ = p;
  }
  return pulseb_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
orl $0x2, %esi
movl %esi, (%rcx,%rdx,4)
cmpq $0x0, 0x30(%rax)
jne 0x285e2
movq -0x28(%rbp), %rdi
callq 0x284d0
movq %rax, %rdi
callq 0x284b0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/./bin/save.pb.h
// Function: Rnes::ApuState::_internal_mutable_triangle()
inline ::Rnes::TriangleState* ApuState::_internal_mutable_triangle() {
  _has_bits_[0] |= 0x00000004u;
  if (triangle_ == nullptr) {
    auto* p = CreateMaybeMessage<::Rnes::TriangleState>(GetArena());
    triangle_ = p;
  }
  return triangle_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
orl $0x4, %esi
movl %esi, (%rcx,%rdx,4)
cmpq $0x0, 0x38(%rax)
jne 0x28652
movq -0x28(%rbp), %rdi
callq 0x284d0
movq %rax, %rdi
callq 0x28660
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/./bin/save.pb.h
// Function: Rnes::ApuState::_internal_mutable_noise()
inline ::Rnes::NoiseState* ApuState::_internal_mutable_noise() {
  _has_bits_[0] |= 0x00000008u;
  if (noise_ == nullptr) {
    auto* p = CreateMaybeMessage<::Rnes::NoiseState>(GetArena());
    noise_ = p;
  }
  return noise_;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x28(%rbp)
movq %rax, %rcx
addq $0x10, %rcx
movq %rcx, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq -0x8(%rbp), %rcx
movslq -0xc(%rbp), %rdx
movl (%rcx,%rdx,4), %esi
orl $0x8, %esi
movl %esi, (%rcx,%rdx,4)
cmpq $0x0, 0x40(%rax)
jne 0x286e2
movq -0x28(%rbp), %rdi
callq 0x284d0
movq %rax, %rdi
callq 0x286f0
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x20(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rax
addq $0x30, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::computeSweepTarget() const
uint16_t Pulse::computeSweepTarget() const {
  uint16_t period = getTimerPeriod();
  uint16_t shiftedPeriod = period >> getSweepShift();
  if (isSweepNegative()) {
    shiftedPeriod = isFirstPulse() ? -shiftedPeriod : -shiftedPeriod + 1;
  }
  uint16_t targetPeriod = period + shiftedPeriod;
  return targetPeriod;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
callq 0x2c9f0
movq -0x20(%rbp), %rdi
movw %ax, -0xa(%rbp)
movzwl -0xa(%rbp), %eax
movl %eax, -0x14(%rbp)
callq 0x2ca20
movq -0x20(%rbp), %rdi
movb %al, %cl
movl -0x14(%rbp), %eax
movzbl %cl, %ecx
sarl %cl, %eax
movw %ax, -0xc(%rbp)
callq 0x2ca40
testb $0x1, %al
jne 0x2be4a
jmp 0x2be7b
movq -0x20(%rbp), %rdi
callq 0x2ca70
testb $0x1, %al
jne 0x2be59
jmp 0x2be66
movzwl -0xc(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x24(%rbp)
jmp 0x2be74
movzwl -0xc(%rbp), %ecx
xorl %eax, %eax
subl %ecx, %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0xc(%rbp)
movzwl -0xa(%rbp), %eax
movzwl -0xc(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0xe(%rbp)
movw -0xe(%rbp), %ax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::sweepPeriod()
void Pulse::sweepPeriod() {
  uint16_t targetPeriod = computeSweepTarget();
  uint16_t period = getTimerPeriod();
  if (targetPeriod > 0x7ff or period < 8) {
    return;
  }
  setTimerPeriod(targetPeriod);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
callq 0x2be00
movq -0x18(%rbp), %rdi
movw %ax, -0xa(%rbp)
callq 0x2c9f0
movw %ax, -0xc(%rbp)
movzwl -0xa(%rbp), %eax
cmpl $0x7ff, %eax            # imm = 0x7FF
jg 0x2bede
movzwl -0xc(%rbp), %eax
cmpl $0x8, %eax
jge 0x2bee0
jmp 0x2beed
movq -0x18(%rbp), %rdi
movzwl -0xa(%rbp), %esi
callq 0x2ca90
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::getVolume() const
uint8_t Pulse::getVolume() const {
  if (isDisabled()) {
    return getEnvelopeN();
  } else {
    return envelope;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x18(%rbp)
callq 0x2cae0
testb $0x1, %al
jne 0x2bf1f
jmp 0x2bf2d
movq -0x18(%rbp), %rdi
callq 0x2cb00
movb %al, -0x1(%rbp)
jmp 0x2bf37
movq -0x18(%rbp), %rax
movb 0x12(%rax), %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::envelopeDividerClock()
void Pulse::envelopeDividerClock() {
  if (envelope) {
    envelope--;
  } else if (isEnvelopeLoopSet()) {
    envelope = 15;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
cmpb $0x0, 0x12(%rax)
je 0x2bf69
movq -0x10(%rbp), %rax
movb 0x12(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x12(%rax)
jmp 0x2bf82
movq -0x10(%rbp), %rdi
callq 0x2cb20
testb $0x1, %al
jne 0x2bf78
jmp 0x2bf80
movq -0x10(%rbp), %rax
movb $0xf, 0x12(%rax)
jmp 0x2bf82
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::save(Rnes::PulseState&)
void Pulse::save(PulseState &pb) {
  // length logic
  pb.set_lengthcounter(lengthCounter);

  // envelope logic
  pb.set_envelope(envelope);
  pb.set_envelopedivider(envelopeDivider);
  pb.set_resetenvelopeanddivider(resetEnvelopeAndDivider);

  // sweep logic
  pb.set_resetsweepdivider(resetSweepDivider);
  pb.set_sweepdivider(sweepDivider);

  // current sample
  pb.set_currentsample(currentSample);

  // timer
  pb.set_timerdivider(timerDivider);

  // sequencer offset
  pb.set_sequenceroffset(sequencerOffset);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
movzbl 0x11(%rax), %esi
callq 0x2cb40
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x12(%rax), %esi
callq 0x2cb70
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x13(%rax), %esi
callq 0x2cba0
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movb 0x14(%rax), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x2cbd0
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movb 0x15(%rax), %al
andb $0x1, %al
movzbl %al, %esi
callq 0x2cc00
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x16(%rax), %esi
callq 0x2cc30
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movzbl 0x17(%rax), %esi
callq 0x2cc60
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x18(%rax), %esi
callq 0x2cc90
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdi
movl 0x1c(%rax), %esi
callq 0x2ccc0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::restore(Rnes::PulseState const&)
void Pulse::restore(const PulseState &pb) {
  lengthCounter = pb.lengthcounter();
  envelope = pb.envelope();
  envelopeDivider = pb.envelopedivider();
  resetEnvelopeAndDivider = pb.resetenvelopeanddivider();

  resetSweepDivider = pb.resetsweepdivider();
  sweepDivider = pb.sweepdivider();
  currentSample = pb.currentsample();
  timerDivider = pb.timerdivider();
  sequencerOffset = pb.sequenceroffset();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2ccf0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movb %cl, 0x11(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cd10
movl %eax, %ecx
movq -0x18(%rbp), %rax
movb %cl, 0x12(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cd30
movl %eax, %ecx
movq -0x18(%rbp), %rax
movb %cl, 0x13(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cd50
movb %al, %cl
movq -0x18(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x14(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cd70
movb %al, %cl
movq -0x18(%rbp), %rax
andb $0x1, %cl
movb %cl, 0x15(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cd90
movl %eax, %ecx
movq -0x18(%rbp), %rax
movb %cl, 0x16(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cdb0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movb %cl, 0x17(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cdd0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rdi
callq 0x2cdf0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x1c(%rax)
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::getCurrentSample() const
uint8_t Pulse::getCurrentSample() const {
  // channel is silenced when period is < 8
  const uint16_t timerPeriod = getTimerPeriod();
  if (timerPeriod < 8) {
    return 0;
  }
  // channel silenced when target is above 0x7ff
  const uint16_t targetPeriod = computeSweepTarget();
  if (targetPeriod > 0x7ff) {
    return 0;
  }
  if (!isNonZeroLength()) {
    return 0;
  }
  if (!currentSample) {
    return 0;
  }
  return getVolume();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x20(%rbp)
callq 0x2c9f0
movw %ax, -0x12(%rbp)
movzwl -0x12(%rbp), %eax
cmpl $0x8, %eax
jge 0x2c14c
movb $0x0, -0x1(%rbp)
jmp 0x2c199
movq -0x20(%rbp), %rdi
callq 0x2be00
movw %ax, -0x14(%rbp)
movzwl -0x14(%rbp), %eax
cmpl $0x7ff, %eax            # imm = 0x7FF
jle 0x2c16a
movb $0x0, -0x1(%rbp)
jmp 0x2c199
movq -0x20(%rbp), %rdi
callq 0x27810
testb $0x1, %al
jne 0x2c17d
movb $0x0, -0x1(%rbp)
jmp 0x2c199
movq -0x20(%rbp), %rax
cmpb $0x0, 0x17(%rax)
jne 0x2c18d
movb $0x0, -0x1(%rbp)
jmp 0x2c199
movq -0x20(%rbp), %rdi
callq 0x2bf00
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::clockEnvelope()
void Pulse::clockEnvelope() {
  if (resetEnvelopeAndDivider) {
    envelope = 15;
    envelopeDivider = getEnvelopeN() + 1;
    resetEnvelopeAndDivider = false;
  } else {
    if (envelopeDivider) {
      envelopeDivider--;
    } else {
      envelopeDividerClock();
      envelopeDivider = getEnvelopeN() + 1;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
testb $0x1, 0x14(%rax)
je 0x2c1ec
movq -0x10(%rbp), %rdi
movb $0xf, 0x12(%rdi)
callq 0x2cb00
movb %al, %cl
movq -0x10(%rbp), %rax
movzbl %cl, %ecx
addl $0x1, %ecx
movb %cl, 0x13(%rax)
movb $0x0, 0x14(%rax)
jmp 0x2c228
movq -0x10(%rbp), %rax
cmpb $0x0, 0x13(%rax)
je 0x2c205
movq -0x10(%rbp), %rax
movb 0x13(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x13(%rax)
jmp 0x2c226
movq -0x10(%rbp), %rdi
callq 0x2bf40
movq -0x10(%rbp), %rdi
callq 0x2cb00
movb %al, %cl
movq -0x10(%rbp), %rax
movzbl %cl, %ecx
addl $0x1, %ecx
movb %cl, 0x13(%rax)
jmp 0x2c228
addq $0x10, %rsp
popq %rbp
retq
nop