LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_jsr(int)
inline void cpu::op_jsr(int addr) {
    //saves address immediately BEFORE the one I want to return to!!!
    //REASON: RTS pops the stack to the PC, THEN increments PC by 1
    pc--;
    push2(pc);
    pc=addr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl (%rdi), %ebp
decl %ebp
movl %ebp, (%rdi)
movl %ebp, %edx
shrl $0x8, %edx
movq 0x10(%rdi), %rdi
movzbl 0xe(%r14), %esi
movl $0x100, %r15d           # imm = 0x100
orl %r15d, %esi
movl $0xff, %r12d
andl %r12d, %edx
callq 0xacaa
movb 0xe(%r14), %al
decb %al
movb %al, 0xe(%r14)
movq 0x10(%r14), %rdi
movzbl %al, %esi
orl %r15d, %esi
andl %r12d, %ebp
movl %ebp, %edx
callq 0xacaa
decb 0xe(%r14)
movl %ebx, (%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bit(int)
inline void cpu::op_bit(int addr) {
    temp=memory->read(addr);
    set_zero(acc&temp);
    set_sign(temp);
    if((temp&0x40)>0)
        status.verflow = 1;
    else
        status.verflow = 0;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movl %eax, 0x454(%rbx)
testb %al, 0x4(%rbx)
sete %cl
movb 0x8(%rbx), %dl
addb %cl, %cl
andb $0x3d, %dl
movl %eax, %esi
andb $-0x80, %sil
orb %dl, %sil
orb %cl, %sil
andb $0x40, %al
orb %sil, %al
movb %al, 0x8(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_rolm(int)
inline void cpu::op_rolm(int addr) {
    temp=memory->read(addr);
    temp2 = status.carry;
    set_carry(temp&0x80);
    temp=((temp<<(1))+temp2);
    memory->write(addr,temp);
    set_zero(temp);
    set_sign(temp);        
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movzbl 0x8(%rbx), %ecx
movl %ecx, %edx
andl $0x1, %edx
movl %edx, 0x458(%rbx)
leal (%rdx,%rax,2), %edx
shrb $0x7, %al
andb $-0x2, %cl
orb %al, %cl
movb %cl, 0x8(%rbx)
movl %edx, 0x454(%rbx)
movq 0x10(%rbx), %rdi
movzbl %dl, %edx
movl %ebp, %esi
callq 0xacaa
movb 0x454(%rbx), %al
testb %al, %al
sete %cl
movb 0x8(%rbx), %dl
addb %cl, %cl
andb $0x7d, %dl
andb $-0x80, %al
orb %dl, %al
orb %cl, %al
movb %al, 0x8(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_rola()
inline void cpu::op_rola() {
    temp = status.carry;
    set_carry(acc&0x80);
    acc=(acc<<(1))+temp;
    set_zero(acc);
    set_sign(acc);
}

// Assembly:
movzbl 0x8(%rdi), %eax
movl %eax, %ecx
andl $0x1, %ecx
movl %ecx, 0x454(%rdi)
movb 0x4(%rdi), %dl
movl %edx, %esi
shrb $0x7, %sil
andb $0x7c, %al
orb %sil, %al
addb %dl, %dl
movl %edx, %esi
orb %cl, %sil
movb %sil, 0x4(%rdi)
sete %cl
addb %cl, %cl
andb $-0x80, %dl
orb %al, %dl
orb %cl, %dl
movb %dl, 0x8(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_eor(int)
inline void cpu::op_eor(int addr) {
    temp=memory->read(addr);
    acc^=temp;
    set_sign(acc);
    set_zero(acc);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movl %eax, 0x454(%rbx)
movb 0x4(%rbx), %cl
movb 0x8(%rbx), %dl
movl %ecx, %esi
xorb %al, %sil
movb %sil, 0x4(%rbx)
andb $-0x80, %sil
andb $0x7d, %dl
cmpb %al, %cl
sete %al
addb %al, %al
orb %sil, %al
orb %dl, %al
movb %al, 0x8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_lsrm(int)
inline void cpu::op_lsrm(int addr) {
    temp=memory->read(addr);
    status.sign = 0;
    set_carry(temp&0x01);
    temp>>=(1);
    set_zero(temp);
    memory->write(addr,temp);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0xa996
movb 0x8(%r14), %cl
movl %eax, %edx
andb $0x1, %dl
andb $0x7c, %cl
orb %dl, %cl
shrl %eax
movl %eax, 0x454(%r14)
testb %al, %al
sete %dl
addb %dl, %dl
orb %cl, %dl
movb %dl, 0x8(%r14)
movq 0x10(%r14), %rdi
movzbl %al, %edx
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xacaa
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::pop2()
inline unsigned int cpu::pop2() {
    sp++;
    unsigned int pcl=memory->read(0x100+sp);
    sp++;
    unsigned int pch=memory->read(0x100+sp);
    return pch*0x100+pcl;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb 0xe(%rdi), %al
incb %al
movb %al, 0xe(%rdi)
movq 0x10(%rdi), %rdi
movzbl %al, %esi
movl $0x100, %r14d           # imm = 0x100
orl %r14d, %esi
callq 0xa996
movl %eax, %ebp
movb 0xe(%rbx), %al
incb %al
movb %al, 0xe(%rbx)
movq 0x10(%rbx), %rdi
movzbl %al, %esi
orl %r14d, %esi
callq 0xa996
shll $0x8, %eax
addl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_adc(int)
inline void cpu::op_adc(int addr) {
    temp=memory->read(addr);
    temp2=temp+acc+status.carry;
    //if the operands have the same sign, AND      The operands have the same sign as the result
    if (!((acc ^ temp) & 0x80) && ((acc ^ temp2) & 0x80))
        status.verflow = 1;
    else
        status.verflow = 0;
    set_zero(temp2);
    set_sign(temp2);
    if((int(temp)+int(acc)+status.carry)>0xFF)
        status.carry = 1;
    else
        status.carry = 0;
    acc=temp2;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movl %eax, 0x454(%rbx)
movzbl 0x4(%rbx), %edi
leal (%rax,%rdi), %edx
movzbl 0x8(%rbx), %esi
movl %esi, %ecx
andl $0x1, %ecx
addl %edx, %ecx
movl %ecx, 0x458(%rbx)
movl %edi, %r8d
xorb %al, %r8b
js 0xd54e
xorb %cl, %dil
js 0xd554
andb $-0x41, %sil
jmp 0xd558
orb $0x40, %sil
testb %cl, %cl
sete %al
addb %al, %al
movl %esi, %edi
andb $0x7c, %dil
movl %ecx, %r8d
andb $-0x80, %r8b
orb %al, %r8b
orb %dil, %r8b
andb $0x1, %sil
movzbl %sil, %eax
addl %eax, %edx
cmpl $0x100, %edx            # imm = 0x100
setge %al
orb %r8b, %al
movb %al, 0x8(%rbx)
movb %cl, 0x4(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_rorm(int)
inline void cpu::op_rorm(int addr) {
    temp=memory->read(addr);
    temp2=status.carry*0x80;
    set_carry(temp&0x01);
    temp=(temp>>(1))+temp2;
    set_sign(temp);
    set_zero(temp);
    memory->write(addr,temp);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0xa996
movb 0x8(%r14), %cl
movl %ecx, %edx
shlb $0x7, %dl
movzbl %dl, %edx
movl %edx, 0x458(%r14)
movl %eax, %esi
andb $0x1, %sil
andb $0x7c, %cl
orb %sil, %cl
shrl %eax
addl %edx, %eax
movl %eax, 0x454(%r14)
movl %eax, %edx
andb $-0x80, %dl
orb %cl, %dl
testb %al, %al
sete %cl
addb %cl, %cl
orb %dl, %cl
movb %cl, 0x8(%r14)
movq 0x10(%r14), %rdi
movzbl %al, %edx
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xacaa
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_rora()
inline void cpu::op_rora() {
    temp2=status.carry*0x80;
    set_carry(acc&0x01);
    acc=(acc>>(1))+temp2;
    set_sign(acc);
    set_zero(acc);
}

// Assembly:
movb 0x4(%rdi), %al
movb 0x8(%rdi), %cl
movl %ecx, %edx
shlb $0x7, %dl
movzbl %dl, %edx
movl %edx, 0x458(%rdi)
movl %eax, %esi
andb $0x1, %sil
andb $0x7c, %cl
orb %sil, %cl
shrb %al
orb %dl, %al
movb %al, 0x4(%rdi)
testb %al, %al
sete %al
addb %al, %al
orb %cl, %al
orb %dl, %al
movb %al, 0x8(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::ind()
inline int cpu::ind() {
    int addr=memory->read2(pc+1);
    if((addr&0xFF)==0xFF) {
        return (memory->read(addr))|((memory->read(addr-0xFF))<<(8));
    }
    else {
        return memory->read2(addr);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
movl (%rbx), %esi
incl %esi
callq 0xac10
movl %eax, %ebp
movq 0x10(%rbx), %rdi
cmpb $-0x1, %bpl
jne 0xd6ae
movl %ebp, %esi
callq 0xa996
movl %eax, %r14d
movq 0x10(%rbx), %rdi
addl $0xffffff01, %ebp       # imm = 0xFFFFFF01
movl %ebp, %esi
callq 0xa996
shll $0x8, %eax
orl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl %ebp, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0xac10
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_cpy(int)
inline void cpu::op_cpy(int addr) {
    temp=memory->read(addr);
    if(y>=temp)
        status.carry = 1;
    else
        status.carry = 0;
    temp=y-temp;
    set_sign(temp);
    set_zero(temp);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movzbl 0xd(%rbx), %ecx
subl %eax, %ecx
setae %al
movb 0x8(%rbx), %dl
andb $0x7c, %dl
orb %al, %dl
movl %ecx, 0x454(%rbx)
movl %ecx, %eax
andb $-0x80, %al
testb %cl, %cl
sete %cl
addb %cl, %cl
orb %al, %cl
orb %dl, %cl
movb %cl, 0x8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_dec(int)
inline void cpu::op_dec(int addr) {
    temp=memory->read(addr);
    temp--;
    set_sign(temp);
    set_zero(temp);
    memory->write(addr,temp);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0xa996
decl %eax
movl %eax, 0x454(%r14)
movl %eax, %ecx
andb $-0x80, %cl
movb 0x8(%r14), %dl
andb $0x7d, %dl
orb %cl, %dl
testb %al, %al
sete %cl
addb %cl, %cl
orb %dl, %cl
movb %cl, 0x8(%r14)
movq 0x10(%r14), %rdi
movzbl %al, %edx
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xacaa
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_sbc(int)
inline void cpu::op_sbc(int addr) {
    temp=memory->read(addr);
    temp2=temp;
    temp+=(status.carry?0:1);
    set_zero(acc-temp);
    set_sign(acc-temp);
    if(((acc^temp)&0x80)>0&&((acc^temp2)&0x80)>0) //magic code from 6502 docs
        status.verflow = 1;
    else
        status.verflow = 0;

    if(acc>=temp) {
        status.carry = 1;
    }
    else {
        status.carry = 0;
    }
    acc-=temp;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq 0x10(%rdi), %rdi
callq 0xa996
movl %eax, 0x458(%rbx)
movl 0x8(%rbx), %r8d
movl %r8d, %ecx
notl %ecx
andl $0x1, %ecx
addl %eax, %ecx
movl %ecx, 0x454(%rbx)
movzbl 0x4(%rbx), %esi
movl %esi, %edx
subb %cl, %dl
sete %dil
addb %dil, %dil
andb $0x7d, %r8b
orb %dil, %r8b
movl %edx, %edi
andb $-0x80, %dil
orb %r8b, %dil
movb %dil, 0x8(%rbx)
movl %ecx, %r8d
xorb %sil, %r8b
jns 0xd8a7
xorb %sil, %al
js 0xd8ad
andb $-0x41, %dil
jmp 0xd8b1
orb $0x40, %dil
cmpl %esi, %ecx
setbe %al
andb $-0x2, %dil
orb %al, %dil
movb %dil, 0x8(%rbx)
movb %dl, 0x4(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_inc(int)
inline void cpu::op_inc(int addr) {
    temp=memory->read(addr);
    temp++;
    set_sign(temp);
    set_zero(temp);
    memory->write(addr,temp);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0xa996
incl %eax
movl %eax, 0x454(%r14)
movl %eax, %ecx
andb $-0x80, %cl
movb 0x8(%r14), %dl
andb $0x7d, %dl
orb %cl, %dl
testb %al, %al
sete %cl
addb %cl, %cl
orb %dl, %cl
movb %cl, 0x8(%r14)
movq 0x10(%r14), %rdi
movzbl %al, %edx
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xacaa
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::set_mirror(unsigned int)
void ppu::set_mirror(unsigned int mode) {
    if(mode == VERT) {
        nt[0] = &(name_table[NT0_OFFSET]);
        nt[2] = nt[0];

        at[0] = &(name_table[AT0_OFFSET]);
        at[2] = at[0];

        nt[1] = &(name_table[NT1_OFFSET]);
        nt[3] = nt[1];

        at[1] = &(name_table[AT1_OFFSET]);
        at[3] = at[1];
    }
    else if(mode == HORIZ) {
        nt[0] = &(name_table[NT0_OFFSET]);
        nt[1] = nt[0];

        at[0] = &(name_table[AT0_OFFSET]);
        at[1] = at[0];

        nt[2] = &(name_table[NT1_OFFSET]);
        nt[3] = nt[2];

        at[2] = &(name_table[AT1_OFFSET]);
        at[3] = at[2];
    }
    else if(mode == FOUR_SCR) {
        nt[0] = &(name_table[NT0_OFFSET]);
        at[0] = &(name_table[AT0_OFFSET]);

        nt[1] = &(name_table[NT1_OFFSET]);
        at[1] = &(name_table[AT1_OFFSET]);

        nt[2] = &(name_table[NT2_OFFSET]);
        at[2] = &(name_table[AT2_OFFSET]);

        nt[3] = &(name_table[NT3_OFFSET]);
        at[3] = &(name_table[AT3_OFFSET]);
    }
    else { cout<<"WTF? Unrecognized mirror mode."<<endl;}
}

// Assembly:
cmpl $0x2, %esi
je 0xde0f
cmpl $0x1, %esi
je 0xddc0
testl %esi, %esi
jne 0xde80
leaq 0x6ec(%rdi), %rax
movq %rax, 0x16f0(%rdi)
movq %rax, 0x1700(%rdi)
leaq 0xaac(%rdi), %rax
movq %rax, 0x1710(%rdi)
movq %rax, 0x1720(%rdi)
leaq 0xaec(%rdi), %rax
movq %rax, 0x16f8(%rdi)
movq %rax, 0x1708(%rdi)
leaq 0xeac(%rdi), %rax
movq %rax, 0x1718(%rdi)
jmp 0xde78
leaq 0x6ec(%rdi), %rax
movq %rax, 0x16f0(%rdi)
movq %rax, 0x16f8(%rdi)
leaq 0xaac(%rdi), %rax
movq %rax, 0x1710(%rdi)
movq %rax, 0x1718(%rdi)
leaq 0xaec(%rdi), %rax
movq %rax, 0x1700(%rdi)
movq %rax, 0x1708(%rdi)
leaq 0xeac(%rdi), %rax
movq %rax, 0x1720(%rdi)
jmp 0xde78
leaq 0x6ec(%rdi), %rax
movq %rax, 0x16f0(%rdi)
leaq 0xaac(%rdi), %rax
movq %rax, 0x1710(%rdi)
leaq 0xaec(%rdi), %rax
movq %rax, 0x16f8(%rdi)
leaq 0xeac(%rdi), %rax
movq %rax, 0x1718(%rdi)
leaq 0xeec(%rdi), %rax
movq %rax, 0x1700(%rdi)
leaq 0x12ac(%rdi), %rax
movq %rax, 0x1720(%rdi)
leaq 0x12ec(%rdi), %rax
movq %rax, 0x1708(%rdi)
leaq 0x16ac(%rdi), %rax
movq %rax, 0x1728(%rdi)
retq
pushq %rbx
movq 0xe128(%rip), %rbx      # 0x1bfb0
leaq 0x76e9(%rip), %rsi      # 0x15578
movl $0x1e, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
popq %rbx
jmp 0x4290
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::clear_surfaces(bool)
void ppu::clear_surfaces(bool bank) {
    if(!bank)
        for(int tile = 0; tile < 256; ++tile)
            for(int palette = 0; palette < 8; ++palette)
                unget_Surface(0,tile,palette);
    else
        for(int tile = 0; tile < 256; ++tile)
            for(int palette = 0; palette < 8; ++palette)
                unget_Surface(1,tile,palette);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
xorl %ebp, %ebp
testl %esi, %esi
je 0xdefb
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xdf26
incl %r14d
cmpl $0x8, %r14d
jne 0xded4
incl %ebp
cmpl $0x100, %ebp            # imm = 0x100
jne 0xded1
jmp 0xdf20
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xdf26
incl %r14d
cmpl $0x8, %r14d
jne 0xdefe
incl %ebp
cmpl $0x100, %ebp            # imm = 0x100
jne 0xdefb
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::unget_Surface(int, int, int)
void ppu::unget_Surface(int table, int tile, int palnum) {
    for(int hf = 0; hf < 2; ++hf) {
        for(int vf = 0; vf < 2; ++vf) {
            SDL_Surface * temp = tile_cache[table][tile][palnum][hf][vf];
            if(!temp) continue;
            SDL_FreeSurface(temp);
            tile_cache[table][tile][palnum][hf][vf] = NULL;
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movslq %esi, %rax
movslq %edx, %rdx
movslq %ecx, %rcx
shlq $0x10, %rax
shlq $0x8, %rdx
addq %rax, %rdx
shlq $0x5, %rcx
addq %rdx, %rcx
leaq (%rdi,%rcx), %rbx
addq $0x1850, %rbx           # imm = 0x1850
xorl %r14d, %r14d
xorl %r15d, %r15d
movq (%rbx,%r15,8), %rdi
testq %rdi, %rdi
je 0xdf6d
callq 0x4360
movq $0x0, (%rbx,%r15,8)
incq %r15
cmpq $0x1, %r15
je 0xdf57
leaq 0x1(%r14), %rax
addq $0x10, %rbx
testq %r14, %r14
movq %rax, %r14
je 0xdf54
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::~ppu()
ppu::~ppu() {
    //cout<<"Start ppu desctructor"<<endl;
    cout<<"Reads: "<<s.reads<<" ("<<s.twok2_reads<<" to 0x2002, "<<s.reads_during_render<<" during render) Writes: "<<s.writes<<" ("<<s.writes_during_render<<" during render) DMAs: "<<(s.dmas/256)<<endl<<"Total cycles: "<<s.cycles<<" Total frames: "<<frame<<endl;
    clear_surfaces(false);
    clear_surfaces(true);
    while(scroll_shifts.size() > 0) scroll_shifts.pop_front();
    //cout<<"End ppu destructor"<<endl<<endl;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0xe013(%rip), %rdi      # 0x1bfb0
leaq 0x7610(%rip), %rsi      # 0x155b4
movl $0x7, %edx
callq 0x4410
movl 0x1b8(%rbx), %esi
movq 0xdff5(%rip), %rdi      # 0x1bfb0
callq 0x4280
movq %rax, %r14
leaq 0x8202(%rip), %rsi      # 0x161cc
movl $0x2, %edx
movq %rax, %rdi
callq 0x4410
movl 0x1bc(%rbx), %esi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
leaq 0x75cd(%rip), %rsi      # 0x155bc
movl $0xc, %edx
movq %rax, %rdi
callq 0x4410
movl 0x1c0(%rbx), %esi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
leaq 0x75b5(%rip), %rsi      # 0x155c9
movl $0x18, %edx
movq %rax, %rdi
callq 0x4410
movl 0x1cc(%rbx), %esi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
leaq 0x8193(%rip), %rsi      # 0x161cc
movl $0x2, %edx
movq %rax, %rdi
callq 0x4410
movl 0x1c4(%rbx), %esi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
leaq 0x7584(%rip), %rsi      # 0x155e2
movl $0x16, %edx
movq %rax, %rdi
callq 0x4410
movl 0x1c8(%rbx), %esi
shrl $0x8, %esi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4290
movq %rax, %r14
leaq 0x7549(%rip), %rsi      # 0x155f9
movl $0xe, %edx
movq %rax, %rdi
callq 0x4410
movq 0x1d8(%rbx), %rsi
movq %r14, %rdi
callq 0x4280
movq %rax, %r14
leaq 0x7532(%rip), %rsi      # 0x15608
movl $0xf, %edx
movq %rax, %rdi
callq 0x4410
movl 0x2185c(%rbx), %esi
movq %r14, %rdi
callq 0x45e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4290
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %rbx, %rdi
xorl %esi, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xdf26
incl %r14d
cmpl $0x8, %r14d
jne 0xe120
incl %ebp
cmpl $0x100, %ebp            # imm = 0x100
jne 0xe11d
xorl %ebp, %ebp
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0x1, %esi
movl %ebp, %edx
movl %r14d, %ecx
callq 0xdf26
incl %r14d
cmpl $0x8, %r14d
jne 0xe147
incl %ebp
cmpl $0x100, %ebp            # imm = 0x100
jne 0xe144
leaq 0x1f0(%rbx), %r15
movq 0x200(%rbx), %rax
testq %rax, %rax
je 0xe1a2
movq 0x1f0(%rbx), %r14
decq %rax
movq %rax, 0x200(%rbx)
movq %r14, %rdi
callq 0x4590
movq %r14, %rdi
callq 0x4380
jmp 0xe173
movq (%r15), %rdi
cmpq %r15, %rdi
je 0xe1ba
movq (%rdi), %r14
callq 0x4380
movq %r14, %rdi
cmpq %r15, %r14
jne 0xe1aa
addq $0x8, %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1212c
jmp 0xe1d4
jmp 0xe1d4
movq %rax, %rdi
callq 0xfd69
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::phase(unsigned int)
const ppu::ppu_phase ppu::phase(const unsigned int cycle) {
    int odd_diff = ((frame % 2 == 0)?0:1);
    ppu_phase choice = DUNNO;

    if(!control1.bits.show_bg && !control1.bits.show_sprites) choice = DISABLED; //DISABLED
    else if(cycle < (unsigned int)(VINT_LINES * CLK_PER_LINE)) choice = VINT; //VINT
    else if(cycle < (unsigned int)((VINT_LINES + PRE_RENDER_LINES) * CLK_PER_LINE - odd_diff)) choice = PRE_RENDER; //PRE_RENDER
    else if(cycle < (unsigned int)((VINT_LINES + PRE_RENDER_LINES + RENDER_LINES) * CLK_PER_LINE) - odd_diff) choice = RENDER; //RENDER
    else if(cycle < (unsigned int)((VINT_LINES + PRE_RENDER_LINES + RENDER_LINES + POST_RENDER_LINES) * CLK_PER_LINE) - odd_diff) choice = POST_RENDER; //POST_RENDER
    return choice;
}

// Assembly:
testb $0x18, 0x21854(%rdi)
je 0xe84b
movl $0x1, %eax
cmpl $0x1aa4, %esi           # imm = 0x1AA4
jb 0xe84a
movl 0x2185c(%rdi), %ecx
andl $0x1, %ecx
movl %ecx, %edx
xorl $0x1bf9, %edx           # imm = 0x1BF9
movl $0x2, %eax
cmpl %esi, %edx
ja 0xe84a
movl %ecx, %edx
xorl $0x15ba9, %edx          # imm = 0x15BA9
movl $0x3, %eax
cmpl %esi, %edx
ja 0xe84a
movl $0x15cfe, %edx          # imm = 0x15CFE
subl %ecx, %edx
xorl %eax, %eax
cmpl %esi, %edx
seta %al
shll $0x2, %eax
retq
movl $0x5, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::s0_hit_cycle(unsigned int)
unsigned int ppu::s0_hit_cycle(unsigned int cycle) {
    //TODO: This is an inexact estimate. It needs fixed, sometime.
    //      (Better than the last version of the estimate, though ;-)
    if(recalc_s0) {
        if(sprites[0].y + 1 > 239) spr_hit0_cycle = -1;
        else {
            int spry = sprites[0].y + 1;
            int sprx = sprites[0].x;
            bool hf = sprites[0].hflip;
            bool vf = sprites[0].vflip;
            int palnum = sprites[0].pal | 4;
            int tile = sprites[0].tile;
            int table = control0.sprite_table;
            SDL_Surface * s = get_Surface(table, tile, palnum, hf, vf);
            int px = -1;
            int py = -1;
            for(int x = 0; x < 8; ++x)
                for(int y = 0; y < 8; ++y) {
                    unsigned char t =((unsigned char *)s->pixels)[y*(s->pitch)+x];
                    if(t != NES_TRANSPARENT) {
                        px = x; py = y; /*cout<<"x: "<<x<<" y: "<<y<<" val: "<<int(t)<<endl;*/ goto loop_exit;
                    }
                }
            loop_exit:
            if(px == -1) spr_hit0_cycle = -1;
            else spr_hit0_cycle = ((spry + 1 + py) * CLK_PER_LINE + sprx + px);
            recalc_s0 = false;
        }
    }
    return spr_hit0_cycle;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x1, 0x6d5(%rdi)
jne 0xe960
movl 0x208(%rbx), %eax
movzbl %al, %ebp
cmpl $0xef, %ebp
jb 0xe889
movl $0xffffffff, 0x6d0(%rbx) # imm = 0xFFFFFFFF
jmp 0xe960
movl %eax, %ecx
shrl $0x18, %ecx
movl %ecx, %r15d
movl %eax, %ecx
shrl $0x10, %ecx
andl $0x3, %ecx
orl $0x4, %ecx
movzbl %ah, %edx
movl 0x21850(%rbx), %esi
shrl $0x3, %esi
andl $0x1, %esi
movl %eax, %r8d
shrl $0x16, %r8d
andl $0x1, %r8d
shrl $0x17, %eax
andl $0x1, %eax
movq %rbx, %rdi
movl %eax, %r9d
callq 0xe972
movq 0x20(%rax), %rcx
movslq 0x18(%rax), %rdx
leaq (%rcx,%rdx), %rsi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %r8d, %r8d
xorl %r9d, %r9d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
cmpb $0x4a, (%rcx,%r9)
cmovnel %r8d, %edi
cmovnel %r9d, %eax
jne 0xe921
movq %rsi, %r11
xorl %r14d, %r14d
movq %r14, %r10
cmpq $0x7, %r14
je 0xe917
leaq 0x1(%r10), %r14
cmpb $0x4a, (%r11)
cmovnel %r14d, %edi
leaq (%r11,%rdx), %r11
cmovnel %r9d, %eax
je 0xe8f8
cmpq $0x7, %r10
setae %r10b
jmp 0xe924
xorl %r10d, %r10d
testb %r10b, %r10b
je 0xe935
incq %r9
incq %rsi
cmpq $0x8, %r9
jne 0xe8e3
cmpl $-0x1, %eax
je 0xe94e
addl %edi, %ebp
imull $0x155, %ebp, %ecx      # imm = 0x155
addl %r15d, %eax
addl %ecx, %eax
addl $0x2aa, %eax            # imm = 0x2AA
jmp 0xe953
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, 0x6d0(%rbx)
movb $0x0, 0x6d5(%rbx)
movl 0x6d0(%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::overflow_cycle(unsigned int)
unsigned int ppu::overflow_cycle(unsigned int cycle) {
    if(recalc_overflow) {
        int lines[240] = {0};
        spr_overflow_cycle = 0;
        for(int sprite = 0; sprite < 64; ++sprite) { //For each sprite...
            //Increment sprite count for each line that the sprite is visible on
            for(int y = sprites[sprite].y; (y < sprites[sprite].y + 8 + (control0.big_sprites * 8)) && y < 240; ++y)
                ++lines[y];
        }
        for(int line = 0; line < 240; ++line) {
            if(lines[line] > 8) {
                spr_overflow_cycle = line * CLK_PER_LINE;
                break;
            }
        }
        //if no overflow found, set the overflow value out of range (ie no overflow occurs)
        if(spr_overflow_cycle == 0) spr_overflow_cycle = -1;
        recalc_overflow = false;
    }
    return spr_overflow_cycle;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x3c0, %rsp            # imm = 0x3C0
movq %rdi, %rbx
cmpb $0x1, 0x6d4(%rdi)
jne 0xec1e
movq %rsp, %r14
xorl %r15d, %r15d
movl $0x3c0, %edx            # imm = 0x3C0
movq %r14, %rdi
xorl %esi, %esi
callq 0x4220
movl $0x0, 0x6cc(%rbx)
movl 0x21850(%rbx), %eax
shrl $0x2, %eax
andl $0x8, %eax
movl $0xf0, %ecx
movzbl 0x208(%rbx,%r15,4), %edx
leal (%rdx,%rax), %esi
addl $0x8, %esi
cmpl %ecx, %esi
cmovael %ecx, %esi
cmpl %esi, %edx
jae 0xebd9
movl %esi, %esi
incl (%rsp,%rdx,4)
incq %rdx
cmpq %rdx, %rsi
jne 0xebce
incq %r15
cmpq $0x40, %r15
jne 0xebb4
xorl %eax, %eax
cmpl $0x9, (%r14)
jge 0xebfe
addq $0x155, %rax            # imm = 0x155
addq $0x4, %r14
cmpq $0x13fb0, %rax          # imm = 0x13FB0
jne 0xebe4
jmp 0xec04
movl %eax, 0x6cc(%rbx)
cmpl $0x0, 0x6cc(%rbx)
jne 0xec17
movl $0xffffffff, 0x6cc(%rbx) # imm = 0xFFFFFFFF
movb $0x0, 0x6d4(%rbx)
movl 0x6cc(%rbx), %eax
addq $0x3c0, %rsp            # imm = 0x3C0
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::set_scroll(int, int, int, int)
void ppu::set_scroll(int rx, int ry, int mod_col, int mod_row) {
    if(scroll_shifts.size() == 0 && rx != init_scroll_x) {
        //cout<<"First: Shifting scroll to "<<rx<<" at line "<<mod_row<<", frame "<<frame<<" (isx="<<init_scroll_x<<", size="<<scroll_shifts.size()<<")"<<endl;
        scroll_shifts.push_back(std::make_pair(rx,mod_row));
    }
    else if(scroll_shifts.size() > 0 && rx != scroll_shifts.back().first) {
        //cout<<"C1: "<<(scroll_shifts.size() == 0)<<" C2: "<<(rx!=init_scroll_x)<<endl;
        //cout<<"Second: Shifting scroll to "<<rx<<" at line "<<mod_row<<", frame "<<frame<<" (isx="<<init_scroll_x<<", size="<<scroll_shifts.size()<<")"<<endl;
        scroll_shifts.push_back(std::make_pair(rx,mod_row));
    }
    else {
        //cout<<"Filtering this scroll."<<endl;
        return;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x200(%rdi), %rax
testq %rax, %rax
jne 0xec5c
cmpl %esi, 0x1e8(%rbx)
jne 0xec6d
testq %rax, %rax
je 0xec9e
movq 0x1f8(%rbx), %rax
cmpl %esi, 0x10(%rax)
je 0xec9e
leaq 0x1f0(%rbx), %r14
shlq $0x20, %r8
movl %esi, %r15d
orq %r8, %r15
movl $0x18, %edi
callq 0x43b0
movq %r15, 0x10(%rax)
movq %rax, %rdi
movq %r14, %rsi
callq 0x4080
incq 0x200(%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::get_nt_pal(int, int, int)
int ppu::get_nt_pal(int table, int tx, int ty) {
    byte at_val;
    at_val.val = at[table][(ty/4)*8+(tx/4)];
    if(tx % 4 < 2 && ty % 4 < 2) return at_val.pairs.first;
    else if(tx % 4 < 2) return at_val.pairs.third;
    else if(ty % 4 < 2) return at_val.pairs.second;
    else return at_val.pairs.fourth;
}

// Assembly:
movslq %esi, %rax
movq 0x1710(%rdi,%rax,8), %rax
leal 0x3(%rcx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
movl %esi, %edi
sarl $0x2, %edi
leal 0x3(%rdx), %r8d
testl %edx, %edx
cmovnsl %edx, %r8d
movl %r8d, %r9d
sarl $0x2, %r9d
leal (%r9,%rdi,8), %edi
movslq %edi, %rdi
movb (%rax,%rdi), %al
andl $-0x4, %r8d
subl %r8d, %edx
cmpl $0x2, %edx
setge %dil
andl $-0x4, %esi
subl %esi, %ecx
cmpl $0x2, %ecx
setge %sil
orb %dil, %sil
je 0xf92a
cmpl $0x1, %edx
jg 0xf922
shrb $0x4, %al
jmp 0xf92a
cmpl $0x1, %ecx
jg 0xf930
shrb $0x2, %al
andb $0x3, %al
movzbl %al, %eax
retq
shrb $0x6, %al
jmp 0xf92c
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::get_color(int, int, int)
int ppu::get_color(int tile, int x, int y) {
    if(y >= 8 || x >= 8 || tile >= 512) {
        cout<<"Tile: "<<tile<<" ("<<x<<", "<<y<<") doesn't exist."<<endl;
        return -1;
    }
    int address = tile * 16 + y;
    int byte1 = cart.get_cbyte(address);
    int byte2 = cart.get_cbyte(address + 8);
    return ((((byte1 & (128>>(x))) > 0)?1:0) + (((byte2 & (128>>(x))) > 0)?2:0));
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebx
movl %edx, %ebp
movl %esi, %r14d
cmpl $0x1ff, %esi            # imm = 0x1FF
jg 0xf99d
cmpl $0x7, %ebp
jg 0xf99d
cmpl $0x8, %ebx
jge 0xf99d
movq %rdi, %r15
shll $0x4, %r14d
leal (%r14,%rbx), %esi
movq (%rdi), %rdi
callq 0xa150
movl %eax, %r12d
movq (%r15), %rdi
leal (%r14,%rbx), %esi
addl $0x8, %esi
callq 0xa150
movl $0x80, %edx
movl %ebp, %ecx
shrl %cl, %edx
xorl %ecx, %ecx
testl %edx, %r12d
setne %cl
xorl %esi, %esi
testl %edx, %eax
setne %sil
leal (%rcx,%rsi,2), %eax
jmp 0xfa48
movq 0xc60c(%rip), %r15      # 0x1bfb0
leaq 0x5c94(%rip), %rsi      # 0x1563f
movl $0x6, %edx
movq %r15, %rdi
callq 0x4410
movq %r15, %rdi
movl %r14d, %esi
callq 0x45e0
movq %rax, %r14
leaq 0x67ff(%rip), %rsi      # 0x161cc
movl $0x2, %edx
movq %rax, %rdi
callq 0x4410
movq %r14, %rdi
movl %ebp, %esi
callq 0x45e0
movq %rax, %r14
leaq 0x67e2(%rip), %rsi      # 0x161d0
movl $0x2, %edx
movq %rax, %rdi
callq 0x4410
movq %r14, %rdi
movl %ebx, %esi
callq 0x45e0
movq %rax, %rbx
leaq 0x5c37(%rip), %rsi      # 0x15646
movl $0x10, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4290
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::apply_updates_to(int)
void ppu::apply_updates_to(int curcycle) {
    //If there've been any mid-screen updates, apply them at the appropriate time (accurate to 1 vertical tile-ish
    rom::ppu_change_t changes = cart.cycle_forward(curcycle - (8 * 2* CLK_PER_LINE));
    if(changes.lo_crom == 1) clear_surfaces(false);
    if(changes.hi_crom == 1) clear_surfaces(true);
    if(changes.set_horiz == 1 || changes.set_vert == 1 || changes.set_4_scr == 1) set_mirror(cart.get_mode());
    if(changes.set_bg0 == 1) control0.bg_table = 0;
    if(changes.set_bg1 == 1) control0.bg_table = 1;
    if(changes.set_spr0 == 1) control0.sprite_table = 0;
    if(changes.set_spr1 == 1) control0.sprite_table = 1;
    int mode_count = changes.set_horiz + changes.set_vert + changes.set_4_scr;
    if(mode_count > 1) cout<<"Multiple mirroring modes set during one vertical tile of time!"<<endl; 
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rdi
addl $0xffffeab0, %esi       # imm = 0xFFFFEAB0
callq 0xa18a
movl %eax, %ebp
testb $0x1, %bpl
je 0xfa9d
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
xorl %esi, %esi
movl %r14d, %edx
movl %r15d, %ecx
callq 0xdf26
incl %r15d
cmpl $0x8, %r15d
jne 0xfa78
incl %r14d
cmpl $0x100, %r14d           # imm = 0x100
jne 0xfa75
testb $0x2, %bpl
je 0xfad1
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, %rdi
movl $0x1, %esi
movl %r14d, %edx
movl %r15d, %ecx
callq 0xdf26
incl %r15d
cmpl $0x8, %r15d
jne 0xfaa9
incl %r14d
cmpl $0x100, %r14d           # imm = 0x100
jne 0xfaa6
movl %ebp, %r14d
shrl $0x2, %r14d
andl $0x1, %r14d
movl %ebp, %eax
andl $0x18, %eax
orl %r14d, %eax
je 0xfaf8
movq (%rbx), %rdi
callq 0xa130
movq %rbx, %rdi
movl %eax, %esi
callq 0xdd58
testb $0x20, %bpl
je 0xfb05
andb $-0x11, 0x21850(%rbx)
testb $0x40, %bpl
je 0xfb12
orb $0x10, 0x21850(%rbx)
testb %bpl, %bpl
jns 0xfb1e
andb $-0x9, 0x21850(%rbx)
btl $0x8, %ebp
jae 0xfb2b
orb $0x8, 0x21850(%rbx)
movl %ebp, %eax
shrl $0x3, %eax
andl $0x1, %eax
btl $0x4, %ebp
adcl %eax, %r14d
cmpl $0x2, %r14d
jb 0xfb8c
movq 0xc469(%rip), %rbx      # 0x1bfb0
leaq 0x5b46(%rip), %rsi      # 0x15694
movl $0x3e, %edx
movq %rbx, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4290
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::toggle_table_view()
void ppu::toggle_table_view() {
    table_view = !table_view;
    if(table_view)
        cout<<"Turn on table view"<<endl;
    else
        cout<<"Turn off table view"<<endl;
    screen.table_view(table_view);
    
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x21860(%rdi), %al
movl %eax, %ecx
xorb $0x1, %cl
movb %cl, 0x21860(%rdi)
movq 0xc3e5(%rip), %rdi      # 0x1bfb0
testb %al, %al
je 0xfbdd
leaq 0x5aaa(%rip), %rsi      # 0x15680
movl $0x13, %edx
jmp 0xfbe9
leaq 0x5a89(%rip), %rsi      # 0x1566d
movl $0x12, %edx
callq 0x4410
movq 0xc3bb(%rip), %r14      # 0x1bfb0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %r14, %rdi
callq 0x4030
movq %rax, %rdi
callq 0x4290
movzbl 0x21860(%rbx), %esi
addq $0x8, %rbx
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x127ea
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/ppu3.cpp
// Function: ppu::print_name_table()
void ppu::print_name_table() {
    bool vars[256] = {false};
    for(int big_y=0;big_y<1;++big_y) {
        for(int tile_y=0;tile_y<32;++tile_y) {
            for(int big_x=0;big_x<1;++big_x) {
                for(int tile_x=0;tile_x<32;++tile_x) {
                    printf("%02x ", name_table[tile_x+32*tile_y+1024*big_x+2048*big_y]);
                    if(tile_y < 30) {
                        vars[name_table[tile_x+32*tile_y+1024*big_x+2048*big_y]] = true;
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    printf("Contains these values: ");
    for(int i=0;i<256;++i) if(vars[i]) printf("%02x ", i);
    printf("\n");
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %rdi, %rbx
movq %rsp, %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0x4220
addq $0x6ec, %rbx            # imm = 0x6EC
leaq 0x481e(%rip), %r14      # 0x144a4
xorl %r15d, %r15d
xorl %r12d, %r12d
movzbl (%rbx,%r12), %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4050
cmpq $0x1d, %r15
ja 0xfcaa
movzbl (%rbx,%r12), %eax
movb $0x1, (%rsp,%rax)
incq %r12
cmpq $0x20, %r12
jne 0xfc8c
movl $0xa, %edi
callq 0x44c0
incq %r15
addq $0x20, %rbx
cmpq $0x20, %r15
jne 0xfc89
movl $0xa, %edi
callq 0x44c0
leaq 0x59f8(%rip), %rdi      # 0x156d3
xorl %eax, %eax
callq 0x4050
leaq 0x47bb(%rip), %rbx      # 0x144a4
xorl %r14d, %r14d
cmpb $0x1, (%rsp,%r14)
jne 0xfd00
movq %rbx, %rdi
movl %r14d, %esi
xorl %eax, %eax
callq 0x4050
incq %r14
cmpq $0x100, %r14            # imm = 0x100
jne 0xfcec
movl $0xa, %edi
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x44c0
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/util.cpp
// Function: util::toggle_log(int)
void util::toggle_log(int origin) {
    if(!init) {
        for(int i=0;i<1000;++i) active[i] = false;
        init=true;
    }
    active[origin]=!(active[origin]);
    switch(origin) {
    case 1:
        printf("1 (CPU)");
        break;
    case 2:
        printf("2 (MAIN)");
        break;
    case 3:
        printf("3 (MEM)");
        break;
    case 4:
        printf("4 (PPU)");
        break;
    case 5:
        printf("5 (ROM)");
        break;
    case 6:
        printf("6 (UTIL)");
        break;
    case 7:
        printf("7 (WAV)");
        break;
    case 8:
        printf("8 (APU)");
        break;
    }
}

// Assembly:
cmpb $0x0, 0xc6a5(%rip)      # 0x1c460
jne 0xfdee
xorl %ecx, %ecx
leaq 0xc6a2(%rip), %rax      # 0x1c468
movq %rcx, %rdx
movq $-0x2, %rsi
rolq %cl, %rsi
shrq $0x6, %rdx
andq %rsi, (%rax,%rdx,8)
incq %rcx
cmpq $0x3e8, %rcx            # imm = 0x3E8
jne 0xfdc6
movb $0x1, 0xc672(%rip)      # 0x1c460
movslq %edi, %rax
movq %rax, %rcx
shrq $0x6, %rcx
leaq 0xc669(%rip), %rdx      # 0x1c468
movq (%rdx,%rcx,8), %rsi
movq %rsi, %rdi
btrq %rax, %rdi
movq %rsi, %r8
btsq %rax, %r8
btq %rax, %rsi
cmovbq %rdi, %r8
movq %r8, (%rdx,%rcx,8)
decl %eax
cmpl $0x7, %eax
ja 0xfe3b
movl %eax, %eax
leaq 0x5d03(%rip), %rcx      # 0x15b30
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
xorl %eax, %eax
jmp 0x4050
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/util.cpp
// Function: util::debug(int, char const*, ...)
int util::debug(int orig,const char * fmt,...) {
    if(!init) {
        for(int i=0;i<1000;++i) {
            active[i]=false;
        }
        init=true;
    }

    if(active[orig]||(orig==999&&active[1])) {
        switch(orig) {
                case 1:
                        printf("CPU: ");
                        break;
                case 2:
                        printf("MAIN: ");
                        break;
                case 3:
                        printf("MEM: ");
                        break;
                case 4:
                        printf("PPU: ");
                        break;
                case 5:
                        printf("ROM: ");
                        break;
                case 6:
                        printf("UTIL: ");
                        break;
                case 7:
                        printf("WAV: ");
                        break;
                case 8:
                        printf("APU: ");
                        break;
                default:
                        break; //Don't print origin label
        }
        va_list ap;
        va_start(ap,fmt);
        return vprintf(fmt,ap);
    }
    else {
        return 0;
    }
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rsi, %rbx
testb %al, %al
je 0xfea0
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
cmpb $0x0, 0xc5a5(%rip)      # 0x1c460
jne 0xfeee
xorl %ecx, %ecx
leaq 0xc5a2(%rip), %rax      # 0x1c468
movq %rcx, %rdx
movq $-0x2, %rsi
rolq %cl, %rsi
shrq $0x6, %rdx
andq %rsi, (%rax,%rdx,8)
incq %rcx
cmpq $0x3e8, %rcx            # imm = 0x3E8
jne 0xfec6
movb $0x1, 0xc572(%rip)      # 0x1c460
movslq %edi, %rax
movq %rax, %rcx
shrq $0x6, %rcx
leaq 0xc569(%rip), %rdx      # 0x1c468
movq (%rdx,%rcx,8), %rcx
btq %rax, %rcx
jae 0xff56
decl %edi
cmpl $0x7, %edi
ja 0xff27
movl %edi, %eax
leaq 0x5c37(%rip), %rcx      # 0x15b50
movslq (%rcx,%rax,4), %rdi
addq %rcx, %rdi
xorl %eax, %eax
callq 0x4050
leaq 0x20(%rsp), %rax
movq %rsp, %rsi
movq %rax, 0x10(%rsi)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsi)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsi)
movq %rbx, %rdi
callq 0x43c0
jmp 0xff69
xorl %eax, %eax
cmpl $0x3e7, %edi            # imm = 0x3E7
jne 0xff69
testb $0x2, 0xc501(%rip)      # 0x1c468
jne 0xff09
addq $0xd0, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/apu.cpp
// Function: my_callback(void*, unsigned char*, int)
void my_callback(void * ud, Uint8 * stream, int len) {
    //cout<<"Actual callback size: "<<len<<endl;
    userdata * dat = (userdata *)(ud);
    //dat->first = !(dat->first);
    //Copy the audio data
    //cout<<"Read: Index: "<<(dat->apui->buffer_read_pos)<<" Samples: "<<(len*(dat->apui->buffer_read_pos))<<" -> "<<(len*(dat->apui->buffer_read_pos+1))<<" len: "<<len<<endl;
    memcpy(stream, &dat->buffer[len*(dat->apui->buffer_read_pos)], len);
    if(dat->buffered >= len) {
        dat->buffered -= len;
        dat->apui->buffer_read_pos++;
        dat->apui->buffer_read_pos%=dat->apui->SAMPLES_PER_FRAME;
        //cout<<"Consume "<<len<<endl;
    }
    else {
        cout<<"Underbuffered by "<<len - dat->buffered<<" bytes!"<<endl;
        //memset(stream + dat->buffered, 0, len - dat->buffered);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edx, %ebx
movq %rsi, %rax
movq %rdi, %r14
movslq %edx, %r15
movq 0x8(%rdi), %rcx
movq 0x10(%rcx), %rsi
imulq %r15, %rsi
addq (%rdi), %rsi
movq %rax, %rdi
movq %r15, %rdx
callq 0x4330
movl 0x14(%r14), %eax
subl %r15d, %eax
jge 0x1082b
movq 0xb7ea(%rip), %r15      # 0x1bfb0
leaq 0x5663(%rip), %rsi      # 0x15e30
movl $0x11, %edx
movq %r15, %rdi
callq 0x4410
subl 0x14(%r14), %ebx
movq %r15, %rdi
movl %ebx, %esi
callq 0x45e0
movq %rax, %rbx
leaq 0x5650(%rip), %rsi      # 0x15e42
movl $0x7, %edx
movq %rax, %rdi
callq 0x4410
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4390
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4030
movq %rax, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x4290
movl %eax, 0x14(%r14)
movq 0x8(%r14), %rcx
movq 0x10(%rcx), %rsi
leaq 0x1(%rsi), %rax
movabsq $-0x4dabb629196d0487, %rdx # imm = 0xB25449D6E692FB79
mulq %rdx
shrq $0x9, %rdx
imulq $0x2df, %rdx, %rax      # imm = 0x2DF
negq %rax
addq %rsi, %rax
incq %rax
movq %rax, 0x10(%rcx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/apu.cpp
// Function: apu::apu(bool)
apu::apu(bool headless/* =false */) {
    //std::cout<<"apu constructor"<<std::endl;
    stat.val = 0;
    linear_cntr = 0;
    enable_linear_cntr = false;
    pin1_enabled = 0;
    pin2_enabled = 0;
    noise_flip_flop = false;
    framecounter_pos = 0;
    framecounter_reset = 89490;
    enable_irq = false;
    counter_mode = 0;

    dmc_pcm_data = 0;
    dmc_addr=0;
    dmc_addr_reset=0xc000;
    dmc_freq_cnt=0;
    dmc_freq=0;
    dmc_length=0;
    dmc_gen_irq=false;
    dmc_loop=false;

    buffer_read_pos = 0;
    buffer_write_pos = 0;

    for(int i=0; i<5; ++i) {
        enabled[i] = false;
        vol[i] = 0;
        decay_count[i] = 0;
        enable_decay[i] = false;
        loop_decay[i] = false;
        decay_vol_lvl[i] = 0;
        duty_cycle[i] = 0;
        sweep_enable[i] = false;
        sweep_shift[i] = 0;
        sweep_dir[i] = 0;
        sweep_rate[i] = 0;
        sweep_count[i] = 0;
        length[i] = 0;
        wavelength_count_reset[i] = 0;
        wave_pos[i] = 0;
    }

    id = 0;
    frame = 0;
    write_pos = 1;

    init(headless);
    generate_arrays();
    
    //Unpause the audio stream
    if(id > 0)
        SDL_PauseAudioDevice(id, false);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x38(%rdi), %r14
xorps %xmm0, %xmm0
movups %xmm0, 0x38(%rdi)
xorl %eax, %eax
movq %rax, 0x48(%rdi)
leaq 0x50(%rdi), %r15
movq %r15, 0x58(%rdi)
movq %r15, 0x50(%rdi)
movq %rax, 0x60(%rdi)
movb %al, 0xb0(%rdi)
movl %eax, 0x118(%rdi)
movb %al, 0x11c(%rdi)
movabsq $0x15d9200000000, %rcx  # imm = 0x15D9200000000
movq %rcx, 0x1d0(%rdi)
movq %rax, 0x1c4(%rdi)
movb %al, 0x1cc(%rdi)
movb %al, 0x1d8(%rdi)
movl %eax, 0x1dc(%rdi)
movq %rax, 0x220(%rdi)
movl $0xc000, 0x228(%rdi)    # imm = 0xC000
movl %eax, 0x238(%rdi)
movl %eax, 0xb4(%rdi)
movb %al, 0xb8(%rdi)
movb %al, 0x121(%rdi)
movl %eax, 0x11d(%rdi)
movl %eax, 0x1c0(%rdi)
movups %xmm0, 0x1b0(%rdi)
movups %xmm0, 0x8(%rdi)
movw %ax, 0xec(%rdi)
movups %xmm0, 0xdc(%rdi)
movups %xmm0, 0xcc(%rdi)
movups %xmm0, 0xbc(%rdi)
movq %rax, 0x110(%rdi)
movups %xmm0, 0x100(%rdi)
movups %xmm0, 0xf0(%rdi)
movq %rax, 0x194(%rdi)
movups %xmm0, 0x184(%rdi)
movups %xmm0, 0x174(%rdi)
movups %xmm0, 0x164(%rdi)
movups %xmm0, 0x154(%rdi)
movups %xmm0, 0x144(%rdi)
movups %xmm0, 0x134(%rdi)
movups %xmm0, 0x124(%rdi)
movw %ax, 0x234(%rdi)
movq %rax, 0x22c(%rdi)
movl %eax, 0x68(%rdi)
movl %eax, 0x244(%rdi)
movb $0x1, (%rdi)
callq 0x1087a
movq %rbx, %rdi
callq 0x10c86
movl 0x68(%rbx), %edi
testl %edi, %edi
je 0x10f64
xorl %esi, %esi
callq 0x4470
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rbx
movq (%r15), %rdi
cmpq %r15, %rdi
je 0x10f8b
movq (%rdi), %r12
callq 0x4380
movq %r12, %rdi
cmpq %r15, %r12
jne 0x10f7b
movq (%r14), %rdi
testq %rdi, %rdi
je 0x10f98
callq 0x4380
movq %rbx, %rdi
callq 0x4610
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/apu.cpp
// Function: apu::clock_quarter()
void apu::clock_quarter() {
    if(enable_linear_cntr && linear_cntr > 0) --linear_cntr;

    //Envelope decay and looping
    for(uint8_t voice = 0; voice < 4; ++voice) {
        if(voice == TRI) continue;
        if(enabled[voice] && enable_decay[voice] && length[voice] > 0) {
            if(decay_count[voice] == 0) {
                --decay_vol_lvl[voice];
                if(decay_vol_lvl[voice] > 15 && loop_decay[voice]) {
                    decay_vol_lvl[voice] = 15;
                }
                else if(decay_vol_lvl[voice] > 15) {
                    decay_vol_lvl[voice] = 0;
                    //enabled[voice] = false;
                    length[voice] = 0;
                }
                else {
                    decay_count[voice] = vol[voice];
                }
                //cout<<"Voice: "<<int(voice)<<" new vol: "<<decay_vol_lvl[voice]<<endl;
            }
            else {
                --decay_count[voice];
            }
        }
    }
}

// Assembly:
cmpb $0x1, 0x11c(%rdi)
jne 0x10fc1
movl 0x118(%rdi), %eax
testl %eax, %eax
je 0x10fc1
decl %eax
movl %eax, 0x118(%rdi)
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x2, %rcx
je 0x11047
cmpb $0x1, 0xb4(%rdi,%rcx)
jne 0x11047
cmpb $0x1, 0xe4(%rdi,%rcx)
jne 0x11047
cmpl $0x0, 0x174(%rdi,%rcx,4)
jle 0x11047
movl 0xd0(%rdi,%rcx,4), %edx
testl %edx, %edx
je 0x10ff8
decl %edx
jmp 0x11040
movl 0xf0(%rdi,%rcx,4), %edx
decl %edx
movl %edx, 0xf0(%rdi,%rcx,4)
cmpl $0x10, %edx
jb 0x11039
cmpb $0x1, 0xe9(%rdi,%rcx)
jne 0x11024
movl $0xf, 0xf0(%rdi,%rcx,4)
jmp 0x11047
cmpl $0x10, %edx
jb 0x11039
movl %eax, 0xf0(%rdi,%rcx,4)
movl %eax, 0x174(%rdi,%rcx,4)
jmp 0x11047
movl 0xbc(%rdi,%rcx,4), %edx
movl %edx, 0xd0(%rdi,%rcx,4)
incq %rcx
cmpq $0x4, %rcx
jne 0x10fc5
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/khedoros[P]khednes/apu.cpp
// Function: apu::clock_half()
void apu::clock_half() {
    for(uint8_t voice = 0; voice < 4; ++voice) {
        //clock length counter
        if(enabled[voice] && length[voice] > 0 && !loop_decay[voice] && (voice != TRI || !enable_linear_cntr)) length[voice]--;

        //Wavelength sweep
        if(voice < 2 && enabled[voice] && length[voice] > 0 && sweep_enable[voice]) {
            --sweep_count[voice];
            if(sweep_count[voice] == 0) {
                int sweep_amount = wavelength_count_reset[voice];
                sweep_amount>>=(sweep_shift[voice]);
                if(sweep_dir[voice] == 1) //decrease wavelength
                    sweep_amount *= -1;
                if(wavelength_count_reset[voice] + sweep_amount < 0x7ff && wavelength_count_reset[voice] + sweep_amount > 0x08) {
                    wavelength_count_reset[voice] += sweep_amount;
                    if(sweep_count[voice] == 0) sweep_count[voice] = sweep_rate[voice] + 1;
                }
                else {
                    length[voice] = 0;
                    //enabled[voice] = 0;
                }
            }
        }   
    }

}

// Assembly:
movb 0x11c(%rdi), %al
xorl %edx, %edx
movb 0xb4(%rdi,%rdx), %cl
cmpb $0x1, %cl
jne 0x11095
movl 0x174(%rdi,%rdx,4), %esi
testl %esi, %esi
jle 0x11095
cmpq $0x2, %rdx
sete %r8b
cmpb $0x0, 0xe9(%rdi,%rdx)
jne 0x11095
andb %al, %r8b
jne 0x11095
decl %esi
movl %esi, 0x174(%rdi,%rdx,4)
xorb $0x1, %cl
cmpq $0x2, %rdx
setae %sil
orb %cl, %sil
jne 0x1111e
cmpl $0x0, 0x174(%rdi,%rdx,4)
jle 0x1111e
cmpb $0x1, 0x11d(%rdi,%rdx)
jne 0x1111e
decl 0x160(%rdi,%rdx,4)
jne 0x1111e
movl 0x188(%rdi,%rdx,4), %esi
movb 0x124(%rdi,%rdx,4), %cl
movl %esi, %r8d
sarl %cl, %r8d
movl %r8d, %ecx
negl %ecx
cmpl $0x1, 0x138(%rdi,%rdx,4)
cmovnel %r8d, %ecx
leal (%rcx,%rsi), %r8d
addl $-0x9, %r8d
cmpl $0x7f5, %r8d            # imm = 0x7F5
ja 0x11113
addl %esi, %ecx
movl %ecx, 0x188(%rdi,%rdx,4)
movl 0x14c(%rdi,%rdx,4), %ecx
incl %ecx
movl %ecx, 0x160(%rdi,%rdx,4)
jmp 0x1111e
movl $0x0, 0x174(%rdi,%rdx,4)
incq %rdx
cmpq $0x4, %rdx
jne 0x1105e
retq