LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::Close()
void CODFile::Close()
{
    if (HeadSeg) delete HeadSeg;
    if (CodeSeg) delete [] CodeSeg;
    if (DataSeg) delete [] DataSeg;
    if (FootSeg) delete [] FootSeg;

    HeadSeg = NULL;
    CodeSeg = DataSeg = FootSeg = NULL;
    Resources.clear();

    isOpen = false;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x2c4d
pushq $0x2c
popq %rsi
callq 0x21b0
movq 0x30(%rbx), %rdi
testq %rdi, %rdi
je 0x2c5b
callq 0x2220
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x2c69
callq 0x2220
leaq 0x28(%rbx), %r14
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x2c7b
callq 0x2220
leaq 0x50(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r14)
movups %xmm0, (%r14)
callq 0x361e
movb $0x0, 0x48(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::FindResource(CODRESType)
CODResource *CODFile::FindResource(CODRESType type)
{
    if (!isOpen) throw "Load file first";

    list<CODResource>::iterator it;

    for(it=Resources.begin(); it!=Resources.end(); it++)
    {
        if (type == it->getType()) return &*it;
    }

    // can't find
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
cmpb $0x0, 0x48(%rdi)
je 0x31ec
movl %esi, %ebx
movq %rdi, %r14
addq $0x50, %r14
movq %r14, %r12
movq (%r12), %r12
cmpq %r14, %r12
je 0x31dd
leaq 0x10(%r12), %r15
movq %r15, %rdi
callq 0x3940
cmpl %ebx, %eax
jne 0x31c1
jmp 0x31e0
xorl %r15d, %r15d
movq %r15, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xfb9(%rip), %rcx       # 0x41b4
movq %rcx, (%rax)
movq 0x2dc3(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::getVersion[abi:cxx11]()
string CODFile::getVersion()
{
    if (!isOpen) throw "Load file first";

    // data segment header
    TDATASEGHEADER *dh = (TDATASEGHEADER *)DataSeg;

    // sanity check - classes and modules list
    u16 tmp = dh->num_classes + 2*dh->num_modules;
    tmp *= sizeof(u16);
    tmp += sizeof(TDATASEGHEADER);
    if (tmp > dh->exported_string_offset) throw "Incorrect file format";

    // there is no modules on the list
    if (dh->num_modules == 0) throw "No version string in module";

    // module version ptr array
    u16 *modv = (u16 *)(DataSeg + sizeof(TDATASEGHEADER) +
                        sizeof(u16)*dh->num_classes +
                        sizeof(u16)*dh->num_modules);

    // check if ptr are in data section
    if (*modv >= HeadSeg->data_size)
            throw "Incorrect file format";

    return &DataSeg[ *modv ];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpb $0x0, 0x48(%rsi)
je 0x32d9
movq %rsi, %rax
movq %rdi, %rbx
movq 0x38(%rsi), %rsi
movzbl 0x5(%rsi), %ecx
movzbl 0x4(%rsi), %edx
leal (,%rdx,4), %edi
leal (%rdi,%rcx,2), %edi
addl $0x34, %edi
movzwl 0x6(%rsi), %r8d
cmpl %r8d, %edi
ja 0x32c8
testq %rdx, %rdx
je 0x32ea
leaq (%rsi,%rcx,2), %rcx
movzwl 0x34(%rcx,%rdx,2), %ecx
movq 0x28(%rax), %rax
cmpw 0x28(%rax), %cx
jae 0x32c8
addq %rcx, %rsi
leaq -0x9(%rbp), %rdx
movq %rbx, %rdi
callq 0x3640
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xec7(%rip), %rcx       # 0x419e
jmp 0x32f9
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xecc(%rip), %rcx       # 0x41b4
jmp 0x32f9
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xed3(%rip), %rcx       # 0x41cc
movq %rcx, (%rax)
movq 0x2cc5(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/sc0ty[P]CODExtract/src/codfile/codfile.cpp
// Function: CODFile::getAppName[abi:cxx11]()
string CODFile::getAppName()
{
    if (!isOpen) throw "Load file first";

    // find resource with name
    CODResource *r = FindResource(CODRESTAppName);

    // can't find
    if (r == NULL) throw "No AppName 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 0x3392
movq %rdi, %rbx
pushq $0x2
popq %rax
movq %rsi, %rdi
movl %eax, %esi
callq 0x31a4
testq %rax, %rax
je 0x33a3
movq %rax, %r12
pushq $0x20
popq %rdi
callq 0x21a0
movq %rax, %r14
movq %r12, %rdi
callq 0x394a
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x395e
movzwl %ax, %eax
movq %r14, %rcx
addq $0x10, %rcx
movq %rcx, (%r14)
leaq (%r15,%rax), %rdx
addq $0x2, %rdx
addq $0x2, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x36b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xe13(%rip), %rcx       # 0x41b4
jmp 0x33b2
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xe36(%rip), %rcx       # 0x41e8
movq %rcx, (%rax)
movq 0x2c0c(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
jmp 0x33c8
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x3462
movq %rdi, %rbx
pushq $0x3
popq %rax
movq %rsi, %rdi
movl %eax, %esi
callq 0x31a4
testq %rax, %rax
je 0x3473
movq %rax, %r12
pushq $0x20
popq %rdi
callq 0x21a0
movq %rax, %r14
movq %r12, %rdi
callq 0x394a
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x395e
movzwl %ax, %eax
movq %r14, %rcx
addq $0x10, %rcx
movq %rcx, (%r14)
leaq (%r15,%rax), %rdx
addq $0x2, %rdx
addq $0x2, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x36b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xd43(%rip), %rcx       # 0x41b4
jmp 0x3482
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xd7e(%rip), %rcx       # 0x4200
movq %rcx, (%rax)
movq 0x2b3c(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
jmp 0x3498
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x3532
movq %rdi, %rbx
pushq $0x4
popq %rax
movq %rsi, %rdi
movl %eax, %esi
callq 0x31a4
testq %rax, %rax
je 0x3543
movq %rax, %r12
pushq $0x20
popq %rdi
callq 0x21a0
movq %rax, %r14
movq %r12, %rdi
callq 0x394a
movq %rax, %r15
movq %r12, %rdi
xorl %esi, %esi
callq 0x395e
movzwl %ax, %eax
movq %r14, %rcx
addq $0x10, %rcx
movq %rcx, (%r14)
leaq (%r15,%rax), %rdx
addq $0x2, %rdx
addq $0x2, %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x36b0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2260
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xc73(%rip), %rcx       # 0x41b4
jmp 0x3552
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xcca(%rip), %rcx       # 0x421c
movq %rcx, (%rax)
movq 0x2a6c(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
jmp 0x3568
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
callq 0x21b0
movq %rbx, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x35c1
movq %rsi, %rbx
pushq $0x5
popq %rsi
callq 0x31a4
testq %rax, %rax
je 0x35ba
movq %rax, %r14
pushq $0x2
popq %rsi
movq %rax, %rdi
callq 0x395e
movw %ax, (%rbx)
movq %r14, %rdi
callq 0x394a
addq $0x4, %rax
jmp 0x35bc
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2100
leaq 0xbe4(%rip), %rcx       # 0x41b4
movq %rcx, (%rax)
movq 0x29ee(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O2/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
movq %rdi, %rbx
movzwl (%rsi), %r14d
leaq (%rdx,%r14), %rdi
movq %rdi, (%rbx)
movzwl 0x2(%rsi), %r12d
movw %r12w, 0x8(%rbx)
movzwl 0x4(%rsi), %r13d
addq %r13, %rdx
movq %rdx, 0x10(%rbx)
andl $0x0, 0x18(%rbx)
movq %rdi, -0x30(%rbp)
callq 0x20c0
addq %rax, %r14
movl %r15d, %ecx
cmpq %rcx, %r14
jae 0x391c
addl %r12d, %r13d
movzwl %r15w, %ecx
cmpl %ecx, %r13d
jae 0x391c
cmpq $0x4, %rax
je 0x38ef
cmpq $0x7, %rax
movq -0x30(%rbp), %r14
jne 0x38fb
leaq 0x9d4(%rip), %rdi       # 0x4284
pushq $0x7
popq %rdx
movq %r14, %rsi
callq 0x21c0
testl %eax, %eax
je 0x3910
leaq 0x9c5(%rip), %rdi       # 0x428b
pushq $0x7
popq %rdx
movq %r14, %rsi
callq 0x21c0
testl %eax, %eax
je 0x3918
leaq 0x9ba(%rip), %rdi       # 0x4296
pushq $0x7
popq %rdx
movq %r14, %rsi
callq 0x21c0
testl %eax, %eax
jne 0x38fb
pushq $0x5
jmp 0x38fd
movq -0x30(%rbp), %rax
cmpl $0x19c9765f, (%rax)     # imm = 0x19C9765F
je 0x3914
pushq $0x1
popq %rax
movl %eax, 0x18(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x2
jmp 0x38fd
pushq $0x4
jmp 0x38fd
pushq $0x3
jmp 0x38fd
pushq $0x8
popq %rdi
callq 0x2100
leaq 0x873(%rip), %rcx       # 0x419e
movq %rcx, (%rax)
movq 0x2693(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x3980
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
pushq $0x8
popq %rdi
callq 0x2100
leaq 0x8d3(%rip), %rcx       # 0x4266
movq %rcx, (%rax)
movq 0x262b(%rip), %rsi      # 0x5fc8
movq %rax, %rdi
xorl %edx, %edx
callq 0x22e0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x42b0
movq %rax, %r14
movq %rax, 0x10(%rbx)
andq $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 0x4130
movl %ebp, (%r14)
movw %r15w, 0x4(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/mikeakohn[P]cloudtari/build/../src/GifCompressor.cxx
// Function: GifCompressor::compute_bits_per_pixel(int)
int GifCompressor::compute_bits_per_pixel(int max_colors)
{
  uint8_t counts[16] =
  {
    0, 1, 2, 2, 3, 3, 3, 3,
    4, 4, 4, 4, 4, 4, 4, 4,
  };

  max_colors -= 1;

  int upper = counts[max_colors >> 4];
  int lower = counts[max_colors & 0xf];

  if (upper != 0) { return upper + 4; }
  if (lower == 0) { lower = 1; }

  return lower;
}

// Assembly:
decl %esi
cmpl $0x10, %esi
jae 0x5145
movl %esi, %eax
leaq 0x5318(%rip), %rcx      # 0xa450
movzbl (%rax,%rcx), %ecx
testl %esi, %esi
pushq $0x1
popq %rax
cmovnel %ecx, %eax
retq
sarl $0x4, %esi
movslq %esi, %rax
leaq 0x52fe(%rip), %rcx      # 0xa450
movzbl (%rax,%rcx), %eax
addl $0x4, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
movq %rdi, %rbx
andq $0x0, 0xc(%rdi)
andl $0x0, 0x14(%rdi)
movq (%rdi), %rdi
movl $0xfffc, %esi           # imm = 0xFFFC
callq 0x6252
movw %ax, 0x18(%rbx)
movw $0xff, 0x1a(%rbx)
andq $0x0, 0x1c(%rbx)
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x56a1(%rip), %rdi      # 0xa86c
xorl %eax, %eax
callq 0x4050
leaq 0x574a(%rip), %rdi      # 0xa923
callq 0x4340
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 0x5671(%rip), %rdi      # 0xa8a6
xorl %eax, %eax
pushq %r10
pushq %r14
pushq %r11
callq 0x4050
addq $0x20, %rsp
movl 0x20(%rbx), %esi
leaq 0x5670(%rip), %rdi      # 0xa8c0
xorl %eax, %eax
callq 0x4050
movl 0x1c(%rbx), %esi
leaq 0x5677(%rip), %rdi      # 0xa8d8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4050
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %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 0x6b14
movq (%r14), %rdi
addb 0x10(%r14), %al
movzbl %al, %esi
callq 0x6252
movzwl %ax, %esi
movl %esi, (%rbx)
movq (%r14), %rdi
callq 0x6b14
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
callq 0x6252
movzwl %ax, %esi
movl %esi, (%rbx)
addw $0x2, 0x18(%r14)
movq (%r14), %rdi
callq 0x6b14
movzbl %al, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rdi
movzwl 0x18(%r15), %esi
leal 0x1(%rsi), %eax
movw %ax, 0x18(%r15)
callq 0x6b14
movzbl %al, %esi
movq (%r15), %rdi
callq 0x6252
movzwl %ax, %eax
movl %eax, (%rbx)
addl 0x14(%r15), %eax
movzwl %ax, %esi
movl %esi, (%r14)
movq (%r15), %rdi
callq 0x6b14
movzbl %al, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rdi
movzwl 0x18(%r15), %esi
callq 0x6252
movzwl %ax, %esi
movl %esi, (%rbx)
addl 0x14(%r15), %esi
movl %esi, (%r14)
addw $0x2, 0x18(%r15)
movq (%r15), %rdi
callq 0x6b14
movzbl %al, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::read_absolute_x(int&, int&)
int read_absolute_x(int &address, int &address_before)
  {
    int m = memory_bus->read16(pc);
    address_before = m;
    m += reg_x;
    address = m;
    pc += 2;
    return memory_bus->read(m);
  }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rdi
movzwl 0x18(%r15), %esi
callq 0x6252
movzwl %ax, %esi
movl %esi, (%rbx)
addl 0x10(%r15), %esi
movl %esi, (%r14)
addw $0x2, 0x18(%r15)
movq (%r15), %rdi
callq 0x6b14
movzbl %al, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
movzbl 0x29(%rdi), %ebp
andl $0x1, %ebp
addl %edx, %edx
leaq 0x4(%rsp), %r15
movl %edx, (%r15)
movq %r15, %rsi
callq 0x6372
orl (%r15), %ebp
movl %ebp, (%r15)
sete %al
movb 0x29(%r14), %cl
addb %al, %al
andb $-0x3, %cl
orb %al, %cl
movb %cl, 0x29(%r14)
movq (%r14), %rdi
movzbl %bpl, %edx
movl %ebx, %esi
callq 0x6b90
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
testw $0x1fe, %dx             # 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 0x6b90
nop
// File: /workspace/github_cpp_makefile_star2_O2/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), %r8d
testb $0x8, %r8b
jne 0x6660
movl %r8d, %eax
andl $0x1, %eax
addl %esi, %eax
addl 0xc(%rdi), %eax
xorl %ecx, %ecx
cmpl $0x100, %eax            # imm = 0x100
setge %cl
andb $0x34, %r8b
orb %cl, %r8b
movl %eax, %edx
andl $0xff, %edx
movl %edx, 0xc(%rdi)
sete %dl
addb %dl, %dl
orb %r8b, %dl
movl %eax, %esi
andb $-0x80, %sil
orb %dl, %sil
shrl $0x7, %eax
xorl %ecx, %eax
shlb $0x6, %al
andb $0x40, %al
orb %sil, %al
jmp 0x66bf
pushq %rbx
movl %esi, %eax
andl $0xf, %eax
sarl $0x4, %esi
movl 0xc(%rdi), %ecx
movl %ecx, %edx
andl $0xf, %edx
sarl $0x4, %ecx
movl %r8d, %ebx
andl $0x1, %ebx
addl %eax, %ebx
addl %edx, %ebx
cmpl $0xb, %ebx
jb 0x6692
movzbl %bl, %eax
movb $0xa, %dl
divb %dl
movzbl %ah, %ebx
movzbl %al, %eax
addl %eax, %ecx
addl %esi, %ecx
cmpl $0xa, %ecx
setge %al
andb $-0x4, %r8b
orb %al, %r8b
movl $0xa, %esi
movl %ecx, %eax
cltd
idivl %esi
shll $0x4, %edx
movzbl %dl, %eax
orl %ebx, %eax
movl %eax, 0xc(%rdi)
sete %al
addb %al, %al
orb %r8b, %al
popq %rbx
movb %al, 0x29(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
callq 0x6252
movzwl %ax, %esi
movl $0x5, (%rbx)
addl 0x14(%r14), %esi
addw $0x2, 0x18(%r14)
movq (%r14), %rdi
movzbl %bpl, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x6b90
// File: /workspace/github_cpp_makefile_star2_O2/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::store_absolute_x(int, int&)
void store_absolute_x(int data, int &cycles)
  {
    int a = memory_bus->read16(pc);
    cycles = 5;
    int address = a + reg_x;
    //if (!same_page(address, a)) { cycles++; }
    pc += 2;
    memory_bus->write(address, data);
  }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdx, %rbx
movl %esi, %ebp
movq %rdi, %r14
movq (%rdi), %rdi
movzwl 0x18(%r14), %esi
callq 0x6252
movzwl %ax, %esi
movl $0x5, (%rbx)
addl 0x10(%r14), %esi
addw $0x2, 0x18(%r14)
movq (%r14), %rdi
movzbl %bpl, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x6b90
// File: /workspace/github_cpp_makefile_star2_O2/mikeakohn[P]cloudtari/build/../src/M6502.h
// Function: M6502::run_compare(int, int)
void run_compare(int reg, int data)
  {
    status.c = reg >= data;
    reg = reg - data;

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

// Assembly:
movb 0x29(%rdi), %al
andb $0x7c, %al
subl %edx, %esi
setge %cl
sete %dl
addb %dl, %dl
orb %cl, %dl
andb $-0x80, %sil
orb %dl, %sil
orb %al, %sil
movb %sil, 0x29(%rdi)
retq
// File: /workspace/github_cpp_makefile_star2_O2/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:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebx
movq %rdi, %r14
decl %edx
movzbl %dl, %eax
leaq 0xc(%rsp), %r15
movl %eax, (%r15)
movq %r15, %rsi
callq 0x676c
movq (%r14), %rdi
movzbl (%r15), %edx
movl %ebx, %esi
callq 0x6b90
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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), %ecx
testb $0x8, %cl
jne 0x69be
movl %ecx, %eax
andl $0x1, %eax
shll $0x8, %eax
orl 0xc(%rdi), %eax
subl %esi, %eax
xorl %edx, %edx
cmpl $0x100, %eax            # imm = 0x100
setge %dl
andb $0x34, %cl
orb %dl, %cl
movl %eax, %esi
andl $0xff, %esi
movl %esi, 0xc(%rdi)
sete %sil
addb %sil, %sil
orb %cl, %sil
movl %eax, %ecx
andb $-0x80, %cl
orb %sil, %cl
shrl $0x7, %eax
xorl %edx, %eax
shlb $0x6, %al
andb $0x40, %al
orb %cl, %al
jmp 0x6a17
movl %esi, %edx
andl $0xf, %edx
sarl $0x4, %esi
movl 0xc(%rdi), %r8d
movl %r8d, %eax
andl $0xf, %eax
sarl $0x4, %r8d
subl %esi, %r8d
movl %ecx, %esi
notl %esi
andl $0x1, %esi
addl %edx, %esi
subl %esi, %eax
movl %eax, %esi
shrl $0x1f, %esi
addl %eax, %esi
sarl $0x1f, %eax
addl %r8d, %eax
cmpl $0xa, %eax
setge %dl
andb $-0x4, %cl
orb %dl, %cl
pushq $0xa
popq %r8
cltd
idivl %r8d
shll $0x4, %edx
orl %esi, %edx
andl $0xff, %edx
movl %edx, 0xc(%rdi)
sete %al
addb %al, %al
orb %cl, %al
movb %al, 0x29(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x6b3a
cmpl $0x3f, %ebx
jg 0x6b5d
movq 0x10(%r14), %rdi
andl $0x3f, %ebx
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x742e
cmpl $0x1ff8, %ebx           # imm = 0x1FF8
je 0x6b6c
cmpl $0x1ff9, %ebx           # imm = 0x1FF9
jne 0x6b7c
movq (%r14), %rdi
pushq $0x1
popq %rsi
callq 0x729e
testb %al, %al
je 0x6b7c
xorl %ebp, %ebp
jmp 0x6b89
movq 0x8(%r14), %rdi
movl %ebx, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x70ae
movq (%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x729e
testb %al, %al
jne 0x6b89
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_O2/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 %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
andl $0xfff0, %ebp           # imm = 0xFFF0
leaq 0x3d63(%rip), %r13      # 0xa93a
pushq $0xa
popq %r15
cmpl %ebx, %ebp
jg 0x6c2f
movl %ebp, %r12d
andl $0xf, %r12d
jne 0x6bf8
leaq 0x3d45(%rip), %rdi      # 0xa934
movl %ebp, %esi
xorl %eax, %eax
callq 0x4050
testb $0x7, %bpl
jne 0x6c06
pushq $0x20
popq %rdi
callq 0x42e0
movq %r14, %rdi
movl %ebp, %esi
callq 0x6b14
movzbl %al, %esi
movq %r13, %rdi
xorl %eax, %eax
callq 0x4050
cmpl $0xf, %r12d
jne 0x6c2b
movl %r15d, %edi
callq 0x42e0
incl %ebp
jmp 0x6bdb
pushq $0xa
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42e0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x6c9d
callq 0x4390
orl $-0x1, 0x4(%rbx)
movl (%rbx), %edi
cmpl $-0x1, %edi
je 0x6cac
callq 0x4390
orl $-0x1, (%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 $0x28, %rsp
movl %esi, %ebp
movq %rdi, %rbx
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x40a0
movl %eax, (%rbx)
testl %eax, %eax
js 0x6d0c
leaq 0x18(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
andl $0x0, 0x4(%rsi)
rolw $0x8, %bp
movw %bp, 0x2(%rsi)
pushq $0x10
popq %rdx
movl %eax, %edi
callq 0x4080
testl %eax, %eax
js 0x6d15
movl (%rbx), %edi
pushq $0x1
popq %rsi
callq 0x4230
testl %eax, %eax
je 0x6d2d
leaq 0x3c95(%rip), %rdi      # 0xa99f
jmp 0x6d1c
leaq 0x3cae(%rip), %rdi      # 0xa9c1
jmp 0x6d1c
leaq 0x3c92(%rip), %rdi      # 0xa9ae
callq 0x4340
pushq $-0x1
popq %rbx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
leaq 0x4(%rsp), %rdx
movl $0x10, (%rdx)
movl (%rbx), %edi
leaq 0x8(%rsp), %rsi
callq 0x40d0
movl %eax, 0x4(%rbx)
cmpl $-0x1, %eax
je 0x6d21
xorl %ebx, %ebx
pushq $0x4
popq %rsi
movl %eax, %edi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x4140
jmp 0x6d24
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movl %edx, %r14d
movq %rsi, (%rsp)
movq %rdi, %r15
xorl %ebx, %ebx
leaq 0x18(%rsp), %r12
leaq 0x8(%rsp), %r13
movl %r14d, %ebp
subl %ebx, %ebp
jle 0x6e21
xorl %eax, %eax
cmpq $0x10, %rax
je 0x6da7
andq $0x0, 0x18(%rsp,%rax,8)
incq %rax
jmp 0x6d96
movl 0x4(%r15), %edi
movl %edi, %eax
cltd
pushq $0x40
popq %rcx
idivl %ecx
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0x18(%rsp,%rdx,8)
movq $0xa, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
incl %edi
xorl %esi, %esi
movq %r12, %rdx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x41d0
cmpl $-0x1, %eax
jne 0x6df9
callq 0x4040
cmpl $0x4, (%rax)
je 0x6d89
jmp 0x6e35
testl %eax, %eax
je 0x6e1c
movl 0x4(%r15), %edi
movl %ebx, %esi
addq (%rsp), %rsi
movslq %ebp, %rdx
xorl %ecx, %ecx
callq 0x4120
testl %eax, %eax
js 0x6e46
addl %eax, %ebx
jmp 0x6d89
pushq $-0x3
popq %rax
movl %eax, %ebx
movl %ebx, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b04(%rip), %rdi      # 0xa940
callq 0x4180
pushq $-0x1
popq %rbx
jmp 0x6e21
pushq $-0x4
jmp 0x6e1e
// File: /workspace/github_cpp_makefile_star2_O2/mikeakohn[P]cloudtari/build/../src/Network.cxx
// Function: Network::net_recv(unsigned char*, int, bool)
int Network::net_recv(uint8_t *buffer, int length, bool wait_for_full_buffer)
{
  struct timeval tv;
  fd_set readset;
  int empty_count = 0;

  int bytes_received = 0;

  while (bytes_received < length)
  {
    FD_ZERO(&readset);
    FD_SET(client, &readset);

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

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

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

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

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

    if (!FD_ISSET(client, &readset)) { continue; }

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

    bytes_received += n;

    if (bytes_received == 0)
    {
      empty_count++;

      if (empty_count == 1) { continue; }
    }

    if (!wait_for_full_buffer) { break; }
  }

  return bytes_received;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movl %ecx, 0xc(%rsp)
movl %edx, %r12d
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
xorl %ecx, %ecx
pushq $0x40
popq %rbx
leaq 0x18(%rsp), %r13
xorl %r14d, %r14d
movl %ecx, 0x8(%rsp)
movl %r12d, %ebp
subl %r14d, %ebp
jle 0x6f5a
xorl %eax, %eax
cmpq $0x10, %rax
je 0x6e9a
andq $0x0, 0x28(%rsp,%rax,8)
incq %rax
jmp 0x6e89
movl 0x4(%r15), %edi
movl %edi, %eax
cltd
idivl %ebx
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0x28(%rsp,%rdx,8)
movq $0xa, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
incl %edi
leaq 0x28(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r13, %r8
callq 0x41d0
cmpl $-0x1, %eax
je 0x6efb
testl %eax, %eax
je 0x6f5f
movl 0x4(%r15), %edi
movl %edi, %eax
cltd
idivl %ebx
cltq
movq 0x28(%rsp,%rax,8), %rax
btq %rdx, %rax
jae 0x6e7b
jmp 0x6f0b
callq 0x4040
cmpl $0x4, (%rax)
je 0x6e7b
jmp 0x6f74
movl %r14d, %esi
addq 0x10(%rsp), %rsi
movslq %ebp, %rdx
xorl %ecx, %ecx
callq 0x40e0
movq %rax, %rcx
testl %ecx, %ecx
js 0x6f84
movl %r14d, %eax
addl %ecx, %eax
je 0x6f31
movl 0x8(%rsp), %edx
jmp 0x6f48
pushq $0x1
popq %rcx
movl $0x0, %r14d
movl 0x8(%rsp), %edx
testl %edx, %edx
je 0x6e77
incl %edx
movl %edx, %ecx
movl %eax, %r14d
cmpb $0x0, 0xc(%rsp)
jne 0x6e77
jmp 0x6f62
movl %r14d, %eax
jmp 0x6f62
pushq $-0x3
popq %rax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x39e5(%rip), %rdi      # 0xa960
callq 0x4180
pushq $-0x1
jmp 0x6f61
pushq $-0x4
jmp 0x6f61
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbp
pushq %rbx
subq $0x98, %rsp
movq %rdi, %rbx
xorl %eax, %eax
cmpq $0x10, %rax
je 0x6fa7
andq $0x0, 0x18(%rsp,%rax,8)
incq %rax
jmp 0x6f96
movl 0x4(%rbx), %edi
pushq $0x40
popq %rbp
movl %edi, %eax
cltd
idivl %ebp
movslq %eax, %rdx
shll $0x6, %eax
movl %edi, %ecx
subl %eax, %ecx
pushq $0x1
popq %rax
shlq %cl, %rax
orq %rax, 0x18(%rsp,%rdx,8)
incl %edi
xorps %xmm0, %xmm0
movq %rsp, %r8
movaps %xmm0, (%r8)
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x41d0
cmpl $-0x1, %eax
je 0x6ffc
movl 0x4(%rbx), %eax
cltd
idivl %ebp
cltq
movq 0x18(%rsp,%rax,8), %rax
btq %rdx, %rax
setb %al
jmp 0x7008
callq 0x4040
cmpl $0x4, (%rax)
jne 0x7012
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %rbp
retq
leaq 0x3967(%rip), %rdi      # 0xa980
callq 0x4180
movq %rbx, %rdi
callq 0x6c88
jmp 0x7006
// File: /workspace/github_cpp_makefile_star2_O2/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:
movl 0x34(%rdi), %eax
decl %eax
testl %esi, %esi
jle 0x7157
movl %eax, 0x34(%rdi)
subl $0x1, %eax
jae 0x7153
andl $0x0, 0x30(%rdi)
decl %esi
jmp 0x7143
movb 0x30(%rdi), %cl
incl %eax
sarl %cl, %eax
movb %al, 0x3c(%rdi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x4130
movq %r15, %rdi
movq %r14, %rsi
callq 0x41a0
movq 0x30(%r14), %r14
cmpl $0x800, %r14d           # imm = 0x800
je 0x71d0
cmpl $0x1000, %r14d          # imm = 0x1000
je 0x71d0
cmpl $0x2000, %r14d          # imm = 0x2000
jne 0x7252
leaq 0x30ec(%rip), %rsi      # 0xa2c3
movq %r15, %rdi
callq 0x4250
testq %rax, %rax
je 0x723f
movq %rax, %r12
leaq 0x1000(%rbx), %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
movq %r14, %rdx
movq %rax, %rcx
callq 0x4330
movl %eax, 0x3000(%rbx)
movq %r12, %rdi
callq 0x41e0
movslq 0x3000(%rbx), %rsi
cmpq %rsi, %r14
jne 0x7267
cmpl $0x800, %esi            # imm = 0x800
jne 0x727d
movl $0x800, %edx            # imm = 0x800
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4170
addq $0x800, %rbx            # imm = 0x800
movl $0x800, %edx            # imm = 0x800
jmp 0x7282
leaq 0x37f8(%rip), %rdi      # 0xaa3e
movq %r15, %rsi
xorl %eax, %eax
callq 0x4050
jmp 0x7263
leaq 0x37b7(%rip), %rdi      # 0xaa10
movl %r14d, %esi
xorl %eax, %eax
callq 0x4050
pushq $-0x1
jmp 0x727a
leaq 0x37ee(%rip), %rdi      # 0xaa5c
movl %r14d, %edx
xorl %eax, %eax
callq 0x4050
pushq $-0x2
popq %rax
jmp 0x728f
movl $0x1000, %edx           # imm = 0x1000
movq %rbx, %rdi
movq %r15, %rsi
callq 0x4170
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O2/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
testb $0x1, 0x8a(%rdi)
jne 0x77c2
movq %rax, %rdx
shlq $0x14, %rdx
jmp 0x77e6
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_O2/mikeakohn[P]cloudtari/build/../src/TIA.cxx
// Function: TIA::clock()
void TIA::clock()
{
  // The main playfield area starts after 68 clocks.
  if (pos_x >= 68 && pos_y >= 40 && pos_y < 232)
  {
    // The point to the first bit to be displayed from PF0, PF1, PF2.
    if (pos_x == 68) { playfield.reset(); }

    playfield.compute_pixel(pos_x);
    player_0.compute_pixel(pos_x);
    player_1.compute_pixel(pos_x);
    missile_0.compute_pixel(pos_x);
    missile_1.compute_pixel(pos_x);
    ball.compute_pixel(pos_x);

    draw_pixel();
    compute_collisions();
  }

  pos_x++;

  if (pos_x == 68 + 160)
  {
    if (player_0.need_update) { build_player_0(); }
    if (player_1.need_update) { build_player_1(); }

    if (!hsync_latch) { write_regs[WSYNC] = 0; }

#if 0
    if (pos_y >= 40 && pos_y <= 232)
    {
      television->refresh();
    }
#endif

    if (pos_y < 40 && (pos_y & 0xf) == 0) { check_events = true; }

    pos_x = 0;
    pos_y++;

    // This really shouldn't be needed.. but..
    if (pos_y > 262) { pos_y = 0; }
  }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x8(%rdi), %esi
cmpl $0x44, %esi
jl 0x7875
movl 0xc(%rbx), %eax
addl $-0x28, %eax
cmpl $0xbf, %eax
ja 0x7875
cmpl $0x44, %esi
jne 0x7814
movq $0x1, 0x28(%rbx)
leal -0x44(%rsi), %eax
movq 0x20(%rbx), %rcx
shrb $0x2, %al
movzbl %al, %eax
btq %rax, %rcx
setb 0x18(%rbx)
leaq 0x30(%rbx), %rdi
callq 0x7bd0
leaq 0x44(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x7bd0
leaq 0x58(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x7bf0
leaq 0x64(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x7bf0
leaq 0x70(%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x7bf0
movq %rbx, %rdi
callq 0x78da
movq %rbx, %rdi
callq 0x795e
movl 0x8(%rbx), %esi
incl %esi
movl %esi, 0x8(%rbx)
cmpl $0xe4, %esi
jne 0x78d8
cmpb $0x1, 0x33(%rbx)
jne 0x7890
movq %rbx, %rdi
callq 0x7726
cmpb $0x1, 0x47(%rbx)
jne 0x789e
movq %rbx, %rdi
callq 0x7752
cmpb $0x0, 0x10(%rbx)
jne 0x78ab
movb $0x0, 0x82(%rbx)
movl 0xc(%rbx), %eax
cmpl $0x28, %eax
setge %cl
testb $0xf, %al
setne %dl
orb %cl, %dl
jne 0x78c4
movb $0x1, 0x1e4(%rbx)
andl $0x0, 0x8(%rbx)
leal 0x1(%rax), %ecx
xorl %edx, %edx
cmpl $0x106, %eax            # imm = 0x106
cmovll %ecx, %edx
movl %edx, 0xc(%rbx)
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O2/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:
movb 0x89(%rdi), %al
testb $0x4, 0x8a(%rdi)
jne 0x790f
cmpb $0x1, 0x34(%rdi)
je 0x792f
cmpb $0x1, 0x5b(%rdi)
je 0x792f
cmpb $0x1, 0x48(%rdi)
je 0x7955
cmpb $0x1, 0x67(%rdi)
je 0x7955
cmpb $0x1, 0x18(%rdi)
je 0x791b
cmpb $0x1, 0x73(%rdi)
je 0x791b
jmp 0x7935
cmpb $0x1, 0x18(%rdi)
je 0x791b
cmpb $0x1, 0x73(%rdi)
jne 0x7923
movb 0x88(%rdi), %al
jmp 0x7935
cmpb $0x1, 0x34(%rdi)
je 0x792f
cmpb $0x1, 0x5b(%rdi)
jne 0x7949
movb 0x86(%rdi), %al
movl 0x8(%rdi), %esi
movl 0xc(%rdi), %edx
addl $-0x44, %esi
addl $-0x28, %edx
movzbl %al, %ecx
jmp 0x7c12
cmpb $0x1, 0x48(%rdi)
je 0x7955
cmpb $0x1, 0x67(%rdi)
jne 0x7935
movb 0x87(%rdi), %al
jmp 0x7935
nop
// File: /workspace/github_cpp_makefile_star2_O2/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
leal (%rsi,%rsi,2), %ebp
testl %ebp, %ebp
jle 0x7a59
movq %rbx, %rdi
callq 0x77ee
decl %ebp
jmp 0x7a49
cmpb $0x1, 0x31(%rbx)
jne 0x7a6c
movl 0x8(%rbx), %eax
addl $0x5, %eax
movl %eax, 0x3c(%rbx)
movb $0x0, 0x31(%rbx)
cmpb $0x1, 0x45(%rbx)
jne 0x7a7f
movl 0x8(%rbx), %eax
addl $0x5, %eax
movl %eax, 0x50(%rbx)
movb $0x0, 0x45(%rbx)
cmpb $0x1, 0x59(%rbx)
jne 0x7a92
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x5c(%rbx)
movb $0x0, 0x59(%rbx)
cmpb $0x1, 0x65(%rbx)
jne 0x7aa5
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x68(%rbx)
movb $0x0, 0x65(%rbx)
cmpb $0x1, 0x71(%rbx)
jne 0x7ab8
movl 0x8(%rbx), %eax
addl $0x4, %eax
movl %eax, 0x74(%rbx)
movb $0x0, 0x71(%rbx)
cmpb $0x1, 0x10(%rbx)
jne 0x7ac9
movb $0x1, 0x82(%rbx)
movb $0x0, 0x10(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq