LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/lrq3000[P]rfrb/./src/raidRecover.cpp
// Function: RaidRecover::RaidRecover(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
RaidRecover::RaidRecover(std::vector<std::string> paths, std::string outPath)
{
	outP = outPath;
	handle = new FileHandler(outPath);
	for (size_t i = 0; i < paths.size(); ++i)
	{
		handle->addImage(paths.at(i));
	}
	system = new RaidSystem(handle);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rdx, %r12
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x10(%rdi), %rax
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
xorl %eax, %eax
movb %al, 0x10(%rdi)
leaq 0x30(%rdi), %rcx
movq %rcx, 0x20(%rdi)
andq $0x0, 0x28(%rdi)
movb %al, 0x30(%rdi)
movq %rdx, %rsi
callq 0x51c0
pushq $0x68
popq %rdi
callq 0x5390
movq %rax, %r15
movq %rsp, %rdi
movq %r12, %rsi
callq 0x54b0
movq %rsp, %rsi
movq %r15, %rdi
callq 0x7472
movq %r15, 0x40(%rbx)
movq %rsp, %rdi
callq 0x5160
xorl %r15d, %r15d
leaq 0x20(%rsp), %r12
movq 0x8(%r14), %rax
subq (%r14), %rax
sarq $0x5, %rax
cmpq %rax, %r15
jae 0x11676
movq 0x40(%rbx), %r13
movq %r14, %rdi
movq %r15, %rsi
callq 0xb8e0
movq %r12, %rdi
movq %rax, %rsi
callq 0x54b0
movq %r13, %rdi
movq %r12, %rsi
callq 0x79d2
movq %r12, %rdi
callq 0x5160
incq %r15
jmp 0x11634
pushq $0x30
popq %rdi
callq 0x5390
movq %rax, %r15
movq 0x40(%rbx), %rsi
movq %rax, %rdi
callq 0x58f6
movq %r15, 0x48(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x116ae
movq %rax, %r14
movq %rsp, %rdi
callq 0x5160
jmp 0x116b1
movq %rax, %r14
movq %r15, %rdi
callq 0x5360
jmp 0x116cf
jmp 0x116cc
movq %rax, %r14
leaq 0x20(%rsp), %rdi
callq 0x5160
jmp 0x116cf
movq %rax, %r14
leaq 0x20(%rbx), %rdi
callq 0x5160
movq %rbx, %rdi
callq 0x5160
movq %r14, %rdi
callq 0x5610
// File: /workspace/github_cpp_makefile_star2_O2/lrq3000[P]rfrb/./src/raidRecover.cpp
// Function: RaidRecover::run()
void RaidRecover::run()
{
	//Set name for recovered dataImage
	std::string o = outP+"dataImage.dd";

	//Start with analysing the case und recover lost data (if possible)
	bool found = system->raidCheck(o);
	std::cout << std::endl;

	//Check if everything went fine
	if (found==true)
		std::cout << "Recovery successful!" << std::endl;
	else
		std::cout << "Recovery was aborted!" << std::endl;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x3ace(%rip), %rdx      # 0x151e5
leaq 0x28(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0xb87b
movq 0x48(%rbx), %rbx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x54b0
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x5c66
movl %eax, %ebx
leaq 0x8(%rsp), %rdi
callq 0x5160
movq 0xc858(%rip), %rdi      # 0x1dfb0
callq 0x5180
leaq 0x3a8e(%rip), %rax      # 0x151f2
leaq 0x3a9c(%rip), %rsi      # 0x15207
testb %bl, %bl
cmovneq %rax, %rsi
movq 0xc838(%rip), %rdi      # 0x1dfb0
callq 0x5380
movq %rax, %rdi
callq 0x5180
leaq 0x28(%rsp), %rdi
callq 0x5160
addq $0x48, %rsp
popq %rbx
popq %r14
retq
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5160
jmp 0x117a9
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x5160
movq %rbx, %rdi
callq 0x5610
nop
// File: /workspace/github_cpp_makefile_star2_O2/ericprud[P]sean-parent-concept-based-polymorphism/doc-user.cpp
// Function: main
int main ()
{
    history_t h;

    h.current().add(string("Hello"));
    h.current().add(0);
    h.current().add(my_class_t());

    draw(h, cout, 0);
    cout << "--------------------------" << endl;

    h.commit();

    h.current()[1] = string("World!");
    h.current().add(h);

    draw(h, cout, 0);
    cout << "--------------------------" << endl;

    h.undo();

    draw(h, cout, 0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0xd0, %rsp
leaq -0x30(%rbp), %rbx
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x2572
movq %rbx, %rdi
callq 0x258a
movq %rax, %rbx
leaq 0x1cd9(%rip), %rsi      # 0x4004
leaq -0xd8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq 0x25ba
leaq -0x80(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x25f6
leaq -0x80(%rbp), %rsi
movq %rbx, %rdi
callq 0x2a98
leaq -0x78(%rbp), %rdi
callq 0x2cbe
leaq -0xd8(%rbp), %rdi
callq 0x2070
leaq -0x30(%rbp), %rdi
callq 0x258a
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x2638
leaq -0x70(%rbp), %rsi
movq %rbx, %rdi
callq 0x2a98
leaq -0x68(%rbp), %rdi
callq 0x2cbe
leaq -0x30(%rbp), %rdi
callq 0x258a
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x2684
leaq -0x60(%rbp), %rsi
movq %rbx, %rdi
callq 0x2a98
leaq -0x58(%rbp), %rdi
callq 0x2cbe
movq 0x5c0f(%rip), %rsi      # 0x7fd8
leaq -0x30(%rbp), %rdi
xorl %edx, %edx
callq 0x26ca
movq 0x5bfd(%rip), %rdi      # 0x7fd8
leaq 0x1c28(%rip), %rsi      # 0x400a
callq 0x2100
movq %rax, %rdi
callq 0x2080
leaq -0x30(%rbp), %rdi
callq 0x27ba
leaq 0x1c26(%rip), %rsi      # 0x4025
leaq -0xb8(%rbp), %rdi
leaq -0x11(%rbp), %rdx
callq 0x25ba
leaq -0x50(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x25f6
leaq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x258a
movq (%rax), %rdi
addq $0x10, %rdi
leaq -0x50(%rbp), %rsi
callq 0x3146
leaq -0x48(%rbp), %rdi
callq 0x2cbe
leaq -0xb8(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x258a
movq %rax, %r14
leaq -0x98(%rbp), %rdi
movq %rbx, %rsi
callq 0x3180
leaq -0x40(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x27ee
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x2a98
leaq -0x38(%rbp), %rdi
callq 0x2cbe
leaq -0x98(%rbp), %rdi
callq 0x3248
movq 0x5b36(%rip), %rsi      # 0x7fd8
leaq -0x30(%rbp), %rdi
xorl %edx, %edx
callq 0x26ca
movq 0x5b24(%rip), %rdi      # 0x7fd8
leaq 0x1b4f(%rip), %rsi      # 0x400a
callq 0x2100
movq %rax, %rdi
callq 0x2080
movq %rbx, %rdi
callq 0x2830
movq 0x5b01(%rip), %rsi      # 0x7fd8
movq %rbx, %rdi
xorl %edx, %edx
callq 0x26ca
leaq -0x30(%rbp), %rdi
callq 0x3248
xorl %eax, %eax
addq $0xd0, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x2cbe
jmp 0x2509
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x3248
jmp 0x2560
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
jmp 0x2554
jmp 0x255d
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
jmp 0x2535
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x2cbe
jmp 0x2560
movq %rax, %rbx
leaq -0x78(%rbp), %rdi
callq 0x2cbe
jmp 0x254d
movq %rax, %rbx
leaq -0xd8(%rbp), %rdi
callq 0x2070
jmp 0x2560
jmp 0x255d
movq %rax, %rbx
leaq -0x30(%rbp), %rdi
callq 0x3248
movq %rbx, %rdi
callq 0x21a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/ericprud[P]sean-parent-concept-based-polymorphism/./doc-library.hh
// Function: draw(history_t const&, std::ostream&, unsigned long)
void draw(const history_t& h, std::ostream& out, size_t position)
    {
        out << std::string(position, ' ') << "<history>" << std::endl;
        for (const auto& doc : h.documents)
            draw(doc, out, position + 2);
        out << std::string(position, ' ') << "</history>" << std::endl;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x48(%rbp), %rdi
pushq $0x20
popq %rdx
movq %r14, %rsi
callq 0x2130
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x20f0
leaq 0x19ac(%rip), %rsi      # 0x40ba
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2080
leaq -0x48(%rbp), %rdi
callq 0x2070
movq (%r15), %r12
movq 0x8(%r15), %r13
leaq 0x2(%r14), %r15
cmpq %r13, %r12
je 0x274b
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2d4e
addq $0x18, %r12
jmp 0x2732
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
pushq $0x20
popq %rdx
movq %r14, %rsi
callq 0x2130
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x20f0
leaq 0x1950(%rip), %rsi      # 0x40c4
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2080
leaq -0x48(%rbp), %rdi
callq 0x2070
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x279e
movq %rax, %rbx
jmp 0x27b1
jmp 0x27a5
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/ericprud[P]sean-parent-concept-based-polymorphism/./doc-library.hh
// Function: draw(document_t const&, std::ostream&, unsigned long)
void draw(const document_t& doc, std::ostream& out, size_t position)
    {
        out << std::string(position, ' ') << "<document>" << std::endl;
        for (const auto& ptr : doc.drawable_ptrs)
            ptr.binding->call_draw(out, position + 2);
        out << std::string(position, ' ') << "</document>" << std::endl;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x48(%rbp), %rdi
pushq $0x20
popq %rdx
movq %r14, %rsi
callq 0x2130
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x20f0
leaq 0x133d(%rip), %rsi      # 0x40cf
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2080
leaq -0x48(%rbp), %rdi
callq 0x2070
movq (%r15), %r13
movq 0x8(%r15), %r12
leaq 0x2(%r14), %r15
cmpq %r12, %r13
je 0x2dd1
movq (%r13), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movq %r15, %rdx
callq *0x10(%rax)
addq $0x10, %r13
jmp 0x2db6
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
pushq $0x20
popq %rdx
movq %r14, %rsi
callq 0x2130
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x20f0
leaq 0x12e0(%rip), %rsi      # 0x40da
movq %rax, %rdi
callq 0x2100
movq %rax, %rdi
callq 0x2080
leaq -0x48(%rbp), %rdi
callq 0x2070
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2e24
movq %rax, %rbx
jmp 0x2e37
jmp 0x2e2b
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x21a0
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/main.cpp
// Function: get_choice(rom&)
unsigned int get_choice(rom& cart) {
    unsigned int choice = 0;
    while(choice < 1 || choice > cart.get_song_count()) {
        cout<<"Choose a song number between 1 and "<<dec<<cart.get_song_count()<<": ";
        cout.flush();
        cin>>choice;
    }
    return choice;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4(%rsp), %rax
andl $0x0, (%rax)
xorl %r14d, %r14d
movq 0x13282(%rip), %r15     # 0x1afb0
leaq 0xa5dd(%rip), %r12      # 0x12312
leaq 0xbe39(%rip), %r13      # 0x13b75
movq 0x13295(%rip), %rbp     # 0x1afd8
testl %r14d, %r14d
je 0x7d55
movq %rbx, %rdi
callq 0x8e78
cmpl %eax, %r14d
jbe 0x7db3
movq %r15, %rdi
movq %r12, %rsi
callq 0x4390
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rax
movl 0x18(%r14,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%r14,%rax)
movq %rbx, %rdi
callq 0x8e78
movl %eax, %esi
movq %r14, %rdi
callq 0x4270
movq %rax, %rdi
movq %r13, %rsi
callq 0x4390
movq %r15, %rdi
callq 0x4280
movq %rbp, %rdi
leaq 0x4(%rsp), %rsi
callq 0x4630
movl 0x4(%rsp), %r14d
jmp 0x7d43
movl 0x4(%rsp), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/main.cpp
// Function: init_nsf(rom&, mem&, cpu&, unsigned int)
bool init_nsf(rom& cart, mem& memi, cpu& cpui, unsigned int choice = 1) {
    cout<<"Playing song "<<dec<<choice<<" out of "<<cart.get_song_count()<<endl;
    cpui.reset(cart.get_rst_addr());
    cpui.set_acc(choice-1);
    cpui.set_x(0);
    for(int i=0;i<0x800;++i)
        memi.write(i,0);
    for(int i=0x6000;i<0x8000;++i)
        memi.write(i,0);
    for(int i=0x4000;i<0x4014;++i)
        memi.write(i,0);
    memi.write(0x4015, 0x0f);
    memi.write(0x4017, 0x40);
    cart.reset_map();
    int ret = 1;
    while(ret) {
        ret = cpui.run_next_op();
        if(ret < 0) return false;
    }
    cpui.reset(cart.get_nmi_addr());
    cout<<"I think I init'ed the program properly."<<endl;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movq 0x131d0(%rip), %rdi     # 0x1afb0
leaq 0xa54f(%rip), %rsi      # 0x12336
callq 0x4390
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
andl $-0x4b, %edx
orl $0x2, %edx
movl %edx, 0x18(%rax,%rcx)
movl %ebp, %esi
movq %rax, %rdi
callq 0x4270
leaq 0xa532(%rip), %rsi      # 0x12344
movq %rax, %rdi
callq 0x4390
movq %rax, %r12
movq %r14, %rdi
callq 0x8e78
movl %eax, %esi
movq %r12, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x41c0
movq %r14, %rdi
callq 0x8ee2
movq %rbx, %rdi
movl %eax, %esi
callq 0xb3b4
decl %ebp
movq %rbx, %rdi
movl %ebp, %esi
callq 0xb3be
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb3b8
cmpl $0x800, %ebp            # imm = 0x800
je 0x7e79
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x99e6
incl %ebp
jmp 0x7e61
movl $0x6000, %ebp           # imm = 0x6000
cmpl $0x8000, %ebp           # imm = 0x8000
je 0x7e96
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x99e6
incl %ebp
jmp 0x7e7e
movl $0x4000, %ebp           # imm = 0x4000
cmpl $0x4014, %ebp           # imm = 0x4014
je 0x7eb3
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x99e6
incl %ebp
jmp 0x7e9b
pushq $0xf
popq %rdx
movq %r15, %rdi
movl $0x4015, %esi           # imm = 0x4015
callq 0x99e6
pushq $0x40
popq %rdx
movq %r15, %rdi
movl $0x4017, %esi           # imm = 0x4017
callq 0x99e6
movq %r14, %rdi
callq 0x8f60
pushq $0x1
popq %rax
movl %eax, %ebp
testl %eax, %eax
je 0x7ef2
movq %rbx, %rdi
callq 0xa3be
testl %eax, %eax
jns 0x7ede
jmp 0x7f1f
movq %r14, %rdi
callq 0x8eea
movq %rbx, %rdi
movl %eax, %esi
callq 0xb3b4
movq 0x130a5(%rip), %rdi     # 0x1afb0
leaq 0xa43b(%rip), %rsi      # 0x1234d
callq 0x4390
movq %rax, %rdi
callq 0x41c0
testl %ebp, %ebp
sete %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/rom.cpp
// Function: rom::rom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
rom::rom(std::string filename, int m) : file(filename), mapper_num(m) {
    valid=load(filename);
    if(valid) {
        print_info();
    }
    else {
        printf("Trying to load as NSF instead\n");
        valid=load_nsf(filename);
        if(nsf) {
            print_nsf_info();
        }
        else {
            print_info();
        }
        if(!valid) {
            printf("Problem loading %s. Make sure it exists and you can read it.\n",filename.c_str());
            exit(1);
        }
    }
    //printf("CHR_PAGE_SIZE: %d sizeof crom: %d crom pages: %d",CHR_PAGE_SIZE,crom_pages,CHR_PAGE_SIZE*crom_pages);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rdi)
movups %xmm0, 0x50(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x10(%rdi)
movq %rsi, 0x70(%rdi)
movl %edx, 0x90(%rdi)
callq 0x8016
movb %al, 0x8(%r14)
testb %al, %al
je 0x7f7e
movq %r14, %rdi
callq 0x84fa
jmp 0x7fbc
leaq 0xa895(%rip), %rdi      # 0x1281a
callq 0x4540
movq %r14, %rdi
movq %r15, %rsi
callq 0x86de
movb %al, 0x8(%r14)
cmpb $0x1, 0xce(%r14)
jne 0x7fad
movq %r14, %rdi
callq 0x8c6c
jmp 0x7fb5
movq %r14, %rdi
callq 0x84fa
cmpb $0x0, 0x8(%r14)
je 0x7fc8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq (%r15), %rsi
leaq 0xa46e(%rip), %rdi      # 0x12440
xorl %eax, %eax
callq 0x4040
pushq $0x1
popq %rdi
callq 0x43f0
movq %rax, %r15
leaq 0x58(%r14), %rdi
leaq 0x40(%r14), %r12
addq $0x28, %r14
callq 0x9000
movq %r12, %rdi
callq 0x900e
movq %r14, %rdi
callq 0x9000
movq %rbx, %rdi
callq 0x9000
movq %r15, %rdi
callq 0x4640
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/mem.cpp
// Function: mem::mem(rom&, ppu&, apu&)
mem::mem(rom &romi, ppu &ppui,apu &apui) : cart(romi), pu(ppui), snd(apui), cycle(0), mouse_x(0), mouse_y(0) {
    ram.resize(0x800);
    sram.resize(0x2000);
    read_from.resize(0x10000, false);
    written_to.resize(0x10000, false);
    for(int i=0;i<8;i++) {
        joy1_buttons[i]=false;
    }
    if(cart.has_sram()) {
        return;
        string infile = cart.filename();
        infile += ".sav";
        cout<<"Trying to open "<<infile<<endl;
        ifstream inf;
        inf.open(infile.c_str());
        if(inf.is_open()) {
            inf.seekg(0,ios::end);
            size_t filesize = inf.tellg();
            inf.seekg(0,ios::beg);
            if(filesize == 0x2000) {
                inf.read(reinterpret_cast<char *>(&(sram[0])), 0x2000);
                cout<<"Loaded "<<infile<<" as save game."<<endl;
            }
            inf.close();
        }
        else cout<<"Couldn't open "<<infile<<" for input."<<endl;
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r13
movq %rsi, (%rdi)
movq %rdx, 0x8(%rdi)
movq %rcx, 0x10(%rdi)
andl $0x0, 0x18(%rdi)
leaq 0x20(%rdi), %rbx
leaq 0x38(%rdi), %r14
leaq 0x80(%rdi), %r15
leaq 0x98(%rdi), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rdi)
movups %xmm0, 0x30(%rdi)
movups %xmm0, 0x40(%rdi)
movups %xmm0, 0x68(%rdi)
movups %xmm0, 0x78(%rdi)
movups %xmm0, 0x88(%rdi)
movups %xmm0, 0x98(%rdi)
andq $0x0, 0xa8(%rdi)
movl $0x800, %esi            # imm = 0x800
movq %rbx, %rdi
callq 0x8f98
movl $0x2000, %esi           # imm = 0x2000
movq %r14, %rdi
callq 0x8f98
leaq 0xc(%rsp), %rdx
andl $0x0, (%rdx)
movl $0x10000, %esi          # imm = 0x10000
movq %r15, %rdi
callq 0x9baa
leaq 0x8(%rsp), %rdx
andl $0x0, (%rdx)
movl $0x10000, %esi          # imm = 0x10000
movq %r12, %rdi
callq 0x9baa
movq 0x70(%r13), %rax
xorl %ecx, %ecx
cmpq $0x8, %rcx
je 0x9537
btrq %rcx, %rax
incq %rcx
jmp 0x9528
movq %rax, 0x70(%r13)
movq (%r13), %rdi
callq 0x8e6a
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x9556
jmp 0x9556
movq %rax, %r13
movq %r12, %rdi
callq 0x9bde
movq %r15, %rdi
callq 0x9bde
movq %r14, %rdi
callq 0x9000
movq %rbx, %rdi
callq 0x9000
movq %r13, %rdi
callq 0x4640
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/mem.cpp
// Function: mem::sendkeydown(SDL_Scancode)
void mem::sendkeydown(SDL_Scancode test) {
        //util::debug(ORIGIN,"Key down! (%04x)\n",test);
        switch(test) {
                case SDL_SCANCODE_A:
                        joy1_buttons[6]=true; //left
                        //printf("LEFT!\n");
                        break;
                case SDL_SCANCODE_D:
                        joy1_buttons[7]=true; //right
                        //printf("RIGHT! ");
                        break;
                case SDL_SCANCODE_G:
                        joy1_buttons[2]=true; //select
                        //printf("SELECT!\n");
                        break;
                case SDL_SCANCODE_H:
                        joy1_buttons[3]=true; //start
                        //printf("START!\n");
                        break;
                case SDL_SCANCODE_K:
                        joy1_buttons[1]=true; //b
                        //printf("B!\n");
                        break;
                case SDL_SCANCODE_L:
                        joy1_buttons[0]=true; //a
                        //printf("A!\n");
                        break;
                case SDL_SCANCODE_S:
                        joy1_buttons[5]=true; //down
                        //printf("DOWN!\n");
                        break;
                case SDL_SCANCODE_W:
                        joy1_buttons[4]=true; //up
                        //printf("UP!\n");
                        break;
                case SDL_SCANCODE_GRAVE:
                        pu.speedup(true);
                        break;
                case SDL_SCANCODE_X:
                        joy2_trigger=16;
                        break;
                case SDL_SCANCODE_Z:
                        joy2_light=0;
                        break;
                case SDL_SCANCODE_N:
                        pu.print_name_table();
                        break;
                default: cout<<"Saw button "<<int(test)<<endl;
        }        
}

// Assembly:
pushq %rbx
movl %esi, %ebx
leal -0x4(%rbx), %eax
cmpl $0x19, %eax
ja 0x95d5
leaq 0x92ee(%rip), %rcx      # 0x128b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x40, 0x70(%rdi)
jmp 0x964e
cmpl $0x35, %ebx
jne 0x95e7
movq 0x8(%rdi), %rdi
pushq $0x1
popq %rsi
popq %rbx
jmp 0xdf9c
movq 0x119c2(%rip), %rdi     # 0x1afb0
leaq 0x9377(%rip), %rsi      # 0x1296c
callq 0x4390
movq %rax, %rdi
movl %ebx, %esi
callq 0x4610
movq %rax, %rdi
popq %rbx
jmp 0x41c0
movq 0x8(%rdi), %rdi
popq %rbx
jmp 0xdfb0
orb $0x1, 0x70(%rdi)
jmp 0x964e
orb $0x8, 0x70(%rdi)
jmp 0x964e
orb $0x4, 0x70(%rdi)
jmp 0x964e
orb $0x20, 0x70(%rdi)
jmp 0x964e
orb $0x2, 0x70(%rdi)
jmp 0x964e
andl $0x0, 0x64(%rdi)
jmp 0x964e
orb $-0x80, 0x70(%rdi)
jmp 0x964e
movl $0x10, 0x60(%rdi)
jmp 0x964e
orb $0x10, 0x70(%rdi)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/mem.cpp
// Function: mem::sendkeyup(SDL_Scancode)
void mem::sendkeyup(SDL_Scancode test) {
        //util::debug(ORIGIN,"Key up! (%04x)\n",test);
        switch(test) {
                case SDL_SCANCODE_A:
                        joy1_buttons[6]=false; //left
                        break;
                case SDL_SCANCODE_D:
                        joy1_buttons[7]=false; //right
                        break;
                case SDL_SCANCODE_G:
                        joy1_buttons[2]=false; //select
                        break;
                case SDL_SCANCODE_H:
                        joy1_buttons[3]=false; //start
                        break;
                case SDL_SCANCODE_K:
                        joy1_buttons[1]=false; //b
                        break;
                case SDL_SCANCODE_L:
                        joy1_buttons[0]=false; //a
                        break;
                case SDL_SCANCODE_S:
                        joy1_buttons[5]=false; //down
                        break;
                case SDL_SCANCODE_W:
                        joy1_buttons[4]=false; //up
                        break;
                case SDL_SCANCODE_GRAVE:
                        pu.speedup(false);
                        break;
                case SDL_SCANCODE_X:
                        joy2_trigger=0;
                        break;
                case SDL_SCANCODE_Z:
                        joy2_light=8;
                        break;
                default: //don't really care about the rest of the values =)
                        break;
        }
}

// Assembly:
leal -0x4(%rsi), %eax
cmpl $0xb, %eax
ja 0x966d
leaq 0x92bd(%rip), %rcx      # 0x1291c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andb $-0x41, 0x70(%rdi)
retq
leal -0x16(%rsi), %eax
cmpl $0x7, %eax
ja 0x968a
leaq 0x92d0(%rip), %rcx      # 0x1294c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
andb $-0x21, 0x70(%rdi)
retq
cmpl $0x35, %esi
jne 0x96c4
movq 0x8(%rdi), %rdi
xorl %esi, %esi
jmp 0xdf9c
andb $-0x3, 0x70(%rdi)
retq
andb $-0x5, 0x70(%rdi)
retq
andb $0x7f, 0x70(%rdi)
retq
andb $-0x9, 0x70(%rdi)
retq
andb $-0x2, 0x70(%rdi)
retq
andl $0x0, 0x60(%rdi)
retq
andb $-0x11, 0x70(%rdi)
retq
movl $0x8, 0x64(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/mem.cpp
// Function: mem::read2(unsigned int)
const unsigned int mem::read2(unsigned int address) {        
        address&=0xFFFF;
        read_from[address]=true;
        read_from[address+1]=true;
        if(address<0x1FFF) { //0x1FFF because I'm returning 2 bytes
                unsigned int temp1=ram[(address+1)&0x7FF];
                temp1<<=(8);
                temp1|=ram[address&0x7FF];
                return temp1;
        }
        if(address>=0x6000&&address<=0x7fff) {
                unsigned int temp1=sram[(address+1)&0x1fff];
                temp1<<=(8);
                temp1|=sram[address&0x1fff];
                return temp1;
        }
        if(address>=0x8000) {
                //unsigned int temp1=cart.get_pbyte(address+1);
                //temp1<<=(8);
                //temp1|=cart.get_pbyte(address);
                //return temp1;
                return cart.get_pword(address);
        }
        util::debug(ORIGIN, "mem read(2) of %04x unhandled. I don't know what the address does.\n",address);
        return 0;
}

// Assembly:
pushq %rbx
movzwl %si, %edx
movq 0x80(%rdi), %rcx
pushq $0x1
popq %r8
movl %r8d, (%rcx,%rdx,4)
leal 0x1(%rdx), %eax
movl %r8d, (%rcx,%rax,4)
cmpl $0x1ffe, %edx           # imm = 0x1FFE
ja 0x997f
movl $0x7ff, %ecx            # imm = 0x7FF
andl %ecx, %eax
movq 0x20(%rdi), %rdx
jmp 0x999a
movl %esi, %ecx
andl $0xe000, %ecx           # imm = 0xE000
cmpl $0x6000, %ecx           # imm = 0x6000
jne 0x99ad
movl $0x1fff, %ecx           # imm = 0x1FFF
andl %ecx, %eax
movq 0x38(%rdi), %rdx
movzbl (%rdx,%rax), %eax
shll $0x8, %eax
andl %ecx, %esi
movzbl (%rdx,%rsi), %ebx
orl %eax, %ebx
movl %ebx, %eax
popq %rbx
retq
cmpl $0x8000, %edx           # imm = 0x8000
jb 0x99c0
movq (%rdi), %rdi
movl %edx, %esi
popq %rbx
jmp 0x8f02
leaq 0x8ff2(%rip), %rsi      # 0x129b9
xorl %ebx, %ebx
pushq $0x3
popq %rdi
xorl %eax, %eax
callq 0xe2fc
jmp 0x99a9
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::cpu(mem*, apu*, unsigned int, bool)
cpu::cpu(mem * data, apu * ap, const unsigned int start_loc, bool is_nsf) : nsf_mode(is_nsf) {
    for(int i=0;i<256;++i) {
        inst_counts[i]=0;
    }
    memory=data;
    audio=ap;
    pc=start_loc;
    status.reg=0;//FLAG_TRUE|FLAG_BRK;
    sp=0;
    acc=0;
    x=0;
    y=0;
    ops_ahead=0;
    ppu_cycle=0;
    addr=0;
    prevpc=0;
    prevop=0;
    prevopaddr = 0;
    prevopoffset = 0;
    prevoparg = 0;
    nextop = 0;
    nextopaddr = 0;
    nextopoffset = 0;
    nextoparg = 0;
    frame = 0;

    addresses.resize(17); //17th page is for any PC values that occur in RAM instead of ROM
    for(int page=0;page<16;page++) {
        addresses[page].resize(PRG_PAGE_SIZE);
        for(int paddr=0;paddr<PRG_PAGE_SIZE;paddr++) {
            addresses[page][paddr] = 0;
        }
    }
    addresses[16].resize(0x8000);
    for(int paddr=0;paddr<0x8000;paddr++) {
        addresses[16][paddr] = 0;
    }
}

// Assembly:
movb %r8b, 0x527(%rdi)
pushq $0x8
popq %rax
cmpq $0x108, %rax            # imm = 0x108
je 0x9e6f
andl $0x0, (%rdi,%rax,4)
incq %rax
jmp 0x9e5e
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, 0x10(%rdi)
movq %rdx, 0x18(%rdi)
movl %ecx, (%rdi)
xorl %ebx, %ebx
movb %bl, 0x8(%rdi)
movb %bl, 0xe(%rdi)
movb %bl, 0x4(%rdi)
andw $0x0, 0xc(%rdi)
andq $0x0, 0x460(%rdi)
andl $0x0, 0x448(%rdi)
andl $0x0, 0x468(%rdi)
movb %bl, 0x428(%rdi)
andq $0x0, 0x420(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x42c(%rdi)
andq $0x0, 0x439(%rdi)
leaq 0x114b6(%rip), %rdi     # 0x1b380
pushq $0x11
popq %rsi
callq 0xb406
movq 0x114a7(%rip), %rdi     # 0x1b380
cmpq $0x10, %rbx
je 0x9f14
imulq $0x18, %rbx, %r14
addq %r14, %rdi
movl $0x4000, %esi           # imm = 0x4000
callq 0xb43c
movq 0x11489(%rip), %rax     # 0x1b380
movq (%rax,%r14), %rax
xorl %ecx, %ecx
cmpq $0x4000, %rcx           # imm = 0x4000
je 0x9f0f
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0x9efd
incq %rbx
jmp 0x9ed2
addq $0x180, %rdi            # imm = 0x180
movl $0x8000, %esi           # imm = 0x8000
callq 0xb43c
movq 0x11454(%rip), %rax     # 0x1b380
movq 0x180(%rax), %rax
xorl %ecx, %ecx
cmpq $0x8000, %rcx           # imm = 0x8000
je 0x9f47
andl $0x0, (%rax,%rcx,4)
incq %rcx
jmp 0x9f35
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::stat_string(cpu::statreg_t)
char * cpu::stat_string(statreg_t status) {
    if(util::is_active(ORIGIN)) {
        for(int i=0;i<9;++i) {
            st[i]=0;
        }
        strncat(st,((status.sign)?"N":"n"),1);
        strncat(st,((status.verflow)?"V":"v"),1);        
        strncat(st,((status.tru)?"T":"t"),1);        
        strncat(st,((status.brk)?"B":"b"),1);        
        strncat(st,((status.dec)?"D":"d"),1);        
        strncat(st,((status.inter)?"I":"i"),1);        
        strncat(st,((status.zero)?"Z":"z"),1);        
        strncat(st,((status.carry)?"C":"c"),1);        
    }
    return st;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
pushq $0x1
popq %rdi
callq 0xe2de
testb %al, %al
je 0xb33b
leaq 0x4c7(%rbx), %r14
pushq $-0x9
popq %rax
testq %rax, %rax
je 0xb1ff
movb $0x0, 0x9(%r14,%rax)
incq %rax
jmp 0xb1ef
movd %ebp, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
movdqa 0x8050(%rip), %xmm1     # 0x13260
pand %xmm0, %xmm1
movdqa %xmm1, 0x10(%rsp)
pand 0x804e(%rip), %xmm0     # 0x13270
movdqa %xmm0, (%rsp)
movq %r14, %rdi
callq 0x41a0
pxor %xmm0, %xmm0
movdqa (%rsp), %xmm2
pcmpeqd %xmm0, %xmm2
movdqa 0x10(%rsp), %xmm1
pcmpeqd %xmm0, %xmm1
packssdw %xmm2, %xmm1
packsswb %xmm1, %xmm1
pmovmskb %xmm1, %ebp
movl %ebp, %ecx
andb $0x2, %cl
shrb %cl
movb %cl, (%rsp)
movl %ebp, %r12d
andb $0x4, %r12b
shrb $0x2, %r12b
movl %ebp, %r13d
andb $0x8, %r13b
shrb $0x3, %r13b
movq %rbx, 0x10(%rsp)
movl %ebp, %ebx
andb $0x10, %bl
shrb $0x4, %bl
movl %ebp, %r15d
shrb $0x6, %r15b
movl %ebp, %ecx
shrb $0x7, %cl
movzbl %cl, %ecx
shll $0x5, %ecx
orl $0x4e, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movzbl %r15b, %ecx
shll $0x5, %ecx
orl $0x56, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movl %ebp, %ecx
andl $0x20, %ecx
orl $0x54, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movzbl %bl, %ecx
movq 0x10(%rsp), %rbx
shll $0x5, %ecx
orl $0x42, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movzbl %r13b, %ecx
shll $0x5, %ecx
orl $0x44, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movzbl %r12b, %ecx
shll $0x5, %ecx
orl $0x49, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
movzbl (%rsp), %ecx
shll $0x5, %ecx
orl $0x5a, %ecx
movw %cx, (%r14,%rax)
movq %r14, %rdi
callq 0x41a0
andl $0x1, %ebp
shll $0x5, %ebp
orl $0x43, %ebp
movw %bp, (%r14,%rax)
addq $0x4c7, %rbx            # imm = 0x4C7
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::trigger_nmi()
void cpu::trigger_nmi() {
    push2(pc);
    status.inter = 0;
    push(status.reg);
    pc=memory->read2(NM_INT_INSERTION);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %esi
callq 0xbfc6
movzbl 0x8(%rbx), %esi
andl $-0x5, %esi
movb %sil, 0x8(%rbx)
movq %rbx, %rdi
callq 0xc020
movq 0x10(%rbx), %rdi
movl $0xfffa, %esi           # imm = 0xFFFA
callq 0x9950
movl %eax, (%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_brk()
inline void cpu::op_brk() {
    pc++;
    push2(pc);
    status.brk = 1;
    push(status.reg);
    status.inter = 1;
    pc=memory->read2(0xFFFE);
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %esi
incl %esi
movl %esi, (%rdi)
callq 0xbfc6
movzbl 0x8(%rbx), %esi
orl $0x10, %esi
movb %sil, 0x8(%rbx)
movq %rbx, %rdi
callq 0xc020
orb $0x4, 0x8(%rbx)
movq 0x10(%rbx), %rdi
movl $0xfffe, %esi           # imm = 0xFFFE
callq 0x9950
movl %eax, (%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_ora(int)
inline void cpu::op_ora(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 0x96dc
movl %eax, 0x454(%rbx)
orb 0x4(%rbx), %al
movb %al, 0x4(%rbx)
movl %eax, %ecx
andb $-0x80, %cl
movb 0x8(%rbx), %dl
andb $0x7d, %dl
orb %cl, %dl
testb %al, %al
sete %al
addb %al, %al
orb %dl, %al
movb %al, 0x8(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_aslm(int)
inline void cpu::op_aslm(int addr) {
    temp=memory->read(addr);
    set_carry(temp&0x80);
    temp<<=(1);
    set_zero(temp);
    set_sign(temp);
    memory->write(addr,temp);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movq 0x10(%rdi), %rdi
callq 0x96dc
movl %eax, %ecx
shrb $0x7, %cl
movb 0x8(%r14), %sil
andb $0x7c, %sil
orb %cl, %sil
addl %eax, %eax
movl %eax, 0x454(%r14)
testb %al, %al
sete %cl
addb %cl, %cl
movzbl %al, %edx
andb $-0x80, %al
orb %cl, %al
orb %sil, %al
movb %al, 0x8(%r14)
movq 0x10(%r14), %rdi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x99e6
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_asla()
inline void cpu::op_asla() {
    set_carry(acc&0x80);
    acc<<=(1);
    set_zero(acc);
    set_sign(acc);
}

// Assembly:
movb 0x4(%rdi), %al
movb 0x8(%rdi), %cl
movl %eax, %edx
shrb $0x7, %dl
andb $0x7c, %cl
orb %dl, %cl
addb %al, %al
movb %al, 0x4(%rdi)
sete %dl
addb %dl, %dl
andb $-0x80, %al
orb %dl, %al
orb %cl, %al
movb %al, 0x8(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bpl(signed char)
inline void cpu::op_bpl(signed char offset) {
    if(!status.sign) {
        pc+=offset;
        extra_time++;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
cmpb $0x0, 0x8(%rdi)
js 0xb61c
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %esi
movl %esi, 0x45c(%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xb61c
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movl (%rdi), %esi
decl %esi
movl %esi, (%rdi)
callq 0xbfc6
movl %ebx, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x96dc
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_O2/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 0x96dc
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 0x99e6
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_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bmi(signed char)
inline void cpu::op_bmi(signed char offset) {
    if(status.sign) {
        pc+=offset;
        extra_time++;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
cmpb $0x0, 0x8(%rdi)
js 0xb809
retq
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %esi
movl %esi, 0x45c(%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xb808
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0x96dc
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_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_lsra()
inline void cpu::op_lsra() {
    status.sign = 0;
    set_carry(acc&0x01);
    acc>>=(1);
    set_zero(acc);
}

// Assembly:
movb 0x4(%rdi), %al
movb 0x8(%rdi), %cl
movl %eax, %edx
andb $0x1, %dl
andb $0x7c, %cl
orb %dl, %cl
movl %eax, %edx
shrb %dl
movb %dl, 0x4(%rdi)
cmpb $0x2, %al
setb %al
addb %al, %al
orb %cl, %al
movb %al, 0x8(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bvc(signed char)
inline void cpu::op_bvc(signed char offset) {
    if(!status.verflow) {
        pc+=offset;
        extra_time++;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
testb $0x40, 0x8(%rdi)
jne 0xb934
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %esi
movl %esi, 0x45c(%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xb934
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x96dc
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 0xb9c6
xorb %cl, %dil
js 0xb9cc
andb $-0x41, %sil
jmp 0xb9d0
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_O2/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 0x9950
movl %eax, %ebp
movq 0x10(%rbx), %rdi
cmpb $-0x1, %bpl
jne 0xbb12
movl %ebp, %esi
callq 0x96dc
movl %eax, %r14d
movq 0x10(%rbx), %rdi
addl $0xffffff01, %ebp       # imm = 0xFFFFFF01
movl %ebp, %esi
callq 0x96dc
shll $0x8, %eax
orl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl %ebp, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x9950
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bvs(signed char)
inline void cpu::op_bvs(signed char offset) {
    if(status.verflow) {
        pc+=offset;
        extra_time++;
        if((pc>>(8))!=((pc-offset)>>(8))) {
                extra_time++;
        }
    }
}

// Assembly:
testb $0x40, 0x8(%rdi)
je 0xbb50
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %esi
movl %esi, 0x45c(%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xbb50
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bcc(signed char)
inline void cpu::op_bcc(signed char offset) {
    if(!status.carry) {
        extra_time++;
        pc+=offset;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
testb $0x1, 0x8(%rdi)
jne 0xbbf6
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x45c(%rdi)
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xbbf6
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bcs(signed char)
inline void cpu::op_bcs(signed char offset) {
    if(status.carry) {
        extra_time++;
        pc+=offset;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
testb $0x1, 0x8(%rdi)
je 0xbd2c
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x45c(%rdi)
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xbd2c
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x96dc
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 0x99e6
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_bne(signed char)
inline void cpu::op_bne(signed char offset) {
    if(!status.zero) {
        pc+=offset;
        extra_time++;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
testb $0x2, 0x8(%rdi)
jne 0xbe7c
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %esi
movl %esi, 0x45c(%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xbe7c
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x96dc
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
movl %ecx, %r8d
xorb %sil, %r8b
jns 0xbf09
xorb %sil, %al
js 0xbf0f
andb $-0x41, %dil
jmp 0xbf13
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_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::op_beq(signed char)
inline void cpu::op_beq(signed char offset) {
    if(status.zero) {
        extra_time++;
        pc+=offset;
        if((pc>>(8))!=((pc-offset)>>(8))) {
            extra_time++;
        }
    }
}

// Assembly:
testb $0x2, 0x8(%rdi)
je 0xbfc4
movl 0x45c(%rdi), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x45c(%rdi)
movsbl %sil, %ecx
movl (%rdi), %edx
addl %edx, %ecx
movl %ecx, (%rdi)
xorl %edx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0xbfc4
addl $0x2, %eax
movl %eax, 0x45c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/khedoros[P]khednes/cpu2.cpp
// Function: cpu::push2(unsigned int)
inline void cpu::push2(unsigned int val) {
    unsigned char pcl=pc&0xff;
    unsigned char pch=(pc/0x100)&0xff;
    //util::debug(ORIGIN, "PCL: %02x PCH:  %02x\n",pcl,pch);
    memory->write(0x100+sp,pch);
    sp--;
    memory->write(0x100+sp,pcl);
    sp--;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl (%rdi), %ebp
movl %ebp, %edx
shrl $0x8, %edx
movq 0x10(%rdi), %rdi
movzbl 0xe(%rbx), %esi
movl $0x100, %r14d           # imm = 0x100
orl %r14d, %esi
movl $0xff, %r15d
andl %r15d, %edx
callq 0x99e6
movb 0xe(%rbx), %al
decb %al
movb %al, 0xe(%rbx)
movq 0x10(%rbx), %rdi
movzbl %al, %esi
orl %r14d, %esi
andl %r15d, %ebp
movl %ebp, %edx
callq 0x99e6
decb 0xe(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 0xc621
cmpl $0x1, %esi
je 0xc5d2
testl %esi, %esi
jne 0xc692
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 0xc68a
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 0xc68a
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 %rax
movq 0xe916(%rip), %rdi      # 0x1afb0
leaq 0x6e67(%rip), %rsi      # 0x13508
callq 0x4390
movq %rax, %rdi
popq %rax
jmp 0x41c0
nop