LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O1/smilingthax[P]libfontembed/cff.c
// Function: cff_load_file
CFF_FILE *cff_load_file(FILE *f) // {{{
{
#define BLOCKSIZE 1024
  char *buf=NULL;
  int pos=0,len=0;
  while (1) {
    if (pos>=len) {
      len+=BLOCKSIZE;
      char *tmp=realloc(buf,len);
      if (!tmp) {
        fprintf(stderr,"Bad alloc: %s\n", strerror(errno));
        free(buf);
        return NULL;
      }
      buf=tmp;
    }
    size_t res=fread(buf+pos,1,len-pos,f);
    if (res==0) {
      if (!feof(f)) {
        fprintf(stderr,"File read error: %s\n", strerror(errno));
        free(buf);
        return NULL;
      }
      break;
    }
    pos+=res;
  }
  return cff_load2(buf,pos,1);
#undef BLOCKSIZE
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdi, %rbx
xorl %r12d, %r12d
xorl %ebp, %ebp
xorl %r14d, %r14d
cmpl %ebp, %r12d
jl 0x71cc
addl $0x400, %ebp            # imm = 0x400
movslq %ebp, %rsi
movq %r14, %rdi
callq 0x41d0
movq %rax, %r15
testq %rax, %rax
je 0x720a
movq %rax, %r14
testq %r15, %r15
je 0x7243
movslq %r12d, %rdi
addq %r14, %rdi
movl %ebp, %eax
subl %r12d, %eax
movslq %eax, %rdx
movl $0x1, %esi
movq %rbx, %rcx
callq 0x4190
testq %rax, %rax
je 0x71f3
addl %eax, %r12d
xorl %ecx, %ecx
jmp 0x7204
movq %rbx, %rdi
callq 0x41b0
movl $0x3, %ecx
testl %eax, %eax
je 0x7217
testl %ecx, %ecx
je 0x71a6
jmp 0x7226
movq %r14, %rdi
callq 0x49d6
movq %r14, %rax
jmp 0x71c4
movq %r14, %rdi
callq 0x4a16
movl $0x1, %ecx
jmp 0x7204
cmpl $0x3, %ecx
jne 0x7243
movslq %r12d, %rsi
movq %r14, %rdi
movl $0x1, %edx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x6fab
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/smilingthax[P]libfontembed/cff.c
// Function: cff_load_filename
CFF_FILE *cff_load_filename(const char *filename) // {{{
{
  FILE *f=fopen(filename,"rb");
  if (!f) {
    fprintf(stderr,"Could not open \"%s\": %s\n", filename, strerror(errno));
    return NULL;
  }
  CFF_FILE *ret=cff_load_file(f);
  fclose(f);
  return ret;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0xf70(%rip), %rsi       # 0x81cc
callq 0x4120
testq %rax, %rax
je 0x7287
movq %rax, %r14
movq %rax, %rdi
callq 0x7193
movq %rax, %rbx
movq %r14, %rdi
callq 0x40f0
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
callq 0x4a56
xorl %eax, %eax
jmp 0x727f
// File: /workspace/github_c_makefile_star2_O1/smilingthax[P]libfontembed/cff_tables.c
// Function: cffop_get_by_value
const struct CFF_OPS *cffop_get_by_value(int value) // {{{
{
  if ( (value>=0)&&(value<sizeof(cff_ops1)/sizeof(*cff_ops1)) ) {
    return &cff_ops1[value];
  }
  value-=0x0c00;
  if ( (value>=0)&&(value<sizeof(cff_ops2)/sizeof(*cff_ops2)) ) {
    return &cff_ops2[value];
  }
  return NULL;
}

// Assembly:
cmpl $0x15, %edi
ja 0x74e0
movl %edi, %ecx
shlq $0x5, %rcx
leaq 0x5132(%rip), %rax      # 0xc610
jmp 0x74f8
addl $0xfffff400, %edi       # imm = 0xFFFFF400
cmpl $0x26, %edi
ja 0x74fc
movl %edi, %ecx
shlq $0x5, %rcx
leaq 0x53d8(%rip), %rax      # 0xc8d0
addq %rcx, %rax
retq
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/smilingthax[P]libfontembed/cff_tables.c
// Function: cff_find_stdstr
int cff_find_stdstr(const char *str) // {{{
{
  // assert(str);
  init_rev_stdstr();
  const char **key=&str;
  const char ***res=bsearch(&key,cff_rev_stdstr,sizeof(cff_rev_stdstr)/sizeof(*cff_rev_stdstr),sizeof(*cff_rev_stdstr),cff_pstrcmp);
  if (!res) {
    return -1;
  }
  return *res-cff_stdstr;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, (%rsp)
cmpq $0x0, 0x6982(%rip)      # 0xdf00
leaq 0x5d2b(%rip), %rbx      # 0xd2b0
jne 0x75c2
leaq 0x6972(%rip), %rax      # 0xdf00
xorl %ecx, %ecx
leaq (%rbx,%rcx), %rdx
movq %rdx, (%rcx,%rax)
addq $0x8, %rcx
cmpq $0xc38, %rcx            # imm = 0xC38
jne 0x7590
leaq 0x6954(%rip), %rdi      # 0xdf00
leaq -0x70(%rip), %rcx       # 0x7543
movl $0x187, %esi            # imm = 0x187
movl $0x8, %edx
callq 0x41e0
movq %rsp, %rax
leaq 0x8(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x692c(%rip), %rsi      # 0xdf00
leaq -0x98(%rip), %r8        # 0x7543
movl $0x187, %edx            # imm = 0x187
movl $0x8, %ecx
callq 0x4140
testq %rax, %rax
je 0x75fb
movq (%rax), %rax
subq %rbx, %rax
shrq $0x3, %rax
jmp 0x7600
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/mijallen[P]SimpleHTTPServer/lib/libyaml/tests/run-emitter.c
// Function: print_output
int print_output(char *name, unsigned char *buffer, size_t size, int count)
{
    FILE *file;
    char data[BUFFER_SIZE];
    size_t data_size = 1;
    size_t total_size = 0;
    if (count >= 0) {
        printf("FAILED (at the event #%d)\nSOURCE:\n", count+1);
    }
    file = fopen(name, "rb");
    assert(file);
    while (data_size > 0) {
        data_size = fread(data, 1, BUFFER_SIZE, file);
        assert(!ferror(file));
        if (!data_size) break;
        assert(fwrite(data, 1, data_size, stdout) == data_size);
        total_size += data_size;
        if (feof(file)) break;
    }
    fclose(file);
    printf("#### (length: %d)\n", total_size);
    printf("OUTPUT:\n%s#### (length: %d)\n", buffer, size);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10018, %rsp          # imm = 0x10018
movq %rdx, 0x8(%rsp)
movq %rsi, %r14
movq %rdi, %r15
testl %ecx, %ecx
js 0x16b9
incl %ecx
leaq 0x99a(%rip), %rdi       # 0x204a
movl %ecx, %esi
xorl %eax, %eax
callq 0x10f0
leaq 0x9ad(%rip), %rsi       # 0x206d
movq %r15, %rdi
callq 0x1200
testq %rax, %rax
je 0x17b4
movq %rax, %r12
xorl %r15d, %r15d
leaq 0x10(%rsp), %r13
movq 0x28fd(%rip), %rbx      # 0x3fe0
movl $0x1, %esi
movl $0x10000, %edx          # imm = 0x10000
movq %r13, %rdi
movq %r12, %rcx
callq 0x1090
movq %rax, %rbp
movq %r12, %rdi
callq 0x1080
testl %eax, %eax
jne 0x1776
testq %rbp, %rbp
je 0x1733
movq (%rbx), %rcx
movl $0x1, %esi
movq %r13, %rdi
movq %rbp, %rdx
callq 0x1230
cmpq %rbp, %rax
jne 0x1795
addq %rbp, %r15
movq %r12, %rdi
callq 0x1150
testl %eax, %eax
je 0x16e3
movq %r12, %rdi
callq 0x10c0
leaq 0x9c0(%rip), %rdi       # 0x2102
movq %r15, %rsi
xorl %eax, %eax
callq 0x10f0
leaq 0x9a5(%rip), %rdi       # 0x20f8
movq %r14, %rsi
movq 0x8(%rsp), %rdx
xorl %eax, %eax
callq 0x10f0
xorl %eax, %eax
addq $0x10018, %rsp          # imm = 0x10018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x93d(%rip), %rdi       # 0x20ba
leaq 0x8f1(%rip), %rsi       # 0x2075
leaq 0x8f8(%rip), %rcx       # 0x2083
movl $0xc9, %edx
callq 0x1110
leaq 0x92c(%rip), %rdi       # 0x20c8
leaq 0x8d2(%rip), %rsi       # 0x2075
leaq 0x8d9(%rip), %rcx       # 0x2083
movl $0xcb, %edx
callq 0x1110
leaq 0x8b5(%rip), %rdi       # 0x2070
leaq 0x8b3(%rip), %rsi       # 0x2075
leaq 0x8ba(%rip), %rcx       # 0x2083
movl $0xc6, %edx
callq 0x1110
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/sha256/main.c
// Function: perftest
static void
print_hardware(const char * str)
{

	/* Inform the user of the general topic... */
	printf("%s", str);

	/* ... and whether we're using hardware acceleration or not. */
#if defined(CPUSUPPORT_CONFIG_FILE)
#if defined(CPUSUPPORT_X86_SHANI) && defined(CPUSUPPORT_X86_SSSE3)
	if (cpusupport_x86_shani() && cpusupport_x86_ssse3())
		printf(" using hardware SHANI.\n");
	else
#endif
#if defined(CPUSUPPORT_X86_SSE2)
	if (cpusupport_x86_sse2())
		printf(" using hardware SSE2.\n");
	else
#endif
#if defined(CPUSUPPORT_ARM_SHA256)
	if (cpusupport_arm_sha256())
		printf(" using hardware ARM SHA256.\n");
	else
#endif
		printf(" using software SHA.\n");
#else
	printf(" with unknown hardware acceleration status.\n");
#endif /* CPUSUPPORT_CONFIG_FILE */
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
leaq 0x52f3(%rip), %rdi      # 0x6ba2
leaq 0x4754(%rip), %rsi      # 0x600a
xorl %eax, %eax
callq 0x10e0
leaq 0x78a8(%rip), %rbx      # 0x916c
cmpl $0x0, (%rbx)
je 0x1903
leaq 0x78ac(%rip), %r14      # 0x917c
leaq 0x4bfa(%rip), %rbx      # 0x64d1
cmpl $0x0, (%r14)
jne 0x1965
leaq 0x7898(%rip), %r15      # 0x9180
cmpl $0x0, (%r15)
jne 0x1910
callq 0x4144
movl %eax, (%r14)
movl $0x1, (%r15)
testl %eax, %eax
jne 0x1965
jmp 0x1910
leaq 0x7866(%rip), %r14      # 0x9170
cmpl $0x0, (%r14)
je 0x193a
leaq 0x785d(%rip), %r14      # 0x9174
leaq 0x4b9d(%rip), %rbx      # 0x64bb
cmpl $0x0, (%r14)
jne 0x1965
leaq 0x784d(%rip), %r15      # 0x9178
cmpl $0x0, (%r15)
je 0x1952
leaq 0x4b6e(%rip), %rbx      # 0x64a6
jmp 0x1965
callq 0x40f0
movl %eax, (%rbx)
movl $0x1, (%r14)
testl %eax, %eax
jne 0x18c9
jmp 0x1910
callq 0x411c
movl %eax, (%r14)
movl $0x1, (%r15)
testl %eax, %eax
je 0x1931
movq %rbx, %rdi
callq 0x1090
movq 0x765c(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
callq 0x1170
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
leaq 0x1b0(%rip), %rax       # 0x1b3b
movq %rax, (%rsp)
leaq 0x4b5a(%rip), %rsi      # 0x64f0
leaq 0x189(%rip), %r9        # 0x1b26
movl $0x1, %ebx
movl $0x5f5e100, %edi        # imm = 0x5F5E100
movl $0x3, %edx
movl $0x989680, %ecx         # imm = 0x989680
movl $0x1, %r8d
callq 0x4868
testl %eax, %eax
je 0x19db
leaq 0x4655(%rip), %rdi      # 0x601c
xorl %eax, %eax
callq 0x4df7
callq 0x1070
movl $0x0, (%rax)
jmp 0x19dd
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/sha256/main.c
// Function: selftest
static int
selftest(void)
{
	SHA256_CTX ctx;
	uint8_t hbuf[32];
	char hbuf_hex[65];
	size_t i;
	size_t failures = 0;

	for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
		printf("Computing SHA256 of \"%s\"...", tests[i].s);
		SHA256_Init(&ctx);
		SHA256_Update(&ctx, (const uint8_t *)tests[i].s,
		    strlen(tests[i].s));
		SHA256_Final(hbuf, &ctx);
		hexify(hbuf, hbuf_hex, 32);
		if (strcmp(hbuf_hex, tests[i].o)) {
			printf(" FAILED!\n");
			printf("Computed SHA256: %s\n", hbuf_hex);
			printf("Correct SHA256:  %s\n", tests[i].o);
			failures++;
		} else {
			printf(" PASSED!\n");
		}
	}

	if (failures)
		return (1);
	else
		return (0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl $0x8, %ebx
leaq 0x70(%rsp), %r14
leaq 0x20(%rsp), %r12
xorl %r15d, %r15d
leaq 0x733d(%rip), %rax      # 0x8d50
movq -0x8(%rbx,%rax), %rbp
movq (%rbx,%rax), %r13
leaq 0x460a(%rip), %rdi      # 0x602d
movq %rbp, %rsi
xorl %eax, %eax
callq 0x10e0
movq %r14, %rdi
callq 0x1b98
movq %rbp, %rdi
callq 0x10c0
movq %r14, %rdi
movq %rbp, %rsi
movq %rax, %rdx
callq 0x1e2a
movq %rsp, %rbp
movq %rbp, %rdi
movq %r14, %rsi
callq 0x1f22
movl $0x20, %edx
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4760
movq %r12, %rdi
movq %r13, %rsi
callq 0x1130
testl %eax, %eax
je 0x1aab
leaq 0x4a1e(%rip), %rdi      # 0x649d
callq 0x1090
leaq 0x45be(%rip), %rdi      # 0x6049
movq %r12, %rsi
xorl %eax, %eax
callq 0x10e0
leaq 0x45c2(%rip), %rdi      # 0x605e
movq %r13, %rsi
xorl %eax, %eax
callq 0x10e0
incq %r15
jmp 0x1ab7
leaq 0x49e2(%rip), %rdi      # 0x6494
callq 0x1090
addq $0x10, %rbx
cmpq $0x98, %rbx
jne 0x1a0c
xorl %eax, %eax
testq %r15, %r15
setne %al
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/Tarsnap[P]libcperciva/tests/sha256/main.c
// Function: perftest_func
static int
perftest_func(void * cookie, uint8_t * buf, size_t buflen, size_t nreps)
{
	SHA256_CTX ctx;
	uint8_t hbuf[32];
	size_t i;

	(void)cookie; /* UNUSED */

	/* Do the hashing. */
	SHA256_Init(&ctx);
	for (i = 0; i < nreps; i++)
		SHA256_Update(&ctx, buf, buflen);
	SHA256_Final(hbuf, &ctx);

	/* Success! */
	return (0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
leaq 0x20(%rsp), %rdi
callq 0x1b98
testq %rbx, %rbx
je 0x1b79
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1e2a
decq %rbx
jne 0x1b66
movq %rsp, %rdi
leaq 0x20(%rsp), %rsi
callq 0x1f22
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_c_makefile_star2_O1/tylerneylon[P]APIsWithLua/ch6/limit_cpu.c
// Function: hook
void hook(lua_State *L, lua_Debug *ar) {

  instruction_count += instructions_per_hook;

  if (!do_limit_instructions) return;

  if (instruction_count > instruction_count_limit) {
    lua_pushstring(L, "exceeded allowed cpu time");
    lua_error(L);
  }
}

// Assembly:
movq 0x28add(%rip), %rax     # 0x2d2e0
addq 0x28aa6(%rip), %rax     # 0x2d2b0
movq %rax, 0x28acf(%rip)     # 0x2d2e0
cmpl $0x0, 0x28a90(%rip)     # 0x2d2a8
je 0x4846
cmpq 0x28a97(%rip), %rax     # 0x2d2b8
jle 0x4846
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1b7d1(%rip), %rsi     # 0x20004
callq 0x511b
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x5e56
retq
// File: /workspace/github_c_makefile_star2_O1/tylerneylon[P]APIsWithLua/ch6/limit_cpu.c
// Function: main
int main() {
  lua_State *L = luaL_newstate();
  luaL_openlibs(L);
  lua_sethook(L, hook, LUA_MASKCOUNT, instructions_per_hook);

  print_status();
  while (accept_and_run_a_line(L)) print_status();

  lua_close(L);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
callq 0x14086
movq %rax, %rbx
movq %rax, %rdi
callq 0x14288
movl 0x28a32(%rip), %ecx     # 0x2d2b0
leaq -0x89(%rip), %rsi       # 0x47fc
movq %rbx, %rdi
movl $0x8, %edx
callq 0x6224
movq 0x28a47(%rip), %rsi     # 0x2d2e0
leaq 0x1b77e(%rip), %rdi     # 0x2001e
xorl %eax, %eax
callq 0x4180
movq %rbx, %rdi
callq 0x1f5b0
testl %eax, %eax
je 0x48d7
leaq 0x1b764(%rip), %r14     # 0x2001e
movq 0x28a1f(%rip), %rsi     # 0x2d2e0
movq %r14, %rdi
xorl %eax, %eax
callq 0x4180
movq %rbx, %rdi
callq 0x1f5b0
testl %eax, %eax
jne 0x48ba
movq %rbx, %rdi
callq 0xdd54
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/chip8.c
// Function: chip8_init
int
chip8_init(struct chip8* chip8)
{
    assert(chip8 != NULL);

    memset(chip8, 0, sizeof(*chip8));
    srand(time(NULL));

    memmove(chip8->mem, CHIP8_FONT, sizeof(CHIP8_FONT));

    return CHIP8_OK;
}

// Assembly:
pushq %rbx
testq %rdi, %rdi
je 0x279f
movq %rdi, %rbx
movl $0x1848, %edx           # imm = 0x1848
xorl %esi, %esi
callq 0x20c0
xorl %edi, %edi
callq 0x2120
movl %eax, %edi
callq 0x2140
leaq 0x1a62(%rip), %rsi      # 0x41f0
movl $0x50, %edx
movq %rbx, %rdi
callq 0x2100
xorl %eax, %eax
popq %rbx
retq
leaq 0x1975(%rip), %rdi      # 0x411b
leaq 0x197c(%rip), %rsi      # 0x4129
leaq 0x1981(%rip), %rcx      # 0x4135
movl $0x29, %edx
callq 0x20e0
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/chip8.c
// Function: chip8_load
int
chip8_load(struct chip8* chip8, const uint8_t* rom, long size)
{
    assert(rom != NULL);

    if (CHIP8_ROM_ADDR + size >= CHIP8_MEM_SIZE) {
        return CHIP8_ERROR_OVERSIZED_ROM;
    }

    memmove(chip8->mem + CHIP8_ROM_ADDR, rom, size);
    chip8->pc = CHIP8_ROM_ADDR;

    return CHIP8_OK;
}

// Assembly:
pushq %rbx
testq %rsi, %rsi
je 0x27ee
movl $0x1, %eax
cmpq $0xdff, %rdx            # imm = 0xDFF
jg 0x27ec
movq %rdi, %rbx
addq $0x200, %rdi            # imm = 0x200
callq 0x21d0
movw $0x200, 0x1012(%rbx)    # imm = 0x200
xorl %eax, %eax
popq %rbx
retq
leaq 0x195f(%rip), %rdi      # 0x4154
leaq 0x192d(%rip), %rsi      # 0x4129
leaq 0x195d(%rip), %rcx      # 0x4160
movl $0x36, %edx
callq 0x20e0
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/chip8.c
// Function: chip8_step
int
chip8_step(struct chip8* chip8)
{
    uint16_t code = chip8->mem[chip8->pc] << 8 | chip8->mem[chip8->pc + 1];

    struct instruction inst = { 0 };
    int rc = instruction_decode(&inst, code);
    if (rc != INSTRUCTION_OK) {
        fprintf(stderr, "attempted to decode a bad instruction\n");
        return CHIP8_ERROR_BAD_INSTRUCTION;
    }

    rc = operation_apply(chip8, &inst);
    if (rc != OPERATION_OK) {
        fprintf(stderr, "attempted to execute a bad operation: %s\n", operation_error_message(rc));
        return CHIP8_ERROR_BAD_OPERATION;
    }

    if (chip8->timer_delay > 0) chip8->timer_delay -= 1;
    if (chip8->timer_sound > 0) chip8->timer_sound -= 1;

    return CHIP8_OK;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movzwl 0x1012(%rdi), %eax
movzwl (%rdi,%rax), %eax
rolw $0x8, %ax
movq %rsp, %rdi
movl $0x0, 0x8(%rdi)
movq $0x0, (%rdi)
movzwl %ax, %esi
callq 0x28bc
testl %eax, %eax
jne 0x287c
movq %rsp, %rsi
movq %rbx, %rdi
callq 0x2964
testl %eax, %eax
jne 0x2888
movb 0x1846(%rbx), %al
testb %al, %al
je 0x2862
decb %al
movb %al, 0x1846(%rbx)
movb 0x1847(%rbx), %cl
xorl %eax, %eax
testb %cl, %cl
je 0x2876
decb %cl
movb %cl, 0x1847(%rbx)
addq $0x10, %rsp
popq %rbx
retq
callq 0x2335
movl $0x2, %eax
jmp 0x2876
movl %eax, %edi
callq 0x2357
movl $0x3, %eax
jmp 0x2876
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/inst.c
// Function: instruction_decode
int
instruction_decode(struct instruction* inst, uint16_t code)
{
    // params can be set now since their position is consistent
    inst->opcode = OPCODE_UNDEFINED;
    inst->nnn = code & 0x0fff;
    inst->n = code & 0x000f;
    inst->x = (code & 0x0f00) >> 8;
    inst->y = (code & 0x00f0) >> 4;
    inst->kk = code & 0x00ff;

    // loop through each opcode and try to find a match
    for (int op = OPCODE_UNDEFINED + 1; op < OPCODE_COUNT; op++) {
        // check for a match by masking the code and comparing the values
        if ((code & INSTRUCTION_MASKS[op].mask) == INSTRUCTION_MASKS[op].value) {
            inst->opcode = op;
            return INSTRUCTION_OK;
        }
    }

    // if nothing matched from the above loop then the code is invalid
    return INSTRUCTION_ERROR;
}

// Assembly:
movl $0x0, (%rdi)
movl %esi, %eax
andl $0xfff, %eax            # imm = 0xFFF
movw %ax, 0x4(%rdi)
movl %esi, %eax
andb $0xf, %al
movb %al, 0x6(%rdi)
movl %esi, %eax
shrl $0x8, %eax
andb $0xf, %al
movb %al, 0x7(%rdi)
movl %esi, %eax
shrb $0x4, %al
movb %al, 0x8(%rdi)
movb %sil, 0x9(%rdi)
cmpl $0xe0, %esi
jne 0x28fb
movl $0x1, %eax
xorl %ecx, %ecx
jmp 0x2932
movl $0x1, %eax
xorl %ecx, %ecx
leaq 0x1937(%rip), %rdx      # 0x4240
cmpq $0x22, %rcx
je 0x2936
movzwl 0x8(%rdx,%rcx,4), %r9d
andw %si, %r9w
leaq 0x1(%rcx), %r8
incq %rax
cmpw 0xa(%rdx,%rcx,4), %r9w
movq %r8, %rcx
jne 0x2909
cmpq $0x23, %r8
setae %cl
movl %eax, (%rdi)
jmp 0x293d
cmpq $0x23, %rax
setae %cl
movzbl %cl, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_apply
int
operation_apply(struct chip8* chip8, const struct instruction* inst)
{
    assert(chip8 != NULL);
    assert(inst != NULL);

    operation_func operation = OPERATIONS[inst->opcode];
    return operation(chip8, inst);
}

// Assembly:
pushq %rax
testq %rdi, %rdi
je 0x297d
testq %rsi, %rsi
je 0x299c
movslq (%rsi), %rax
leaq 0x4347(%rip), %rcx      # 0x6cc0
popq %rdx
jmpq *(%rcx,%rax,8)
leaq 0x1797(%rip), %rdi      # 0x411b
leaq 0x1c09(%rip), %rsi      # 0x4594
leaq 0x1c0b(%rip), %rcx      # 0x459d
movl $0x17d, %edx            # imm = 0x17D
callq 0x20e0
leaq 0x1c3a(%rip), %rdi      # 0x45dd
leaq 0x1bea(%rip), %rsi      # 0x4594
leaq 0x1bec(%rip), %rcx      # 0x459d
movl $0x17e, %edx            # imm = 0x17E
callq 0x20e0
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_RET_00EE
static int
operation_RET_00EE(struct chip8* chip8, const struct instruction* inst)
{
    if (chip8->sp <= 0) return OPERATION_ERROR_STACK_UNDERFLOW;

    chip8->sp -= 1;
    chip8->pc = chip8->stack[chip8->sp];
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzwl 0x1034(%rdi), %eax
testw %ax, %ax
je 0x2a2f
decl %eax
movw %ax, 0x1034(%rdi)
movzwl %ax, %eax
movzwl 0x1014(%rdi,%rax,2), %eax
addl $0x2, %eax
movw %ax, 0x1012(%rdi)
xorl %eax, %eax
retq
movl $0x4, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_CALL_2nnn
static int
operation_CALL_2nnn(struct chip8* chip8, const struct instruction* inst)
{
    if (chip8->sp >= CHIP8_STACK_SIZE - 1) return OPERATION_ERROR_STACK_OVERFLOW;

    chip8->stack[chip8->sp] = chip8->pc;
    chip8->sp += 1;
    chip8->pc = inst->nnn;
    return OPERATION_OK;
}

// Assembly:
movzwl 0x1034(%rdi), %ecx
movl $0x3, %eax
cmpq $0xe, %rcx
ja 0x2a86
movzwl 0x1012(%rdi), %eax
movw %ax, 0x1014(%rdi,%rcx,2)
incw 0x1034(%rdi)
movzwl 0x4(%rsi), %eax
movw %ax, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_ADD_8xy4
static int
operation_ADD_8xy4(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = (chip8->reg[inst->x] + chip8->reg[inst->y] > 0xff) ? 1 : 0;
    chip8->reg[inst->x] += chip8->reg[inst->y];
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x7(%rsi), %eax
movzbl 0x1000(%rdi,%rax), %eax
movzbl 0x8(%rsi), %ecx
movzbl 0x1000(%rdi,%rcx), %ecx
addl %eax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
setae 0x100f(%rdi)
movzbl 0x8(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
movzbl 0x7(%rsi), %ecx
addb %al, 0x1000(%rdi,%rcx)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_SUB_8xy5
static int
operation_SUB_8xy5(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = (chip8->reg[inst->x] > chip8->reg[inst->y]) ? 1 : 0;
    chip8->reg[inst->x] -= chip8->reg[inst->y];
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x7(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
movzbl 0x8(%rsi), %ecx
cmpb 0x1000(%rdi,%rcx), %al
seta 0x100f(%rdi)
movzbl 0x8(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
movzbl 0x7(%rsi), %ecx
subb %al, 0x1000(%rdi,%rcx)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_SHR_8xy6
static int
operation_SHR_8xy6(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = (chip8->reg[inst->x] & 0x1) ? 1 : 0;
    chip8->reg[inst->x] >>= 1;
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x7(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
andb $0x1, %al
movb %al, 0x100f(%rdi)
movzbl 0x7(%rsi), %eax
shrb 0x1000(%rdi,%rax)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_SUBN_8xy7
static int
operation_SUBN_8xy7(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = (chip8->reg[inst->y] > chip8->reg[inst->x]) ? 1 : 0;
    chip8->reg[inst->x] = chip8->reg[inst->y] - chip8->reg[inst->x];
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x8(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
movzbl 0x7(%rsi), %ecx
cmpb 0x1000(%rdi,%rcx), %al
seta 0x100f(%rdi)
movzbl 0x8(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
movzbl 0x7(%rsi), %ecx
subb 0x1000(%rdi,%rcx), %al
movb %al, 0x1000(%rdi,%rcx)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_SHL_8xyE
static int
operation_SHL_8xyE(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = (chip8->reg[inst->x] & 0x8) ? 1 : 0;
    chip8->reg[inst->x] <<= 1;
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x7(%rsi), %eax
movb 0x1000(%rdi,%rax), %al
shrb $0x3, %al
andb $0x1, %al
movb %al, 0x100f(%rdi)
movzbl 0x7(%rsi), %eax
shlb 0x1000(%rdi,%rax)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_DRW_Dxyn
static int
operation_DRW_Dxyn(struct chip8* chip8, const struct instruction* inst)
{
    chip8->reg[CHIP8_REG_VF] = 0;
    for (long dy = 0; dy < inst->n; dy++) {
        uint8_t sprite = chip8->mem[chip8->index + dy];
        for (long dx = 0; dx < CHIP8_SPRITE_WIDTH; dx++) {
            // account for pixels wrapping around edges of the display
            long x = (chip8->reg[inst->x] + dx) % CHIP8_DISPLAY_WIDTH;
            long y = (chip8->reg[inst->y] + dy) % CHIP8_DISPLAY_HEIGHT;

            // chip8->display is stored as a row-major matrix
            long pixel_index = (y * CHIP8_DISPLAY_WIDTH) + x;

            // determine what the resulting pixel value will be
            bool new_pixel = sprite & (0x80 >> dx);
            bool old_pixel = chip8->display[pixel_index];
            bool resulting_pixel = new_pixel ^ old_pixel;

            // set VF register to 1 if a pixel gets turned off
            if (old_pixel && !resulting_pixel) chip8->reg[CHIP8_REG_VF] = 1;

            chip8->display[pixel_index] = resulting_pixel;
        }
    }
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movb $0x0, 0x100f(%rdi)
cmpb $0x0, 0x6(%rsi)
je 0x2df8
pushq %rbx
movzwl 0x1010(%rdi), %eax
xorl %edx, %edx
leaq (%rdx,%rax), %rcx
movzbl (%rdi,%rcx), %r8d
xorl %ecx, %ecx
movzbl 0x7(%rsi), %r9d
movzbl 0x1000(%rdi,%r9), %r10d
addl %ecx, %r10d
andl $0x3f, %r10d
movzbl 0x8(%rsi), %r9d
movzbl 0x1000(%rdi,%r9), %r9d
addl %edx, %r9d
andl $0x1f, %r9d
shll $0x6, %r9d
orl %r10d, %r9d
movl %r8d, %r10d
shll %cl, %r10d
movb 0x1046(%rdi,%r9), %bl
shrb $0x7, %r10b
cmpb %r10b, %bl
setne %r11b
cmpb $0x1, %bl
jne 0x2dd6
cmpb %r10b, %bl
jne 0x2dd6
movb $0x1, 0x100f(%rdi)
movb %r11b, 0x1046(%rdi,%r9)
incq %rcx
cmpq $0x8, %rcx
jne 0x2d7b
incq %rdx
movzbl 0x6(%rsi), %ecx
cmpq %rcx, %rdx
jb 0x2d70
popq %rbx
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_LD_Fx33
static int
operation_LD_Fx33(struct chip8* chip8, const struct instruction* inst)
{
    chip8->mem[chip8->index + 0] = (chip8->reg[inst->x] / 100);
    chip8->mem[chip8->index + 1] = (chip8->reg[inst->x] / 10)  % 10;
    chip8->mem[chip8->index + 2] = (chip8->reg[inst->x] / 100) % 10;
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
movzbl 0x7(%rsi), %eax
movzbl 0x1000(%rdi,%rax), %eax
leal (%rax,%rax,4), %ecx
leal (%rax,%rcx,8), %eax
shrl $0xc, %eax
movzwl 0x1010(%rdi), %ecx
movb %al, (%rdi,%rcx)
movzbl 0x7(%rsi), %eax
movzbl 0x1000(%rdi,%rax), %eax
imull $0xcd, %eax, %eax
shrl $0xb, %eax
leal (%rax,%rax,4), %ecx
leal (%rcx,%rcx,4), %ecx
addl %eax, %ecx
shrl $0x7, %ecx
andl $0x6, %ecx
leal (%rcx,%rcx,4), %ecx
subb %cl, %al
movzwl 0x1010(%rdi), %ecx
movb %al, 0x1(%rcx,%rdi)
movzbl 0x7(%rsi), %eax
movzbl 0x1000(%rdi,%rax), %eax
leal (%rax,%rax,4), %ecx
leal (%rax,%rcx,8), %eax
shrl $0xc, %eax
movzwl 0x1010(%rdi), %ecx
movb %al, 0x2(%rcx,%rdi)
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_LD_Fx55
static int
operation_LD_Fx55(struct chip8* chip8, const struct instruction* inst)
{
    for (long i = 0; i < inst->x; i++) {
        chip8->mem[chip8->index + i] = chip8->reg[i];
    }
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
cmpb $0x0, 0x7(%rsi)
je 0x2fbd
xorl %eax, %eax
leaq (%rdi,%rax), %rcx
movb 0x1000(%rdi,%rax), %dl
movzwl 0x1010(%rdi), %r8d
movb %dl, (%r8,%rcx)
incq %rax
movzbl 0x7(%rsi), %ecx
cmpq %rcx, %rax
jb 0x2f9a
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/theandrew168[P]skylark/src/op.c
// Function: operation_LD_Fx65
static int
operation_LD_Fx65(struct chip8* chip8, const struct instruction* inst)
{
    for (long i = 0; i < inst->x; i++) {
        chip8->reg[i] = chip8->mem[chip8->index + i];
    }
    chip8->pc += 2;
    return OPERATION_OK;
}

// Assembly:
cmpb $0x0, 0x7(%rsi)
je 0x2ff1
xorl %eax, %eax
movzwl 0x1010(%rdi), %ecx
leaq (%rdi,%rax), %rdx
movb (%rcx,%rdx), %cl
movb %cl, 0x1000(%rdi,%rax)
incq %rax
movzbl 0x7(%rsi), %ecx
cmpq %rcx, %rax
jb 0x2fd0
addw $0x2, 0x1012(%rdi)
xorl %eax, %eax
retq
// File: /workspace/github_c_makefile_star2_O1/albinoloverats[P]hide/src/tiff.c
// Function: init
extern image_type_t *init(void)
{
	static image_type_t tiff;
	tiff.type = "TIFF";
	tiff.is_type = is_tiff;
	tiff.read = read_tiff;
	tiff.write = write_tiff;
	tiff.info = info_tiff;
	tiff.free = free_tiff;
	return &tiff;
}

// Assembly:
leaq 0xe3d(%rip), %rax       # 0x2000
movq %rax, 0x2ebe(%rip)      # 0x4088
leaq 0x2eb7(%rip), %rax      # 0x4088
leaq 0x40(%rip), %rcx        # 0x1218
movq %rcx, 0x2eb1(%rip)      # 0x4090
leaq 0x6b(%rip), %rcx        # 0x1251
movq %rcx, 0x2eab(%rip)      # 0x4098
leaq 0x14b(%rip), %rcx       # 0x133f
movq %rcx, 0x2ea5(%rip)      # 0x40a0
leaq 0x2be(%rip), %rcx       # 0x14c0
movq %rcx, 0x2e9f(%rip)      # 0x40a8
leaq 0x2ca(%rip), %rcx       # 0x14da
movq %rcx, 0x2e99(%rip)      # 0x40b0
retq
// File: /workspace/github_c_makefile_star2_O1/albinoloverats[P]hide/src/tiff.c
// Function: is_tiff
static bool is_tiff(char *file_name)
{
	TIFFSetErrorHandler(NULL);
	TIFFSetWarningHandler(NULL);

	TIFF *tif = TIFFOpen(file_name, "r");
	if (!tif)
		return false;
	TIFFClose(tif);
	return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorl %edi, %edi
callq 0x10e0
xorl %edi, %edi
callq 0x1090
leaq 0xdd4(%rip), %rsi       # 0x2005
movq %rbx, %rdi
callq 0x1050
movq %rax, %rbx
testq %rax, %rax
je 0x1249
movq %rbx, %rdi
callq 0x10d0
testq %rbx, %rbx
setne %al
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/albinoloverats[P]hide/src/tiff.c
// Function: read_tiff
static int read_tiff(image_info_t *image_info, void (*progress_update)(uint64_t, uint64_t))
{
	errno = EXIT_SUCCESS;

	TIFF *tif = TIFFOpen(image_info->file, "r");
	if (!tif)
		return errno;

	TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &image_info->width);
	TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &image_info->height);
	TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &image_info->bpp);

	image_info->buffer = malloc(sizeof (uint8_t *) * image_info->height);
	for (uint64_t y = 0; y < image_info->height; y++)
	{
		image_info->buffer[y] = malloc(image_info->width * image_info->bpp);
		TIFFReadScanline(tif, image_info->buffer[y], y, 0);
		if (progress_update)
			progress_update(y, image_info->height);
	}

	TIFFClose(tif);

	return errno;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %r15
callq 0x1040
movq %rax, %rbx
movl $0x0, (%rax)
movq (%r15), %rdi
leaq 0xd8b(%rip), %rsi       # 0x2005
callq 0x1050
testq %rax, %rax
je 0x132e
movq %rax, %r12
leaq 0x30(%r15), %rdx
movq %rax, %rdi
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x1070
leaq 0x28(%r15), %r13
movq %r12, %rdi
movl $0x101, %esi            # imm = 0x101
movq %r13, %rdx
xorl %eax, %eax
callq 0x1070
leaq 0x38(%r15), %rdx
movq %r12, %rdi
movl $0x115, %esi            # imm = 0x115
xorl %eax, %eax
callq 0x1070
movq 0x28(%r15), %rbp
leaq (,%rbp,8), %rdi
callq 0x10a0
movq %rax, 0x40(%r15)
testq %rbp, %rbp
je 0x1326
xorl %ebp, %ebp
movzwl 0x38(%r15), %edi
imulq 0x30(%r15), %rdi
callq 0x10a0
movq 0x40(%r15), %rcx
movq %rax, (%rcx,%rbp,8)
movq 0x40(%r15), %rax
movq (%rax,%rbp,8), %rsi
movq %r12, %rdi
movl %ebp, %edx
xorl %ecx, %ecx
callq 0x10b0
testq %r14, %r14
je 0x131d
movq (%r13), %rsi
movq %rbp, %rdi
callq *%r14
incq %rbp
cmpq (%r13), %rbp
jb 0x12e3
movq %r12, %rdi
callq 0x10d0
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/albinoloverats[P]hide/src/tiff.c
// Function: write_tiff
static int write_tiff(image_info_t image_info, void (*progress_update)(uint64_t, uint64_t))
{
	errno = EXIT_SUCCESS;

	TIFF *tif = TIFFOpen(image_info.file, "w");
	if (!tif)
		return errno;

	TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, image_info.width);
	TIFFSetField(tif, TIFFTAG_IMAGELENGTH, image_info.height);
	TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, image_info.bpp);
	TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);

	TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
	TIFFSetField(tif, TIFFTAG_RESOLUTIONUNIT, RESUNIT_CENTIMETER);
	TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
	TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
	TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);

	TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, image_info.width * image_info.bpp));

	for (uint64_t y = 0; y < image_info.height; y++)
	{
		TIFFWriteScanline(tif, image_info.buffer[y], y, 0);
		free(image_info.buffer[y]);
		if (progress_update)
			progress_update(y, image_info.height);
	}
	free(image_info.buffer);

	TIFFClose(tif);

	return errno;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x1040
movq %rax, %rbx
movl $0x0, (%rax)
movq 0x40(%rsp), %rdi
leaq 0xca0(%rip), %rsi       # 0x2007
callq 0x1050
testq %rax, %rax
je 0x14af
movq %rax, %r15
leaq 0x40(%rsp), %rbp
movq 0x30(%rbp), %r13
movq %rax, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdx
xorl %eax, %eax
callq 0x1080
movq 0x28(%rbp), %r12
movq %r15, %rdi
movl $0x101, %esi            # imm = 0x101
movq %r12, %rdx
xorl %eax, %eax
callq 0x1080
movzwl 0x38(%rbp), %ebp
movq %r15, %rdi
movl $0x115, %esi            # imm = 0x115
movl %ebp, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x103, %esi            # imm = 0x103
movl $0x5, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x102, %esi            # imm = 0x102
movl $0x8, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x128, %esi            # imm = 0x128
movl $0x3, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x112, %esi            # imm = 0x112
movl $0x1, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x11c, %esi            # imm = 0x11C
movl $0x1, %edx
xorl %eax, %eax
callq 0x1080
movq %r15, %rdi
movl $0x106, %esi            # imm = 0x106
movl $0x2, %edx
xorl %eax, %eax
callq 0x1080
imull %ebp, %r13d
movq %r15, %rdi
movl %r13d, %esi
callq 0x1060
movq %r15, %rdi
movl $0x116, %esi            # imm = 0x116
movl %eax, %edx
xorl %eax, %eax
callq 0x1080
testq %r12, %r12
je 0x1499
leaq 0x40(%rsp), %rax
movq 0x40(%rax), %rbp
xorl %r13d, %r13d
movq (%rbp,%r13,8), %rsi
movq %r15, %rdi
movl %r13d, %edx
xorl %ecx, %ecx
callq 0x10c0
movq (%rbp,%r13,8), %rdi
callq 0x1030
testq %r14, %r14
je 0x1491
movq %r13, %rdi
movq %r12, %rsi
callq *%r14
incq %r13
cmpq %r13, %r12
jne 0x1467
leaq 0x40(%rsp), %rax
movq 0x40(%rax), %rdi
callq 0x1030
movq %r15, %rdi
callq 0x10d0
movl (%rbx), %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_log_init
bool ce_log_init(const char* filename){
     g_ce_log = fopen(filename, "wa");
     if(!g_ce_log){
          fprintf(stderr, "error: unable to create ce log: fopen(\"%s\", \"wa\") failed: '%s'\n", filename, strerror(errno));
          return false;
     }

     static const char* greetings [] = {
          "Thank you for flying ce",
          "There's nothing like a fresh cup of ce in the morning",
          "Why do kids love the taste of C Editor?\n\nIt's the taste you can ce",
          "ce is for C Editor, that's good enough for me",
          "I missed you.",
          "Hope you're having a great day! -ce",
          "You're a special person -- or robot. I don't judge.",
          "I missed you... in a creepy way.",
          "I'm a potato",
          "At least this isn't emacs? Am I right!",
          "TACOCAT is the best palindrome",
          "Found a bug? It's a feature.",
          "Yo.",
          "Slurp'n up whitespace since 2016",
          "Welcome to GNU Emacs, one component of the GNU/Linux operating system.",
          "ce, the world's only editor with a Michelin star.",
          "Oy! ce's a beaut!",
          "The default config has a great vimplementation!",
          "They see me slurpin' They hatin'",
          "'Days of pain are worth the years of upcoming prosperity' -confucius, probably",
          "ce, aka, 'the cache miss king'",
          "All the terminal you want with none of the illness",
          "I used ce before it was cool",
          "'Where has this been all my life' -emacs enthusiast",
     };

     srand(time(NULL));
     ce_log("%s\n", greetings[rand() % (sizeof(greetings) / sizeof(greetings[0]))]);
     return true;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x2082a(%rip), %rsi     # 0x2e104
callq 0xd5b0
movq %rax, %rbx
movq %rax, 0x2e207(%rip)     # 0x3baf0
testq %rax, %rax
je 0xd94a
xorl %edi, %edi
callq 0xd450
movl %eax, %edi
callq 0xd370
callq 0xd710
movslq %eax, %rcx
movabsq $-0x5555555555555555, %rdx # imm = 0xAAAAAAAAAAAAAAAB
movq %rcx, %rax
mulq %rdx
shrq $0x4, %rdx
shll $0x3, %edx
leal (%rdx,%rdx,2), %eax
subl %eax, %ecx
leaq 0x2077d(%rip), %rax     # 0x2e0a4
movslq (%rax,%rcx,4), %rsi
addq %rax, %rsi
leaq 0x23f72(%rip), %rdi     # 0x318a7
xorl %eax, %eax
callq 0xd954
testq %rbx, %rbx
setne %al
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %r14, %rdi
callq 0xd760
jmp 0xd93c
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_log
void ce_log(const char* fmt, ...){
     va_list args;
     va_start(args, fmt);
     size_t string_len = vsnprintf(g_log_string, BUFSIZ, fmt, args);
     va_end(args);

#if defined(PLATFORM_WINDOWS)
     printf("%s", g_log_string);
#else
     fwrite(g_log_string, string_len, 1, g_ce_log);
#endif
     CePoint_t end = ce_buffer_end_point(g_ce_log_buffer);
     g_ce_log_buffer->status = CE_BUFFER_STATUS_NONE;
     ce_buffer_insert_string(g_ce_log_buffer, g_log_string, end);
     g_ce_log_buffer->status = CE_BUFFER_STATUS_READONLY;
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdi, %r10
leaq 0x20(%rsp), %rdi
movq %rsi, 0x8(%rdi)
movq %rdx, 0x10(%rdi)
movq %rcx, 0x18(%rdi)
movq %r8, 0x20(%rdi)
movq %r9, 0x28(%rdi)
testb %al, %al
je 0xd9b3
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
movq %rsp, %rcx
movq %rdi, 0x10(%rcx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rcx)
movabsq $0x3000000008, %rax     # imm = 0x3000000008
movq %rax, (%rcx)
leaq 0x2e126(%rip), %rbx     # 0x3bb00
movl $0x2000, %esi           # imm = 0x2000
movq %rbx, %rdi
movq %r10, %rdx
callq 0xd180
movslq %eax, %rsi
movq 0x2e0fc(%rip), %rcx     # 0x3baf0
movl $0x1, %edx
movq %rbx, %rdi
callq 0xd610
movq 0x2e0f0(%rip), %rdi     # 0x3baf8
callq 0xda40
movq %rdx, %rcx
movq 0x2e0e1(%rip), %rdi     # 0x3baf8
movl $0x0, 0x18(%rdi)
movq %rbx, %rsi
movq %rax, %rdx
callq 0xda6e
movq 0x2e0c8(%rip), %rax     # 0x3baf8
movl $0x2, 0x18(%rax)
addq $0xd0, %rsp
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_end_point
CePoint_t ce_buffer_end_point(CeBuffer_t* buffer){
     CePoint_t point = {0, buffer->line_count};
     if(point.y > 0){
          point.y--;
          point.x = ce_utf8_last_index(buffer->lines[point.y]);
     }
     return point;
}

// Assembly:
pushq %rbx
movq 0x8(%rdi), %rbx
testq %rbx, %rbx
jle 0xda67
movq (%rdi), %rax
movq -0x8(%rax,%rbx,8), %rdi
decq %rbx
callq 0xe485
xorl %ecx, %ecx
testq %rax, %rax
setg %cl
subq %rcx, %rax
jmp 0xda69
xorl %eax, %eax
movq %rbx, %rdx
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_alloc
bool ce_buffer_alloc(CeBuffer_t* buffer, int64_t line_count, const char* name){
     if(buffer->lines) ce_buffer_free(buffer);

     if(line_count <= 0){
          ce_log("%s() error: 0 line_count specified.\n", __FUNCTION__);
          return false;
     }

     buffer->lines = (char**)malloc(line_count * sizeof(*buffer->lines));
     if(!buffer->lines){
          ce_log("%s() failed to malloc() %ld lines.\n", __FUNCTION__, line_count);
          return false;
     }

     buffer->line_count = line_count;
     buffer->name = strdup(name);

     for(int64_t i = 0; i < line_count; i++){
          buffer->lines[i] = (char*)calloc(1, sizeof(buffer->lines[i]));
     }

     buffer->status = CE_BUFFER_STATUS_MODIFIED;
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
cmpq $0x0, (%rdi)
je 0xde0f
movq %r14, %rdi
callq 0xdea7
testq %rbx, %rbx
jle 0xde67
leaq (,%rbx,8), %rdi
callq 0xd4c0
movq %rax, (%r14)
testq %rax, %rax
je 0xde80
movq %rbx, 0x8(%r14)
movq %r15, %rdi
callq 0xd640
movq %rax, 0x10(%r14)
xorl %r15d, %r15d
movl $0x1, %edi
movl $0x8, %esi
callq 0xd380
movq (%r14), %rcx
movq %rax, (%rcx,%r15,8)
incq %r15
cmpq %r15, %rbx
jne 0xde3c
movl $0x1, 0x18(%r14)
movb $0x1, %bpl
jmp 0xde9a
leaq 0x20682(%rip), %rdi     # 0x2e4f0
leaq 0x206a0(%rip), %rsi     # 0x2e515
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xd954
jmp 0xde9a
leaq 0x2069e(%rip), %rdi     # 0x2e525
leaq 0x20687(%rip), %rsi     # 0x2e515
xorl %ebp, %ebp
movq %rbx, %rdx
xorl %eax, %eax
callq 0xd954
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_free
void ce_buffer_free(CeBuffer_t* buffer){
     for(int64_t i = 0; i < buffer->line_count; i++){
          free(buffer->lines[i]);
     }

     free(buffer->lines);
     free(buffer->name);

     if(buffer->change_node){
          CeBufferChangeNode_t* head = buffer->change_node;
          while(head->prev) head = head->prev;
          ce_buffer_change_node_free(&head);
     }

     memset(buffer, 0, sizeof(*buffer));
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
jle 0xdecd
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xd090
incq %r14
cmpq 0x8(%rbx), %r14
jl 0xdeb8
movq (%rbx), %rdi
callq 0xd090
movq 0x10(%rbx), %rdi
callq 0xd090
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0xdefe
movq %rax, %rcx
movq 0x48(%rax), %rax
testq %rax, %rax
jne 0xdee7
movq %rsp, %rdi
movq %rcx, (%rdi)
callq 0xdf24
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
movups %xmm0, 0x50(%rbx)
movups %xmm0, 0x40(%rbx)
movups %xmm0, 0x30(%rbx)
movups %xmm0, 0x20(%rbx)
movups %xmm0, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_change_node_free
static void ce_buffer_change_node_free(CeBufferChangeNode_t** head){
     CeBufferChangeNode_t* itr = *head;
     while(itr){
          CeBufferChangeNode_t* tmp = itr;
          itr = itr->next;
          free(tmp->change.string);
          free(tmp);
     }

     *head = NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r14
testq %r14, %r14
je 0xdf51
movq 0x8(%r14), %rdi
movq 0x40(%r14), %r15
callq 0xd090
movq %r14, %rdi
callq 0xd090
movq %r15, %r14
testq %r15, %r15
jne 0xdf34
movq $0x0, (%rbx)
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_util_count_string_lines
int64_t ce_util_count_string_lines(const char* string){
     int64_t string_length = strlen(string);
     int64_t line_count = 0;
     for(int64_t i = 0; i <= string_length; ++i){
          if(string[i] == CE_NEWLINE || string[i] == 0) line_count++;
     }

     return line_count;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
callq 0xd210
testq %rax, %rax
js 0xe2eb
incq %rax
xorl %edx, %edx
xorl %ecx, %ecx
movzbl (%rbx,%rdx), %esi
cmpl $0xa, %esi
je 0xe2de
testl %esi, %esi
jne 0xe2e1
incq %rcx
incq %rdx
cmpq %rdx, %rax
jne 0xe2d1
jmp 0xe2ed
xorl %ecx, %ecx
movq %rcx, %rax
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_save
bool ce_buffer_save(CeBuffer_t* buffer){
     FILE* file = fopen(buffer->name, "wb");
     if(!file){
          ce_log("%s() fopen('%s', 'wb') failed: '%s'\n", __FUNCTION__, buffer->name, strerror(errno));
          return false;
     }

     char newline = CE_NEWLINE;
     for(int64_t i = 0; i < buffer->line_count; ++i){
          int64_t line_len = strlen(buffer->lines[i]);
          fwrite(buffer->lines[i], 1, line_len, file);
          fwrite(&newline, 1, 1, file);
     }

     fclose(file);
     if(buffer->status == CE_BUFFER_STATUS_MODIFIED) buffer->status = CE_BUFFER_STATUS_NONE;
     buffer->save_at_change_node = buffer->change_node;

     struct stat statbuf;
     if(stat(buffer->name, &statbuf) == 0){
          buffer->file_modified_time = statbuf.st_mtime;
     }

     return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdi, %r14
movq 0x10(%rdi), %rdi
leaq 0x2030a(%rip), %rsi     # 0x2e618
callq 0xd5b0
movq %rax, %rbx
testq %rax, %rax
je 0xe399
cmpq $0x0, 0x8(%r14)
jle 0xe35d
xorl %r12d, %r12d
movq (%r14), %rax
movq (%rax,%r12,8), %r15
movq %r15, %rdi
callq 0xd210
movl $0x1, %esi
movq %r15, %rdi
movq %rax, %rdx
movq %rbx, %rcx
callq 0xd610
movl $0xa, %edi
movq %rbx, %rsi
callq 0xd330
incq %r12
cmpq 0x8(%r14), %r12
jl 0xe325
movq %rbx, %rdi
callq 0xd1f0
cmpl $0x1, 0x18(%r14)
jne 0xe374
movl $0x0, 0x18(%r14)
movq 0x40(%r14), %rax
movq %rax, 0x48(%r14)
movq 0x10(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0xd3f0
testl %eax, %eax
jne 0xe3c4
movq 0x60(%rsp), %rax
movq %rax, 0x68(%r14)
jmp 0xe3c4
movq 0x10(%r14), %r14
callq 0xd0a0
movl (%rax), %edi
callq 0xd650
leaq 0x2026b(%rip), %rdi     # 0x2e61b
leaq 0x20289(%rip), %rsi     # 0x2e640
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xd954
testq %rbx, %rbx
setne %al
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_empty
bool ce_buffer_empty(CeBuffer_t* buffer){
     if(buffer->lines == NULL) return false;

     // free all lines after the first
     for(int64_t i = 0; i < buffer->line_count; ++i){
          free(buffer->lines[i]);
     }

     // re allocate it down to a single blank line
     buffer->lines = realloc(buffer->lines, sizeof(*buffer->lines));
     buffer->lines[0] = malloc(sizeof(buffer->lines[0]));
     buffer->lines[0][0] = 0;
     buffer->line_count = 1;
     buffer->status = CE_BUFFER_STATUS_NONE;

     return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq (%rdi), %r15
testq %r15, %r15
je 0xe43a
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
jle 0xe408
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0xd090
incq %r14
cmpq 0x8(%rbx), %r14
jl 0xe3f3
movq (%rbx), %rdi
movl $0x8, %esi
callq 0xd520
movq %rax, %r14
movq %rax, (%rbx)
movl $0x8, %edi
callq 0xd4c0
movq %rax, (%r14)
movb $0x0, (%rax)
movq $0x1, 0x8(%rbx)
movl $0x0, 0x18(%rbx)
testq %r15, %r15
setne %al
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce.c
// Function: ce_buffer_contains_point
bool ce_buffer_contains_point(CeBuffer_t* buffer, CePoint_t point){
     if(point.y < 0 || point.y >= buffer->line_count || point.x < 0) return false;
     int64_t line_len = ce_utf8_strlen(buffer->lines[point.y]);
     if(point.x >= line_len){
          if(line_len == 0 && point.x == 0){
               return true;
          }
          return false;
     }

     return true;
}

// Assembly:
testq %rdx, %rdx
js 0xe464
pushq %rbx
movq %rsi, %rbx
cmpq %rdx, 0x8(%rdi)
setle %al
testq %rsi, %rsi
sets %cl
orb %al, %cl
je 0xe467
xorl %eax, %eax
jmp 0xe483
xorl %eax, %eax
retq
movq (%rdi), %rax
movq (%rax,%rdx,8), %rdi
callq 0xe485
movq %rax, %rcx
movb $0x1, %al
cmpq %rbx, %rcx
jg 0xe483
orq %rbx, %rcx
sete %al
popq %rbx
retq