LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::getDescription[abi:cxx11]()
string CODFile::getDescription()
{
    if (!isOpen) throw "Load file first";

    // find resource with name
    CODResource *r = FindResource(CODRESTDescription);

    // can't find
    if (r == NULL) throw "No Description in resources";

    return *( new string(r->getData()+2, r->getReversedU16(0)) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpb $0x0, 0x48(%rsi)
je 0x3b7e
movq %rdi, %r14
movq %rsi, %rdi
movl $0x3, %esi
callq 0x3856
testq %rax, %rax
je 0x3b91
movq %rax, %r12
movl $0x20, %edi
callq 0x21b0
movq %rax, %rbx
movq %r12, %rdi
callq 0x4022
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x4036
movzwl %ax, %eax
movq %rbx, %rcx
addq $0x10, %rcx
movq %rcx, (%rbx)
leaq (%r15,%rax), %rdx
addq $0x2, %rdx
addq $0x2, %r15
movb $0x1, %r12b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3dc2
leaq 0x10(%r14), %rax
movq %rax, (%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x3e5c
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2110
leaq 0x1625(%rip), %rcx      # 0x51b4
jmp 0x3ba2
movl $0x8, %edi
callq 0x2110
leaq 0x165e(%rip), %rcx      # 0x5200
movq %rcx, (%rax)
movq 0x340c(%rip), %rsi      # 0x6fb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2300
movq %rax, %r14
jmp 0x3bc1
movq %rax, %r14
movb $0x1, %r12b
testb %r12b, %r12b
je 0x3bd3
movl $0x20, %esi
movq %rbx, %rdi
callq 0x21c0
movq %r14, %rdi
callq 0x2310
nop
// File: /workspace/github_cpp_makefile_star2_O1/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::getVendor[abi:cxx11]()
string CODFile::getVendor()
{
    if (!isOpen) throw "Load file first";

    // find resource with name
    CODResource *r = FindResource(CODRESTVendor);

    // can't find
    if (r == NULL) throw "No Vendor in resources";

    return *( new string(r->getData()+2, r->getReversedU16(0)) );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpb $0x0, 0x48(%rsi)
je 0x3c7e
movq %rdi, %r14
movq %rsi, %rdi
movl $0x4, %esi
callq 0x3856
testq %rax, %rax
je 0x3c91
movq %rax, %r12
movl $0x20, %edi
callq 0x21b0
movq %rax, %rbx
movq %r12, %rdi
callq 0x4022
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x4036
movzwl %ax, %eax
movq %rbx, %rcx
addq $0x10, %rcx
movq %rcx, (%rbx)
leaq (%r15,%rax), %rdx
addq $0x2, %rdx
addq $0x2, %r15
movb $0x1, %r12b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3dc2
leaq 0x10(%r14), %rax
movq %rax, (%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x3e5c
movq %r14, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2110
leaq 0x1525(%rip), %rcx      # 0x51b4
jmp 0x3ca2
movl $0x8, %edi
callq 0x2110
leaq 0x157a(%rip), %rcx      # 0x521c
movq %rcx, (%rax)
movq 0x330c(%rip), %rsi      # 0x6fb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2300
movq %rax, %r14
jmp 0x3cc1
movq %rax, %r14
movb $0x1, %r12b
testb %r12b, %r12b
je 0x3cd3
movl $0x20, %esi
movq %rbx, %rdi
callq 0x21c0
movq %r14, %rdi
callq 0x2310
nop
// File: /workspace/github_cpp_makefile_star2_O1/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::getIcon(unsigned short&)
char *CODFile::getIcon(u16 &size)
{
    if (!isOpen) throw "Load file first";

    // find resource with icon
    CODResource *r = FindResource(CODRESTIcon);

    // can't find
    if (r == NULL) return NULL;

    size = r->getReversedU16(2);
    return r->getData() + 4;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
cmpb $0x0, 0x48(%rdi)
je 0x3d23
movq %rsi, %rbx
movl $0x5, %esi
callq 0x3856
testq %rax, %rax
je 0x3d1c
movq %rax, %r14
movq %rax, %rdi
movl $0x2, %esi
callq 0x4036
movw %ax, (%rbx)
movq %r14, %rdi
callq 0x4022
addq $0x4, %rax
jmp 0x3d1e
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movl $0x8, %edi
callq 0x2110
leaq 0x1480(%rip), %rcx      # 0x51b4
movq %rcx, (%rax)
movq 0x327a(%rip), %rsi      # 0x6fb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2300
// File: /workspace/github_cpp_makefile_star2_O1/sc0ty[P]CODExtract/src/codfile/codresource.cpp
// Function: CODResource::CODResource(TCODRESOURCE*, char*, unsigned short)
CODResource::CODResource(TCODRESOURCE *res, char *DataSeg, u16 DataSZ)
{
    // set data
    type = (char *)(DataSeg + res->type_ptr);
    size = res->size;
    data = (char *)(DataSeg + res->data_ptr);
    itype = CODRESTUndefined;

    // sanity check
    if ( (res->type_ptr + (strlen(type)) >= DataSZ) ||
         (res->data_ptr + size >= DataSZ))
        throw "Incorrect file format";

	#define CMPRES(res) ((strlen(type) == sizeof(res)) && \
						 (memcmp(res, (u8 *)type, sizeof(res)) == 0))

    // decode resource type
    if      (CMPRES(CODRESAppName))     itype = CODRESTAppName;
    else if (CMPRES(CODRESDescription)) itype = CODRESTDescription;
    else if (CMPRES(CODRESVendor))      itype = CODRESTVendor;
    else if (CMPRES(CODRESIcon))        itype = CODRESTIcon;
    else itype = CODRESTUnknown;

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movzwl (%rsi), %ebx
leaq (%rdx,%rbx), %r14
movq %r14, (%rdi)
movzwl 0x2(%rsi), %r12d
movw %r12w, 0x8(%rdi)
movzwl 0x4(%rsi), %r13d
addq %r13, %rdx
movq %rdx, 0x10(%rdi)
movq %rdi, -0x30(%rbp)
movl $0x0, 0x18(%rdi)
movq %r14, %rdi
callq 0x20f0
addq %rax, %rbx
movl %r15d, %ecx
cmpq %rcx, %rbx
jae 0x3ff2
addl %r12d, %r13d
movzwl %r15w, %ecx
cmpl %ecx, %r13d
jae 0x3ff2
cmpq $0x7, %rax
jne 0x3f91
movl $0x4e70185f, %ecx       # imm = 0x4E70185F
xorl (%r14), %ecx
movl $0x73652c4e, %edx       # imm = 0x73652C4E
xorl 0x3(%r14), %edx
orl %ecx, %edx
je 0x3fc2
cmpq $0x7, %rax
jne 0x3f91
movl $0x6373065f, %ecx       # imm = 0x6373065F
xorl (%r14), %ecx
movl $0x88697263, %edx       # imm = 0x88697263
xorl 0x3(%r14), %edx
orl %ecx, %edx
je 0x3fd7
cmpq $0x4, %rax
jne 0x3fa0
cmpl $0x19c9765f, (%r14)     # imm = 0x19C9765F
je 0x3fc9
cmpq $0x7, %rax
jne 0x3fbb
movl $0x4970185f, %eax       # imm = 0x4970185F
xorl (%r14), %eax
movl $0x73106349, %ecx       # imm = 0x73106349
xorl 0x3(%r14), %ecx
orl %eax, %ecx
je 0x3fd0
movl $0x1, %eax
jmp 0x3fdc
movl $0x2, %eax
jmp 0x3fdc
movl $0x4, %eax
jmp 0x3fdc
movl $0x5, %eax
jmp 0x3fdc
movl $0x3, %eax
movq -0x30(%rbp), %rcx
movl %eax, 0x18(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x8, %edi
callq 0x2110
leaq 0x119b(%rip), %rcx      # 0x519e
movq %rcx, (%rax)
movq 0x2fab(%rip), %rsi      # 0x6fb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2300
nop
// File: /workspace/github_cpp_makefile_star2_O1/sc0ty[P]CODExtract/src/codfile/codresource.cpp
// Function: CODResource::getReversedU16(unsigned short)
u16 CODResource::getReversedU16(u16 offset)
{
    // sanity check
    if (offset+1 >= size) throw "Exceeded end of resource data";

    // get two bytes from data
    u8 b1 = data[offset];
    u8 b2 = data[offset + 1];

    // revers byte order and return
    return (u16)(b1 * 256 + b2);
}

// Assembly:
movl %esi, %eax
incq %rax
movzwl 0x8(%rdi), %ecx
cmpl %ecx, %eax
jae 0x4058
movq 0x10(%rdi), %rcx
movzwl %si, %edx
movzbl (%rcx,%rax), %esi
movzbl (%rcx,%rdx), %eax
shll $0x8, %eax
orl %esi, %eax
retq
pushq %rbp
movq %rsp, %rbp
movl $0x8, %edi
callq 0x2110
leaq 0x11f9(%rip), %rcx      # 0x5266
movq %rcx, (%rax)
movq 0x2f41(%rip), %rsi      # 0x6fb8
movq %rax, %rdi
xorl %edx, %edx
callq 0x2300
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/GifCompressor.cxx
// Function: GifCompressor::GifCompressor()
GifCompressor::GifCompressor() : gif_length{0}
{
  data_length = 65536;
  data = (uint8_t *)malloc(data_length);

  memset(data, 0, data_length);

  memset(&gif_header, 0, sizeof(gif_header));
  memcpy(gif_header.version, "GIF87a", 6);
  memcpy(data, "GIF87a", 6);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq $0x10000, 0x18(%rdi)    # imm = 0x10000
movl $0x10000, %edi          # imm = 0x10000
callq 0x4270
movq %rax, %r14
movq %rax, 0x10(%rbx)
movq $0x0, 0x6(%rbx)
movl $0x38464947, %ebp       # imm = 0x38464947
movl %ebp, (%rbx)
movw $0x6137, %r15w          # imm = 0x6137
movw %r15w, 0x4(%rbx)
leaq 0x6(%rax), %rdi
movl $0xfffa, %edx           # imm = 0xFFFA
xorl %esi, %esi
callq 0x4110
movl %ebp, (%r14)
movw %r15w, 0x4(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.cxx
// Function: M6502::reset()
void M6502::reset()
{
  reg_a = 0;
  reg_x = 0;
  reg_y = 0;

  pc = memory_bus->read16(0xfffc);
  sp = 0xff;
  total_cycles = 0;
  total_instructions = 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %r15d, %r15d
movq %r15, 0xc(%rdi)
movl $0x0, 0x14(%rdi)
movq (%rdi), %r14
movq %r14, %rdi
movl $0xfffc, %esi           # imm = 0xFFFC
callq 0x6f2a
movzbl %al, %ebp
movq %r14, %rdi
movl $0xfffd, %esi           # imm = 0xFFFD
callq 0x6f2a
movzbl %al, %eax
shll $0x8, %eax
orl %ebp, %eax
movw %ax, 0x18(%rbx)
movw $0xff, 0x1a(%rbx)
movq %r15, 0x1c(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.cxx
// Function: M6502::dump()
void M6502::dump()
{
  printf(" PC: 0x%04x, SP: 0x%04x, A: 0x%02x, X: 0x%02x, Y: 0x%02x\n",
    pc, sp, reg_a, reg_x, reg_y);
  printf(" N V B * D I Z C\n");
  printf(" %d %d %d %d %d %d %d %d\n",
    status.n,
    status.v,
    status.b,
    status.one,
    status.d,
    status.i,
    status.z,
    status.c);
  printf(" total_instructions=%d\n", total_instructions);
  printf(" total_cycles=%d\n", total_cycles);
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movzwl 0x18(%rdi), %esi
movzwl 0x1a(%rdi), %edx
movl 0xc(%rdi), %ecx
movl 0x10(%rdi), %r8d
movl 0x14(%rdi), %r9d
leaq 0x5613(%rip), %rdi      # 0xa85c
xorl %eax, %eax
callq 0x4050
leaq 0x56bc(%rip), %rdi      # 0xa913
callq 0x4300
movzbl 0x29(%rbx), %r10d
movl %r10d, %esi
shrl $0x7, %esi
movl %r10d, %edx
shrl $0x6, %edx
andl $0x1, %edx
movl %r10d, %ecx
shrl $0x4, %ecx
andl $0x1, %ecx
movl %r10d, %r8d
shrl $0x5, %r8d
andl $0x1, %r8d
movl %r10d, %r9d
shrl $0x3, %r9d
andl $0x1, %r9d
movl %r10d, %r11d
shrl $0x2, %r11d
andl $0x1, %r11d
movl %r10d, %r14d
shrl %r14d
andl $0x1, %r14d
andl $0x1, %r10d
subq $0x8, %rsp
leaq 0x55e3(%rip), %rdi      # 0xa896
xorl %eax, %eax
pushq %r10
pushq %r14
pushq %r11
callq 0x4050
addq $0x20, %rsp
movl 0x20(%rbx), %esi
leaq 0x55e2(%rip), %rdi      # 0xa8b0
xorl %eax, %eax
callq 0x4050
movl 0x1c(%rbx), %esi
leaq 0x55e9(%rip), %rdi      # 0xa8c8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4050
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.cxx
// Function: M6502::step()
int M6502::step()
{
  int cycles = execute_instruction();

  total_cycles += cycles;
  total_instructions++;

  return cycles;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0x5324
addl %eax, 0x1c(%rbx)
incl 0x20(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_indirect_x(int&)
int read_indirect_x(int &address)
  {
    int m;
    m = memory_bus->read(pc++) + reg_x;
    m = memory_bus->read16(m & 0xff);
    address = m;
    return memory_bus->read(m);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
movzwl 0x18(%rbx), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%rbx)
callq 0x6f2a
movq (%rbx), %r15
addb 0x10(%rbx), %al
movzbl %al, %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r12d
incl %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %esi
shll $0x8, %esi
orl %r12d, %esi
movl %esi, (%r14)
movq (%rbx), %rdi
callq 0x6f2a
movzbl %al, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::set_flags(int&)
void set_flags(int &data)
  {
    status.c = (data & 0x100) != 0;
    data &= 0xff;

    status.z = data == 0;
    status.n = (data & 0x80) != 0;
  }

// Assembly:
movb 0x1(%rsi), %al
andb $0x1, %al
movb 0x29(%rdi), %cl
andb $-0x2, %cl
orb %al, %cl
movb %cl, 0x29(%rdi)
movzbl (%rsi), %eax
movl %eax, (%rsi)
testl %eax, %eax
sete %al
movb 0x29(%rdi), %cl
addb %al, %al
andb $-0x3, %cl
orb %al, %cl
movb %cl, 0x29(%rdi)
movb (%rsi), %al
andb $-0x80, %al
andb $0x7f, %cl
orb %al, %cl
movb %cl, 0x29(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_absolute(int&)
int read_absolute(int &address)
  {
    int m = memory_bus->read16(pc);
    address = m;
    pc += 2;
    return memory_bus->read(m);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %r15
movzwl 0x18(%rdi), %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r12d
incl %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %esi
shll $0x8, %esi
orl %r12d, %esi
movl %esi, (%rbx)
addw $0x2, 0x18(%r14)
movq (%r14), %rdi
callq 0x6f2a
movzbl %al, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_indirect_y(int&, int&)
int read_indirect_y(int &address, int &address_before)
  {
    int m;
    m = memory_bus->read(pc++);
    m = memory_bus->read16(m);
    address_before = m;
    m += reg_y;
    m = m & 0xffff;
    address = m;
    return memory_bus->read(m);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %rdi
movzwl 0x18(%rbx), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%rbx)
callq 0x6f2a
movzbl %al, %ebp
movq (%rbx), %r12
movq %r12, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r13d
incl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %eax
shll $0x8, %eax
orl %r13d, %eax
movl %eax, (%r15)
addl 0x14(%rbx), %eax
movzwl %ax, %esi
movl %esi, (%r14)
movq (%rbx), %rdi
callq 0x6f2a
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_zero_page_x(int&)
int read_zero_page_x(int &address)
  {
    int m;
    m = memory_bus->read(pc++) + reg_x;
    m = m & 0xff;
    address = m;
    return memory_bus->read(m);
  }

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%r14)
callq 0x6f2a
addb 0x10(%r14), %al
movzbl %al, %esi
movl %esi, (%rbx)
movq (%r14), %rdi
callq 0x6f2a
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_absolute_y(int&, int&)
int read_absolute_y(int &address, int &address_before)
  {
    int m = memory_bus->read16(pc);
    address_before = m;
    m += reg_y;
    address = m;
    pc += 2;
    return memory_bus->read(m);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %r12
movzwl 0x18(%rdi), %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r13d
incl %ebp
movq %r12, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %esi
shll $0x8, %esi
orl %r13d, %esi
movl %esi, (%rbx)
addl 0x14(%r15), %esi
movl %esi, (%r14)
addw $0x2, 0x18(%r15)
movq (%r15), %rdi
callq 0x6f2a
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_rol_memory(int, int)
void run_rol_memory(int address, int data)
  {
    int c = status.c;
    data = data << 1;
    set_flags(data);
    data |= c;
    status.z = data == 0;
    memory_bus->write(address, data);
  }

// Assembly:
movzbl 0x29(%rdi), %ecx
movl %ecx, %eax
andl $0x1, %eax
leal (%rdx,%rdx), %r8d
shrb $0x7, %dl
andb $0x7c, %cl
movzbl %r8b, %r8d
movl %r8d, %r9d
andb $-0x80, %r9b
orl %r8d, %eax
sete %r8b
addb %r8b, %r8b
orb %dl, %r9b
orb %cl, %r9b
orb %r8b, %r9b
movb %r9b, 0x29(%rdi)
movq (%rdi), %rdi
movl %eax, %edx
jmp 0x6fa8
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_ror_memory(int, int)
void run_ror_memory(int address, int data)
  {
    int c = status.c;
    status.c = data & 1;
    data = data >> 1;
    data |= c << 7;
    status.z = data == 0;
    status.n = (data & 0x80) != 0;
    memory_bus->write(address, data);
  }

// Assembly:
movb 0x29(%rdi), %al
movl %edx, %ecx
andb $0x1, %cl
movl %eax, %r8d
andb $0x7c, %r8b
orb %cl, %r8b
sarl %edx
shlb $0x7, %al
movzbl %al, %eax
orl %edx, %eax
sete %cl
addb %cl, %cl
orb %r8b, %cl
movzbl %al, %edx
andb $-0x80, %al
orb %cl, %al
movb %al, 0x29(%rdi)
movq (%rdi), %rdi
jmp 0x6fa8
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_lsr_memory(int, int)
void run_lsr_memory(int address, int data)
  {
    status.c = data & 1;
    data = (data >> 1) & 0xff;
    status.z = data == 0;
    status.n = (data & 0x80) != 0;
    memory_bus->write(address, data);
  }

// Assembly:
movl %edx, %eax
andb $0x1, %al
movb 0x29(%rdi), %cl
andb $0x7c, %cl
movl %edx, %r8d
shrl %r8d
testl $0x1fe, %edx            # imm = 0x1FE
sete %r9b
addb %r9b, %r9b
orb %al, %r9b
movzbl %r8b, %edx
andb $-0x80, %r8b
orb %r9b, %r8b
orb %cl, %r8b
movb %r8b, 0x29(%rdi)
movq (%rdi), %rdi
jmp 0x6fa8
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_adc(int)
void run_adc(int data)
  {
    if (status.d == 0)
    {
      reg_a = reg_a + data + status.c;

      status.c = reg_a > 0xff;
      reg_a &= 0xff;
      status.z = reg_a == 0;
      status.n = (reg_a & 0x80) != 0;
      status.v = status.c ^ status.n;
    }
      else
    {
      int d0 = data & 0xf;
      int d1 = data >> 4;
      int a0 = reg_a & 0xf;
      int a1 = reg_a >> 4;

      a0 = a0 + d0 + status.c;

      if (a0 > 10)
      {
        a1 += a0 / 10;
        a0 = a0 % 10;
      }

      a1 = a1 + d1;

      status.c = a1 / 10 > 0;
      a1 = a1 % 10;

      reg_a = ((a1 << 4) | a0) & 0xff;
      status.z = reg_a == 0;
    }
  }

// Assembly:
movzbl 0x29(%rdi), %eax
testb $0x8, %al
jne 0x69bc
movl %eax, %ecx
andl $0x1, %ecx
addl %esi, %ecx
addl 0xc(%rdi), %ecx
xorl %edx, %edx
cmpl $0x100, %ecx            # imm = 0x100
setge %dl
andb $-0xc, %al
orb %dl, %al
movl %ecx, %esi
andl $0xff, %esi
movl %esi, 0xc(%rdi)
sete %sil
addb %sil, %sil
orb %al, %sil
movb %sil, 0x29(%rdi)
movl %ecx, %eax
andb $-0x80, %al
andb $0x37, %sil
orb %al, %sil
shrl $0x7, %ecx
xorl %edx, %ecx
shlb $0x6, %cl
andb $0x40, %cl
orb %sil, %cl
movl %ecx, %eax
jmp 0x6a42
movl %esi, %r8d
andl $0xf, %r8d
sarl $0x4, %esi
movl 0xc(%rdi), %edx
movl %edx, %r9d
andl $0xf, %r9d
sarl $0x4, %edx
movl %eax, %ecx
andl $0x1, %ecx
addl %r8d, %ecx
addl %r9d, %ecx
cmpl $0xb, %ecx
jb 0x69fe
movl %ecx, %r8d
imulq $0x1999999a, %r8, %r8   # imm = 0x1999999A
shrq $0x20, %r8
addl %r8d, %edx
addl %r8d, %r8d
leal (%r8,%r8,4), %r8d
subl %r8d, %ecx
addl %esi, %edx
cmpl $0xa, %edx
setge %sil
andb $-0x2, %al
orb %sil, %al
movb %al, 0x29(%rdi)
movslq %edx, %rdx
imulq $0x66666667, %rdx, %rsi # imm = 0x66666667
movq %rsi, %r8
shrq $0x3f, %r8
sarq $0x22, %rsi
addl %r8d, %esi
addl %esi, %esi
leal (%rsi,%rsi,4), %esi
subl %esi, %edx
shll $0x4, %edx
movzbl %dl, %edx
orl %ecx, %edx
movl %edx, 0xc(%rdi)
sete %cl
addb %cl, %cl
andb $-0x3, %al
orb %cl, %al
movb %al, 0x29(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_ror()
void run_ror()
  {
    int c = status.c;
    status.c = reg_a & 1;
    reg_a = reg_a >> 1;
    reg_a |= c << 7;
    status.z = reg_a == 0;
    status.n = (reg_a & 0x80) != 0;
  }

// Assembly:
movb 0x29(%rdi), %al
movl 0xc(%rdi), %ecx
movl %ecx, %edx
andb $0x1, %dl
movl %eax, %esi
andb $0x7c, %sil
orb %dl, %sil
sarl %ecx
shlb $0x7, %al
movzbl %al, %eax
orl %ecx, %eax
movl %eax, 0xc(%rdi)
sete %cl
addb %cl, %cl
orb %sil, %cl
andb $-0x80, %al
orb %cl, %al
movb %al, 0x29(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::store_indirect_x(int)
void store_indirect_x(int data)
  {
    int address;
    address = memory_bus->read(pc++) + reg_x;
    address = memory_bus->read16(address & 0xff);
    memory_bus->write(address, data);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%r14)
callq 0x6f2a
movq (%r14), %r15
addb 0x10(%r14), %al
movzbl %al, %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r12d
incl %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %esi
shll $0x8, %esi
orl %r12d, %esi
movq (%r14), %rdi
movzbl %bl, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6fa8
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::store_indirect_y(int)
void store_indirect_y(int data)
  {
    int address;
    address = memory_bus->read(pc++);
    address = memory_bus->read16(address) + reg_y;
    memory_bus->write(address, data);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%r14)
callq 0x6f2a
movzbl %al, %ebp
movq (%r14), %r15
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %r12d
incl %ebp
movq %r15, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %eax
shll $0x8, %eax
addl 0x14(%r14), %r12d
addl %eax, %r12d
movq (%r14), %rdi
movzbl %bl, %edx
movl %r12d, %esi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6fa8
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::store_absolute_y(int, int&)
void store_absolute_y(int data, int &cycles)
  {
    int a = memory_bus->read16(pc);
    cycles = 5;
    int address = a + reg_y;
    //if (!same_page(address, a)) { cycles++; }
    pc += 2;
    memory_bus->write(address, data);
  }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %r15
movzwl 0x18(%rdi), %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x6f2a
movzbl %al, %r13d
incl %r12d
movq %r15, %rdi
movl %r12d, %esi
callq 0x6f2a
movzbl %al, %esi
shll $0x8, %esi
orl %r13d, %esi
movl $0x5, (%rbx)
addl 0x14(%r14), %esi
addw $0x2, 0x18(%r14)
movq (%r14), %rdi
movzbl %bpl, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6fa8
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_dec_memory(int, int)
void run_dec_memory(int address, int data)
  {
    data--;
    data &= 0xff;
    set_load_flags(data);
    memory_bus->write(address, data);
  }

// Assembly:
movl $0xff, %eax
addl %eax, %edx
andl %edx, %eax
sete %cl
movb 0x29(%rdi), %r8b
addb %cl, %cl
andb $0x7d, %r8b
andb $-0x80, %dl
orb %cl, %dl
orb %r8b, %dl
movb %dl, 0x29(%rdi)
movq (%rdi), %rdi
movl %eax, %edx
jmp 0x6fa8
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_sbc(int)
void run_sbc(int data)
  {
    if (status.d == 0)
    {
      reg_a = ((status.c << 8) | reg_a) - data;
      status.c = reg_a > 0xff;
      reg_a &= 0xff;
      status.z = reg_a == 0;
      status.n = (reg_a & 0x80) != 0;
      status.v = status.c ^ status.n;
    }
      else
    {
      int d0 = data & 0xf;
      int d1 = data >> 4;
      int a0 = reg_a & 0xf;
      int a1 = reg_a >> 4;

      a0 = a0 - d0 - (status.c ^ 1);

      if (a0 < 0)
      {
        a1--;
        a0 += 1;
      }

      a1 = a1 - d1;

      status.c = a1 / 10 > 0;
      a1 = a1 % 10;

      reg_a = ((a1 << 4) | a0) & 0xff;
      status.z = reg_a == 0;
    }
  }

// Assembly:
movzbl 0x29(%rdi), %eax
testb $0x8, %al
jne 0x6dba
movl %eax, %ecx
andl $0x1, %ecx
shll $0x8, %ecx
orl 0xc(%rdi), %ecx
subl %esi, %ecx
xorl %edx, %edx
cmpl $0x100, %ecx            # imm = 0x100
setge %dl
andb $-0xc, %al
orb %dl, %al
movl %ecx, %esi
andl $0xff, %esi
movl %esi, 0xc(%rdi)
sete %sil
addb %sil, %sil
orb %al, %sil
movb %sil, 0x29(%rdi)
movl %ecx, %eax
andb $-0x80, %al
andb $0x37, %sil
orb %al, %sil
shrl $0x7, %ecx
xorl %edx, %ecx
shlb $0x6, %cl
andb $0x40, %cl
orb %sil, %cl
jmp 0x6e33
movl %esi, %ecx
andl $0xf, %ecx
sarl $0x4, %esi
movl 0xc(%rdi), %edx
movl %edx, %r8d
andl $0xf, %r8d
sarl $0x4, %edx
subl %esi, %edx
movl %eax, %esi
notl %esi
andl $0x1, %esi
addl %ecx, %esi
subl %esi, %r8d
movl %r8d, %ecx
shrl $0x1f, %ecx
addl %r8d, %ecx
sarl $0x1f, %r8d
addl %edx, %r8d
cmpl $0xa, %r8d
setge %dl
andb $-0x2, %al
orb %dl, %al
movb %al, 0x29(%rdi)
movslq %r8d, %rdx
imulq $0x66666667, %rdx, %rsi # imm = 0x66666667
movq %rsi, %r8
shrq $0x3f, %r8
sarq $0x22, %rsi
addl %r8d, %esi
addl %esi, %esi
leal (%rsi,%rsi,4), %esi
subl %esi, %edx
shll $0x4, %edx
orl %ecx, %edx
andl $0xff, %edx
movl %edx, 0xc(%rdi)
sete %cl
addb %cl, %cl
andb $-0x3, %al
orb %cl, %al
movl %eax, %ecx
movb %cl, 0x29(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_inc_memory(int, int)
void run_inc_memory(int address, int data)
  {
    data++;
    data &= 0xff;
    set_load_flags(data);
    memory_bus->write(address, data);
  }

// Assembly:
incl %edx
movl %edx, %eax
andl $0xff, %eax
sete %cl
movb 0x29(%rdi), %r8b
addb %cl, %cl
andb $0x7d, %r8b
andb $-0x80, %dl
orb %cl, %dl
orb %r8b, %dl
movb %dl, 0x29(%rdi)
movq (%rdi), %rdi
movl %eax, %edx
jmp 0x6fa8
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/MemoryBus.cxx
// Function: MemoryBus::read(int)
uint8_t MemoryBus::read(int address)
{
  // Takes care of mirrored memory.
  if ((address & 0x1000) == 0x1000)
  {
    if (address == 0x1ff9)
    {
      if (rom->set_bank(1)) { return 0; }
    }
      else
    if (address == 0x1ff8)
    {
      if (rom->set_bank(0)) { return 0; }
    }

    return rom->read_int8(address & 0x0fff);
  }

  if (address <= 0x3f)
  {
    return tia->read_memory(address & 0x3f);
  }

  return riot->read_memory(address);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
btl $0xc, %esi
jb 0x6f50
cmpl $0x3f, %ebx
jg 0x6f75
movq 0x10(%r14), %rdi
andl $0x3f, %ebx
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x79ae
cmpl $0x1ff8, %ebx           # imm = 0x1FF8
je 0x6f84
cmpl $0x1ff9, %ebx           # imm = 0x1FF9
jne 0x6f94
movq (%r14), %rdi
movl $0x1, %esi
callq 0x7820
testb %al, %al
je 0x6f94
xorl %ebp, %ebp
jmp 0x6fa1
movq 0x8(%r14), %rdi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x760a
movq (%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x7820
testb %al, %al
jne 0x6fa1
movq (%r14), %rax
andl $0xfff, %ebx            # imm = 0xFFF
movb (%rax,%rbx), %bpl
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/MemoryBus.cxx
// Function: MemoryBus::dump(int, int)
void MemoryBus::dump(int start, int end)
{
  start &= 0xfff0;

  for (int n = start; n <= end; n++)
  {
    if ((n % 16) == 0)
    {
      printf("%04x:", n);
    }

    if ((n % 8) == 0)
    {
      printf(" " );
    }

    printf(" %02x", read(n));

    if ((n % 16) == 15)
    {
      printf("\n");
    }
  }

  printf("\n");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebp
andl $0xfff0, %ebp           # imm = 0xFFF0
cmpl %edx, %ebp
jg 0x704e
movl %edx, %ebx
movq %rdi, %r14
incl %ebx
leaq 0x392f(%rip), %r15      # 0xa924
leaq 0x392e(%rip), %r12      # 0xa92a
movl %ebp, %r13d
andl $0xf, %r13d
jne 0x7011
movq %r15, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x4050
testb $0x7, %bpl
jne 0x7021
movl $0x20, %edi
callq 0x42a0
movq %r14, %rdi
movl %ebp, %esi
callq 0x6f2a
movzbl %al, %esi
movq %r12, %rdi
xorl %eax, %eax
callq 0x4050
cmpl $0xf, %r13d
jne 0x7048
movl $0xa, %edi
callq 0x42a0
incl %ebp
cmpl %ebp, %ebx
jne 0x6ffc
movl $0xa, %edi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/Network.cxx
// Function: Network::net_close()
void Network::net_close()
{
  if (client != -1)
  {
    close(client);
    client = -1;
  }

  if (socket_id != -1)
  {
    close(socket_id);
    socket_id = -1;
  }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x4(%rdi), %edi
cmpl $-0x1, %edi
je 0x70c4
callq 0x4350
movl $0xffffffff, 0x4(%rbx)  # imm = 0xFFFFFFFF
movl (%rbx), %edi
cmpl $-0x1, %edi
je 0x70d6
callq 0x4350
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/Network.cxx
// Function: Network::net_open(int)
int Network::net_open(int port)
{
  struct sockaddr_in server_addr;
  struct sockaddr_in client_addr;

  socket_id = socket(AF_INET, SOCK_STREAM, 0);

  if (socket_id < 0)
  {
    printf("Can't open socket.\n");
    return -1;
  }

  memset((char*)&server_addr, 0, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  server_addr.sin_port = htons(port);

  if (bind(socket_id, (const sockaddr *)&server_addr, sizeof(server_addr)) < 0)
  {
    printf("Server can't bind.\n");
    return -1;
  }

  if (listen(socket_id, 1) != 0)
  {
    printf("Listen failed.\n");
    return -1;
  }

  socklen_t n = sizeof(client_addr);

  client = accept(socket_id, (struct sockaddr *)&client_addr, &n);

  if (client == -1) { return -1; }

  fcntl(client, F_SETFL, O_NONBLOCK);

  return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40a0
movl %eax, (%rbx)
testl %eax, %eax
js 0x7142
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, (%rsi)
movw $0x2, (%rsi)
movl $0x0, 0x4(%rsi)
rolw $0x8, %bp
movw %bp, 0x2(%rsi)
movl %eax, %edi
movl $0x10, %edx
callq 0x4080
testl %eax, %eax
js 0x714b
movl (%rbx), %edi
movl $0x1, %esi
callq 0x41f0
testl %eax, %eax
je 0x7165
leaq 0x385f(%rip), %rdi      # 0xa99f
jmp 0x7152
leaq 0x3878(%rip), %rdi      # 0xa9c1
jmp 0x7152
leaq 0x385c(%rip), %rdi      # 0xa9ae
callq 0x4300
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %rbp
retq
leaq 0xc(%rsp), %rdx
movl $0x10, (%rdx)
movl (%rbx), %edi
leaq 0x28(%rsp), %rsi
callq 0x40c0
movl %eax, 0x4(%rbx)
cmpl $-0x1, %eax
je 0x7157
xorl %ebx, %ebx
movl %eax, %edi
movl $0x4, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4120
jmp 0x715c
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/Network.cxx
// Function: Network::net_send(unsigned char const*, int)
int Network::net_send(const uint8_t *buffer, int length)
{
  struct timeval tv;
  fd_set writeset;

  int bytes_sent = 0;

  while (bytes_sent < length)
  {
    FD_ZERO(&writeset);
    FD_SET(client, &writeset);

    tv.tv_sec = 10;
    tv.tv_usec = 0;

    int n = select(client + 1, NULL, &writeset, NULL, &tv);

    if (n == -1)
    {
      if (errno == EINTR) { continue; }

      perror("Problem with select in net_send");
      return -1;
    }

    if (n == 0) { return -3; }

    n = send(client, buffer + bytes_sent, length - bytes_sent, 0);
    if (n < 0) { return -4; }

    bytes_sent += n;
  }

  return bytes_sent;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, 0x8(%rsp)
testl %edx, %edx
jle 0x72c3
movl %edx, %ebp
movq %rdi, %r15
xorl %ebx, %ebx
leaq 0x20(%rsp), %r12
leaq 0x10(%rsp), %r13
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl 0x4(%r15), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl %eax, %edx
andl $-0x40, %edx
movl %edi, %ecx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0x20(%rsp,%rax,8)
movq $0xa, 0x10(%rsp)
movq $0x0, 0x18(%rsp)
incl %edi
xorl %esi, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x41a0
movl $0x1, %r14d
testl %eax, %eax
je 0x7267
cmpl $-0x1, %eax
jne 0x7271
callq 0x4040
cmpl $0x4, (%rax)
jne 0x72ad
movl $0x2, %r14d
jmp 0x729d
movl $0xfffffffd, 0x4(%rsp)  # imm = 0xFFFFFFFD
jmp 0x729d
movl 0x4(%r15), %edi
movl %ebx, %esi
addq 0x8(%rsp), %rsi
movl %ebp, %eax
subl %ebx, %eax
movslq %eax, %rdx
xorl %ecx, %ecx
callq 0x4100
testl %eax, %eax
js 0x7295
addl %eax, %ebx
xorl %r14d, %r14d
jmp 0x729d
movl $0xfffffffc, 0x4(%rsp)  # imm = 0xFFFFFFFC
testb $0x1, %r14b
jne 0x72c7
cmpl %ebp, %ebx
jl 0x71cb
jmp 0x72cd
leaq 0x368c(%rip), %rdi      # 0xa940
callq 0x4150
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
jmp 0x729d
xorl %ebx, %ebx
jmp 0x72cd
movl 0x4(%rsp), %eax
movl %eax, %ebx
movl %ebx, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/Network.cxx
// Function: Network::net_has_data()
bool Network::net_has_data()
{
  struct timeval tv;
  fd_set readset;

  FD_ZERO(&readset);
  FD_SET(client, &readset);

  tv.tv_sec = 0;
  tv.tv_usec = 0;

  int n = select(client + 1, &readset, NULL, NULL, &tv);

  if (n == -1)
  {
    if (errno == EINTR) { return false; }

    perror("Problem with select in Network");
    net_close();
    return false;
  }

  return FD_ISSET(client, &readset);
}

// Assembly:
pushq %rbx
subq $0x90, %rsp
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rsi
movaps %xmm0, 0x70(%rsi)
movaps %xmm0, 0x60(%rsi)
movaps %xmm0, 0x50(%rsi)
movaps %xmm0, 0x40(%rsi)
movaps %xmm0, 0x30(%rsi)
movaps %xmm0, 0x20(%rsi)
movaps %xmm0, 0x10(%rsi)
movaps %xmm0, (%rsi)
movl 0x4(%rdi), %edi
leal 0x3f(%rdi), %eax
testl %edi, %edi
cmovnsl %edi, %eax
movl %eax, %edx
andl $-0x40, %edx
movl %edi, %ecx
subl %edx, %ecx
movl $0x1, %edx
shlq %cl, %rdx
sarl $0x6, %eax
cltq
orq %rdx, 0x10(%rsp,%rax,8)
incl %edi
movq %rsp, %r8
movaps %xmm0, (%r8)
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41a0
cmpl $-0x1, %eax
je 0x7536
movl 0x4(%rbx), %eax
leal 0x3f(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x6, %ecx
movslq %ecx, %rcx
movq 0x10(%rsp,%rcx,8), %rcx
btq %rax, %rcx
setb %al
jmp 0x7542
callq 0x4040
cmpl $0x4, (%rax)
jne 0x754b
xorl %eax, %eax
addq $0x90, %rsp
popq %rbx
retq
leaq 0x342e(%rip), %rdi      # 0xa980
callq 0x4150
movq %rbx, %rdi
callq 0x70ac
jmp 0x7540
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/RIOT.cxx
// Function: RIOT::reset()
void RIOT::reset()
{
  memset(ram, 0, sizeof(ram));
  memset(riot, 0, sizeof(riot));

  riot[SWCHA & 0x07] = 0xff;
  riot[SWACNT & 0x07] = 0xff;
  riot[SWCHB & 0x07] = 0x0b;

  prescale = TIM1T;
  prescale_shift = TIM1T_SHIFT;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
addq $0x38, %rdi
movl $0x108, %edx            # imm = 0x108
xorl %esi, %esi
callq 0x4110
movl 0x20(%rbx), %eax
andl $0x7, %eax
movb $-0x1, %cl
movb %cl, 0x38(%rbx,%rax)
movl 0x24(%rbx), %eax
andl $0x7, %eax
movb %cl, 0x38(%rbx,%rax)
movl 0x28(%rbx), %eax
andl $0x7, %eax
movb $0xb, 0x38(%rbx,%rax)
movl (%rbx), %eax
movl 0x10(%rbx), %ecx
movl %eax, 0x2c(%rbx)
movl %ecx, 0x30(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/RIOT.cxx
// Function: RIOT::clock(int)
void RIOT::clock(int ticks)
{
  while (ticks > 0)
  {
    interrupt_timer--;

    if (interrupt_timer == 0)
    {
      prescale_shift = 0;
    }

    ticks--;
  }

  riot[4] = (interrupt_timer >> prescale_shift) & 0xff;
}

// Assembly:
testl %esi, %esi
jle 0x76cf
movl 0x34(%rdi), %eax
leal -0x1(%rax), %ecx
leal 0x1(%rsi), %edx
subl $0x1, %ecx
jae 0x76c3
movl $0x0, 0x30(%rdi)
decl %edx
cmpl $0x1, %edx
jg 0x76b7
subl %esi, %eax
movl %eax, 0x34(%rdi)
movl 0x34(%rdi), %eax
movb 0x30(%rdi), %cl
sarl %cl, %eax
movb %al, 0x3c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/ROM.cxx
// Function: ROM::load(char const*)
int ROM::load(const char *filename)
{
  struct stat statbuf;
  memset(&statbuf, 0, sizeof(statbuf));
  stat(filename, &statbuf);

  const int file_size = statbuf.st_size;

  if (file_size != 2048 &&
      file_size != 4096 &&
      file_size != 8192)
  {
    printf("Error: ROM size is not 2048, 4096, 8192 (%d)\n", file_size);
    return -1;
  }

  FILE *in = fopen(filename, "rb");

  if (in == NULL)
  {
    printf("Error: Couldn't open file %s\n", filename);
    return -1;
  }

  size = fread(full, 1, statbuf.st_size, in);
  fclose(in);

  if (size != statbuf.st_size)
  {
    printf("Error: Could not load ROM %d/%d\n", size, file_size);
    return -2;
  }

  if (size == 2048)
  {
    memcpy(memory +    0, full, 2048);
    memcpy(memory + 2048, full, 2048);
  }
    else
  {
    memcpy(memory, full, 4096);
  }

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rsp), %r14
movl $0x90, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4110
movq %r15, %rdi
movq %r14, %rsi
callq 0x4170
movq 0x30(%r14), %r14
cmpl $0x800, %r14d           # imm = 0x800
je 0x774a
cmpl $0x1000, %r14d          # imm = 0x1000
je 0x774a
cmpl $0x2000, %r14d          # imm = 0x2000
jne 0x77ce
leaq 0x2b72(%rip), %rsi      # 0xa2c3
movq %r15, %rdi
callq 0x4220
testq %rax, %rax
je 0x77bb
movq %rax, %r12
leaq 0x1000(%rbx), %r15
movl $0x1, %esi
movq %r15, %rdi
movq %r14, %rdx
movq %rax, %rcx
callq 0x42f0
movl %eax, 0x3000(%rbx)
movq %r12, %rdi
callq 0x41b0
movslq 0x3000(%rbx), %rsi
cmpq %rsi, %r14
jne 0x77e6
cmpl $0x800, %esi            # imm = 0x800
jne 0x77fe
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4140
addq $0x800, %rbx            # imm = 0x800
movl $0x800, %edx            # imm = 0x800
jmp 0x7803
leaq 0x327c(%rip), %rdi      # 0xaa3e
movq %r15, %rsi
xorl %eax, %eax
callq 0x4050
jmp 0x77df
leaq 0x323b(%rip), %rdi      # 0xaa10
movl %r14d, %esi
xorl %eax, %eax
callq 0x4050
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x7810
leaq 0x326f(%rip), %rdi      # 0xaa5c
movl %r14d, %edx
xorl %eax, %eax
callq 0x4050
movl $0xfffffffe, %eax       # imm = 0xFFFFFFFE
jmp 0x7810
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4140
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::TIA()
TIA::TIA() :
  pos_x{0},
  pos_y{0},
  hsync_latch{false},
  image_32{nullptr},
  image_8{nullptr},
  check_events{false},
  fps{0},
  timestamp{0}
{
  for (int n = 0; n < 256; n++)
  {
    reverse[n]=
      (((n & 0x01) << 7) | ((n & 0x02) << 5) |
       ((n & 0x04) << 3) | ((n & 0x08) << 1) |
       ((n & 0x10) >> 1) | ((n & 0x20) >> 3) |
       ((n & 0x40) >> 5) | ((n & 0x80) >> 7));
  }

  reset();
}

// Assembly:
leaq 0x8(%rdi), %rax
xorl %ecx, %ecx
movq %rcx, 0x20(%rdi)
movq %rcx, 0x8(%rdi)
movb %cl, 0x10(%rdi)
movq $0x1, 0x28(%rdi)
movl %ecx, 0x30(%rdi)
movl $0x1, %edx
movl %edx, 0x38(%rdi)
movl %ecx, 0x3c(%rdi)
movl %ecx, 0x40(%rdi)
movl %ecx, 0x44(%rdi)
movl %edx, 0x4c(%rdi)
movl %ecx, 0x50(%rdi)
movl %ecx, 0x54(%rdi)
movw $0x1, %dx
movw %dx, 0x58(%rdi)
movb %cl, 0x5a(%rdi)
movl %ecx, 0x5c(%rdi)
movw %dx, 0x64(%rdi)
movb %cl, 0x66(%rdi)
movl %ecx, 0x68(%rdi)
movw %dx, 0x70(%rdi)
movb %cl, 0x72(%rdi)
movl %ecx, 0x74(%rdi)
movw $0x0, 0x7c(%rdi)
movb %cl, 0x1e4(%rdi)
movl %ecx, 0x1e8(%rdi)
movq %rcx, 0x1f0(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0x1d0(%rdi)
movl %ecx, %edx
andb $0x70, %dl
movl %ecx, %esi
shlb $0x4, %sil
shrb $0x4, %dl
orb %sil, %dl
movl %edx, %esi
andb $0x33, %sil
shlb $0x2, %sil
shrb $0x2, %dl
andb $0x31, %dl
orb %sil, %dl
movl %edx, %esi
andb $0x55, %sil
addb %sil, %sil
shrb %dl
andb $0x54, %dl
orb %sil, %dl
movl %ecx, %esi
shrl $0x7, %esi
orb %dl, %sil
movb %sil, 0xd0(%rdi,%rcx)
incq %rcx
cmpq $0x100, %rcx            # imm = 0x100
jne 0x78d3
movb $0x0, 0x8(%rax)
movq $0x0, (%rax)
movq $0x1, 0x28(%rdi)
xorps %xmm0, %xmm0
movups %xmm0, 0xc0(%rdi)
movups %xmm0, 0x80(%rdi)
movups %xmm0, 0x90(%rdi)
movups %xmm0, 0xa0(%rdi)
movups %xmm0, 0xb0(%rdi)
movw $0x8080, 0xcc(%rdi)     # imm = 0x8080
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::build_playfield()
void TIA::build_playfield()
{
  playfield.data =
    ((write_regs[PF0] >> 4) & 0x0f) |
     (reverse[write_regs[PF1]] << 4) |
     (write_regs[PF2] << 12);

  if ((write_regs[CTRLPF] & 1) == 0)
  {
    // Non-mirroed playfield
    playfield.data |= playfield.data << 20;
  }
    else
  {
    // Mirrored playfield.
    playfield.data |=
      (((uint64_t)reverse[write_regs[PF0]] & 0x0f) << 36) |
       ((uint64_t)write_regs[PF1] << 28) |
       ((uint64_t)reverse[write_regs[PF2]] << 20);
  }
}

// Assembly:
movzbl 0x8d(%rdi), %edx
movl %edx, %eax
shrl $0x4, %eax
movzbl 0x8e(%rdi), %ecx
movzbl 0xd0(%rdi,%rcx), %r8d
shll $0x4, %r8d
orl %eax, %r8d
movzbl 0x8f(%rdi), %esi
movl %esi, %eax
shll $0xc, %eax
orl %r8d, %eax
movq %rax, 0x20(%rdi)
testb $0x1, 0x8a(%rdi)
jne 0x7de6
movq %rax, %rdx
shlq $0x14, %rdx
jmp 0x7e0a
movzbl 0xd0(%rdi,%rdx), %edx
andl $0xf, %edx
shlq $0x24, %rdx
shlq $0x1c, %rcx
orq %rdx, %rcx
movzbl 0xd0(%rdi,%rsi), %edx
shll $0x14, %edx
orq %rcx, %rdx
orq %rax, %rdx
movq %rdx, 0x20(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::draw_pixel()
void TIA::draw_pixel()
{
  uint8_t color = write_regs[COLUBK];

  if ((write_regs[CTRLPF] & 4) == 0)
  {
    // Sprites have priority.
    do
    {
      if (player_0.is_pixel_on())  { color = write_regs[COLUP0]; break; }
      if (missile_0.is_pixel_on()) { color = write_regs[COLUP0]; break; }
      if (player_1.is_pixel_on())  { color = write_regs[COLUP1]; break; }
      if (missile_1.is_pixel_on()) { color = write_regs[COLUP1]; break; }
      if (playfield.is_pixel_on()) { color = write_regs[COLUPF]; break; }
      if (ball.is_pixel_on())      { color = write_regs[COLUPF]; break; }
    } while (false);
  }
    else
  {
    // Playfield has priority.
    do
    {
      if (playfield.is_pixel_on()) { color = write_regs[COLUPF]; break; }
      if (ball.is_pixel_on())      { color = write_regs[COLUPF]; break; }
      if (player_0.is_pixel_on())  { color = write_regs[COLUP0]; break; }
      if (missile_0.is_pixel_on()) { color = write_regs[COLUP0]; break; }
      if (player_1.is_pixel_on())  { color = write_regs[COLUP1]; break; }
      if (missile_1.is_pixel_on()) { color = write_regs[COLUP1]; break; }
    } while (false);
  }

  set_pixel(get_x(), get_y(), color);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movb 0x89(%rdi), %al
testb $0x4, 0x8a(%rdi)
jne 0x8008
cmpb $0x1, 0x34(%rbx)
je 0x802c
cmpb $0x1, 0x5b(%rbx)
je 0x802c
cmpb $0x1, 0x48(%rbx)
je 0x80ef
cmpb $0x1, 0x67(%rbx)
je 0x80ef
cmpb $0x1, 0x18(%rbx)
je 0x8014
cmpb $0x1, 0x73(%rbx)
je 0x8014
jmp 0x8032
cmpb $0x1, 0x18(%rbx)
je 0x8014
cmpb $0x1, 0x73(%rbx)
jne 0x801c
movb 0x88(%rbx), %al
jmp 0x8032
cmpb $0x1, 0x34(%rbx)
je 0x802c
cmpb $0x1, 0x5b(%rbx)
jne 0x80df
movb 0x86(%rbx), %al
movl 0x8(%rbx), %ecx
movl 0xc(%rbx), %edx
leal (%rcx,%rcx,2), %ecx
leal -0x50(,%rdx,2), %edx
movq (%rbx), %rsi
movl 0x8(%rsi), %ebp
imull %ebp, %edx
leal (%rdx,%rcx), %r14d
addl $0xffffff34, %r14d      # imm = 0xFFFFFF34
cmpl $0x8, 0x1e0(%rbx)
jne 0x80ac
shrb %al
movq 0x1d8(%rbx), %rcx
movslq %r14d, %rdx
movb %al, (%rcx,%rdx)
movq 0x1d8(%rbx), %rcx
movb %al, 0x1(%rcx,%rdx)
movq 0x1d8(%rbx), %rcx
movb %al, 0x2(%rcx,%rdx)
addl %r14d, %ebp
movq 0x1d8(%rbx), %rcx
movslq %ebp, %rdx
movb %al, (%rcx,%rdx)
movq 0x1d8(%rbx), %rcx
movb %al, 0x1(%rcx,%rdx)
movq 0x1d8(%rbx), %rcx
movb %al, 0x2(%rcx,%rdx)
jmp 0x80da
movzbl %al, %edi
callq 0x4ae4
movq 0x1d0(%rbx), %rcx
movslq %r14d, %rdx
movl %eax, (%rcx,%rdx,4)
movl %eax, 0x4(%rcx,%rdx,4)
movl %eax, 0x8(%rcx,%rdx,4)
addl %r14d, %ebp
movslq %ebp, %rdx
movl %eax, (%rcx,%rdx,4)
movl %eax, 0x4(%rcx,%rdx,4)
movl %eax, 0x8(%rcx,%rdx,4)
popq %rbx
popq %r14
popq %rbp
retq
cmpb $0x1, 0x48(%rbx)
je 0x80ef
cmpb $0x1, 0x67(%rbx)
jne 0x8032
movb 0x87(%rbx), %al
jmp 0x8032
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::clock(int)
void TIA::clock(int ticks)
{
  // Every CPU cycle is 3 pixels.
  ticks = ticks * 3;

  while (ticks > 0)
  {
    clock();
    ticks--;
  }

  // For some reason (according to some forum) the TIA delays setting the
  // X position for player sprites by 5 TIA clocks and ball / missile by 4.
  if (player_0.need_set_position())  { player_0.set_position(pos_x + 5); }
  if (player_1.need_set_position())  { player_1.set_position(pos_x + 5); }
  if (missile_0.need_set_position()) { missile_0.set_position(pos_x + 4); }
  if (missile_1.need_set_position()) { missile_1.set_position(pos_x + 4); }
  if (ball.need_set_position())      { ball.set_position(pos_x + 4); }

  if (hsync_latch)
  {
    write_regs[WSYNC] = 1;
    hsync_latch = false;
  }
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
testl %esi, %esi
jle 0x81fa
leal (%rsi,%rsi,2), %ebp
incl %ebp
movq %rbx, %rdi
callq 0x7e12
decl %ebp
cmpl $0x1, %ebp
jg 0x81eb
cmpb $0x1, 0x31(%rbx)
jne 0x820d
movl 0x8(%rbx), %eax
addl $0x5, %eax
movl %eax, 0x3c(%rbx)
movb $0x0, 0x31(%rbx)
cmpb $0x1, 0x45(%rbx)
jne 0x8220
movl 0x8(%rbx), %eax
addl $0x5, %eax
movl %eax, 0x50(%rbx)
movb $0x0, 0x45(%rbx)
cmpb $0x1, 0x59(%rbx)
jne 0x8233
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x5c(%rbx)
movb $0x0, 0x59(%rbx)
cmpb $0x1, 0x65(%rbx)
jne 0x8246
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x68(%rbx)
movb $0x0, 0x65(%rbx)
cmpb $0x1, 0x71(%rbx)
jne 0x8259
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x74(%rbx)
movb $0x0, 0x71(%rbx)
cmpb $0x1, 0x10(%rbx)
jne 0x826a
movb $0x1, 0x82(%rbx)
movb $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::dump()
void TIA::dump()
{
  printf("TIA: pos_x=%d pos_y=%d  wait_for_hsync=%s\n",
    pos_x, pos_y, wait_for_hsync() ? "on" : "off");

  printf("playfield: ");
  for (int n = 0; n < 40; n++)
  {
    printf("%c", (playfield.data & (1ULL << n)) != 0 ? '*' : '.');
  }
  printf("\n");

  printf("player_0: ");
  for (int n = 0; n < 8; n++)
  {
    printf("%c", (player_0.data & (1 << n)) != 0 ? '*' : '.');
  }
  printf(" x=%d (move=%d)\n",
    player_0.start_pos,
    player_0.move);

  printf("player_1: ");
  for (int n = 0; n < 8; n++)
  {
    printf("%c", (player_1.data & (1 << n)) != 0 ? '*' : '.');
  }
  printf(" x=%d (move=%d)\n",
    player_1.start_pos,
    player_1.move);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %esi
movl 0xc(%rdi), %edx
cmpb $0x0, 0x82(%rdi)
leaq 0x28d5(%rip), %rax      # 0xab62
leaq 0x28cb(%rip), %rcx      # 0xab5f
cmoveq %rax, %rcx
leaq 0x2895(%rip), %rdi      # 0xab34
xorl %r14d, %r14d
xorl %eax, %eax
callq 0x4050
leaq 0x28b6(%rip), %rdi      # 0xab66
xorl %eax, %eax
callq 0x4050
movq 0x20(%rbx), %rax
xorl %ecx, %ecx
btq %r14, %rax
setae %cl
leal 0x2a(,%rcx,4), %edi
callq 0x42a0
incq %r14
cmpq $0x28, %r14
jne 0x82b7
movl $0xa, %edi
callq 0x42a0
leaq 0x2888(%rip), %rdi      # 0xab72
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4050
movzbl 0x30(%rbx), %eax
xorl %ecx, %ecx
btl %ebp, %eax
setae %cl
leal 0x2a(,%rcx,4), %edi
callq 0x42a0
incl %ebp
cmpl $0x8, %ebp
jne 0x82f3
movl 0x3c(%rbx), %esi
movl 0x40(%rbx), %edx
leaq 0x285e(%rip), %rdi      # 0xab7d
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x4050
leaq 0x285f(%rip), %rdi      # 0xab8e
xorl %eax, %eax
callq 0x4050
movzbl 0x44(%rbx), %eax
xorl %ecx, %ecx
btl %ebp, %eax
setae %cl
leal 0x2a(,%rcx,4), %edi
callq 0x42a0
incl %ebp
cmpl $0x8, %ebp
jne 0x8336
movl 0x50(%rbx), %esi
movl 0x54(%rbx), %edx
leaq 0x281b(%rip), %rdi      # 0xab7d
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
jmp 0x4050
nopl (%rax)