LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::Value::releasePayload()
void Value::releasePayload() {
  switch (type_) {
  case nullValue:
  case intValue:
  case uintValue:
  case realValue:
  case booleanValue:
    break;
  case stringValue:
    if (allocated_)
      releasePrefixedStringValue(value_.string_);
    break;
  case arrayValue:
  case objectValue:
    delete value_.map_;
    break;
  default:
    JSON_ASSERT_UNREACHABLE;
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movzwl 0x8(%rdi), %eax
cmpb $0x7, %al
ja 0xd432
movzbl %al, %ecx
movl $0x2f, %edx
btl %ecx, %edx
jae 0xd3f6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movl $0xc0, %edx
btl %ecx, %edx
jae 0xd41e
movq (%rdi), %rbx
testq %rbx, %rbx
je 0xd410
movq %rbx, %rdi
callq 0x15bf8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4320
btl $0x8, %eax
jae 0xd3ef
movq (%rdi), %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x4440
leaq 0xf60c(%rip), %rdi      # 0x1ca45
leaq 0xf1a2(%rip), %rsi      # 0x1c5e2
leaq 0xfaf5(%rip), %rcx      # 0x1cf3c
movl $0xdc8, %edx            # imm = 0xDC8
callq 0x4280
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::Value::isInt() const
bool Value::isInt() const {
  switch (type_) {
  case intValue:
#if defined(JSON_HAS_INT64)
    return value_.int_ >= minInt && value_.int_ <= maxInt;
#else
    return true;
#endif
  case uintValue:
    return value_.uint_ <= UInt(maxInt);
  case realValue:
    return value_.real_ >= minInt && value_.real_ <= maxInt &&
           IsIntegral(value_.real_);
  default:
    break;
  }
  return false;
}

// Assembly:
movzbl 0x8(%rdi), %eax
cmpl $0x3, %eax
je 0xda25
cmpl $0x2, %eax
je 0xda1a
cmpl $0x1, %eax
jne 0xda6b
movq (%rdi), %rax
movslq %eax, %rcx
cmpq %rax, %rcx
jmp 0xda21
movq (%rdi), %rax
shrq $0x1f, %rax
sete %al
retq
movsd (%rdi), %xmm0
xorl %eax, %eax
ucomisd 0xeacd(%rip), %xmm0     # 0x1c500
jb 0xda24
movsd 0xeacb(%rip), %xmm1     # 0x1c508
ucomisd %xmm0, %xmm1
jb 0xda24
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq -0x8(%rbp), %rdi
callq 0x45d0
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movq %xmm1, %rax
andl $0x1, %eax
addq $0x10, %rsp
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::Value::isUInt() const
bool Value::isUInt() const {
  switch (type_) {
  case intValue:
#if defined(JSON_HAS_INT64)
    return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
#else
    return value_.int_ >= 0;
#endif
  case uintValue:
#if defined(JSON_HAS_INT64)
    return value_.uint_ <= maxUInt;
#else
    return true;
#endif
  case realValue:
    return value_.real_ >= 0 && value_.real_ <= maxUInt &&
           IsIntegral(value_.real_);
  default:
    break;
  }
  return false;
}

// Assembly:
movzbl 0x8(%rdi), %eax
cmpl $0x3, %eax
je 0xdc47
cmpl $0x2, %eax
je 0xdc3f
cmpl $0x1, %eax
jne 0xdc8d
cmpl $0x0, 0x4(%rdi)
sete %al
retq
movsd (%rdi), %xmm0
xorl %eax, %eax
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0xdc46
movsd 0xe8b1(%rip), %xmm1     # 0x1c510
ucomisd %xmm0, %xmm1
jb 0xdc46
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
leaq -0x8(%rbp), %rdi
callq 0x45d0
xorpd %xmm1, %xmm1
cmpeqsd %xmm0, %xmm1
movq %xmm1, %rax
andl $0x1, %eax
addq $0x10, %rsp
popq %rbp
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::Value::removeMember(char const*, char const*, Json::Value*)
bool Value::removeMember(const char* key, const char* cend, Value* removed)
{
  if (type_ != objectValue) {
    return false;
  }
  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
  ObjectValues::iterator it = value_.map_->find(actualKey);
  if (it == value_.map_->end())
    return false;
  if (removed)
#if JSON_HAS_RVALUE_REFERENCES
    *removed = std::move(it->second);
#else
    *removed = it->second;
#endif
  value_.map_->erase(it);
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpb $0x7, 0x8(%rdi)
jne 0xf567
movq %rcx, %r15
movq %rdi, %r14
subl %esi, %edx
leaq -0x38(%rbp), %rax
movq %rsi, (%rax)
shll $0x2, %edx
movl %edx, 0x8(%rax)
movq (%rdi), %rdi
movq %rax, %rsi
callq 0x1785c
movq %rax, %r12
movq (%r14), %rdi
leaq 0x8(%rdi), %rax
cmpq %rax, %r12
setne %bl
je 0xf54c
testq %r15, %r15
je 0xf544
movq %r12, %rsi
addq $0x30, %rsi
leaq -0x60(%rbp), %r13
movq %r13, %rdi
callq 0xd2ce
movzwl 0x8(%r15), %eax
movzwl 0x8(%r13), %ecx
movl $0xfe00, %edx           # imm = 0xFE00
movl %eax, %esi
andl %edx, %esi
andl %ecx, %edx
movq (%r15), %rdi
movq (%r13), %r8
movq %r8, (%r15)
movq %rdi, (%r13)
movl $0x1ff, %edi            # imm = 0x1FF
andl %edi, %ecx
orl %esi, %ecx
movw %cx, 0x8(%r15)
andl %edi, %eax
orl %edx, %eax
movw %ax, 0x8(%r13)
movq 0x10(%r15), %rax
movq 0x10(%r13), %rcx
movq %rcx, 0x10(%r15)
movq %rax, 0x10(%r13)
movq 0x18(%r15), %rax
movq 0x18(%r13), %rcx
movq %rcx, 0x18(%r15)
movq %rax, 0x18(%r13)
movq 0x20(%r15), %rax
movq 0x20(%r13), %rcx
movq %rcx, 0x20(%r15)
movq %rax, 0x20(%r13)
movq %r13, %rdi
callq 0xd372
movq (%r14), %rdi
movq %r12, %rsi
callq 0x17548
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0xf569
movl -0x30(%rbp), %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xf569
callq 0x4440
jmp 0xf569
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0xf596
movl -0x30(%rbp), %eax
andl $0x3, %eax
cmpl $0x1, %eax
jne 0xf596
callq 0x4440
movq %rbx, %rdi
callq 0x45c0
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::writeString[abi:cxx11](Json::StreamWriter::Factory const&, Json::Value const&)
JSONCPP_STRING writeString(StreamWriter::Factory const& builder, Value const& root) {
  JSONCPP_OSTRINGSTREAM sout;
  StreamWriterPtr const writer(builder.newStreamWriter());
  writer->write(root, &sout);
  return sout.str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x178, %rsp            # imm = 0x178
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x190(%rbp), %rdi
callq 0x44b0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq %rax, %r14
movq (%rax), %rax
leaq -0x190(%rbp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq *0x10(%rax)
leaq -0x188(%rbp), %rsi
movq %rbx, %rdi
callq 0x4560
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq 0x182a6(%rip), %rsi     # 0x27fc0
leaq -0x190(%rbp), %rdi
callq 0x41d0
leaq -0x120(%rbp), %rdi
callq 0x4110
movq %rbx, %rax
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0xfd54
movq %rax, %rbx
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq 0x18265(%rip), %rsi     # 0x27fc0
leaq -0x190(%rbp), %rdi
callq 0x41d0
leaq -0x120(%rbp), %rdi
callq 0x4110
movq %rbx, %rdi
callq 0x45c0
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::StyledStreamWriter::write(std::ostream&, Json::Value const&)
void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
  document_ = &out;
  addChildValues_ = false;
  indentString_.clear();
  indented_ = true;
  writeCommentBeforeValue(root);
  if (!indented_) writeIndent();
  indented_ = true;
  writeValue(root);
  writeCommentAfterValueOnSameLine(root);
  *document_ << "\n";
  document_ = NULL; // Forget the stream, for safety.
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq %rsi, 0x18(%rdi)
andb $-0x2, 0x68(%rdi)
movq %rdx, %r14
movq $0x0, 0x28(%rdi)
movq 0x20(%rdi), %rax
movb $0x0, (%rax)
orb $0x2, 0x68(%rdi)
movq %rdx, %rsi
callq 0x11d3a
movb 0x68(%rbx), %al
testb $0x2, %al
jne 0x11cfc
movq %rbx, %rdi
callq 0x11e32
movb 0x68(%rbx), %al
orb $0x2, %al
movb %al, 0x68(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x11e68
movq %rbx, %rdi
movq %r14, %rsi
callq 0x122a0
movq 0x18(%rbx), %rdi
leaq 0xc977(%rip), %rsi      # 0x1e699
movl $0x1, %edx
callq 0x4400
movq $0x0, 0x18(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::BuiltStyledStreamWriter::write(Json::Value const&, std::ostream*)
int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
{
  sout_ = sout;
  addChildValues_ = false;
  indented_ = true;
  indentString_.clear();
  writeCommentBeforeValue(root);
  if (!indented_) writeIndent();
  indented_ = true;
  writeValue(root);
  writeCommentAfterValueOnSameLine(root);
  *sout_ << endingLineFeedSymbol_;
  sout_ = NULL;
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rdx, 0x8(%rdi)
movb 0xd8(%rdi), %al
andb $-0x4, %al
orb $0x2, %al
movb %al, 0xd8(%rdi)
movq $0x0, 0x30(%rdi)
movq 0x28(%rdi), %rax
movb $0x0, (%rax)
callq 0x12a90
movb 0xd8(%rbx), %al
testb $0x2, %al
jne 0x12a4b
movq %rbx, %rdi
callq 0x12b98
movb 0xd8(%rbx), %al
orb $0x2, %al
movb %al, 0xd8(%rbx)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12bd4
movq %rbx, %rdi
movq %r14, %rsi
callq 0x12ff0
movq 0x8(%rbx), %rdi
movq 0xb8(%rbx), %rsi
movq 0xc0(%rbx), %rdx
callq 0x4400
movq $0x0, 0x8(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::BuiltStyledStreamWriter::writeCommentBeforeValue(Json::Value const&)
void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
  if (cs_ == CommentStyle::None) return;
  if (!root.hasComment(commentBefore))
    return;

  if (!indented_) writeIndent();
  const JSONCPP_STRING& comment = root.getComment(commentBefore);
  JSONCPP_STRING::const_iterator iter = comment.begin();
  while (iter != comment.end()) {
    *sout_ << *iter;
    if (*iter == '\n' &&
       ((iter+1) != comment.end() && *(iter + 1) == '/'))
      // writeIndent();  // would write extra newline
      *sout_ << indentString_;
    ++iter;
  }
  indented_ = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
cmpl $0x0, 0x70(%rdi)
je 0x12b6e
movq %rsi, %r14
movq 0x10(%rsi), %rax
testq %rax, %rax
je 0x12b6e
cmpq $0x0, (%rax)
je 0x12b6e
movq %rdi, %rbx
testb $0x2, 0xd8(%rdi)
jne 0x12ad7
movq %rbx, %rdi
callq 0x12b98
leaq -0x48(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0xfb56
movq (%r15), %r12
cmpq $0x0, 0x8(%r15)
je 0x12b56
leaq -0x21(%rbp), %r14
movq 0x8(%rbx), %rdi
movb (%r12), %al
movb %al, -0x21(%rbp)
movl $0x1, %edx
movq %r14, %rsi
callq 0x4400
cmpb $0xa, (%r12)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
jne 0x12b49
leaq 0x1(%r12), %rcx
leaq (%rdi,%rax), %rdx
cmpq %rdx, %rcx
je 0x12b49
cmpb $0x2f, (%rcx)
jne 0x12b49
movq 0x8(%rbx), %rdi
movq 0x28(%rbx), %rsi
movq 0x30(%rbx), %rdx
callq 0x4400
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rax
incq %r12
addq %rdi, %rax
cmpq %rax, %r12
jne 0x12af6
jmp 0x12b59
movq %r12, %rdi
andb $-0x3, 0xd8(%rbx)
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x12b6e
callq 0x4320
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x38(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12b90
callq 0x4320
movq %rbx, %rdi
callq 0x45c0
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/include/jsoncpp.cpp
// Function: Json::OurCharReader::parse(char const*, char const*, Json::Value*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*)
bool parse(
      char const* beginDoc, char const* endDoc,
      Value* root, JSONCPP_STRING* errs) JSONCPP_OVERRIDE {
    bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
    if (errs) {
      *errs = reader_.getFormattedErrorMessages();
    }
    return ok;
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %r8, %r14
movq %rdi, %r15
movzbl 0x8(%rdi), %r8d
addq $0x10, %r15
movq %r15, %rdi
callq 0x7af0
movl %eax, %ebx
testq %r14, %r14
je 0x15505
leaq -0x40(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0xa2be
movq %r14, %rdi
movq %r12, %rsi
callq 0x4460
movq (%r12), %rdi
leaq -0x30(%rbp), %rax
cmpq %rax, %rdi
je 0x15505
callq 0x4320
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::Get(FULL_REGISTERS)
std::uint16_t CPU::Get(FULL_REGISTERS r) {
    std::uint16_t value = 0;
    switch (r) {
        case FULL_REGISTERS::AF:
            value = regs[REGISTERS::A] << 8 | regs[REGISTERS::F];
            break;
        case FULL_REGISTERS::BC:
            value = regs[REGISTERS::B] << 8 | regs[REGISTERS::C];
            break;
        case FULL_REGISTERS::DE:
            value = regs[REGISTERS::D] << 8 | regs[REGISTERS::E];
            break;
        case FULL_REGISTERS::HL:
            value = regs[REGISTERS::H] << 8 | regs[REGISTERS::L];
            break;
    }

    return value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x3, %esi
ja 0x18776
movl %esi, %eax
leaq 0x5162(%rip), %rcx      # 0x1d8b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzwl (%rdi), %eax
jmp 0x18770
movzwl 0x4(%rdi), %eax
jmp 0x18770
movzwl 0x6(%rdi), %eax
jmp 0x18778
movzwl 0x2(%rdi), %eax
rolw $0x8, %ax
jmp 0x18778
xorl %eax, %eax
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::Set(FULL_REGISTERS, unsigned short)
void CPU::Set(FULL_REGISTERS r, std::uint16_t value) {
    uint8_t hi = (uint8_t)(value >> 8);
    uint8_t lo = (uint8_t)(value);
    switch (r) {
        case FULL_REGISTERS::AF:
            regs[REGISTERS::A] = hi;
            regs[REGISTERS::F] = lo;
            break;
        case FULL_REGISTERS::BC:
            regs[REGISTERS::B] = hi;
            regs[REGISTERS::C] = lo;
            break;
        case FULL_REGISTERS::DE:
            regs[REGISTERS::D] = hi;
            regs[REGISTERS::E] = lo;
            break;
        case FULL_REGISTERS::HL:
            regs[REGISTERS::H] = hi;
            regs[REGISTERS::L] = lo;
            break;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl $0x3, %esi
ja 0x187c3
movl %edx, %eax
shrl $0x8, %eax
movl %esi, %ecx
leaq 0x5127(%rip), %rsi      # 0x1d8c4
movslq (%rsi,%rcx,4), %rcx
addq %rsi, %rcx
jmpq *%rcx
movb %al, (%rdi)
movb %dl, 0x1(%rdi)
jmp 0x187c3
movb %al, 0x4(%rdi)
movb %dl, 0x5(%rdi)
jmp 0x187c3
movb %al, 0x7(%rdi)
movb %dl, 0x6(%rdi)
jmp 0x187c3
movb %al, 0x2(%rdi)
movb %dl, 0x3(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::ReadPC16()
std::uint16_t CPU::ReadPC16() {
    std::uint8_t lo = ReadPC();
    std::uint8_t hi = ReadPC();
    std::uint16_t addr = (((uint16_t)hi) << 8) | lo;

    return addr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movzwl 0x18(%rbx), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%rbx)
callq 0x1a3d4
movl %eax, %r14d
movq 0x10(%rbx), %rdi
movzwl 0x18(%rbx), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%rbx)
callq 0x1a3d4
movzbl %al, %ecx
shll $0x8, %ecx
movzbl %r14b, %eax
orl %ecx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::PopSP16()
uint16_t CPU::PopSP16() {
    uint16_t addr = stackPointer++;
    stackPointer++;
    uint16_t n = mmu->Read16Bit(addr);
    //mmu->Write(addr, (uint16_t)0x00);
    return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzwl 0x1a(%rdi), %esi
leal 0x2(%rsi), %eax
movw %ax, 0x1a(%rdi)
movq 0x10(%rdi), %rdi
popq %rbp
jmp 0x1a4d4
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::PushSP(unsigned short)
void CPU::PushSP(uint16_t value) {
    uint8_t hi = (uint8_t)((value >> 8) & 0xFF);
    uint8_t lo = (uint8_t)((value) & 0xFF);
    PushSP(hi);
    PushSP(lo);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl %esi, %edx
shrl $0x8, %edx
movzwl 0x1a(%rdi), %esi
decl %esi
movw %si, 0x1a(%rdi)
movq 0x10(%rdi), %rdi
movl $0xffff, %r15d          # imm = 0xFFFF
andl %r15d, %esi
callq 0x1a0fc
movzwl 0x1a(%r14), %esi
decl %esi
movw %si, 0x1a(%r14)
movq 0x10(%r14), %rdi
andl %r15d, %esi
movzbl %bl, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1a0fc
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::Read()
void CPU::Read() {
    if (!halt) {
        // uint16_t pc = programCounter;
        uint8_t opcode = ReadPC();

        // if (pc == 0xC04F) {
        //     loopCounter++;
        // }

        // if (mmu->enableDebugger && loopCounter > 5) {
        //     std::fprintf(stderr, "%.4X: %.2X\n", pc, opcode);
        // }
        CheckOpcode(opcode);
    } else {
        cycles = 4;
    }

    if (imeNext) {
        imeNext = false;
        IME = 0xFF;
    }

    if (haltNext) {
        haltNext = false;
        halt = true;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x0, 0x1d(%rdi)
je 0x18a51
movb $0x4, 0x8(%rbx)
jmp 0x18a70
movq 0x10(%rbx), %rdi
movzwl 0x18(%rbx), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%rbx)
callq 0x1a3d4
movzbl %al, %esi
movq %rbx, %rdi
callq 0x18a92
cmpb $0x1, 0x1f(%rbx)
jne 0x18a7e
movb $0x0, 0x1f(%rbx)
movb $-0x1, 0x9(%rbx)
cmpb $0x1, 0x1e(%rbx)
jne 0x18a8a
movw $0x1, 0x1d(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/CPU.cpp
// Function: CPU::CheckRegisters()
void CPU::CheckRegisters() {
    if(Get(REGISTERS::A) != 0x01) { std::cout << "Failed on register a" << std::endl; exit(1); }
    if(Get(REGISTERS::B) != 0x00) { std::cout << "Failed on register b" << std::endl; exit(1); }
    if(Get(REGISTERS::C) != 0x13) { std::cout << "Failed on register c" << std::endl; exit(1); }
    if(Get(REGISTERS::D) != 0x00) { std::cout << "Failed on register d" << std::endl; exit(1); }
    if(Get(REGISTERS::E) != 0xD8) { std::cout << "Failed on register e" << std::endl; exit(1); }
    if(Get(REGISTERS::H) != 0x01) { std::cout << "Failed on register h" << std::endl; exit(1); }
    if(Get(REGISTERS::L) != 0x4D) { std::cout << "Failed on register l" << std::endl; exit(1); }
    if(stackPointer != 0xFFFE) { std::cout << "Failed on registers sp" << std::endl; exit(1); }
    if(programCounter != 0x0100) { std::cout << "Failed on registers pc" << std::endl; exit(1); }

    if (GetZ() != 0x1) { std::cout << "Failed on flag Z" << std::endl; exit(1); }
    if (GetN() != 0x0) { std::cout << "Failed on flag N" << std::endl; exit(1); }
    if (GetH() != 0x1) { std::cout << "Failed on flag H" << std::endl; exit(1); }
    if (GetCY() != 0x1) { std::cout << "Failed on flag CY" << std::endl; exit(1); }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpb $0x1, 0x7(%rdi)
jne 0x19f7d
cmpb $0x0, (%rdi)
jne 0x19f90
cmpb $0x13, 0x1(%rdi)
jne 0x19fa3
cmpb $0x0, 0x2(%rdi)
jne 0x19fb6
cmpb $-0x28, 0x3(%rdi)
jne 0x19fc9
cmpb $0x1, 0x4(%rdi)
jne 0x19fd9
cmpb $0x4d, 0x5(%rdi)
jne 0x19fe9
cmpw $-0x2, 0x1a(%rdi)
jne 0x19ff9
cmpw $0x100, 0x18(%rdi)      # imm = 0x100
jne 0x1a009
movb 0x6(%rdi), %al
testb %al, %al
jns 0x1a019
testb $0x40, %al
jne 0x1a029
testb $0x20, %al
je 0x1a039
testb $0x10, %al
je 0x1a049
popq %rbp
retq
movq 0xe044(%rip), %rdi      # 0x27fc8
leaq 0x4199(%rip), %rsi      # 0x1e124
jmp 0x1a057
movq 0xe031(%rip), %rdi      # 0x27fc8
leaq 0x419b(%rip), %rsi      # 0x1e139
jmp 0x1a057
movq 0xe01e(%rip), %rdi      # 0x27fc8
leaq 0x419d(%rip), %rsi      # 0x1e14e
jmp 0x1a057
movq 0xe00b(%rip), %rdi      # 0x27fc8
leaq 0x419f(%rip), %rsi      # 0x1e163
jmp 0x1a057
movq 0xdff8(%rip), %rdi      # 0x27fc8
leaq 0x41a1(%rip), %rsi      # 0x1e178
jmp 0x1a057
movq 0xdfe8(%rip), %rdi      # 0x27fc8
leaq 0x41a6(%rip), %rsi      # 0x1e18d
jmp 0x1a057
movq 0xdfd8(%rip), %rdi      # 0x27fc8
leaq 0x41ab(%rip), %rsi      # 0x1e1a2
jmp 0x1a057
movq 0xdfc8(%rip), %rdi      # 0x27fc8
leaq 0x41b0(%rip), %rsi      # 0x1e1b7
jmp 0x1a057
movq 0xdfb8(%rip), %rdi      # 0x27fc8
leaq 0x41b7(%rip), %rsi      # 0x1e1ce
jmp 0x1a057
movq 0xdfa8(%rip), %rdi      # 0x27fc8
leaq 0x41be(%rip), %rsi      # 0x1e1e5
jmp 0x1a057
movq 0xdf98(%rip), %rdi      # 0x27fc8
leaq 0x41bf(%rip), %rsi      # 0x1e1f6
jmp 0x1a057
movq 0xdf88(%rip), %rdi      # 0x27fc8
leaq 0x41c0(%rip), %rsi      # 0x1e207
jmp 0x1a057
movq 0xdf78(%rip), %rdi      # 0x27fc8
leaq 0x41c1(%rip), %rsi      # 0x1e218
callq 0x4360
movq %rax, %rdi
callq 0x4190
movl $0x1, %edi
callq 0x4450
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/MMU.cpp
// Function: MMU::MMU(Cartridge*)
MMU::MMU(Cartridge* crt) {
    for (uint32_t ii = 0; ii < 0x8000; ii++) {
        cart[ii] = crt->Read(ii);
    }

    palette[0] = 0;
    palette[1] = 1;
    palette[2] = 2;
    palette[3] = 3;

    readBios = true;
    enableDebugger = false;

    Write(0xFF00, (uint8_t)0x1);
    Write(0xFF41, (uint8_t)3);

    loadBootrom();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x41cd(%rip), %rax      # 0x1e254
movq %rax, 0xe380(%rdi)
leaq 0x43c0(%rip), %rax      # 0x1e455
movq %rax, 0xe388(%rdi)
leaq 0x4413(%rip), %rax      # 0x1e4b6
movq %rax, 0xe390(%rdi)
xorl %r15d, %r15d
movq %r14, %rdi
movl %r15d, %esi
callq 0x1a8ba
movb %al, (%rbx,%r15)
incq %r15
cmpq $0x8000, %r15           # imm = 0x8000
jne 0x1a0ad
movl $0x3020100, 0xe39a(%rbx) # imm = 0x3020100
movw $0x1, 0xe398(%rbx)
movb $0x1, 0xa000(%rbx)
movb $0x3, 0xa041(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1a76e
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/MMU.cpp
// Function: MMU::Read(unsigned short)
std::uint8_t MMU::Read(uint16_t addr) {
    // cartridge / bios
    if (addr <= 0x7FFF) {
        if (readBios && addr < 0xFF)
            return bios[addr];

        return cart[addr];
    }
    // sram
    else if (addr >= 0xA000 && addr <= 0xBFFF)
        return sram[addr - 0xA000];
    // video ram
    else if (addr >= 0x8000 && addr <= 0x9FFF) {
        return vram[addr - 0x8000];
    }

    // writable ram
    else if (addr >= 0xC000 && addr <= 0xDFFF)
        return wram[addr - 0xC000];

    // more writable ram
    else if (addr >= 0xE000 && addr <= 0xFDFF)
        return wram[addr - 0xE000];

    // oam
    else if (addr >= 0xFE00 && addr <= 0xFEFF)
        return oam[addr - 0xFE00];

    // io
    // this includes FFOO - user input joypad
    // timers
    // gpu

    else if (addr >= 0xFF80 && addr <= 0xFFFE)
        return hram[addr - 0xFF80];
    else if (addr >= 0xFF00 && addr <= 0xFF7F) {
        if (addr == 0xff00) return 1;
        return io[(uint8_t)(addr - 0xFF00)];
    }
    else if (addr == 0xFFFF)
        return interrupt;

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
testw %si, %si
js 0x1a3f9
movzwl %si, %eax
cmpl $0xfe, %eax
ja 0x1a416
cmpb $0x0, 0xe398(%rdi)
je 0x1a416
movb 0xe281(%rdi,%rax), %al
jmp 0x1a464
movl %esi, %eax
andl $0xe000, %eax           # imm = 0xE000
cmpl $0xa000, %eax           # imm = 0xA000
jne 0x1a41b
addl $0xffff6000, %esi       # imm = 0xFFFF6000
movb 0x8000(%rdi,%rsi), %al
jmp 0x1a464
movb (%rdi,%rax), %al
jmp 0x1a464
movzwl %si, %ecx
cmpl $0x9fff, %ecx           # imm = 0x9FFF
ja 0x1a435
addl $0xffff8000, %esi       # imm = 0xFFFF8000
movb 0xa100(%rdi,%rsi), %al
jmp 0x1a464
movzwl %ax, %eax
cmpl $0xc000, %eax           # imm = 0xC000
jne 0x1a447
addl $0xffff4000, %esi       # imm = 0xFFFF4000
jmp 0x1a45d
leal 0x2000(%rsi), %eax
movzwl %ax, %eax
cmpl $0x1dff, %eax           # imm = 0x1DFF
ja 0x1a466
addl $0xffff2000, %esi       # imm = 0xFFFF2000
movb 0xc200(%rdi,%rsi), %al
popq %rbp
retq
movl %esi, %eax
andl $0xff00, %eax           # imm = 0xFF00
cmpl $0xfe00, %eax           # imm = 0xFE00
jne 0x1a483
addl $0xffff0200, %esi       # imm = 0xFFFF0200
movb 0xc100(%rdi,%rsi), %al
jmp 0x1a464
leal 0x80(%rsi), %eax
cmpw $0x7e, %ax
ja 0x1a49e
addl $0xffff0080, %esi       # imm = 0xFFFF0080
movb 0xe200(%rdi,%rsi), %al
jmp 0x1a464
movl %esi, %eax
andl $0xff80, %eax           # imm = 0xFF80
cmpl $0xff00, %eax           # imm = 0xFF00
jne 0x1a4c2
movb $0x1, %al
cmpl $0xff00, %ecx           # imm = 0xFF00
je 0x1a464
andl $0x7f, %ecx
movb 0xa000(%rdi,%rcx), %al
jmp 0x1a464
cmpw $-0x1, %si
je 0x1a4cc
xorl %eax, %eax
jmp 0x1a464
movb 0xe280(%rdi), %al
jmp 0x1a464
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/MMU.cpp
// Function: MMU::Read16Bit(unsigned short)
std::uint16_t MMU::Read16Bit(uint16_t addr) {
    uint16_t value = 0;

    uint16_t lo = (uint16_t)Read(addr);
    uint16_t hi = (uint16_t)Read(addr+1);
    value = (hi << 8) | lo;
    return value;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
callq 0x1a3d4
movl %eax, %r15d
incl %ebx
movzwl %bx, %esi
movq %r14, %rdi
callq 0x1a3d4
movzbl %al, %ecx
shll $0x8, %ecx
movzbl %r15b, %eax
orl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/MMU.h
// Function: MMU::loadBootrom()
void loadBootrom() {
        uint16_t x = 0x0000;
        for(unsigned int i = 0; i < strlen(bootrom); i += 2) {
            uint8_t out = Utils::ParseCharsToHex(bootrom[i], bootrom[i + 1]);

            bios[x] = out;
            x++;
        }

        //loadDebugLogo();
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xe380(%rdi), %r14
cmpb $0x0, (%r14)
je 0x1a7f3
movq %rdi, %rbx
movl $0x2, %r15d
xorl %r13d, %r13d
xorl %r12d, %r12d
movb (%r14,%r13), %cl
movl $0x39, %eax
cmpb $0x3a, %cl
jge 0x1a7a8
xorl %eax, %eax
leal -0x1(%r15), %edx
movb (%r14,%rdx), %sil
movl $0xc9, %edx
cmpb $0x3a, %sil
jge 0x1a7c0
movl $0xd0, %edx
addb %cl, %al
addb %sil, %dl
shlb $0x4, %al
orb %dl, %al
movzwl %r12w, %ecx
movb %al, 0xe281(%rbx,%rcx)
incl %r12d
movl %r15d, %r13d
movq 0xe380(%rbx), %r14
movq %r14, %rdi
callq 0x4170
addl $0x2, %r15d
cmpq %r13, %rax
ja 0x1a798
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/Cartridge.cpp
// Function: Cartridge::Cartridge(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Cartridge::Cartridge(std::string fileName) {
    std::FILE* file;
    file = fopen (fileName.c_str() , "rb");
    if (file==NULL) {fputs ("File error",stderr); exit (1);}

    // obtain file size:
    fseek (file , 0 , SEEK_END);
    fileSize = ftell (file);
    rewind (file);

    // allocate memory to contain the whole file:
    rom = new uint8_t[fileSize];
    if (rom == NULL) {fputs ("Memory error",stderr); exit (2);}

    // copy the file into the buffer:
    uint32_t result = fread (rom,1,fileSize,file);
    if (result != fileSize) {fputs ("Reading error",stderr); exit (3);}
    fclose (file);

    printf("File loaded: %s\n", fileName.c_str());

    fileLoaded = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rdi
leaq 0x3d44(%rip), %rsi      # 0x1e563
callq 0x4430
testq %rax, %rax
je 0x1a89b
movq %rax, %r15
movq %rax, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x43d0
movq %r15, %rdi
callq 0x4030
movl %eax, 0xc(%rbx)
movq %r15, %rdi
callq 0x4090
movl 0xc(%rbx), %r12d
movq %r12, %rdi
callq 0x4040
movq %rax, (%rbx)
movl $0x1, %esi
movq %rax, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x4500
cmpl %eax, 0xc(%rbx)
jne 0x1a8a0
movq %r15, %rdi
callq 0x4370
movq (%r14), %rsi
leaq 0x3cf8(%rip), %rdi      # 0x1e57f
xorl %eax, %eax
callq 0x4070
movb $0x1, 0x8(%rbx)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x47a5
callq 0x4783
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::DisableHalt()
void InterruptService::DisableHalt() {
    uint8_t ie = mmu->Read(IE);
    uint8_t flags = mmu->Read(IFLAGS);

    // if any interrupt enable bit and corresponding flags are set
    // regardless of the IME, disable HALT
    if (((ie & flags & vBlankBit)  > 0) ||
        ((ie & flags & lcdStatBit) > 0) ||
        ((ie & flags & timerBit)   > 0) ||
        ((ie & flags & serialBit)  > 0) ||
        ((ie & flags & joyPadBit)  > 0))
    {
        if (cpu->halt) {
            cpu->AddCycles(4);
        }

        cpu->halt = false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x1a3d4
movl %eax, %r14d
movq (%rbx), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
andb %r14b, %al
testb $0x1f, %al
je 0x1a96a
movq 0x8(%rbx), %rdi
cmpb $0x1, 0x1d(%rdi)
jne 0x1a966
movl $0x4, %esi
callq 0x18894
movq 0x8(%rbx), %rdi
movb $0x0, 0x1d(%rdi)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::CheckInterrupts()
bool InterruptService::CheckInterrupts() {
    DisableHalt();
    if (cpu->GetIME() != 0x00) {
        uint8_t ie = mmu->Read(IE);
        uint8_t flags = mmu->Read(IFLAGS);

        // if bit0 (vBlankBit) is enable on IE and 0xFF0F
        if ((ie & flags & vBlankBit) > 0) {
            dispatch = vBlankBit;
            return true;
        }

        // if bit1 (lcdStatBit) is enable on IE and 0xFF0F
        if ((ie & flags & lcdStatBit) > 0) {
            dispatch = lcdStatBit;
            return true;
        }

        // if bit2 (timerBit) is enable on IE and 0xFF0F
        if ((ie & flags & timerBit) > 0) {
            dispatch = timerBit;
            return true;
        }

        // if bit3 (serialBit) is enable on IE and 0xFF0F
        if ((ie & flags & serialBit) > 0) {
            dispatch = serialBit;
            return true;
        }

        // if bit4 (joyPadBit) is enable on IE and 0xFF0F
        if ((ie & flags & joyPadBit) > 0) {
            dispatch = joyPadBit;
            return true;
        }
    }

    dispatch = 0xFF;
    return false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x1a920
movq 0x8(%rbx), %rdi
callq 0x1886c
testb %al, %al
je 0x1a9d1
movq (%rbx), %rdi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x1a3d4
movl %eax, %r14d
movq (%rbx), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
movl %eax, %ecx
andb %r14b, %cl
movb $0x1, %al
testb $0x1, %cl
jne 0x1a9d7
movb $0x2, %dl
testb $0x2, %cl
jne 0x1a9d9
movb $0x4, %dl
testb $0x4, %cl
jne 0x1a9d9
movb $0x8, %dl
testb $0x8, %cl
jne 0x1a9d9
movb $0x10, %dl
testb $0x10, %cl
jne 0x1a9d9
movb $-0x1, %dl
xorl %eax, %eax
jmp 0x1a9d9
movb $0x1, %dl
movb %dl, 0x10(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::Dispatch()
void InterruptService::Dispatch() {
    if ((cpu->GetIME() != 0x00)) {
        switch (dispatch) {
            case vBlankBit: {
                VBlankInterrupt();
            }
                break;
            case lcdStatBit: {
                LCDStatInterrupt();
            }
                break;
            case timerBit: {
                TimerInterrupt();
            }
                break;
            case serialBit: {
                SerialInterrupt();
            }
                break;
            case joyPadBit: {
                JoyPadInterrupt();
            }
                break;
            default:
                break;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
callq 0x1886c
testb %al, %al
je 0x1aa35
movzbl 0x10(%rbx), %ecx
leal -0x1(%rcx), %eax
cmpl $0x7, %eax
ja 0x1aa22
leaq 0x3b85(%rip), %rcx      # 0x1e590
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1aa66
cmpl $0x10, %ecx
jne 0x1aa35
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1abf6
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1ab2e
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1ab92
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1aaca
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::VBlankInterrupt()
void InterruptService::VBlankInterrupt() {
    uint8_t flags = mmu->Read(IFLAGS);
    flags &= ~vBlankBit;
    cpu->SetIME(0x00);
    cpu->PushSP(cpu->programCounter);
    cpu->AddCycles(20);
    cpu->programCounter = vBlankISR;
    mmu->Write(IFLAGS, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
movl %eax, %r14d
andb $-0x2, %r14b
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x18876
movq 0x8(%rbx), %rdi
movzwl 0x18(%rdi), %esi
callq 0x189e6
movq 0x8(%rbx), %rdi
movl $0x14, %esi
callq 0x18894
movq 0x8(%rbx), %rax
movw $0x40, 0x18(%rax)
movq (%rbx), %rdi
movzbl %r14b, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
popq %rbx
popq %r14
popq %rbp
jmp 0x1a0fc
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::LCDStatInterrupt()
void InterruptService::LCDStatInterrupt() {
    uint8_t flags = mmu->Read(IFLAGS);
    flags &= ~lcdStatBit;
    cpu->SetIME(0x00);
    cpu->PushSP(cpu->programCounter);
    cpu->AddCycles(20);
    cpu->programCounter = lcdStatISR;
    mmu->Write(IFLAGS, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
movl %eax, %r14d
andb $-0x3, %r14b
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x18876
movq 0x8(%rbx), %rdi
movzwl 0x18(%rdi), %esi
callq 0x189e6
movq 0x8(%rbx), %rdi
movl $0x14, %esi
callq 0x18894
movq 0x8(%rbx), %rax
movw $0x48, 0x18(%rax)
movq (%rbx), %rdi
movzbl %r14b, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
popq %rbx
popq %r14
popq %rbp
jmp 0x1a0fc
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::TimerInterrupt()
void InterruptService::TimerInterrupt() {
    uint8_t flags = mmu->Read(IFLAGS);
    flags &= ~timerBit;
    cpu->SetIME(0x00);
    cpu->PushSP(cpu->programCounter);
    cpu->AddCycles(20);
    cpu->programCounter = timerISR;
    mmu->Write(IFLAGS, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
movl %eax, %r14d
andb $-0x5, %r14b
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x18876
movq 0x8(%rbx), %rdi
movzwl 0x18(%rdi), %esi
callq 0x189e6
movq 0x8(%rbx), %rdi
movl $0x14, %esi
callq 0x18894
movq 0x8(%rbx), %rax
movw $0x50, 0x18(%rax)
movq (%rbx), %rdi
movzbl %r14b, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
popq %rbx
popq %r14
popq %rbp
jmp 0x1a0fc
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/InterruptService.cpp
// Function: InterruptService::SerialInterrupt()
void InterruptService::SerialInterrupt() {
    uint8_t flags = mmu->Read(IFLAGS);
    flags &= ~serialBit;
    cpu->SetIME(0x00);
    cpu->PushSP(cpu->programCounter);
    cpu->AddCycles(20);
    cpu->programCounter = serialISR;
    mmu->Write(IFLAGS, flags);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
movl %eax, %r14d
andb $-0x9, %r14b
movq 0x8(%rbx), %rdi
xorl %esi, %esi
callq 0x18876
movq 0x8(%rbx), %rdi
movzwl 0x18(%rdi), %esi
callq 0x189e6
movq 0x8(%rbx), %rdi
movl $0x14, %esi
callq 0x18894
movq 0x8(%rbx), %rax
movw $0x58, 0x18(%rax)
movq (%rbx), %rdi
movzbl %r14b, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
popq %rbx
popq %r14
popq %rbp
jmp 0x1a0fc
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/TimerService.cpp
// Function: TimerService::Increment()
void TimerService::Increment() {
    uint16_t cycles = cpu->GetCycles();

    // counter mess
    timaClock += cycles;
    CheckTima();

    // divider clock
    divClock += cycles;
    CheckDiv();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x18880
movzbl %al, %r14d
addl %r14d, 0x10(%rbx)
movq %rbx, %rdi
callq 0x1ad1e
addl %r14d, 0xc(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1ad94
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/TimerService.cpp
// Function: TimerService::CheckTima()
void TimerService::CheckTima() {
    uint8_t control = mmu->Read(controlAddr);
    uint32_t clockSpeed;

    if (control & runningBit) {
         // divide the operation speed of the cpu clock by the speed set in the control to get the "clockSpeed" variable value
        switch (control & speedBits) {
            case 0: // 4096hz
                clockSpeed = 1024;
                break;
            case 1: // 262144hz
                clockSpeed = 16;
                break;
            case 2: // 65536hz
                clockSpeed = 64;
                break;
            case 3: // 16384hz
                clockSpeed = 256;
                break;
        }

        bool trig = false;
        while (timaClock >= clockSpeed) {
            timaClock -= clockSpeed;
            StepTima();
            trig = true;
        }

        if (trig) {
            timaClock = 0;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movzwl 0x6(%rbx), %esi
callq 0x1a3d4
testb %al, 0x9(%rbx)
je 0x1ad88
andb 0x8(%rbx), %al
decb %al
movl $0x400, %r14d           # imm = 0x400
cmpb $0x2, %al
ja 0x1ad5a
movzbl %al, %eax
leaq 0x385a(%rip), %rcx      # 0x1e5b0
movl (%rcx,%rax,4), %r14d
movl 0x10(%rbx), %r15d
cmpl %r14d, %r15d
jb 0x1ad88
movl %r15d, %eax
subl %r14d, %eax
movl %eax, 0x10(%rbx)
movq %rbx, %rdi
callq 0x1add2
movl 0x10(%rbx), %eax
cmpl %r14d, %eax
jae 0x1ad66
cmpl %r14d, %r15d
jb 0x1ad88
movl $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/TimerService.cpp
// Function: TimerService::CheckDiv()
void TimerService::CheckDiv() {
    if (divClock >= 0xFF) {
        uint8_t div = mmu->Read(divAddr);
        div++;
        mmu->WriteTimers(divAddr, div);
        divClock %= 256; // we want to keep ALL OF THE CLOCKS
    }
}

// Assembly:
cmpl $0xff, 0xc(%rdi)
jb 0x1add0
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movzwl (%rbx), %esi
callq 0x1a3d4
incb %al
movq 0x20(%rbx), %rdi
movzwl (%rbx), %esi
movzbl %al, %edx
callq 0x1a5fc
movzbl 0xc(%rbx), %eax
movl %eax, 0xc(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/TimerService.cpp
// Function: TimerService::StepTima()
void TimerService::StepTima() {
    uint16_t tima = mmu->Read(timaAddr);
    tima++;

    if (tima > 255) {
        tima = mmu->Read(moduloAddr);
        cpu->AddCycles(4);
        TimaInterrupt();
    }

    mmu->Write(timaAddr, (uint8_t)(tima & 0xFF));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movzwl 0x2(%rbx), %esi
callq 0x1a3d4
movl %eax, %r14d
incb %r14b
jne 0x1ae17
movq 0x20(%rbx), %rdi
movzwl 0x4(%rbx), %esi
callq 0x1a3d4
movl %eax, %r14d
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0x18894
movq %rbx, %rdi
callq 0x1ae2c
movq 0x20(%rbx), %rdi
movzwl 0x2(%rbx), %esi
movzbl %r14b, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x1a0fc
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/TimerService.cpp
// Function: TimerService::TimaInterrupt()
void TimerService::TimaInterrupt() {
    uint8_t flags = mmu->Read(InterruptService::IFLAGS);
    flags |= InterruptService::timerBit;
    mmu->Write(InterruptService::IFLAGS, flags);
    cpu->AddCycles(4);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
orb $0x4, %al
movq 0x20(%rbx), %rdi
movzbl %al, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a0fc
movq 0x18(%rbx), %rdi
movl $0x4, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x18894
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/Graphics/XGPU.cpp
// Function: XGPU::init_palette()
void XGPU::init_palette() {
    Visual* visual = DefaultVisual(display, screen);

    cmap = XCreateColormap(
        display,
        RootWindow(display, screen),
        visual,
        AllocNone
    );

    for (int ii = 0; ii < 4; ii++) {
        uint8_t mmuColor = mmu->palette[ii];
        Status rc;

        switch (mmuColor) {
            XColor xc;
            case 0:
            {
                rc = XAllocNamedColor(display, cmap, "Gray100", &palette[ii], &xc);
            }
                break;
            case 1:
            {
                rc = XAllocNamedColor(display, cmap, "Gray85", &palette[ii], &xc);
            }
                break;
            case 2:
            {
                rc = XAllocNamedColor(display, cmap, "Gray55", &palette[ii], &xc);
            }
                break;
            case 3:
            {
                rc = XAllocNamedColor(display, cmap, "Gray0", &palette[ii], &xc);
            }
                break;
        }

        if (rc == 0) {
            printf("Color Alloc [%d] failed.\n", ii);
        }
    }

    XSetWindowColormap(display, window, cmap);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x5a20(%rdi), %rdi
movq 0xe8(%rdi), %rax
movslq 0x5a28(%rbx), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rsi
movq 0x40(%rax,%rcx), %rdx
xorl %ecx, %ecx
callq 0x4260
movq %rax, 0x5a40(%rbx)
leaq 0x5a50(%rbx), %r14
leaq 0x3503(%rip), %r15      # 0x1e5d4
xorl %r13d, %r13d
movq 0x5a98(%rbx), %rax
movzbl 0xe39a(%rax,%r13), %eax
cmpq $0x3, %rax
ja 0x1b10e
movslq (%r15,%rax,4), %rdx
addq %r15, %rdx
movq 0x5a20(%rbx), %rdi
movq 0x5a40(%rbx), %rsi
movq %r14, %rcx
leaq -0x38(%rbp), %r8
callq 0x4470
movl %eax, %r12d
testl %r12d, %r12d
jne 0x1b124
leaq 0x3567(%rip), %rdi      # 0x1e681
movl %r13d, %esi
xorl %eax, %eax
callq 0x4070
incq %r13
addq $0x10, %r14
cmpq $0x4, %r13
jne 0x1b0d4
movq 0x5a20(%rbx), %rdi
movq 0x5a30(%rbx), %rsi
movq 0x5a40(%rbx), %rdx
callq 0x4540
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/Graphics/XGPU.cpp
// Function: XGPU::XGPU(MMU*, unsigned char)
XGPU::XGPU(MMU* m, uint8_t ws = 1){
    mmu = m;
    windowScalar = ws;
    init_x();
    init_palette();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xca24(%rip), %rax      # 0x27cb8
movq %rax, (%rdi)
movq %rsi, 0x5a98(%rdi)
movb %dl, 0x5a90(%rdi)
callq 0x1ae6c
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x1b07e
nop
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/Graphics/XGPU.cpp
// Function: XGPU::SyncMemory()
void XGPU::SyncMemory() {
    // lcdc stats
    // clear bits; conditionally clear the coincidence
    lcdStat = lcdStat & ~(Utils::BIT_1 | Utils::BIT_0) & ~(useLYC ? Utils::BIT_2 : 0x00);
    lcdStat |= mode;
    lcdStat |= (scanline == lyc) ? Utils::BIT_2 : 0x00;

    if (scanline == lyc) {
        TriggerLCDStat(Utils::BIT_6); // trigger hblank lcdc status interrupt
    }
    SetLCDStat(lcdStat);

    // LY (scanline)
    SetScanline(scanline);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x5a16(%rdi), %cl
notb %cl
shlb $0x2, %cl
orb $-0x8, %cl
andb 0x5a15(%rdi), %cl
orb 0x5a18(%rdi), %cl
movb 0x5a1e(%rdi), %dl
movb 0x5a1f(%rdi), %sil
cmpb %sil, %dl
sete %al
shlb $0x2, %al
orb %cl, %al
movb %al, 0x5a15(%rdi)
cmpb %sil, %dl
jne 0x1b583
movq %rbx, %rdi
movl $0x40, %esi
callq 0x1b5a8
movb 0x5a15(%rbx), %al
movq (%rbx), %rcx
movzbl %al, %esi
movq %rbx, %rdi
callq *0x48(%rcx)
movzbl 0x5a1e(%rbx), %esi
movq (%rbx), %rax
movq 0x60(%rax), %rax
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmpq *%rax
// File: /workspace/github_cpp_makefile_star2_O3/RegulusImpact[P]sadboy/src/Graphics/XGPU.cpp
// Function: XGPU::Step(unsigned int)
void XGPU::Step(uint32_t clockStep) {
    Sync();
    clocks += clockStep;

    switch (mode) {
        case GPU_MODE::OAM: // 2
        {
            if (clocks >= 80) {
                clocks = 0;
                mode = GPU_MODE::VRAM;
            }
        }
            break;
        case GPU_MODE::VRAM: // 3
        {
            if (clocks >= 172) {
                clocks = 0;
                mode = GPU_MODE::HBLANK;
                TriggerLCDStat(Utils::BIT_3); // trigger hblank lcdc status interrupt

                RenderScanline();
            }
        }
            break;
        case GPU_MODE::HBLANK: // 0
        {
            if (clocks >= 204) {
                clocks = 0;
                IncrementScanline();

                if (scanline == 143) {
                    mode = GPU_MODE::VBLANK;
                    TriggerVBlank();
                    TriggerLCDStat(Utils::BIT_4); // trigger vblank lcdc status interrupt
                    RenderFrame();
                } else {
                    mode = GPU_MODE::OAM;
                }
            }
        }
            break;
        case GPU_MODE::VBLANK: // 1
        {
            if (clocks >= 456) {
                clocks = 0;

                IncrementScanline();

                if (scanline > 153) {
                    mode = GPU_MODE::OAM;
                    TriggerLCDStat(Utils::BIT_5); // trigger oam-rams lcdc status interrupt

                    ResetScanline();
                    //XFlush(display);
                }
            }
        }
            break;
    }

    SyncMemory();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
callq 0x1b436
addl 0x8(%rbx), %r14d
movl %r14d, 0x8(%rbx)
movl 0x5a18(%rbx), %eax
cmpq $0x3, %rax
ja 0x1b798
leaq 0x2f3b(%rip), %rcx      # 0x1e5bc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0xcc, %r14d
jb 0x1b798
movl $0x0, 0x8(%rbx)
movb 0x5a1e(%rbx), %al
incb %al
movb %al, 0x5a1e(%rbx)
cmpb $-0x71, %al
jne 0x1b78e
movl $0x1, 0x5a18(%rbx)
movq 0x5a98(%rbx), %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a3d4
orb $0x1, %al
movq 0x5a98(%rbx), %rdi
movzbl %al, %edx
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x1a0fc
movq %rbx, %rdi
movl $0x10, %esi
callq 0x1b5a8
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x70(%rax)
jmp 0x1b798
cmpl $0x50, %r14d
jb 0x1b798
movl $0x0, 0x8(%rbx)
movl $0x3, 0x5a18(%rbx)
jmp 0x1b798
cmpl $0xac, %r14d
jb 0x1b798
xorl %eax, %eax
movl %eax, 0x8(%rbx)
movl %eax, 0x5a18(%rbx)
movq %rbx, %rdi
movl $0x8, %esi
callq 0x1b5a8
movq (%rbx), %rax
movq %rbx, %rdi
callq *0xa0(%rax)
jmp 0x1b798
cmpl $0x1c8, %r14d           # imm = 0x1C8
jb 0x1b798
movl $0x0, 0x8(%rbx)
movb 0x5a1e(%rbx), %al
incb %al
movb %al, 0x5a1e(%rbx)
cmpb $-0x66, %al
jb 0x1b798
movl $0x2, 0x5a18(%rbx)
movq %rbx, %rdi
movl $0x20, %esi
callq 0x1b5a8
movb $0x0, 0x5a1e(%rbx)
jmp 0x1b798
movl $0x2, 0x5a18(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x1b52a