LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x8(%rdi), %rdi
callq 0x217f2
movl %eax, %r15d
addl $0x8, %ebx
movq 0x8(%r14), %rdi
movzwl %bx, %esi
callq 0x217f2
movzbl %r15b, %edx
movzbl %al, %esi
xorl %ecx, %ecx
xorl %eax, %eax
movl $0x1, %edi
shll %cl, %edi
movl %edi, %r8d
andl %edx, %r8d
shll %cl, %r8d
andl %esi, %edi
incl %ecx
shll %cl, %edi
orl %r8d, %edi
orl %edi, %eax
cmpl $0x8, %ecx
jne 0x18fb1
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/ppu.cpp
// Function: Rnes::Ppu::restore(Rnes::PpuState const&)
void Ppu::restore(const PpuState &pb) {
  cycle = pb.cycle();
  frame = pb.frame();

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

  for (int i = 0; i < pb.spriteram_size(); i++) {
    const PpuState_SpriteState &sprite = pb.spriteram(i);
    spriteRam[i].yCoordMinus1 = sprite.ycoordminus1();
    spriteRam[i].tileIndex = sprite.tileindex();
    spriteRam[i].attr = sprite.attr();
    spriteRam[i].xCoord = sprite.xcoord();
  }

  vramToggle = pb.vramtoggle();
  vramFineXScroll = pb.vramfinexscroll();
  vramCurrentAddr = pb.vramcurrentaddr();
  vramTempAddr = pb.vramtempaddr();
  vramMachineAddr = pb.vrammachineaddr();
  vramReadLatch = pb.vramreadlatch();
  scrollingMachineState = pb.scrollingmachinestate();
  xScrollOrigin = pb.xscrollorigin();
  yScrollOrigin = pb.yscrollorigin();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0x40(%rsi), %rax
movq %rax, 0x18(%rdi)
movq 0x48(%rsi), %rax
movq %rax, 0x20(%rdi)
cmpl $0x0, 0x18(%rsi)
jle 0x19213
leaq 0x18(%r14), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0xb720
movb (%rax), %al
movb %al, 0x28(%rbx,%r12)
incq %r12
movslq (%r15), %rax
cmpq %rax, %r12
jl 0x191f6
cmpl $0x0, 0x30(%r14)
jle 0x19258
leaq 0x28(%r14), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x19d26
movb 0x18(%rax), %cl
movb %cl, 0x30(%rbx,%r12,4)
movb 0x1c(%rax), %cl
movb %cl, 0x31(%rbx,%r12,4)
movb 0x20(%rax), %cl
movb %cl, 0x32(%rbx,%r12,4)
movb 0x24(%rax), %al
movb %al, 0x33(%rbx,%r12,4)
incq %r12
movslq 0x30(%r14), %rax
cmpq %rax, %r12
jl 0x19221
movl 0x50(%r14), %eax
movl %eax, 0x130(%rbx)
movl 0x54(%r14), %eax
movl %eax, 0x134(%rbx)
movzwl 0x58(%r14), %eax
movw %ax, 0x138(%rbx)
movzwl 0x5c(%r14), %eax
movw %ax, 0x13a(%rbx)
movzwl 0x60(%r14), %eax
movw %ax, 0x13c(%rbx)
movb 0x64(%r14), %al
movb %al, 0x13e(%rbx)
movl 0x68(%r14), %eax
movl %eax, 0x140(%rbx)
movb 0x6c(%r14), %al
movb %al, 0x144(%rbx)
movb 0x70(%r14), %al
movb %al, 0x145(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
cmpl $0x7, %esi
ja 0x1977f
movq %rdi, %rbx
movl %esi, %eax
leaq 0x1b5e4(%rip), %rcx     # 0x34c80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movb 0x2a(%rbx), %r14b
movl %r14d, %eax
andb $0x7f, %al
movb %al, 0x2a(%rbx)
movl $0x0, 0x130(%rbx)
jmp 0x196fb
movb 0x138(%rbx), %r14b
jmp 0x196fb
movb 0x13e(%rbx), %r14b
movq 0x8(%rbx), %rdi
movzwl 0x138(%rbx), %esi
callq 0x217f2
movb %al, 0x13e(%rbx)
testb $0x4, 0x28(%rbx)
movl $0x1, %eax
movl $0x20, %ecx
cmovel %eax, %ecx
addw %cx, 0x138(%rbx)
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1ad9a(%rip), %rdi     # 0x344a4
leaq 0x1b6cb(%rip), %rsi     # 0x34ddc
leaq 0x1b769(%rip), %rcx     # 0x34e81
movl $0x11a, %edx            # imm = 0x11A
callq 0xb160
leaq 0x1ad7b(%rip), %rdi     # 0x344a4
leaq 0x1b6ac(%rip), %rsi     # 0x34ddc
leaq 0x1b74a(%rip), %rcx     # 0x34e81
movl $0x105, %edx            # imm = 0x105
callq 0xb160
leaq 0x1ad5c(%rip), %rdi     # 0x344a4
leaq 0x1b68d(%rip), %rsi     # 0x34ddc
leaq 0x1b72b(%rip), %rcx     # 0x34e81
movl $0x10a, %edx            # imm = 0x10A
callq 0xb160
leaq 0x1ad3d(%rip), %rdi     # 0x344a4
leaq 0x1b66e(%rip), %rsi     # 0x34ddc
leaq 0x1b70c(%rip), %rcx     # 0x34e81
movl $0x123, %edx            # imm = 0x123
callq 0xb160
leaq 0x1ad1e(%rip), %rdi     # 0x344a4
leaq 0x1b64f(%rip), %rsi     # 0x34ddc
leaq 0x1b6ed(%rip), %rcx     # 0x34e81
movl $0x12e, %edx            # imm = 0x12E
callq 0xb160
// File: /workspace/github_cpp_makefile_star2_O1/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
movl %ecx, %r9d
shrl $0x10, %ecx
movl %r9d, %r8d
shrl $0x8, %r8d
movq 0x10(%rdi), %rdi
movl $0xff, %eax
andl %eax, %r9d
andl %eax, %ecx
andl %eax, %r8d
popq %rbp
jmp 0x22a40
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
cmpl $0x8, %ecx
jae 0x19ce7
cmpl $0x10, %r8d
jae 0x19d06
movl %ecx, %r14d
movq %rdi, %rbx
movl %edx, %eax
andl $0x8000ffe, %eax        # imm = 0x8000FFE
andl $0x1, %edx
shll $0xc, %edx
leal 0xfff8(%r8), %ecx
xorl %edi, %edi
cmpl $0x8, %r8d
setae %dil
cmovbl %r8d, %ecx
orl %eax, %edi
shll $0x4, %edi
addl %edx, %ecx
leal (%rdi,%rcx), %r15d
addl $0x8, %r15d
movl %ecx, %esi
addl %edi, %esi
movq 0x8(%rbx), %rdi
movl $0xffff, %r12d          # imm = 0xFFFF
andl %r12d, %esi
callq 0x217f2
movzbl %al, %eax
movb $0x7, %cl
subb %r14b, %cl
movzbl %cl, %r14d
xorl %r13d, %r13d
btl %r14d, %eax
setb %r13b
movq 0x8(%rbx), %rdi
andl %r12d, %r15d
movl %r15d, %esi
callq 0x217f2
movzbl %al, %eax
movl %r14d, %ecx
shrl %cl, %eax
andl $0x1, %eax
leal (%r13,%rax,2), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1b22f(%rip), %rdi     # 0x34f1d
leaq 0x1b0e7(%rip), %rsi     # 0x34ddc
leaq 0x1b28b(%rip), %rcx     # 0x34f87
movl $0x136, %edx            # imm = 0x136
callq 0xb160
leaq 0x1b2d9(%rip), %rdi     # 0x34fe6
leaq 0x1b0c8(%rip), %rsi     # 0x34ddc
leaq 0x1b26c(%rip), %rcx     # 0x34f87
movl $0x138, %edx            # imm = 0x138
callq 0xb160
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xe8(%rdi), %rdi
callq 0x1b5b6
movq 0xf0(%rbx), %rdi
callq 0x1b5b6
movq 0xf8(%rbx), %rdi
callq 0x1b70a
movq 0x100(%rbx), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1b92e
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movq $0x0, 0x10(%rdi)
cmpb $0x0, 0xcf(%rdi)
js 0x19eaf
popq %rbp
retq
popq %rbp
jmp 0x19eb6
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r14
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0xcf(%rdi)
movl 0x14(%rdi), %eax
js 0x19efe
testb $0x1, %al
je 0x19ed8
movq %rbx, %rdi
callq 0x19e24
movq %rbx, %rdi
callq 0x19e64
movl $0x4, %r14d
cmpl $0x3, 0x14(%rbx)
jne 0x19f22
testb $0x40, 0xcf(%rbx)
jne 0x19f22
orb $0x40, 0xcd(%rbx)
jmp 0x19f22
cmpl $0x3, %eax
ja 0x19f0b
movq %rbx, %rdi
callq 0x19e64
movl $0x5, %r14d
testl $0xfffffffd, 0x14(%rbx) # imm = 0xFFFFFFFD
jne 0x19f22
movq %rbx, %rdi
callq 0x19e24
movl 0x14(%rbx), %eax
incl %eax
xorl %ecx, %ecx
cmpl %r14d, %eax
cmovnel %eax, %ecx
movl %ecx, 0x14(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::tick()
void Apu::tick() {
  // Divider logic for frame
  if (frameDivider == 0) {
    stepAdvance();
  }
  frameDivider = (frameDivider + 1) % frameCycles;

  // Divider logic for timers
  stepFastTimers();
  if (halfTimerDivider == 0) {
    stepSlowTimers();
  }
  halfTimerDivider = !halfTimerDivider;

  // Compute output each cycle
  sampleOffset += 1;
  float sample =
      95.88f /
      ((8128.0f / (float(pulseA->getCurrentSample() + pulseB->getCurrentSample()))) + 100.0f);
  sample += 159.79f / (100.0f + (1.0f / ((float(triangle->getCurrentSample()) / 8227.0f) +
                                         float(noise->getCurrentSample()) / 12241.0f)));
  samples[sampleOffset % sampleBufferSize] = sample;

  // Determine when to sample, and sample if needed.
  nextSampleCountdown--;
  if (!nextSampleCountdown) {
    float prevSampleClk = currentSampleClk;
    currentSampleClk += clksPerSample;
    nextSampleCountdown = (uint32_t)currentSampleClk - (uint32_t)prevSampleClk;
    if (currentSampleClk >= float(cpuClk)) {
      currentSampleClk = 0.0f;
    }
    generateSample();
  }

  /*
  if (samplerDivider == 0) {
  }
  samplerDivider = (samplerDivider + 1) % uint32_t(cpuClk/ sampleRate);
  */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x0, 0x10(%rdi)
jne 0x1a156
movq %rbx, %rdi
callq 0x19eb6
movl 0x10(%rbx), %eax
movl %eax, %ecx
incl %ecx
movl $0x8c9dc80b, %edx       # imm = 0x8C9DC80B
imulq %rcx, %rdx
shrq $0x2c, %rdx
imull $0x1d21, %edx, %ecx     # imm = 0x1D21
negl %ecx
addl %ecx, %eax
incl %eax
movl %eax, 0x10(%rbx)
movq 0xf8(%rbx), %rdi
callq 0x1b76e
cmpl $0x0, 0x18(%rbx)
jne 0x1a193
movq %rbx, %rdi
callq 0x19f4a
xorl %eax, %eax
cmpl $0x0, 0x18(%rbx)
sete %al
movl %eax, 0x18(%rbx)
incq 0xb0(%rbx)
movq 0xe8(%rbx), %rdi
callq 0x1b4ea
movzbl %al, %r14d
movq 0xf0(%rbx), %rdi
callq 0x1b4ea
movzbl %al, %eax
addl %r14d, %eax
cvtsi2ss %eax, %xmm0
movss 0x1ae40(%rip), %xmm1    # 0x35014
divss %xmm0, %xmm1
addss 0x1ae38(%rip), %xmm1    # 0x35018
movss 0x1ae34(%rip), %xmm0    # 0x3501c
movq 0xf8(%rbx), %rax
movzbl 0x2b(%rax), %eax
cvtsi2ss %eax, %xmm2
divss %xmm1, %xmm0
movss %xmm0, -0x18(%rbp)
movq 0x100(%rbx), %rdi
divss 0x1ae11(%rip), %xmm2    # 0x35020
movss %xmm2, -0x14(%rbp)
callq 0x1b814
movzbl %al, %eax
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
divss 0x1adf9(%rip), %xmm0    # 0x35024
addss -0x14(%rbp), %xmm0
movss 0x1adf0(%rip), %xmm1    # 0x35028
divss %xmm0, %xmm1
addss 0x1add4(%rip), %xmm1    # 0x35018
movss 0x1ade0(%rip), %xmm0    # 0x3502c
divss %xmm1, %xmm0
addss -0x18(%rbp), %xmm0
movl 0xb0(%rbx), %eax
andl $0x1f, %eax
movss %xmm0, 0x2c(%rbx,%rax,4)
decl 0x28(%rbx)
je 0x1a272
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movss 0x24(%rbx), %xmm0
movss 0x20(%rbx), %xmm1
addss %xmm0, %xmm1
cvttss2si %xmm1, %rax
movss %xmm1, 0x24(%rbx)
cvttss2si %xmm0, %rcx
subl %ecx, %eax
movl %eax, 0x28(%rbx)
ucomiss 0x1ad95(%rip), %xmm1    # 0x35030
jb 0x1a2a4
movl $0x0, 0x24(%rbx)
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x19f7e
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::writeReg(unsigned int, unsigned char)
void Apu::writeReg(uint32_t reg, uint8_t val) {
  regs[reg] = val;
  if (reg == SOFTCLOCK) {
    resetFrameCounter();
  } else if (reg == CONTROL_STATUS) {
    clearRequestDmcIrq();
    // xx what to do with the upper bits here
    if (~val & STATUS_CHANNEL1_LENGTH) {
      pulseA->zeroLength();
    }
    if (~val & STATUS_CHANNEL2_LENGTH) {
      pulseB->zeroLength();
    }
    if (~val & STATUS_CHANNEL3_LENGTH) {
      triangle->zeroLength();
    }
    if (~val & STATUS_CHANNEL4_LENGTH) {
      noise->zeroLength();
    }
  } else if (reg == CHANNEL1_LENGTH) {
    pulseA->resetLength();
    pulseA->resetSequencer();
    pulseA->resetEnvelope();
  } else if (reg == CHANNEL2_LENGTH) {
    pulseB->resetLength();
    pulseB->resetSequencer();
    pulseB->resetEnvelope();
  } else if (reg == CHANNEL3_LENGTH) {
    triangle->resetLength();
    triangle->setHaltFlag();
  } else if (reg == CHANNEL4_LENGTH) {
    noise->resetLength();
    noise->resetEnvelope();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, %eax
movb %dl, 0xb8(%rdi,%rax)
addl $-0x3, %esi
rorl %esi
cmpl $0xa, %esi
ja 0x1a3e4
leaq 0x1ad3c(%rip), %rax     # 0x35034
movslq (%rax,%rsi,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq 0xe8(%rdi), %rax
jmp 0x1a354
movq 0xf8(%rdi), %rax
movq 0x20(%rax), %rcx
movzbl 0x3(%rcx), %ecx
shrl $0x3, %ecx
leaq 0x1ad3d(%rip), %rdx     # 0x35060
movb (%rcx,%rdx), %cl
movb %cl, 0x28(%rax)
movb $0x1, 0x29(%rax)
jmp 0x1a3e4
movq $0x0, 0x10(%rdi)
cmpb $0x0, 0xcf(%rdi)
jns 0x1a3e4
popq %rbp
jmp 0x19eb6
movq 0xf0(%rdi), %rax
movq 0x8(%rax), %rcx
movzbl 0x3(%rcx), %ecx
shrl $0x3, %ecx
leaq 0x1acfa(%rip), %rdx     # 0x35060
movb (%rcx,%rdx), %cl
movb %cl, 0x11(%rax)
movl $0x0, 0x1c(%rax)
movb $0x1, 0x14(%rax)
jmp 0x1a3e4
movq 0x100(%rdi), %rax
movq (%rax), %rcx
movzbl 0x3(%rcx), %ecx
shrl $0x3, %ecx
leaq 0x1accf(%rip), %rdx     # 0x35060
movb (%rcx,%rdx), %cl
movb %cl, 0x8(%rax)
movb $0x1, 0xe(%rax)
jmp 0x1a3e4
andb $0x7f, 0xcd(%rdi)
testb $0x1, %dl
jne 0x1a3b4
movq 0xe8(%rdi), %rax
movb $0x0, 0x11(%rax)
testb $0x2, %dl
jne 0x1a3c4
movq 0xf0(%rdi), %rax
movb $0x0, 0x11(%rax)
testb $0x4, %dl
jne 0x1a3d4
movq 0xf8(%rdi), %rax
movb $0x0, 0x28(%rax)
testb $0x8, %dl
jne 0x1a3e4
movq 0x100(%rdi), %rax
movb $0x0, 0x8(%rax)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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:
movl %esi, %eax
movb 0xb8(%rdi,%rax), %al
cmpl $0x15, %esi
jne 0x1a44a
pushq %rbp
movq %rsp, %rbp
andb $-0x41, 0xcd(%rdi)
andb $-0x40, %al
movq 0xe8(%rdi), %rcx
movq 0xf0(%rdi), %rdx
cmpb $0x0, 0x11(%rcx)
setne %cl
orb %al, %cl
cmpb $0x0, 0x11(%rdx)
setne %al
addb %al, %al
orb %cl, %al
movq 0xf8(%rdi), %rcx
cmpb $0x0, 0x28(%rcx)
setne %cl
shlb $0x2, %cl
orb %al, %cl
movq 0x100(%rdi), %rax
cmpb $0x0, 0x8(%rax)
setne %al
shlb $0x3, %al
orb %cl, %al
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apu.cpp
// Function: Rnes::Apu::restore(Rnes::ApuState const&)
void Apu::restore(const ApuState &pb) {
  // Restore sub-units.
  pulseA->restore(pb.pulsea());
  pulseB->restore(pb.pulseb());
  triangle->restore(pb.triangle());
  noise->restore(pb.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 (int i = 0; i < pb.reg_size(); i++) {
    regs[i] = pb.reg(i);
  }

  sampleRate = pb.samplerate();
  fourFrameCount = pb.fourframecount();
  fiveFrameCount = pb.fiveframecount();
  frameDivider = pb.framedivider();
  step = pb.step();
  halfTimerDivider = pb.halftimerdivider();
  samplerDivider = pb.samplerdivider();
  clksPerSample = pb.clkspersample();
  currentSampleClk = pb.currentsampleclk();
  nextSampleCountdown = pb.nextsamplecountdown();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq 0xe8(%rdi), %rdi
movq 0x28(%rsi), %rsi
testq %rsi, %rsi
leaq 0x2e196(%rip), %r15     # 0x48840
cmoveq %r15, %rsi
callq 0x1b4ae
movq 0xf0(%rbx), %rdi
movq 0x30(%r14), %rsi
testq %rsi, %rsi
cmoveq %r15, %rsi
callq 0x1b4ae
movq 0xf8(%rbx), %rdi
movq 0x38(%r14), %rsi
testq %rsi, %rsi
jne 0x1a6e1
leaq 0x2e197(%rip), %rsi     # 0x48878
callq 0x1b6e0
movq 0x100(%rbx), %rdi
movq 0x40(%r14), %rsi
testq %rsi, %rsi
jne 0x1a6fd
leaq 0x2e1ab(%rip), %rsi     # 0x488a8
callq 0x1b8aa
cmpl $0x0, 0x18(%r14)
jle 0x1a730
leaq 0x18(%r14), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0xb720
movb (%rax), %al
movb %al, 0xb8(%rbx,%r12)
incq %r12
movslq (%r15), %rax
cmpq %rax, %r12
jl 0x1a710
movl 0x48(%r14), %eax
movl %eax, 0xd0(%rbx)
movl 0x4c(%r14), %eax
movq %rax, 0xd8(%rbx)
movl 0x50(%r14), %eax
movq %rax, 0xe0(%rbx)
movl 0x54(%r14), %eax
movl %eax, 0x10(%rbx)
movl 0x58(%r14), %eax
movl %eax, 0x14(%rbx)
movl 0x5c(%r14), %eax
movl %eax, 0x18(%rbx)
movl 0x60(%r14), %eax
movl %eax, 0x1c(%rbx)
movss 0x64(%r14), %xmm0
movss %xmm0, 0x20(%rbx)
movss 0x68(%r14), %xmm0
movss %xmm0, 0x24(%rbx)
movl 0x6c(%r14), %eax
movl %eax, 0x28(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edx, %r15d
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x30(%rdi), %rax
leaq -0x40(%rbp), %r12
movq %rax, (%r12)
movb $0x0, 0x8(%r12)
movq %r12, %rdi
callq 0x1ae82
movb $0x1, 0x8(%r12)
movl %r15d, -0x2c(%rbp)
movl %r15d, %r15d
movq 0x20(%rbx), %rax
addq %r15, %rax
cmpq 0x28(%rbx), %rax
jbe 0x1ac2b
movq 0x20(%rbx), %rax
addq %r15, %rax
cmpq 0x28(%rbx), %rax
jbe 0x1ac2b
leaq 0x58(%rbx), %r12
leaq -0x40(%rbp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xb4c0
movq 0x20(%rbx), %rax
addq %r15, %rax
cmpq 0x28(%rbx), %rax
ja 0x1ac13
cmpl $0x0, -0x2c(%rbp)
je 0x1ac56
movl 0x18(%rbx), %eax
decl %eax
movq (%rbx), %rcx
xorl %edx, %edx
movq 0x20(%rbx), %rsi
andl %eax, %esi
movzwl (%rcx,%rsi,2), %esi
movw %si, (%r14,%rdx,2)
incq 0x20(%rbx)
incq %rdx
cmpq %rdx, %r15
jne 0x1ac3b
leaq -0x40(%rbp), %rdi
callq 0x1ae68
addq $0x88, %rbx
movq %rbx, %rdi
callq 0xb460
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl %edx, -0x1c(%rbp)
leaq 0x30(%rdi), %rax
leaq -0x30(%rbp), %r15
movq %rax, (%r15)
movb $0x0, 0x8(%r15)
movq %r15, %rdi
callq 0x1ae82
movb $0x1, 0x8(%r15)
movl -0x1c(%rbp), %eax
addq 0x28(%rbx), %rax
subq 0x20(%rbx), %rax
movl 0x18(%rbx), %ecx
cmpq %rcx, %rax
jbe 0x1acdb
leaq 0x88(%rbx), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x1c(%rbp), %rcx
movq %rbx, %rdx
callq 0x1b03a
movl -0x1c(%rbp), %eax
testq %rax, %rax
je 0x1ad0a
movl 0x18(%rbx), %ecx
decl %ecx
movq (%rbx), %rdx
xorl %esi, %esi
movzwl (%r14,%rsi,2), %edi
movq 0x28(%rbx), %r8
andl %ecx, %r8d
movw %di, (%rdx,%r8,2)
incq 0x28(%rbx)
incq %rsi
cmpq %rsi, %rax
jne 0x1aced
leaq -0x30(%rbp), %rdi
callq 0x1ae68
addq $0x58, %rbx
movq %rbx, %rdi
callq 0xb460
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x1ae68
movq %rbx, %rdi
callq 0xb4d0
// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x8(%rdi), %rax
movzbl 0x2(%rax), %ecx
movzbl 0x3(%rax), %edx
andl $0x7, %edx
shll $0x8, %edx
leal (%rcx,%rdx), %esi
incl %esi
movl %ecx, %r8d
orl %edx, %r8d
movb 0x1(%rax), %al
movl %eax, %ecx
andb $0x7, %cl
shrl %cl, %esi
movzbl 0x10(%rdi), %ecx
xorl $0x1, %ecx
subl %esi, %ecx
testb $0x8, %al
cmovel %esi, %ecx
leal 0x1(%rcx,%r8), %eax
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x8(%rdi), %rax
movzbl 0x2(%rax), %edx
movzbl 0x3(%rax), %esi
andl $0x7, %esi
shll $0x8, %esi
leal (%rdx,%rsi), %r8d
incl %r8d
movb 0x1(%rax), %r9b
movl %r9d, %ecx
andb $0x7, %cl
movl %r8d, %r10d
shrl %cl, %r10d
movzbl 0x10(%rdi), %ecx
xorl $0x1, %ecx
subl %r10d, %ecx
testb $0x8, %r9b
cmovel %r10d, %ecx
cmpw $0x8, %r8w
jb 0x1b3dc
orl %esi, %edx
addl %edx, %ecx
incl %ecx
movzwl %cx, %edx
cmpl $0x7ff, %edx            # imm = 0x7FF
ja 0x1b3dc
movb %cl, 0x2(%rax)
movq 0x8(%rdi), %rax
movb 0x3(%rax), %dl
andb $-0x8, %dl
shrl $0x8, %ecx
orb %dl, %cl
movb %cl, 0x3(%rax)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x8(%rdi), %rax
movb (%rax), %al
movl %eax, %ecx
andb $0xf, %cl
testb $0x10, %al
movzbl 0x12(%rdi), %edx
movzbl %cl, %eax
cmovel %edx, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movb 0x12(%rdi), %al
testb %al, %al
je 0x1b40b
decb %al
jmp 0x1b416
movq 0x8(%rdi), %rcx
movb $0xf, %al
testb $0x20, (%rcx)
je 0x1b419
movb %al, 0x12(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
movzbl 0x11(%rdi), %ecx
movl 0x10(%rsi), %eax
movl %eax, %edx
orl $0x1, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x18(%rsi)
movzbl 0x12(%rdi), %ecx
movl %eax, %edx
orl $0x3, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x1c(%rsi)
movzbl 0x13(%rdi), %ecx
movl %eax, %edx
orl $0x7, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x20(%rsi)
movb 0x14(%rdi), %cl
movl %eax, %edx
orl $0x17, %edx
movl %edx, 0x10(%rsi)
movb %cl, 0x25(%rsi)
movb 0x15(%rdi), %cl
movl %eax, %edx
orl $0x37, %edx
movl %edx, 0x10(%rsi)
movb %cl, 0x26(%rsi)
movzbl 0x16(%rdi), %ecx
movl %eax, %edx
orl $0x77, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x28(%rsi)
movzbl 0x17(%rdi), %ecx
movl %eax, %edx
orl $0xf7, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x2c(%rsi)
movl 0x18(%rdi), %ecx
movl %eax, %edx
orl $0x1f7, %edx            # imm = 0x1F7
movl %edx, 0x10(%rsi)
movl %ecx, 0x30(%rsi)
movl 0x1c(%rdi), %ecx
orl $0x3f7, %eax            # imm = 0x3F7
movl %eax, 0x10(%rsi)
movl %ecx, 0x34(%rsi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movb 0x18(%rsi), %al
movb %al, 0x11(%rdi)
movb 0x1c(%rsi), %al
movb %al, 0x12(%rdi)
movb 0x20(%rsi), %al
movb %al, 0x13(%rdi)
movb 0x25(%rsi), %al
movb %al, 0x14(%rdi)
movb 0x26(%rsi), %al
movb %al, 0x15(%rdi)
movb 0x28(%rsi), %al
movb %al, 0x16(%rdi)
movb 0x2c(%rsi), %al
movb %al, 0x17(%rdi)
movl 0x30(%rsi), %eax
movl %eax, 0x18(%rdi)
movl 0x34(%rsi), %eax
movl %eax, 0x1c(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
movq 0x8(%rdi), %rdx
movzbl 0x2(%rdx), %eax
movzbl 0x3(%rdx), %ecx
andl $0x7, %ecx
shll $0x8, %ecx
addl %ecx, %eax
incl %eax
cmpw $0x8, %ax
jb 0x1b53a
movb 0x1(%rdx), %sil
movl %esi, %ecx
andb $0x7, %cl
movl %eax, %r8d
shrl %cl, %r8d
movzbl 0x10(%rdi), %ecx
xorl $0x1, %ecx
subl %r8d, %ecx
testb $0x8, %sil
cmovel %r8d, %ecx
movzwl %ax, %eax
addl %ecx, %eax
movzwl %ax, %eax
cmpl $0x7ff, %eax            # imm = 0x7FF
jbe 0x1b53e
xorl %eax, %eax
popq %rbp
retq
xorl %eax, %eax
cmpb $0x0, 0x11(%rdi)
je 0x1b53c
cmpb $0x0, 0x17(%rdi)
je 0x1b53c
movb (%rdx), %al
movl %eax, %ecx
andb $0xf, %cl
testb $0x10, %al
movzbl 0x12(%rdi), %edx
movzbl %cl, %eax
cmovel %edx, %eax
jmp 0x1b53c
nop
// File: /workspace/github_cpp_makefile_star2_O1/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
cmpb $0x1, 0x14(%rdi)
jne 0x1b583
movb $0xf, 0x12(%rdi)
movq 0x8(%rdi), %rax
movb (%rax), %al
andb $0xf, %al
incb %al
movb %al, 0x13(%rdi)
movb $0x0, 0x14(%rdi)
jmp 0x1b5b4
movb 0x13(%rdi), %al
testb %al, %al
je 0x1b58e
decb %al
jmp 0x1b5b1
movb 0x12(%rdi), %al
testb %al, %al
je 0x1b599
decb %al
jmp 0x1b5a4
movq 0x8(%rdi), %rcx
movb $0xf, %al
testb $0x20, (%rcx)
je 0x1b5a7
movb %al, 0x12(%rdi)
movq 0x8(%rdi), %rax
movb (%rax), %al
andb $0xf, %al
incb %al
movb %al, 0x13(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Pulse::clockLengthAndSweep()
void Pulse::clockLengthAndSweep() {
  // Length
  if (!isHalted() and lengthCounter) {
    lengthCounter--;
  }
  // Sweep
  if (resetSweepDivider) {
    sweepDivider = getSweepP() + 1;
    resetSweepDivider = false;
  } else {
    if (sweepDivider) {
      sweepDivider--;
    } else {
      if (isSweepEnabled()) {
        sweepDivider = getSweepP() + 1;
        sweepPeriod();
      }
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq 0x8(%rdi), %rax
testb $0x20, (%rax)
jne 0x1b5cf
movb 0x11(%rdi), %cl
testb %cl, %cl
je 0x1b5cf
decb %cl
movb %cl, 0x11(%rdi)
cmpb $0x1, 0x15(%rdi)
jne 0x1b5e8
movb 0x1(%rax), %al
shrb $0x4, %al
andb $0x7, %al
incb %al
movb %al, 0x16(%rdi)
movb $0x0, 0x15(%rdi)
jmp 0x1b5fd
movb 0x16(%rdi), %cl
testb %cl, %cl
je 0x1b5f6
decb %cl
movb %cl, 0x16(%rdi)
jmp 0x1b5fd
movb 0x1(%rax), %al
testb %al, %al
js 0x1b5ff
popq %rbp
retq
shrb $0x4, %al
andb $0x7, %al
incb %al
movb %al, 0x16(%rdi)
popq %rbp
jmp 0x1b370
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Triangle::save(Rnes::TriangleState&)
void Triangle::save(TriangleState &pb) {
  // length logic
  pb.set_lengthcounter(lengthCounter);

  // linear counter logic
  pb.set_linearcounterhalt(linearCounterHalt);
  pb.set_linearcounter(linearCounter);

  // current sample
  pb.set_currentsample(currentSample);

  // timer
  pb.set_timerdivider(timerDivider);

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl 0x28(%rdi), %eax
movl 0x10(%rsi), %ecx
movl %ecx, %edx
orl $0x1, %edx
movl %edx, 0x10(%rsi)
movl %eax, 0x18(%rsi)
movb 0x29(%rdi), %al
movl %ecx, %edx
orl $0x3, %edx
movl %edx, 0x10(%rsi)
movb %al, 0x1c(%rsi)
movzbl 0x2a(%rdi), %eax
movl %ecx, %edx
orl $0x7, %edx
movl %edx, 0x10(%rsi)
movl %eax, 0x20(%rsi)
movzbl 0x2b(%rdi), %eax
movl %ecx, %edx
orl $0xf, %edx
movl %edx, 0x10(%rsi)
movl %eax, 0x24(%rsi)
movl 0x2c(%rdi), %eax
movl %ecx, %edx
orl $0x1f, %edx
movl %edx, 0x10(%rsi)
movl %eax, 0x28(%rsi)
movl 0x30(%rdi), %eax
orl $0x3f, %ecx
movl %ecx, 0x10(%rsi)
movl %eax, 0x2c(%rsi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Triangle::restore(Rnes::TriangleState const&)
void Triangle::restore(const TriangleState &pb) {
  lengthCounter = pb.lengthcounter();
  linearCounterHalt = pb.linearcounterhalt();
  linearCounter = pb.linearcounter();

  currentSample = pb.currentsample();
  timerDivider = pb.timerdivider();

  sequencerOffset = pb.sequenceroffset();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x18(%rsi), %al
movb %al, 0x28(%rdi)
movb 0x1c(%rsi), %al
movb %al, 0x29(%rdi)
movb 0x20(%rsi), %al
movb %al, 0x2a(%rdi)
movb 0x24(%rsi), %al
movb %al, 0x2b(%rdi)
movl 0x28(%rsi), %eax
movl %eax, 0x2c(%rdi)
movl 0x2c(%rsi), %eax
movl %eax, 0x30(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Triangle::clockLinearCounter()
void Triangle::clockLinearCounter() {
  if (linearCounterHalt) {
    linearCounter = getLinearCounterReload();
  } else if (linearCounter) {
    linearCounter--;
  }
  if (!getControlFlag()) {
    linearCounterHalt = false;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x1, 0x29(%rdi)
jne 0x1b73a
movq 0x20(%rdi), %rax
movb (%rax), %al
andb $0x7f, %al
jmp 0x1b743
movb 0x2a(%rdi), %al
testb %al, %al
je 0x1b746
decb %al
movb %al, 0x2a(%rdi)
movq 0x20(%rdi), %rax
cmpb $0x0, (%rax)
js 0x1b753
movb $0x0, 0x29(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::getNextShiftReg(unsigned short) const
uint16_t Noise::getNextShiftReg(uint16_t reg) const {
  uint16_t newBit = 0;
  if (isShortMode()) {
    newBit = (0x1 & ((reg) ^ (reg >> 6))) << 14;
  } else {
    newBit = (0x1 & ((reg) ^ (reg >> 1))) << 14;
  }
  return newBit | (reg >> 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rcx
movl %esi, %eax
shrl $0x6, %eax
movl %esi, %edx
shrl %edx
cmpb $0x0, 0x2(%rcx)
cmovnsl %edx, %eax
xorl %esi, %eax
andl $0x1, %eax
shll $0xe, %eax
orl %edx, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::getVolume() const
uint8_t Noise::getVolume() const {
  if (isDisabled()) {
    return getEnvelopeN();
  } else {
    return envelope;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movb (%rax), %al
testb $0x10, %al
jne 0x1b7ee
movl 0xc(%rdi), %eax
jmp 0x1b7f3
andb $0xf, %al
movzbl %al, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::envelopeDividerClock()
void Noise::envelopeDividerClock() {
  if (envelope) {
    envelope--;
  } else if (isEnvelopeLoopSet()) {
    envelope = 15;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0xc(%rdi), %al
testb %al, %al
je 0x1b805
decb %al
jmp 0x1b80f
movq (%rdi), %rcx
movb $0xf, %al
testb $0x20, (%rcx)
je 0x1b812
movb %al, 0xc(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::getCurrentSample() const
uint8_t Noise::getCurrentSample() const {
  if (!currentSample) {
    return 0;
  }
  if (!isNonZeroLength()) {
    return 0;
  }
  return getVolume();
}

// Assembly:
xorl %eax, %eax
cmpb $0x0, 0xf(%rdi)
je 0x1b83a
cmpb $0x0, 0x8(%rdi)
je 0x1b83a
pushq %rbp
movq %rsp, %rbp
movq (%rdi), %rax
movb (%rax), %al
testb $0x10, %al
jne 0x1b834
movl 0xc(%rdi), %eax
jmp 0x1b839
andb $0xf, %al
movzbl %al, %eax
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::save(Rnes::NoiseState&)
void Noise::save(NoiseState &pb) {
  // length logic
  pb.set_lengthcounter(lengthCounter);

  // noise shift register
  pb.set_shiftregister(shiftRegister);

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

  // current sample
  pb.set_currentsample(currentSample);

  // timer
  pb.set_timerdivider(timerDivider);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl 0x8(%rdi), %ecx
movl 0x10(%rsi), %eax
movl %eax, %edx
orl $0x1, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x18(%rsi)
movzwl 0xa(%rdi), %ecx
movl %eax, %edx
orl $0x3, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x1c(%rsi)
movzbl 0xc(%rdi), %ecx
movl %eax, %edx
orl $0x7, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x20(%rsi)
movzbl 0xd(%rdi), %ecx
movl %eax, %edx
orl $0xf, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x24(%rsi)
movb 0xe(%rdi), %cl
movl %eax, %edx
orl $0x1f, %edx
movl %edx, 0x10(%rsi)
movb %cl, 0x28(%rsi)
movzbl 0xf(%rdi), %ecx
movl %eax, %edx
orl $0x3f, %edx
movl %edx, 0x10(%rsi)
movl %ecx, 0x2c(%rsi)
movl 0x10(%rdi), %ecx
orl $0x7f, %eax
movl %eax, 0x10(%rsi)
movl %ecx, 0x30(%rsi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/apuunit.cpp
// Function: Rnes::Noise::restore(Rnes::NoiseState const&)
void Noise::restore(const NoiseState &pb) {
  lengthCounter = pb.lengthcounter();
  shiftRegister = pb.shiftregister();
  envelope = pb.envelope();
  envelopeDivider = pb.envelopedivider();
  resetEnvelopeAndDivider = pb.resetenvelopeanddivider();
  currentSample = pb.currentsample();
  timerDivider = pb.timerdivider();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x18(%rsi), %al
movb %al, 0x8(%rdi)
movzwl 0x1c(%rsi), %eax
movw %ax, 0xa(%rdi)
movb 0x20(%rsi), %al
movb %al, 0xc(%rdi)
movb 0x24(%rsi), %al
movb %al, 0xd(%rdi)
movb 0x28(%rsi), %al
movb %al, 0xe(%rdi)
movb 0x2c(%rsi), %al
movb %al, 0xf(%rdi)
movl 0x30(%rsi), %eax
movl %eax, 0x10(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::setZeroAndNeg(unsigned char)
void Cpu::setZeroAndNeg(uint8_t val) {
  if (val == 0) {
    setFlag(ZERO);
  } else {
    clearFlag(ZERO);
  }
  if (val & (1 << 7)) {
    setFlag(NEGATIVE);
  } else {
    clearFlag(NEGATIVE);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testl %esi, %esi
sete %al
movb 0x18(%rdi), %cl
andb $0x7d, %cl
addb %al, %al
orb %cl, %al
andb $-0x80, %sil
orb %al, %sil
movb %sil, 0x18(%rdi)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::doInt()
uint32_t Cpu::doInt() {
  pushStack((uint8_t)(pc >> 8));
  pushStack((uint8_t)pc);
  pushStack(status);
  setFlag(INT_DISABLE);
  pc = load(irqBaseAddr) | ((uint16_t)load(irqBaseAddr + 1) << 8);
  cycle += 7;
  return 7;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movzbl 0xd(%rdi), %edx
movzbl 0xe(%rdi), %esi
movl $0x100, %r14d           # imm = 0x100
orl %r14d, %esi
movq (%rdi), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0xc(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0x18(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
callq 0x215d0
decb 0xe(%rbx)
orb $0x4, 0x18(%rbx)
movq (%rbx), %rdi
movl $0xfffe, %esi           # imm = 0xFFFE
callq 0x216a8
movzbl %al, %r14d
movq (%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x216a8
movzbl %al, %eax
shll $0x8, %eax
orl %r14d, %eax
movw %ax, 0xc(%rbx)
addq $0x7, 0x10(%rbx)
movl $0x7, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::doNmi()
uint32_t Cpu::doNmi() {
  pushStack((uint8_t)(pc >> 8));
  pushStack((uint8_t)pc);
  pushStack(status);
  setFlag(INT_DISABLE);
  pc = load(nmiBaseAddr) | ((uint16_t)load(nmiBaseAddr + 1) << 8);
  cycle += 7;
  return 7;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movzbl 0xd(%rdi), %edx
movzbl 0xe(%rdi), %esi
movl $0x100, %r14d           # imm = 0x100
orl %r14d, %esi
movq (%rdi), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0xc(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0x18(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
callq 0x215d0
decb 0xe(%rbx)
orb $0x4, 0x18(%rbx)
movq (%rbx), %rdi
movl $0xfffa, %esi           # imm = 0xFFFA
callq 0x216a8
movzbl %al, %r14d
movq (%rbx), %rdi
movl $0xfffb, %esi           # imm = 0xFFFB
callq 0x216a8
movzbl %al, %eax
shll $0x8, %eax
orl %r14d, %eax
movw %ax, 0xc(%rbx)
addq $0x7, 0x10(%rbx)
movl $0x7, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::adcInst(unsigned short)
void Cpu::adcInst(uint16_t addr) {
  uint8_t v = load(addr);
  uint16_t result = a + v + (getFlag(CARRY) ? 1 : 0);
  if (result & (1u << 8)) {
    setFlag(CARRY);
  } else {
    clearFlag(CARRY);
  }
  if (isNeg((uint8_t)result) && isPos(a) && isPos(v)) {
    setFlag(OVERFL);
  } else if (isPos((uint8_t)result) && isNeg((a) && isNeg(v))) {
    setFlag(OVERFL);
  } else {
    clearFlag(OVERFL);
  }
  a = (uint8_t)result;
  setZeroAndNeg(a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x216a8
movzbl 0x8(%rbx), %ecx
movzbl %al, %edx
movzbl 0x18(%rbx), %esi
movl %esi, %eax
andl $0x1, %eax
addl %ecx, %eax
addl %edx, %eax
andb $-0x2, %sil
movl %eax, %edi
shrl $0x8, %edi
andb $0x1, %dil
orb %sil, %dil
movl %edi, %esi
andb $0x3d, %sil
orb $0x40, %dil
testb %al, %al
movzbl %dil, %edi
movzbl %sil, %esi
cmovnsl %esi, %edi
sete %r8b
orb %cl, %dl
cmovsl %esi, %edi
movb %al, 0x8(%rbx)
andb $0x7d, %dil
addb %r8b, %r8b
orb %dil, %r8b
andb $-0x80, %al
orb %r8b, %al
movb %al, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::aslInstMem(unsigned short)
void Cpu::aslInstMem(uint16_t addr) {
  uint8_t src = load(addr);
  uint8_t result = src << 1;
  store(addr, result);
  setZeroAndNeg(result);
  if (src & (1 << 7)) {
    setFlag(CARRY);
  } else {
    clearFlag(CARRY);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r15d
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x216a8
movl %eax, %r14d
leal (%r14,%r14), %eax
movq (%rbx), %rdi
movzbl %al, %r12d
movl %r15d, %esi
movl %r12d, %edx
callq 0x215d0
testb %r12b, %r12b
sete %al
movb 0x18(%rbx), %cl
andb $0x7c, %cl
addb %al, %al
orb %cl, %al
andb $-0x80, %r12b
orb %al, %r12b
shrb $0x7, %r14b
orb %r12b, %r14b
movb %r14b, 0x18(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::aslInstReg(unsigned short)
void Cpu::aslInstReg(uint16_t addr) {
  if (a & (1 << 7)) {
    setFlag(CARRY);
  } else {
    clearFlag(CARRY);
  }

  a <<= 1;
  setZeroAndNeg(a);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movb 0x8(%rdi), %al
movb 0x18(%rdi), %cl
andb $0x7c, %cl
movl %eax, %edx
shrb $0x7, %dl
orb %cl, %dl
addb %al, %al
movb %al, 0x8(%rdi)
sete %cl
addb %cl, %cl
orb %dl, %cl
andb $-0x80, %al
orb %cl, %al
movb %al, 0x18(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::bitInst(unsigned short)
void Cpu::bitInst(uint16_t addr) {
  uint8_t v = load(addr);
  bool zero = (a & v) == 0;
  if (zero) {
    setFlag(ZERO);
  } else {
    clearFlag(ZERO);
  }
  if (v & (1 << 7)) {
    setFlag(NEGATIVE);
  } else {
    clearFlag(NEGATIVE);
  }
  if (v & (1 << 6)) {
    setFlag(OVERFL);
  } else {
    clearFlag(OVERFL);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
callq 0x216a8
testb %al, 0x8(%rbx)
sete %cl
movb 0x18(%rbx), %dl
andb $0x3d, %dl
addb %cl, %cl
orb %dl, %cl
andb $-0x40, %al
orb %cl, %al
movb %al, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::brkInst(unsigned short)
void Cpu::brkInst(uint16_t) {
  pc++;
  pushStack((uint8_t)(pc >> 8));
  pushStack((uint8_t)pc);
  pushStack(status | BREAK);

  pc = load(irqBaseAddr) | ((uint16_t)load(irqBaseAddr + 1) << 8);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0xc(%rdi), %eax
incl %eax
movw %ax, 0xc(%rdi)
movzbl %ah, %edx
movzbl 0xe(%rdi), %esi
movl $0x100, %r14d           # imm = 0x100
orl %r14d, %esi
movq (%rdi), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0xc(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
callq 0x215d0
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movzbl 0x18(%rbx), %edx
movzbl %al, %esi
orl %r14d, %esi
movq (%rbx), %rdi
orl $0x10, %edx
callq 0x215d0
decb 0xe(%rbx)
movq (%rbx), %rdi
movl $0xfffe, %esi           # imm = 0xFFFE
callq 0x216a8
movzbl %al, %r14d
movq (%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x216a8
movzbl %al, %eax
shll $0x8, %eax
orl %r14d, %eax
movw %ax, 0xc(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::cmp(unsigned short, unsigned char)
void Cpu::cmp(uint16_t addr, uint8_t val) {
  uint8_t v = load(addr);
  uint8_t result;
  result = val - v;
  setZeroAndNeg(result);
  if (val >= v) {
    setFlag(CARRY);
  } else {
    clearFlag(CARRY);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x216a8
movb 0x18(%r14), %cl
andb $0x7c, %cl
subb %al, %bl
sete %al
setae %dl
addb %al, %al
orb %cl, %al
andb $-0x80, %bl
orb %al, %bl
orb %dl, %bl
movb %bl, 0x18(%r14)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::jsrInst(unsigned short)
void Cpu::jsrInst(uint16_t addr) {
  uint16_t pcm = pc - 1;
  pushStack((uint8_t)(pcm >> 8));
  pushStack((uint8_t)pcm);
  pc = addr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r15d
movq %rdi, %r14
movl 0xc(%rdi), %ebx
decl %ebx
movzbl %bh, %edx
movzbl 0xe(%rdi), %esi
movl $0x100, %r12d           # imm = 0x100
orl %r12d, %esi
movq (%rdi), %rdi
callq 0x215d0
movb 0xe(%r14), %al
decb %al
movb %al, 0xe(%r14)
movzbl %al, %esi
orl %r12d, %esi
movq (%r14), %rdi
movzbl %bl, %edx
callq 0x215d0
decb 0xe(%r14)
movw %r15w, 0xc(%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::rtsInst(unsigned short)
void Cpu::rtsInst(uint16_t) {
  uint16_t newpc;
  newpc = popStack();
  newpc |= (uint16_t)popStack() << 8;
  newpc++;
  pc = newpc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0xe(%rdi), %al
incb %al
movb %al, 0xe(%rdi)
movzbl %al, %esi
movl $0x100, %r15d           # imm = 0x100
orl %r15d, %esi
movq (%rdi), %rdi
callq 0x216a8
movl %eax, %r14d
movb 0xe(%rbx), %al
incb %al
movb %al, 0xe(%rbx)
movzbl %al, %esi
orl %r15d, %esi
movq (%rbx), %rdi
callq 0x216a8
movzbl %al, %eax
shll $0x8, %eax
movzbl %r14b, %ecx
addl %ecx, %eax
incl %eax
movw %ax, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mindbeast[P]rnes/cpu.cpp
// Function: Rnes::Cpu::lsrInstMem(unsigned short)
void Cpu::lsrInstMem(uint16_t addr) {
  uint8_t t = load(addr);
  uint8_t result = t >> 1;
  setZeroAndNeg(result);
  if (t & 1) {
    setFlag(CARRY);
  } else {
    clearFlag(CARRY);
  }
  store(addr, result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
callq 0x216a8
cmpb $0x2, %al
setb %cl
movb 0x18(%r14), %dl
andb $0x7c, %dl
addb %cl, %cl
orb %dl, %cl
leal 0x1(%rcx), %edx
testb $0x1, %al
movzbl %cl, %ecx
movzbl %dl, %edx
cmovel %ecx, %edx
movb %dl, 0x18(%r14)
shrb %al
movq (%r14), %rdi
movzbl %al, %edx
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x215d0
nop