LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/CPU.cc
// Function: CPU::updateTimers(unsigned char)
void CPU::updateTimers(uint8_t cyclesPassed) {
  // Keep track of Cycles passed for each of the Timers
  this->timerCycles.div += cyclesPassed;

  // Get TAC Configuration
  uint8_t TAC = this->memory.read(0xFF07);


  if (this->timerCycles.div >= 64) {
    uint8_t DIV = this->memory.read(0xFF04);
    memory.memory[0xFF04] = ++DIV;
    this->timerCycles.div -= 64;
  }



  // TAC-Enabled, Tick TIMA
  // TODO: Figure out what happens if TAC changes interval while TAC enabled.
  if (TAC & (1 << 2)) {
    this->timerCycles.tima += cyclesPassed;
    uint8_t TIMA_OLD = this->memory.read(0xFF05);
    uint8_t TIMA = TIMA_OLD;

    switch (TAC & 0x03) {
      case 0x00:
        if (timerCycles.tima >= 256) {
          TIMA++;
          timerCycles.tima -= 256;
        }
        break;
      case 0x01:
        if (timerCycles.tima >= 4) {
          TIMA++;
          timerCycles.tima -= 4;
        }
        break;
      case 0x10:
        if (timerCycles.tima >= 16) {
          TIMA++;
          timerCycles.tima -= 16;
        }
        break;
      case 0x11:
        if (timerCycles.tima >= 64) {
          TIMA++;
          timerCycles.tima -= 64;
        }
        break;
    }

    // CHECK IF OVERFLOW
    if (TIMA < TIMA_OLD) {
      // Request Timer Interrupt
      uint8_t IF = this->memory.read(0xFF0F);
      this->memory.write(0xFF0F, IF |= 0x04);

      // Set TIMA = TAC
      TIMA = this->memory.read(0xFF06);
    }


    this->memory.write(0xFF05, TIMA);
  }


}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %r15d
movq %rdi, %r14
addl %esi, 0x120(%rdi)
leaq 0x130(%rdi), %rbx
movq %rbx, %rdi
movl $0xff07, %esi           # imm = 0xFF07
callq 0x3d1ac
movl %eax, %r12d
cmpl $0x40, 0x120(%r14)
jb 0x319c2
movq %rbx, %rdi
movl $0xff04, %esi           # imm = 0xFF04
callq 0x3d1ac
incb %al
movb %al, 0x10054(%r14)
addl $-0x40, 0x120(%r14)
testb $0x4, %r12b
jne 0x319d1
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movzbl %r12b, %r12d
addl %r15d, 0x124(%r14)
movq %rbx, %rdi
movl $0xff05, %esi           # imm = 0xFF05
callq 0x3d1ac
andl $0x3, %r12d
cmpl $0x1, %r12d
je 0x31a11
testl %r12d, %r12d
jne 0x31a2e
movl 0x124(%r14), %edx
movl %eax, %ecx
cmpl $0x100, %edx            # imm = 0x100
jb 0x31a30
addl $0xffffff00, %edx       # imm = 0xFFFFFF00
jmp 0x31a22
movl 0x124(%r14), %edx
movl %eax, %ecx
cmpl $0x4, %edx
jb 0x31a30
addl $-0x4, %edx
leal 0x1(%rax), %ecx
movl %edx, 0x124(%r14)
jmp 0x31a30
movl %eax, %ecx
cmpb %al, %cl
jae 0x31a62
movq %rbx, %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x3d1ac
orb $0x4, %al
movzbl %al, %edx
movq %rbx, %rdi
movl $0xff0f, %esi           # imm = 0xFF0F
callq 0x3d1b8
movq %rbx, %rdi
movl $0xff06, %esi           # imm = 0xFF06
callq 0x3d1ac
movl %eax, %ecx
movzbl %cl, %edx
movq %rbx, %rdi
movl $0xff05, %esi           # imm = 0xFF05
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/CPU.cc
// Function: CPU::getCpuStateSnapshot()
const CPU_State CPU::getCpuStateSnapshot() {
  return {
    reg,
    SP,
    PC,
    ppu->getLY(),
    IME,
    halted,
    running
  };
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %r15
movq (%rdi), %rdi
movq 0x118(%r15), %rbx
movzwl 0x12e(%r15), %r12d
movl 0x12c(%r15), %r14d
callq 0x3d66e
movzbl 0x128(%r15), %ecx
movzbl 0x12a(%r15), %edx
movzbl 0x12b(%r15), %esi
shlq $0x38, %rsi
shlq $0x30, %rdx
shlq $0x28, %rcx
orq %rdx, %rcx
orq %rsi, %rcx
movzbl %al, %eax
shlq $0x20, %rax
orq %rcx, %rax
shll $0x10, %r14d
orq %rax, %r14
orq %r12, %r14
movq %rbx, %rax
movq %r14, %rdx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::ADC(unsigned char)
void CPU::ADC(uint8_t u8) {                 // ADC A, u8
  uint8_t result = this->reg.A + ((this->reg.F & 0x10) >> 4) + u8;

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(false);   // Unset N Flag
  this->checkHalfCarry(result, this->reg.A);
  this->checkCarry(this->reg.A, result);

  // Set new A Value
  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movzbl 0x11d(%rdi), %eax
btl $0x4, %eax
adcb 0x118(%rdi), %r14b
sete %al
movzbl %al, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movzbl 0x118(%rbx), %edx
movzbl %r14b, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x30930
movzbl 0x118(%rbx), %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x3095e
movb %r14b, 0x118(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::ADD(unsigned char)
void CPU::ADD(uint8_t u8) {                 // ADD A, u8
  uint8_t result = this->reg.A + u8;

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(false);   // Unset N Flag
  this->checkHalfCarry(result, this->reg.A);
  this->checkCarry(this->reg.A, result);

  // New A Value
  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
xorl %esi, %esi
addb 0x118(%rdi), %r14b
sete %sil
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movzbl 0x118(%rbx), %edx
movzbl %r14b, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0x30930
movzbl 0x118(%rbx), %esi
movq %rbx, %rdi
movl %r14d, %edx
callq 0x3095e
movb %r14b, 0x118(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::AND(unsigned char)
void CPU::AND(uint8_t u8) {                 // AND A, u8
  uint8_t result = this->reg.A & u8;

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(false);   // Unset N Flag
  this->setHalfCarryFlag(true); // Set H Flag
  this->setCarryFlag(false);    // Unset C Flag

  // New A Value
  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
xorl %esi, %esi
andb 0x118(%rdi), %bl
sete %sil
callq 0x308c0
movq %r14, %rdi
xorl %esi, %esi
callq 0x308dc
movq %r14, %rdi
movl $0x1, %esi
callq 0x308f8
movq %r14, %rdi
xorl %esi, %esi
callq 0x30914
movb %bl, 0x118(%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::CP(unsigned char)
void CPU::CP(uint8_t u8) {                  // CP A, u8
  uint8_t result = this->reg.A - u8;

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(true);  // Set N Flag
  this->checkHalfCarry(this->reg.A, result); // Set if borrow from bit 4
  this->checkCarry(u8, this->reg.A); // Set if borrow
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movb 0x118(%rdi), %r15b
xorl %esi, %esi
subb %bl, %r15b
sete %sil
callq 0x308c0
movq %r14, %rdi
movl $0x1, %esi
callq 0x308dc
movzbl 0x118(%r14), %esi
movzbl %r15b, %edx
movq %r14, %rdi
callq 0x30930
movzbl 0x118(%r14), %edx
movq %r14, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3095e
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::DEC(unsigned char*)
void CPU::DEC(uint8_t *r8) {                // DEC r8
  uint8_t result = *r8 - 1;

  // Set Flags
  this->setZeroFlag(result == 0);   // Zero Flag
  this->setAddSubFlag(true);  // Set N Flag
  this->checkHalfCarry(*r8, result); // Set if borrow from bit 4

  // New r8 value
  *r8 = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb (%rsi), %r15b
xorl %esi, %esi
decb %r15b
sete %sil
callq 0x308c0
movq %r14, %rdi
movl $0x1, %esi
callq 0x308dc
movzbl (%rbx), %esi
movzbl %r15b, %r15d
movq %r14, %rdi
movl %r15d, %edx
callq 0x30930
movb %r15b, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::DEC(unsigned short)
void CPU::DEC(uint16_t a16) {               // DEC [HL]
  uint8_t result = this->memory.read(a16) - 1;

  // Set Flags
  this->setZeroFlag(result == 0);   // Zero Flag
  this->setAddSubFlag(true);  // Set N Flag
  this->checkHalfCarry(this->memory.read(a16), result); // Set if borrow from bit 4

  this->memory.write(a16, result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r15
leaq 0x130(%rdi), %r14
movq %r14, %rdi
callq 0x3d1ac
movl %eax, %r12d
xorl %esi, %esi
decb %r12b
sete %sil
movq %r15, %rdi
callq 0x308c0
movq %r15, %rdi
movl $0x1, %esi
callq 0x308dc
movq %r14, %rdi
movl %ebx, %esi
callq 0x3d1ac
movzbl %r12b, %r12d
movzbl %al, %esi
movq %r15, %rdi
movl %r12d, %edx
callq 0x30930
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::INC(unsigned char*)
void CPU::INC(uint8_t *r8) {                // INC r8
  uint8_t result = *r8 + 1;

  // Set Flags
  this->setZeroFlag(result == 0);   // Zero Flag
  this->setAddSubFlag(false);       // Unset N Flag
  this->checkHalfCarry(*r8, result);     // Set if overflow from bit 3

  // New r8 value
  *r8 = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb (%rsi), %r15b
xorl %esi, %esi
incb %r15b
sete %sil
callq 0x308c0
movq %r14, %rdi
xorl %esi, %esi
callq 0x308dc
movzbl (%rbx), %esi
movzbl %r15b, %r15d
movq %r14, %rdi
movl %r15d, %edx
callq 0x30930
movb %r15b, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::INC(unsigned short)
void CPU::INC(uint16_t a16) {               // INC [HL]
  uint8_t result = this->memory.read(a16) + 1;

  // Set Flags
  this->setZeroFlag(result == 0);   // Zero Flag
  this->setAddSubFlag(false);  // Unset N Flag
  this->checkHalfCarry(this->memory.read(a16), result); // Set if overflow from bit 3

  this->memory.write(a16, result);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r15
leaq 0x130(%rdi), %r14
movq %r14, %rdi
callq 0x3d1ac
movl %eax, %r12d
xorl %esi, %esi
incb %r12b
sete %sil
movq %r15, %rdi
callq 0x308c0
movq %r15, %rdi
xorl %esi, %esi
callq 0x308dc
movq %r14, %rdi
movl %ebx, %esi
callq 0x3d1ac
movzbl %r12b, %r12d
movzbl %al, %esi
movq %r15, %rdi
movl %r12d, %edx
callq 0x30930
movq %r14, %rdi
movl %ebx, %esi
movl %r12d, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::OR(unsigned char)
void CPU::OR(uint8_t u8) {                  // OR A, u8
  uint8_t result = this->reg.A | u8;

  // Set Flags
  this->reg.F = 0x00;                // Reset Flags
  this->setZeroFlag(result == 0);     // Zero Flag

  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movb $0x0, 0x11d(%rdi)
xorl %esi, %esi
orb 0x118(%rdi), %bl
sete %sil
callq 0x308c0
movb %bl, 0x118(%r14)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SBC(unsigned char)
void CPU::SBC(uint8_t u8) {                 // SBC A, u8
  uint8_t result = this->reg.A - u8 - ((this->reg.F & 0x10) >> 4);

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(true);  // Set N Flag
  this->checkHalfCarry(this->reg.A, result);
  this->checkCarry(u8 + ((this->reg.F & 0x10) >> 4), this->reg.A);  // Check Carry for Subtraction

  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movzbl 0x11d(%rdi), %eax
btl $0x4, %eax
movl %r14d, %eax
adcb $0x0, %al
movb 0x118(%rdi), %r15b
xorl %esi, %esi
subb %al, %r15b
sete %sil
callq 0x308c0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308dc
movzbl 0x118(%rbx), %esi
movzbl %r15b, %r15d
movq %rbx, %rdi
movl %r15d, %edx
callq 0x30930
movzbl 0x11d(%rbx), %eax
btl $0x4, %eax
adcb $0x0, %r14b
movzbl 0x118(%rbx), %edx
movzbl %r14b, %esi
movq %rbx, %rdi
callq 0x3095e
movb %r15b, 0x118(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SUB(unsigned char)
void CPU::SUB(uint8_t u8) {                 // SUB A, u8
  uint8_t result = this->reg.A - u8;

  // Set Flags
  this->setZeroFlag(result == 0);      // Zero Flag
  this->setAddSubFlag(true);  // Set N Flag
  this->checkHalfCarry(this->reg.A, result);
  this->checkCarry(u8, this->reg.A);  // Check Carry for Subtraction

  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movb 0x118(%rdi), %r15b
xorl %esi, %esi
subb %r14b, %r15b
sete %sil
callq 0x308c0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308dc
movzbl 0x118(%rbx), %esi
movzbl %r15b, %r15d
movq %rbx, %rdi
movl %r15d, %edx
callq 0x30930
movzbl 0x118(%rbx), %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x3095e
movb %r15b, 0x118(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::XOR(unsigned char)
void CPU::XOR(uint8_t u8) {                 // XOR A, u8
  uint8_t result = this->reg.A ^ u8;

  // Set Flags
  this->reg.F = 0x00;                // Reset Flags
  this->setZeroFlag(result == 0);     // Zero Flag

  this->reg.A = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb 0x118(%rdi), %cl
movl %ecx, %r14d
xorb %sil, %r14b
movb $0x0, 0x11d(%rdi)
xorl %eax, %eax
cmpb %sil, %cl
sete %al
movl %eax, %esi
callq 0x308c0
movb %r14b, 0x118(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::ADDHL(unsigned short)
void CPU::ADDHL(uint16_t r16) {             // ADD HL, r16
  uint16_t HL = (this->reg.H << 8) | this->reg.L;
  uint16_t result = HL + r16;

  // Set Flags
  this->setAddSubFlag(false);  // Unset N Flag
  this->checkHalfCarry(HL >> 8, result >> 8);
  this->checkCarry_16(HL, HL + r16);

  this->reg.H = result >> 8;
  this->reg.L = result & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl 0x11e(%rdi), %r14d
movl %r14d, %eax
shll $0x8, %eax
movzbl 0x11f(%rdi), %r15d
orl %eax, %r15d
leal (%rsi,%r15), %r13d
xorl %esi, %esi
callq 0x308dc
movl %r13d, %r12d
andl $0xffff, %r12d          # imm = 0xFFFF
movl %r12d, %edx
shrl $0x8, %edx
movq %rbx, %rdi
movl %r14d, %esi
callq 0x30930
movq %rbx, %rdi
movl %r15d, %esi
movl %r12d, %edx
callq 0x3097e
rolw $0x8, %r13w
movw %r13w, 0x11e(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::DEC(unsigned char*, unsigned char*)
void CPU::DEC(uint8_t *ru, uint8_t *rl) {    // DEC r16
  uint16_t r16 = (*ru << 8) | *rl;
  uint16_t result = r16 - 1;

  *ru = result >> 8;
  *rl = result & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl (%rsi), %eax
shll $0x8, %eax
movzbl (%rdx), %ecx
addl %ecx, %eax
addl $0xffff, %eax           # imm = 0xFFFF
movb %ah, (%rsi)
movb %al, (%rdx)
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::INC(unsigned char*, unsigned char*)
void CPU::INC(uint8_t *ru, uint8_t *rl) {    // INC r16
  uint16_t r16 = (*ru << 8) | *rl;
  uint16_t result = r16 + 1;

  *ru = result >> 8;
  *rl = result & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movzbl (%rsi), %eax
shll $0x8, %eax
movzbl (%rdx), %ecx
addl %ecx, %eax
incl %eax
movb %ah, (%rsi)
movb %al, (%rdx)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::BIT(unsigned char, unsigned char*)
void CPU::BIT(uint8_t u3, uint8_t *r8) {     // BIT u3, r8
  // Check bit at u3 in r8's Bytes
  // Shift byte to u3 Bit to check if R8 Bit is set
  if ( ((1 << u3) & *r8) == 0 ) {
    this->setZeroFlag(true);
  }
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzbl (%rdx), %eax
btl %esi, %eax
jb 0x3bd16
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x308f8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::BIT(unsigned char, unsigned short)
void CPU::BIT(uint8_t u3, uint16_t a16) {    // BIT u3, [HL]
  uint8_t value = this->memory.read(a16);
  this->BIT(u3, &value);
  this->memory.write(a16, value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %r14d
movq %rdi, %r15
leaq 0x130(%rdi), %r12
movq %r12, %rdi
movl %edx, %esi
callq 0x3d1ac
movl %eax, %r13d
leaq -0x29(%rbp), %rdx
movb %al, (%rdx)
movq %r15, %rdi
movl %r14d, %esi
callq 0x3bcf8
movzbl %r13b, %edx
movq %r12, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RES(unsigned char, unsigned short)
void CPU::RES(uint8_t u3, uint16_t a16) {    // RES u3, [HL]
  uint8_t value = this->memory.read(a16);
  this->RES(u3, &value);
  this->memory.write(a16, value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebx
movl %esi, %r14d
movq %rdi, %r15
addq $0x130, %r15            # imm = 0x130
movq %r15, %rdi
movl %edx, %esi
callq 0x3d1ac
movl $0x1, %edx
movl %r14d, %ecx
shll %cl, %edx
notb %dl
andb %al, %dl
movzbl %dl, %edx
movq %r15, %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SWAP(unsigned char*)
void CPU::SWAP(uint8_t *r8) {               // SWAP r8
  uint8_t L = *r8 >> 4;
  uint8_t R = *r8 << 4;
  uint8_t result = L | R;

  // Set Flags
  this->setZeroFlag(result == 0);     // Zero Flag
  this->setAddSubFlag(false);     // Unset N Flag
  this->setHalfCarryFlag(false);  // Unset Half Carry Flag
  this->setCarryFlag(false);      // Unset Carry Flag
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %eax, %eax
cmpb $0x0, (%rsi)
sete %al
movl %eax, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308f8
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x30914
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SWAP(unsigned short)
void CPU::SWAP(uint16_t a16) {             // SWAP [HL]
  uint8_t value = this->memory.read(a16);
  this->SWAP(&value);
  this->memory.write(a16, value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x130(%rdi), %r15
movq %r15, %rdi
callq 0x3d1ac
movl %eax, %r12d
leaq -0x21(%rbp), %rsi
movb %al, (%rsi)
movq %r14, %rdi
callq 0x3be40
movzbl %r12b, %edx
movq %r15, %rdi
movl %ebx, %esi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RL(unsigned char*)
void CPU::RL(uint8_t *r8) {                // RL r8
  uint8_t carry = (this->reg.F & 0x10) << 3;

  // Set Carry flag according to 7th Bit
  this->setCarryFlag((*r8 & 0x80) != 0);

  *r8 = (*r8 << 1) | carry;  // Set right most bit

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb 0x11d(%rdi), %r15b
shlb $0x3, %r15b
andb $-0x80, %r15b
movb (%rsi), %al
shrb $0x7, %al
movzbl %al, %esi
callq 0x30914
movb (%r14), %al
addb %al, %al
orb %r15b, %al
movb %al, (%r14)
jne 0x3bf10
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x308f8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RL(unsigned short)
void CPU::RL(uint16_t a16) {               // RL [HL]
  uint8_t value = this->memory.read(a16);
  this->RL(&value);
  this->memory.write(a16, value);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
leaq 0x130(%rdi), %r15
movq %r15, %rdi
callq 0x3d1ac
leaq -0x21(%rbp), %r12
movb %al, (%r12)
movq %r14, %rdi
movq %r12, %rsi
callq 0x3beca
movzbl (%r12), %edx
movq %r15, %rdi
movl %ebx, %esi
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x3d1b8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RLC(unsigned char*)
void CPU::RLC(uint8_t *r8) {               // RLC r8
  // Set Carry flag according to 7th Bit
  this->setCarryFlag((*r8 & 0x80) != 0);

  // Carry 7th Bit over
  *r8 = (*r8 << 1) | ((this->reg.F & 0x10) >> 4);

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movb (%rsi), %al
shrb $0x7, %al
movzbl %al, %esi
callq 0x30914
movb (%r14), %al
addb %al, %al
movb 0x11d(%rbx), %cl
shrb $0x4, %cl
andb $0x1, %cl
orb %al, %cl
movb %cl, (%r14)
jne 0x3bfe5
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x308f8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RR(unsigned char*)
void CPU::RR(uint8_t *r8) {                // RR r8
  uint8_t carry = (this->reg.F & 0x10) << 3; // Set to Top Bit

  // Set Carry flag according to 7th Bit
  this->setCarryFlag((*r8 & 0x01) != 0);

  *r8 = (*r8 >> 1) | carry;  // Set left most bit

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb 0x11d(%rdi), %r15b
shlb $0x3, %r15b
andb $-0x80, %r15b
movzbl (%rsi), %esi
andl $0x1, %esi
callq 0x30914
movb (%r14), %al
shrb %al
orb %r15b, %al
movb %al, (%r14)
jne 0x3c0ba
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x308f8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RRC(unsigned char*)
void CPU::RRC(uint8_t *r8) {                // RRC r8
  // Set Carry flag according to 7th Bit
  this->setCarryFlag((*r8 & 0x01) != 0);

  // Carry 7th Bit over
  *r8 = (*r8 >> 1) | ((this->reg.F & 0x10) << 3);

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %esi
andl $0x1, %esi
callq 0x30914
movb (%r14), %al
shrb %al
movb 0x11d(%rbx), %cl
shlb $0x3, %cl
andb $-0x80, %cl
orb %al, %cl
movb %cl, (%r14)
jne 0x3c18d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x308f8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SLA(unsigned char*)
void CPU::SLA(uint8_t *r8) {               // SLA r8
  // Set Carry from Left Shift
  this->setCarryFlag((*r8 & 0x80) != 0);

  // Shift Left
  *r8 = *r8 << 1;

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movb (%rsi), %al
shrb $0x7, %al
movzbl %al, %esi
callq 0x30914
movb (%r14), %al
addb %al, %al
movb %al, (%r14)
jne 0x3c24f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x308f8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SRA(unsigned char*)
void CPU::SRA(uint8_t *r8) {               // SRA r8
  // Set Carry from Right Shift
  this->setCarryFlag((*r8 & 0x01) != 0);

  // Shift Arithmetic Right
  uint8_t topBit = *r8 & 0x80;
  *r8 = topBit | (*r8 >> 1);

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %esi
andl $0x1, %esi
callq 0x30914
movb (%r14), %al
movl %eax, %ecx
andb $-0x80, %cl
shrb %al
orb %cl, %al
movb %al, (%r14)
jne 0x3c2f0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x308f8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SRL(unsigned char*)
void CPU::SRL(uint8_t *r8) {                // SRL r8
  // Set Carry from Right Shift
  this->setCarryFlag((*r8 & 0x01) != 0);

  // Shift Logic Right
  *r8 = *r8 >> 1;

  // Set Flags
  if (*r8 == 0)
    this->setZeroFlag(true);
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movzbl (%rsi), %esi
andl $0x1, %esi
callq 0x30914
movb (%r14), %al
movl %eax, %ecx
shrb %cl
movb %cl, (%r14)
cmpb $0x1, %al
ja 0x3c38d
movq %rbx, %rdi
movl $0x1, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x308f8
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::LDHLI()
void CPU::LDHLI() {            // LD [HLI], A
  uint16_t HL = (this->reg.H << 8) | this->reg.L;

  this->memory.write(HL, this->reg.A);
  HL++;

  this->reg.H = HL >> 8;
  this->reg.L = HL & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movzwl 0x11e(%rdi), %r14d
rolw $0x8, %r14w
addq $0x130, %rdi            # imm = 0x130
movzbl 0x118(%rbx), %edx
movzwl %r14w, %esi
callq 0x3d1b8
leal 0x1(%r14), %eax
rolw $0x8, %ax
movw %ax, 0x11e(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::LDAHLI()
void CPU::LDAHLI() {                        // LD A, [HLI]
  uint16_t HL = (this->reg.H << 8) | this->reg.L;

  this->reg.A = this->memory.read(HL);
  HL++;

  this->reg.H = HL >> 8;
  this->reg.L = HL & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movzwl 0x11e(%rdi), %r14d
rolw $0x8, %r14w
addq $0x130, %rdi            # imm = 0x130
movzwl %r14w, %esi
callq 0x3d1ac
movb %al, 0x118(%rbx)
leal 0x1(%r14), %eax
movb %ah, 0x11e(%rbx)
movb %al, 0x11f(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::CALL(unsigned short)
void CPU::CALL(uint16_t u16) {                  // CALL, u16
  // Push Address to Stack
  uint16_t offsetAddr = this->PC + 0x03;        // Offset from CALL
  this->PUSH(&offsetAddr);

  // JP to address
  this->PC = u16 - 0x03;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
movl 0x12c(%rdi), %eax
addl $0x3, %eax
leaq -0x12(%rbp), %rsi
movw %ax, (%rsi)
callq 0x3c5d6
addl $-0x3, %ebx
movw %bx, 0x12c(%r14)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::CALL(ConditionCode, unsigned short)
void CPU::CALL(ConditionCode cc, uint16_t a16) {   // CALL cc, u16
  this->extraCycles = 3;

  switch (cc) {
    case Z:
      if ((this->reg.F & 0x80) != 0)
        return this->CALL(a16);
      break;
    case NZ:
      if ((this->reg.F & 0x80) == 0)
        return this->CALL(a16);
      break;
    case C:
      if ((this->reg.F & 0x10) != 0)
        return this->CALL(a16);
      break;
    case NC:
      if ((this->reg.F & 0x10) == 0)
        return this->CALL(a16);
      break;
  }

  this->extraCycles = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movl $0x3, 0xc(%rdi)
cmpl $0x3, %esi
ja 0x3c6ec
movl %edx, %ebx
movl %esi, %eax
leaq 0x7a82f(%rip), %rcx     # 0xb6e94
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x11d(%r14)
jns 0x3c6ec
movl 0x12c(%r14), %eax
addl $0x3, %eax
leaq -0x12(%rbp), %rsi
jmp 0x3c6d4
testb $0x10, 0x11d(%r14)
je 0x3c6ec
movl 0x12c(%r14), %eax
addl $0x3, %eax
leaq -0x16(%rbp), %rsi
jmp 0x3c6d4
testb $0x10, 0x11d(%r14)
jne 0x3c6ec
movl 0x12c(%r14), %eax
addl $0x3, %eax
leaq -0x18(%rbp), %rsi
jmp 0x3c6d4
cmpb $0x0, 0x11d(%r14)
js 0x3c6ec
movl 0x12c(%r14), %eax
addl $0x3, %eax
leaq -0x14(%rbp), %rsi
movw %ax, (%rsi)
movq %r14, %rdi
callq 0x3c5d6
addl $-0x3, %ebx
movw %bx, 0x12c(%r14)
jmp 0x3c6f4
movl $0x0, 0xc(%r14)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::JP(ConditionCode, unsigned short)
void CPU::JP(ConditionCode cc, uint16_t a16) {  // JP cc, u16
  this->extraCycles = 1;

  switch (cc) {
    case Z:
      if ((this->reg.F & 0x80) != 0)
        return this->JP(a16);
      break;
    case NZ:
      if ((this->reg.F & 0x80) == 0)
        return this->JP(a16);
      break;
    case C:
      if ((this->reg.F & 0x10) != 0)
        return this->JP(a16);
      break;
    case NC:
      if ((this->reg.F & 0x10) == 0)
        return this->JP(a16);
      break;
  }

  this->extraCycles = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x1, 0xc(%rdi)
cmpl $0x3, %esi
ja 0x3c749
movl %esi, %eax
leaq 0x7a76d(%rip), %rcx     # 0xb6ea4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x11d(%rdi)
js 0x3c771
movl $0x0, 0xc(%rdi)
jmp 0x3c77b
testb $0x10, 0x11d(%rdi)
je 0x3c749
jmp 0x3c771
testb $0x10, 0x11d(%rdi)
jne 0x3c749
jmp 0x3c771
cmpb $0x0, 0x11d(%rdi)
js 0x3c749
addl $-0x3, %edx
movw %dx, 0x12c(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::JR(ConditionCode, signed char)
void CPU::JR(ConditionCode cc, int8_t e8) {     // JR cc, e8
  this->extraCycles = 1;

  switch (cc) {
    case Z:
      if ((this->reg.F & 0x80) != 0)
        return this->JR(e8);
      break;
    case NZ:
      if ((this->reg.F & 0x80) == 0)
        return this->JR(e8);
      break;
    case C:
      if ((this->reg.F & 0x10) != 0)
        return this->JR(e8);
      break;
    case NC:
      if ((this->reg.F & 0x10) == 0)
        return this->JR(e8);
      break;
  }

  this->extraCycles = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl $0x1, 0xc(%rdi)
cmpl $0x3, %esi
ja 0x3c7b7
movl %esi, %eax
leaq 0x7a70f(%rip), %rcx     # 0xb6eb4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x11d(%rdi)
js 0x3c7df
movl $0x0, 0xc(%rdi)
jmp 0x3c7e9
testb $0x10, 0x11d(%rdi)
je 0x3c7b7
jmp 0x3c7df
testb $0x10, 0x11d(%rdi)
jne 0x3c7b7
jmp 0x3c7df
cmpb $0x0, 0x11d(%rdi)
js 0x3c7b7
movsbl %dl, %eax
addw %ax, 0x12c(%rdi)
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::RET(ConditionCode)
void CPU::RET(ConditionCode cc) {                 // RET cc
  this->extraCycles = 3;

  switch (cc) {
    case Z:
      if ((this->reg.F & 0x80) != 0)
        return this->RET();
      break;
    case NZ:
      if ((this->reg.F & 0x80) == 0)
        return this->RET();
      break;
    case C:
      if ((this->reg.F & 0x10) != 0)
        return this->RET();
      break;
    case NC:
      if ((this->reg.F & 0x10) == 0)
        return this->RET();
      break;
  }

  this->extraCycles = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x3, 0xc(%rdi)
cmpl $0x3, %esi
ja 0x3c81c
movl %esi, %eax
leaq 0x7a6ba(%rip), %rcx     # 0xb6ec4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpb $0x0, 0x11d(%rbx)
js 0x3c844
movl $0x0, 0xc(%rbx)
jmp 0x3c85a
testb $0x10, 0x11d(%rbx)
je 0x3c81c
jmp 0x3c844
testb $0x10, 0x11d(%rbx)
jne 0x3c81c
jmp 0x3c844
cmpb $0x0, 0x11d(%rbx)
js 0x3c81c
leaq 0x12c(%rbx), %rsi
movq %rbx, %rdi
callq 0x3c886
decw 0x12c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::ADDSP(signed char)
void CPU::ADDSP(int8_t e8) {                     // ADD SP, e8
  uint16_t result = this->SP + e8;

  // Set Flags
  this->setZeroFlag(false);
  this->setAddSubFlag(false);
  this->checkHalfCarry(this->SP >> 8, result >> 8);
  this->checkCarry_16(SP, SP + e8);

  this->SP = result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movzwl 0x12e(%rdi), %eax
addw %r14w, %ax
movzwl %ax, %r15d
xorl %esi, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movzbl 0x12f(%rbx), %esi
movl %r15d, %edx
shrl $0x8, %edx
movq %rbx, %rdi
callq 0x30930
movzwl 0x12e(%rbx), %esi
addl %esi, %r14d
movzwl %r14w, %edx
movq %rbx, %rdi
callq 0x3097e
movw %r15w, 0x12e(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::LDHL(signed char)
void CPU::LDHL(int8_t e8) {                      // LD HL, SP+e8
  uint16_t result = this->SP + e8;

  // Set Flags
  this->setZeroFlag(false);
  this->setAddSubFlag(false);
  this->checkHalfCarry(this->SP >> 8, result >> 8);
  this->checkCarry_16(SP, SP + e8);

  // Store into HL
  this->reg.H = this->SP << 8;
  this->reg.L = this->SP & 0xFF;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %rbx
movzwl 0x12e(%rdi), %eax
addw %r14w, %ax
movzwl %ax, %r15d
xorl %esi, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308dc
movzbl 0x12f(%rbx), %esi
shrl $0x8, %r15d
movq %rbx, %rdi
movl %r15d, %edx
callq 0x30930
movzwl 0x12e(%rbx), %esi
addl %esi, %r14d
movzwl %r14w, %edx
movq %rbx, %rdi
callq 0x3097e
movb $0x0, 0x11e(%rbx)
movb 0x12e(%rbx), %al
movb %al, 0x11f(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::CCF()
void CPU::CCF() {                                // CCF
  // Set Flags
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
  this->reg.F ^= 0x10;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308f8
xorb $0x10, 0x11d(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::CPL()
void CPU::CPL() {                                // CPL
  this->reg.A = ~this->reg.A;

  // Set Flags
  this->setZeroFlag(false);
  this->setHalfCarryFlag(false);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
notb 0x118(%rdi)
xorl %esi, %esi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x308f8
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::DAA()
void CPU::DAA() {                                // DAA
  uint8_t A = this->reg.A;
  bool isAddedSix = false;

  // Addition
  if (!(this->reg.F & 0x40)) {
    if (this->reg.F & 0x20 || (A & 0x0F) > 0x09) {
      A += 0x06;
      isAddedSix = true;
    }
    if (this->reg.F & 0x10 || A > 0x9F || isAddedSix && A < 0x06) { // PATCHED END: If overflow from prev A
      A += 0x60;
      this->setCarryFlag(true);
    }
  }
  
  // Subtraction
  else {
    if (this->reg.F & 0x20) {
      A -= 0x06;
    }
    if (this->reg.F & 0x10) {
      A -= 0x60;
    }
  }

  this->setZeroFlag(A == 0);
  this->setHalfCarryFlag(false);

  // Set the Value
  this->reg.A = A;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb 0x118(%rdi), %cl
movzbl 0x11d(%rdi), %eax
testb $0x40, %al
jne 0x3cce1
movl %eax, %esi
andl $0x20, %esi
shrl $0x5, %esi
movl %ecx, %edx
andb $0xe, %dl
cmpb $0xa, %dl
setae %dl
orb %sil, %dl
movzbl %cl, %esi
addb $0x6, %cl
movzbl %cl, %r14d
testb %dl, %dl
cmovel %esi, %r14d
cmpb $0x6, %r14b
setb %cl
testb $0x10, %al
jne 0x3ccce
cmpb $-0x61, %r14b
ja 0x3ccce
andb %cl, %dl
je 0x3ccfc
addb $0x60, %r14b
movq %rbx, %rdi
movl $0x1, %esi
callq 0x30914
jmp 0x3ccfc
leal -0x6(%rcx), %edx
testb $0x20, %al
movzbl %cl, %ecx
movzbl %dl, %edx
cmovel %ecx, %edx
leal -0x60(%rdx), %ecx
testb $0x10, %al
movzbl %cl, %r14d
cmovel %edx, %r14d
xorl %esi, %esi
testb %r14b, %r14b
sete %sil
movq %rbx, %rdi
callq 0x308c0
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308f8
movb %r14b, 0x118(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Instructions.cc
// Function: CPU::SCF()
void CPU::SCF() {                                // SCF
  // Set Flags
  this->setAddSubFlag(false);
  this->setHalfCarryFlag(false);
  this->setCarryFlag(true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %esi, %esi
callq 0x308dc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x308f8
movq %rbx, %rdi
movl $0x1, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x30914
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Memory.cc
// Function: Memory::Memory(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
Memory::Memory(std::string ROMPath) {
  std::cout << "Dumping ROM...\n";
  dumpROM(ROMPath);

  // Populate Memory
  std::cout << "Populating Memory...\n";
  if (disassembledROM.size() >= 0x7FFF) {
    for (int i = 0; i <= 0x7FFF; i++) {
      memory[i] = disassembledROM[i];
    }
  } else {
    // TODO: Halt, bad dump
  }

  // TODO: Intitial Values
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movl $0x10018, %edx          # imm = 0x10018
movq %r14, %rdi
xorl %esi, %esi
callq 0xc260
movq 0xbc13d(%rip), %rdi     # 0xf8ee8
leaq 0x7a122(%rip), %rsi     # 0xb6ed4
movl $0xf, %edx
callq 0xc830
leaq -0x30(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x40(%rbp), %rdi
callq 0x3a9cc
leaq -0x40(%rbp), %rsi
movq %rbx, %rdi
callq 0x3ce80
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x3cdf9
movq -0x30(%rbp), %rsi
incq %rsi
callq 0xc0d0
movq 0xbc0e8(%rip), %rdi     # 0xf8ee8
leaq 0x7a0dd(%rip), %rsi     # 0xb6ee4
movl $0x15, %edx
callq 0xc830
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rax, %rcx
cmpq $0x7fff, %rcx           # imm = 0x7FFF
jb 0x3ce3a
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
movb %dl, 0x20(%rbx,%rcx)
incq %rcx
cmpq $0x8000, %rcx           # imm = 0x8000
jne 0x3ce27
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
movq -0x40(%rbp), %rdi
cmpq %r12, %rdi
je 0x3ce64
movq -0x30(%rbp), %rsi
incq %rsi
callq 0xc0d0
jmp 0x3ce64
movq %rax, %r15
movq (%r14), %rdi
testq %rdi, %rdi
je 0x3ce78
movq 0x18(%rbx), %rsi
subq %rdi, %rsi
callq 0xc0d0
movq %r15, %rdi
callq 0xc560
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Memory.cc
// Function: Memory::dumpROM(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Memory::dumpROM(std::string ROMPath) {
  std::ifstream infile;
  infile.open(ROMPath);

  // Check if file exists
  if (!infile) {
    std::cout << "ROM not found" << std::endl;
    return;
  }

  // Allocate Space
  disassembledROM.clear();
  disassembledROM.reserve(1024 * 32);

  uint8_t buffer[1];
  for (int i=0; !infile.eof(); i++) {
    infile.read((char *) buffer, 1);
    if (infile.gcount())
      disassembledROM.push_back(buffer[0]);
  }
  std::cout << "ROM Disassembled!\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x210, %rsp            # imm = 0x210
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x230(%rbp), %r15
movq %r15, %rdi
callq 0xc2d0
movq %r15, %rdi
movq %r14, %rsi
movl $0x8, %edx
callq 0xc1b0
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x5, -0x210(%rbp,%rax)
je 0x3cf17
movq 0xbc015(%rip), %rbx     # 0xf8ee8
leaq 0x7a020(%rip), %rsi     # 0xb6efa
movl $0xd, %edx
movq %rbx, %rdi
callq 0xc830
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0xc8b0
movsbl %al, %esi
movq 0xbbfe3(%rip), %rdi     # 0xf8ee8
callq 0xc4a0
movq %rax, %rdi
callq 0xc440
jmp 0x3cfb6
leaq 0x8(%rbx), %r14
movq 0x8(%rbx), %rax
cmpq %rax, 0x10(%rbx)
je 0x3cf29
movq %rax, 0x10(%rbx)
movl $0x8000, %esi           # imm = 0x8000
movq %r14, %rdi
callq 0x3d2ec
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x210(%rbp,%rax)
jne 0x3cf9e
leaq -0x21(%rbp), %r12
movl $0x1, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0xc420
cmpq $0x0, -0x228(%rbp)
je 0x3cf89
movq 0x10(%rbx), %rsi
cmpq 0x18(%rbx), %rsi
je 0x3cf7e
movb -0x21(%rbp), %al
movb %al, (%rsi)
incq 0x10(%rbx)
jmp 0x3cf89
movq %r14, %rdi
movq %r12, %rdx
callq 0x3d390
movq -0x230(%rbp), %rax
movq -0x18(%rax), %rax
testb $0x2, -0x210(%rbp,%rax)
je 0x3cf4f
movq 0xbbf43(%rip), %rdi     # 0xf8ee8
leaq 0x79f5c(%rip), %rsi     # 0xb6f08
movl $0x12, %edx
callq 0xc830
leaq -0x230(%rbp), %rdi
callq 0xc030
addq $0x210, %rsp            # imm = 0x210
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3cfd6
jmp 0x3cfd6
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
callq 0xc030
movq %rbx, %rdi
callq 0xc560
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Memory.cc
// Function: Memory::dump(std::ostream&)
void Memory::dump(std::ostream &out) {
  std::ios init(nullptr);
  init.copyfmt(out);
  out << std::hex << std::uppercase << std::setfill('0') << std::setw(4) << 0 << ": ";

  int j = 0;
  for (int i = 0; i < 0xFFFF; i++) {
    if (j == 16) {
      j = 0;
      out << "\n" << std::setw(4) << i << ": ";
    }
    j++;
    out << std::setw(2) << (int)memory[i] << (j == 8 ? "\t\t" : " ");
  }
  out.copyfmt(init);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rsi, %rbx
movq %rdi, %r14
leaq -0x130(%rbp), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0xc5f0
movq (%rbx), %rax
movq -0x18(%rax), %rsi
addq %rbx, %rsi
movq %r15, %rdi
callq 0xc250
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl $-0x4b, %edx
orl $0x8, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rcx
orl $0x4000, 0x18(%rbx,%rcx) # imm = 0x4000
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %r15
cmpb $0x0, 0xe1(%rbx,%rax)
jne 0x3d07a
movq %r15, %rdi
movl $0x20, %esi
callq 0xc8b0
movb %al, 0xe0(%r15)
movb $0x1, 0xe1(%r15)
movb $0x30, 0xe0(%r15)
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x10(%rbx,%rax)
movq %rbx, %rdi
xorl %esi, %esi
callq 0xc270
leaq 0x75fe3(%rip), %rsi     # 0xb3086
movl $0x2, %edx
movq %rax, %rdi
callq 0xc830
xorl %r15d, %r15d
leaq 0x7e146(%rip), %r13     # 0xbb200
xorl %r12d, %r12d
cmpl $0x10, %r12d
jne 0x3d109
movl $0x1, %edx
movq %rbx, %rdi
leaq 0x867f5(%rip), %rsi     # 0xc38c7
callq 0xc830
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x4, 0x10(%rbx,%rax)
movq %rbx, %rdi
movl %r15d, %esi
callq 0xc270
xorl %r12d, %r12d
movl $0x2, %edx
movq %rax, %rdi
leaq 0x75f82(%rip), %rsi     # 0xb3086
callq 0xc830
movq (%rbx), %rax
movq -0x18(%rax), %rax
movq $0x2, 0x10(%rbx,%rax)
movzbl 0x20(%r14,%r15), %esi
movq %rbx, %rdi
callq 0xc270
incl %r12d
xorl %edx, %edx
cmpl $0x8, %r12d
sete %dl
movq %r13, %rsi
leaq 0x79dde(%rip), %rcx     # 0xb6f1b
cmoveq %rcx, %rsi
incq %rdx
movq %rax, %rdi
callq 0xc830
incq %r15
cmpq $0xffff, %r15           # imm = 0xFFFF
jne 0x3d0bd
movq (%rbx), %rax
addq -0x18(%rax), %rbx
leaq -0x130(%rbp), %rsi
movq %rbx, %rdi
callq 0xc250
leaq -0x130(%rbp), %rdi
callq 0xc5e0
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3d194
jmp 0x3d194
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0xc5e0
movq %rbx, %rdi
callq 0xc560
nop
// File: /workspace/github_cpp_makefile_star2_O1/Ciaxur[P]yagb-emu/src/Memory.cc
// Function: Memory::write(unsigned short, unsigned char)
void Memory::write(uint16_t address, uint8_t value) {
  // TODO: MBC Switch
  if (address < 0x7FFF) {

  }

  // Output Serial Link
  else if (address == 0xFF02 && value == 0x81) {
//    std::cout << "Serial Link Value: " << std::hex << (int)this->read(0xFF01) << '\n';
    std::cout << (char)this->read(0xFF01);

    // Serial Write Interrupt
    memory[0xFF0F] |= 0x08;
  }

  // VRAM Write
  else if (address >= 0x8000 && address <= 0x9FFF && *(this->LCDMode) != 3) {
    memory[address] = value;
  }

  // Reset DIV if writen to
  else if (address == 0xFF04) {
    memory[0xFF04] = 0;
  }

  // Prohibited Areas, NO.
  else if (!(address >= 0xE000 && address <= 0xFDFF) && !(address >= 0xFEA0 && address <= 0xFEFF)) {
    memory[address] = value;
  }

  else {
    // Writing out of range
    std::cout << "Memory.write [" << std::hex << address << std::dec << "]: INVALID RANGE!\n";
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl $0x7fff, %esi           # imm = 0x7FFF
jb 0x3d2e3
movq %rdi, %r14
movzwl %si, %ebx
cmpl $0xff02, %ebx           # imm = 0xFF02
setne %al
cmpb $-0x7f, %dl
setne %cl
orb %al, %cl
jne 0x3d213
movb 0xff21(%r14), %al
leaq -0x11(%rbp), %rsi
movb %al, (%rsi)
movq 0xbbcec(%rip), %rdi     # 0xf8ee8
movl $0x1, %edx
callq 0xc830
orb $0x8, 0xff2f(%r14)
jmp 0x3d2e3
cmpl $0x7fff, %ebx           # imm = 0x7FFF
sete %al
cmpl $0xa000, %ebx           # imm = 0xA000
setae %cl
orb %al, %cl
jne 0x3d239
movq 0x10020(%r14), %rax
cmpb $0x3, (%rax)
jne 0x3d2de
cmpl $0xff04, %ebx           # imm = 0xFF04
jne 0x3d24e
movb $0x0, 0xff24(%r14)
jmp 0x3d2e3
leal 0x2000(%rsi), %eax
movzwl %ax, %eax
cmpl $0x1e00, %eax           # imm = 0x1E00
setb %al
addl $0x160, %esi            # imm = 0x160
cmpw $0x60, %si
setb %cl
orb %al, %cl
je 0x3d2de
movq 0xbbc71(%rip), %r14     # 0xf8ee8
leaq 0x79ca0(%rip), %rsi     # 0xb6f1e
movl $0xe, %edx
movq %r14, %rdi
callq 0xc830
movq (%r14), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%r14,%rax)
movq %r14, %rdi
movq %rbx, %rsi
callq 0xc460
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
leaq 0x79c64(%rip), %rsi     # 0xb6f2d
movl $0x12, %edx
movq %rax, %rdi
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0xc830
movb %dl, 0x20(%r14,%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq