LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/jacereda[P]fsatrace/src/unix/proc.c
// Function: procRun
enum procerr
procRun(unsigned nargs, char *const args[], int *rc)
{
	extern char **environ;
	int	      ret;
	int	      child;
	char	      so[PATH_MAX + 3];
	char	      fullpath[PATH_MAX];
	procPath(fullpath);
	snprintf(so, sizeof(so), "%s.so", fullpath);
#if defined __linux__
	setenv("LD_PRELOAD", so, 1);
#else
	setenv("DYLD_INSERT_LIBRARIES", so, 1);
	setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
#endif

#if 0
	if (posix_spawnp(&child, args[0], 0, 0, args, environ))
		ret = ERR_PROC_FORK;
	else
		ret = waitchild(child, rc);
#else
	child = fork();
	switch (child) {
	case -1:
		ret = ERR_PROC_FORK;
		break;
	case 0:
		execvp(args[0], args);
		_exit(EXIT_FAILURE);
		break;
	default:
		ret = waitchild(child, rc);
	}
#endif
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2010, %rsp           # imm = 0x2010
movq %rdx, %rbx
movq %rsi, %r14
movq %rsp, %r15
movq %r15, %rdi
callq 0x19d8
leaq 0x85f(%rip), %rdx       # 0x22d9
leaq 0x1000(%rsp), %r12
movl $0x1003, %esi           # imm = 0x1003
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x10e0
leaq 0x844(%rip), %rdi       # 0x22df
movl $0x1, %ebp
movq %r12, %rsi
movl $0x1, %edx
callq 0x1080
callq 0x1210
cmpl $-0x1, %eax
je 0x1b0f
testl %eax, %eax
je 0x1b21
movl %eax, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x1190
cmpl $-0x1, %eax
je 0x1b01
movl (%rbx), %ecx
movl %ecx, %eax
andl $0x7f, %eax
je 0x1b08
movl %eax, %edx
shll $0x18, %edx
addl $0x1000000, %edx        # imm = 0x1000000
movl $0x3, %ebp
cmpl $0x1ffffff, %edx        # imm = 0x1FFFFFF
jg 0x1b0d
movl $0x6, %ebp
cmpb $0x7f, %cl
jne 0x1b0f
movzbl %ch, %eax
movl $0x4, %ebp
jmp 0x1b0d
movl $0x5, %ebp
jmp 0x1b0f
movzbl %ch, %eax
xorl %ebp, %ebp
movl %eax, (%rbx)
movl %ebp, %eax
addq $0x2010, %rsp           # imm = 0x2010
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdi
movq %r14, %rsi
callq 0x11c0
movl $0x1, %edi
callq 0x1050
nop
// File: /workspace/github_c_makefile_star2_O3/jacereda[P]fsatrace/src/unix/shm.c
// Function: shmInit
int
shmInit(struct shm *shm, const char *key, size_t sz, int root)
{
	int	     err = 0;
	struct priv *p = (struct priv *)shm->storage;
	char *	     shname = shm->name;
	assert(key);
	assert(sizeof(shm->storage) > sizeof(*p));
	snprintf(shname, sizeof(shm->storage), "/fsatrace%ld",
	    hash((unsigned char *)key));
	for (size_t i = 0, l = strlen(shname); i < l; i++)
		if (shname[i] == '/')
			shname[i] = '_';
	if (root)
		shm_unlink(shname); // Just in case, it might have crashed on a
				    // previous execution
	err +=
	    (-1 == (p->fd = shm_open(shname, (root * O_CREAT) | O_RDWR, 0666)))
	    << 0;
	err += (root && (-1 == ftruncate(p->fd, sz))) << 1;
	err += (MAP_FAILED ==
		   (shm->buf = mmap(
			0, sz, PROT_READ | PROT_WRITE, MAP_SHARED, p->fd, 0)))
	    << 2;
	p->sz = sz;
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rsi, %rsi
je 0x1c53
movl %ecx, %ebp
movq %rdx, %rbx
movq %rdi, %r14
leaq 0x8(%rdi), %r15
movb (%rsi), %al
testb %al, %al
je 0x1b7e
incq %rsi
movl $0x1505, %ecx           # imm = 0x1505
movq %rcx, %rdx
shlq $0x5, %rdx
addq %rcx, %rdx
movzbl %al, %ecx
addq %rdx, %rcx
movb (%rsi), %al
incq %rsi
testb %al, %al
jne 0x1b63
jmp 0x1b83
movl $0x1505, %ecx           # imm = 0x1505
leaq 0x7a8(%rip), %rdx       # 0x2332
movl $0x20, %esi
movq %r15, %rdi
xorl %eax, %eax
callq 0x10e0
movq %r15, %rdi
callq 0x10b0
testq %rax, %rax
je 0x1bbc
xorl %ecx, %ecx
cmpb $0x2f, (%r15,%rcx)
jne 0x1bb4
movb $0x5f, (%r15,%rcx)
incq %rcx
cmpq %rcx, %rax
jne 0x1ba8
testl %ebp, %ebp
je 0x1bc8
movq %r15, %rdi
callq 0x1200
movl %ebp, %esi
shll $0x6, %esi
orl $0x2, %esi
movq %r15, %rdi
movl $0x1b6, %edx            # imm = 0x1B6
callq 0x11e0
movl %eax, %r15d
movl %eax, 0x1008(%r14)
testl %ebp, %ebp
je 0x1c09
movl %r15d, %edi
movq %rbx, %rsi
callq 0x10f0
xorl %ecx, %ecx
cmpl $-0x1, %eax
sete %cl
addl %ecx, %ecx
movl 0x1008(%r14), %r8d
jmp 0x1c0e
xorl %ecx, %ecx
movl %r15d, %r8d
xorl %r12d, %r12d
cmpl $-0x1, %r15d
sete %r12b
orl %ecx, %r12d
xorl %edi, %edi
movq %rbx, %rsi
movl $0x3, %edx
movl $0x1, %ecx
xorl %r9d, %r9d
callq 0x10c0
movq %rax, (%r14)
xorl %ecx, %ecx
cmpq $-0x1, %rax
sete %cl
leal (%r12,%rcx,4), %eax
movq %rbx, 0x1010(%r14)
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x690(%rip), %rdi       # 0x22ea
leaq 0x68d(%rip), %rsi       # 0x22ee
leaq 0x695(%rip), %rcx       # 0x22fd
movl $0x22, %edx
callq 0x1100
// File: /workspace/github_c_makefile_star2_O3/jacereda[P]fsatrace/src/unix/shm.c
// Function: shmTerm
int
shmTerm(struct shm *shm, int root)
{
	struct priv *p = (struct priv *)shm->storage;
	int	     err = 0;
	err += (-1 == munmap(shm->buf, p->sz)) << 0;
	err += (-1 == close(p->fd)) << 1;
	err += (root && (-1 == shm_unlink(shm->name))) << 2;
	return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r15d
movq %rdi, %r14
movq (%rdi), %rdi
movq 0x1010(%r14), %rsi
callq 0x1180
movl %eax, %ebx
movl 0x1008(%r14), %edi
callq 0x1110
movl %eax, %ebp
testl %r15d, %r15d
je 0x1cbc
addq $0x8, %r14
movq %r14, %rdi
callq 0x1200
xorl %ecx, %ecx
cmpl $-0x1, %eax
sete %cl
shll $0x2, %ecx
jmp 0x1cbe
xorl %ecx, %ecx
xorl %eax, %eax
cmpl $-0x1, %ebx
sete %al
xorl %edx, %edx
cmpl $-0x1, %ebp
sete %dl
leal (%rax,%rdx,2), %eax
orl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_dump_tsv
void
shmqueue_dump_tsv(struct shmqueue *shmq_header)
{
	struct shmqueue_header *header;
	struct shmqueue_item *item;

	header = shmq_header->header;

	for (item = RTAILQ_FIRST(&header->sha_lrulist, shmqueue_item);
	    item != NULL;
	    item = RTAILQ_NEXT(item, &header->sha_lrulist, shmqueue_item, shi_list)) {

		printf("%s\t", KEYVALUE_KEY(&item->shi_keyvalue));
		dumpdata(KEYVALUE_STORAGE(&item->shi_keyvalue), item->shi_keyvalue.kv_storagesize);
		printf("\n");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %rcx
movq 0x10(%rcx), %rbx
addq $0x10, %rcx
testq %rbx, %rbx
sete %al
movq %rcx, (%rsp)
addq %rcx, %rbx
sete %cl
orb %al, %cl
jne 0x1724
leaq 0x1d83(%rip), %r15      # 0x3407
movabsq $0x40000000000002d, %r14 # imm = 0x40000000000002D
leaq 0x2c(%rbx), %r12
leaq 0x1b4f(%rip), %rdi      # 0x31e8
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
movl 0x24(%rbx), %ebp
movl 0x28(%rbx), %r13d
leaq 0x1d51(%rip), %rdi      # 0x3402
movl %r13d, %esi
xorl %eax, %eax
callq 0x1070
testq %r13, %r13
je 0x16fe
addq %rbp, %r12
xorl %ebp, %ebp
movb (%r12,%rbp), %al
movzbl %al, %esi
leal -0x7f(%rsi), %eax
cmpb $-0x5f, %al
jb 0x16e1
leal -0x22(%rsi), %eax
cmpl $0x3a, %eax
ja 0x16f5
btq %rax, %r14
jae 0x16f5
movq %r15, %rdi
xorl %eax, %eax
callq 0x1070
incq %rbp
cmpl %ebp, %r13d
jne 0x16c5
jmp 0x16fe
movl %esi, %edi
callq 0x1030
jmp 0x16eb
movl $0x22, %edi
callq 0x1030
movl $0xa, %edi
callq 0x1030
movq (%rbx), %rbx
testq %rbx, %rbx
je 0x1724
addq (%rsp), %rbx
jne 0x168e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_dump_statistics
void
shmqueue_dump_statistics(struct shmqueue *shmq_header)
{
	int i;

	for (i = 0; i < SHMQUEUE_NBUCKET; i++)
		printf("store (new)   success (bucket=%d): %llu\n", i, shmq_header->header->sha_stat.ss_store_new_success[i]);

	for (i = 0; i < SHMQUEUE_NBUCKET; i++)
		printf("store (reuse) success (bucket=%d): %llu\n", i, shmq_header->header->sha_stat.ss_store_reuse_success[i]);

	for (i = 0; i < SHMQUEUE_NBUCKET; i++)
		printf("store failure         (bucket=%d): %llu\n", i, shmq_header->header->sha_stat.ss_store_failure[i]);

	for (i = 0; i < SHMQUEUE_NBUCKET; i++)
		printf("fetch (peek) success  (bucket=%d): %llu\n", i, shmq_header->header->sha_stat.ss_fetch_success[i]);

	printf("fetch (peek) failure  (bucket=%d): %llu\n", i, shmq_header->header->sha_stat.ss_fetch_failure);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x1aaa(%rip), %r14      # 0x31ec
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x40(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
cmpq $0x8, %r15
jne 0x1745
leaq 0x1aab(%rip), %r14      # 0x3215
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x80(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
cmpq $0x8, %r15
jne 0x176d
leaq 0x1aa9(%rip), %r14      # 0x323e
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0xc0(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
cmpq $0x8, %r15
jne 0x1798
leaq 0x1aa7(%rip), %r14      # 0x3267
xorl %r15d, %r15d
movq (%rbx), %rax
movq 0x100(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
cmpq $0x8, %r15
jne 0x17c3
movq (%rbx), %rax
movq 0x140(%rax), %rdx
leaq 0x1a9b(%rip), %rdi      # 0x3290
movl $0x8, %esi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x1070
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_new
struct shmqueue *
shmqueue_new(int shmid, size_t size, int reuse, int verbose)
{
	struct shmqueue *shmqueue;
	void *mem;
	int id, rc;

	if (size == 0) {
		id = shmget(shmid, size, 0);
	} else {
		id = shmget(shmid, size,
#ifdef SHM_HUGETLB
//		    SHM_HUGETLB |
#endif
		    IPC_EXCL | IPC_CREAT | 0666);
		reuse = 0;
	}
	if (id == -1)
		return NULL;

	mem = shmat(id, NULL, 0);
	if (mem == NULL)
		return NULL;

	if (verbose) {
		printf("shmid = %d\n", id);
	}

	shmqueue = malloc(sizeof(struct shmqueue));
	if (shmqueue == NULL)
		return NULL;

	if (!reuse) {
		if (verbose) {
			printf("create memory: %p[%llu]\n", mem, (unsigned long long)size);
		}
		if (shmqueue_create(shmqueue, mem, size) < 0) {
			rc = shmctl(id, IPC_RMID, NULL);
			return NULL;
		}
	} else {
		if (shmqueue_attach(shmqueue, mem) < 0) {
			rc = shmctl(id, IPC_RMID, NULL);
			return NULL;
		}
		if (verbose) {
			printf("attach memory: %p[%llu]\n", mem, (unsigned long long)shmqueue->header->sha_memsize);
		}
	}
	return shmqueue;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rsi, %rbx
testq %rsi, %rsi
je 0x1830
movq %rbx, %rsi
movl $0x7b6, %edx            # imm = 0x7B6
callq 0x1100
movl %eax, %ebp
movb $0x1, %r13b
jmp 0x1845
movl %edx, %r14d
xorl %esi, %esi
xorl %edx, %edx
callq 0x1100
movl %eax, %ebp
testl %r14d, %r14d
sete %r13b
cmpl $-0x1, %ebp
je 0x18c7
xorl %r14d, %r14d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10f0
testq %rax, %rax
je 0x18ca
movq %rax, %r12
testl %r15d, %r15d
je 0x1875
leaq 0x1a4d(%rip), %rdi      # 0x32b9
movl %ebp, %esi
xorl %eax, %eax
callq 0x1070
movl $0x10, %edi
callq 0x10c0
testq %rax, %rax
je 0x18c7
movq %rax, %r14
testb %r13b, %r13b
je 0x18dc
testl %r15d, %r15d
je 0x18a5
leaq 0x1a2d(%rip), %rdi      # 0x32c5
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1907
testl %eax, %eax
jns 0x18ca
xorl %r14d, %r14d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10d0
jmp 0x18ca
xorl %r14d, %r14d
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r12, (%r14)
leaq -0x602(%rip), %rax      # 0x12e4
movq %rax, 0x8(%r14)
testl %r15d, %r15d
je 0x18ca
movq 0x20(%r12), %rdx
leaq 0x19e3(%rip), %rdi      # 0x32de
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
jmp 0x18ca
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_init
void
shmqueue_init(struct shmqueue_header *header)
{
	int i;

	/* init queue headers */
	RTAILQ_INIT(&header->sha_freelist);
	RTAILQ_INIT(&header->sha_lrulist);

	for (i = 0; i < header->sha_hashnum; i++)
		RTAILQ_INIT(&header->sha_hashlist[i]);

	/* insert all itempool to freelist */
	header->sha_item_inuse = 0;
	for (i = 0; i < header->sha_itemnum; i++) {
		RTAILQ_INSERT_TAIL(&header->sha_freelist,
		    &header->sha_pool[i], shmqueue_item, shi_list);
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movl 0x28(%rdi), %edx
testq %rdx, %rdx
je 0x1aca
leaq 0x150(%rbx), %rdi
shlq $0x4, %rdx
xorl %esi, %esi
callq 0x1080
movl $0x0, 0x34(%rbx)
cmpl $0x0, 0x30(%rbx)
je 0x1b1f
movq 0x38(%rbx), %rdx
movq %rbx, %rax
negq %rax
xorl %ecx, %ecx
xorl %esi, %esi
movq $0x0, (%rdx,%rcx)
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rdx
movq %rdi, 0x8(%rdx,%rcx)
movq 0x38(%rbx), %rdx
leaq (%rax,%rcx), %r8
addq %rdx, %r8
movq %r8, (%rdi,%rbx)
movq %r8, 0x8(%rbx)
incq %rsi
movl 0x30(%rbx), %edi
addq $0x800, %rcx            # imm = 0x800
cmpq %rdi, %rsi
jb 0x1ae5
popq %rbx
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_remove_from_freelist
struct shmqueue_item *
shmqueue_remove_from_freelist(struct shmqueue *shmq_header)
{
	struct shmqueue_header *header;
	struct shmqueue_item *item;

	header = shmq_header->header;

	shmqueue_lock(shmq_header);

	item = RTAILQ_FIRST(&header->sha_freelist, shmqueue_item);
	if (item == NULL) {
		shmqueue_unlock(shmq_header);
		return NULL;
	}

	/* remove from FREE list */
	RTAILQ_REMOVE(&header->sha_freelist,
	    item, shmqueue_item, shi_list);

	shmqueue_unlock(shmq_header);

	item->shi_hashidx = 0;
	item->shi_keyvalue.kv_keysize = 1;
	item->shi_keyvalue.kv_storagesize = 0;
	item->shi_keyvalue.kv_data[0] = '\0';

	return item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movq (%rdi), %r15
leaq 0x148(%r15), %rdi
callq 0x2648
movq (%r15), %rbx
testq %rbx, %rbx
setne %al
addq %r15, %rbx
setne %cl
testb %cl, %al
jne 0x1b61
movl $0x148, %edi            # imm = 0x148
addq (%r14), %rdi
callq 0x2668
xorl %ebx, %ebx
jmp 0x1ba4
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
leaq (%rax,%r15), %rdx
testq %rax, %rax
cmoveq %r15, %rdx
movq %rcx, 0x8(%rdx)
movq (%rbx), %rax
movq %rax, (%rcx,%r15)
movl $0x148, %edi            # imm = 0x148
addq (%r14), %rdi
callq 0x2668
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x20(%rbx)
movl $0x0, 0x28(%rbx)
movb $0x0, 0x2c(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_add_to_lru
int
shmqueue_add_to_lru(struct shmqueue *shmq_header, struct shmqueue_item *item, uint32_t hashidx)
{
	struct shmqueue_header *header;

	header = shmq_header->header;
	item->shi_hashidx = hashidx;

	shmqueue_lock(shmq_header);

	/* insert to LRU list */
	RTAILQ_INSERT_HEAD(&header->sha_lrulist,
	    item, shmqueue_item, shi_list);

	/* insert to HASH list */
	RTAILQ_INSERT_HEAD(&header->sha_hashlist[item->shi_hashidx],
	    item, shmqueue_item, shi_hashlist);

	header->sha_item_inuse++;

	shmqueue_unlock(shmq_header);

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %r12
movl %edx, 0x20(%rsi)
movl $0x148, %r14d           # imm = 0x148
movq (%rdi), %rdi
addq %r14, %rdi
callq 0x2648
leaq 0x10(%r12), %rax
movq 0x10(%r12), %rcx
movq %r15, %rdx
subq %rax, %rdx
leaq 0x18(%r12), %rax
testq %rcx, %rcx
leaq 0x18(%rcx,%r12), %rsi
cmoveq %rax, %rsi
movq %rcx, (%r15)
movq %rdx, (%rsi)
movq %rdx, 0x10(%r12)
xorl %eax, %eax
movq %rax, 0x8(%r15)
movl 0x20(%r15), %ecx
shlq $0x4, %rcx
leaq (%r12,%rcx), %rdx
addq $0x150, %rdx            # imm = 0x150
addq %r12, %rcx
addq $0x158, %rcx            # imm = 0x158
movq -0x8(%rcx), %rsi
leaq 0x10(%r15), %rdi
subq %rdx, %rdi
testq %rsi, %rsi
leaq 0x18(%rsi,%rdx), %rdx
cmoveq %rcx, %rdx
movq %rsi, 0x10(%r15)
movq %rdi, (%rdx)
movl 0x20(%r15), %ecx
shlq $0x4, %rcx
addq %r12, %rcx
addq $0x150, %rcx            # imm = 0x150
movq %r15, %rdx
subq %rcx, %rdx
movq %rdx, (%rcx)
movq %rax, 0x18(%r15)
incl 0x34(%r12)
addq (%rbx), %r14
movq %r14, %rdi
callq 0x2668
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_remove_from_lru
struct shmqueue_item *
shmqueue_remove_from_lru(struct shmqueue *shmq_header)
{
	struct shmqueue_header *header;
	struct shmqueue_item *item;

	header = shmq_header->header;

	shmqueue_lock(shmq_header);

	/* get tail of LRU list */
	item = RTAILQ_LAST(&header->sha_lrulist, shmqueue_item);
	if (item == NULL) {
		shmqueue_unlock(shmq_header);
		return NULL;
	}

	/* remove from LRU list */
	RTAILQ_REMOVE(&header->sha_lrulist,
	    item, shmqueue_item, shi_list);

	/* remove from HASH list */
	RTAILQ_REMOVE(&header->sha_hashlist[item->shi_hashidx],
	    item, shmqueue_item, shi_hashlist);

	header->sha_item_inuse--;

	shmqueue_unlock(shmq_header);

	return item;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq (%rdi), %r15
leaq 0x148(%r15), %rdi
callq 0x2648
leaq 0x10(%r15), %rax
movq 0x18(%r15), %rcx
movq 0x18(%rcx,%r15), %rcx
movq 0x10(%rcx,%r15), %r14
testq %r14, %r14
sete %cl
addq %rax, %r14
sete %dl
orb %cl, %dl
je 0x1cba
xorl %r14d, %r14d
jmp 0x1d29
leaq 0x18(%r15), %rcx
movq (%r14), %rdx
movq 0x8(%r14), %rsi
testq %rdx, %rdx
leaq 0x8(%rdx,%rax), %rax
cmoveq %rcx, %rax
movq %rsi, (%rax)
movq (%r14), %rax
movq %rax, 0x10(%r15,%rsi)
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movl 0x20(%r14), %edx
shlq $0x4, %rdx
testq %rax, %rax
leaq 0x158(%r15,%rdx), %rsi
leaq 0x150(%r15,%rdx), %rdx
leaq 0x18(%rax,%rdx), %rax
cmoveq %rsi, %rax
movq %rcx, (%rax)
movq 0x10(%r14), %rax
movl 0x20(%r14), %edx
shlq $0x4, %rdx
addq %r15, %rdx
addq $0x150, %rdx            # imm = 0x150
movq %rax, (%rcx,%rdx)
decl 0x34(%r15)
movl $0x148, %edi            # imm = 0x148
addq (%rbx), %rdi
callq 0x2668
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_add_to_freelist
void
shmqueue_add_to_freelist(struct shmqueue *shmq_header, struct shmqueue_item *item)
{
	struct shmqueue_header *header;

	header = shmq_header->header;

	shmqueue_lock(shmq_header);

	/* insert to FREE list */
	RTAILQ_INSERT_HEAD(&header->sha_freelist,
	    item, shmqueue_item, shi_list);

	shmqueue_unlock(shmq_header);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %r12
movl $0x148, %r15d           # imm = 0x148
leaq (%r12,%r15), %rdi
callq 0x2648
movq (%r12), %rax
movq %rax, (%rbx)
movq %rbx, %rcx
subq %r12, %rcx
leaq (%rax,%r12), %rdx
testq %rax, %rax
cmoveq %r12, %rdx
movq %rcx, 0x8(%rdx)
movq %rcx, (%r12)
movq $0x0, 0x8(%rbx)
addq (%r14), %r15
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2668
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_keyvalue_peek
const struct keyvalue *
shmqueue_keyvalue_peek(struct shmqueue *shmq_header, uint8_t *key)
{
	struct shmqueue_header *header;
	struct shmqueue_item *item;
	uint32_t hashidx;

	header = shmq_header->header;
	hashidx = shmq_header->hash_callback(key) % header->sha_hashnum;

	shmqueue_lock(shmq_header);
	for (item = RTAILQ_FIRST(&header->sha_hashlist[hashidx], shmqueue_item);
	    item != NULL;
	    item = RTAILQ_NEXT(item, &header->sha_hashlist[hashidx], shmqueue_item, shi_hashlist)) {

		if (SHMQUEUE_STRCMP(KEYVALUE_KEY(&item->shi_keyvalue), key) == 0) {
			/* found! */

			/*
			 * move to top of LRU.
			 * delete from LRU, and insert to top
			 */
			RTAILQ_REMOVE(&header->sha_lrulist,
			    item, shmqueue_item, shi_list);
			RTAILQ_INSERT_HEAD(&header->sha_lrulist,
			    item, shmqueue_item, shi_list);

			/* update statistics */
			header->sha_stat.ss_fetch_success[SIZE2BUCKET(item->shi_keyvalue.kv_storagesize)]++;

			shmqueue_unlock(shmq_header);
			return &item->shi_keyvalue;
		}
	}

	/* update statistics */
	header->sha_stat.ss_fetch_failure++;

	shmqueue_unlock(shmq_header);
	return NULL;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %r12
movq %rsi, %rdi
callq *0x8(%rbx)
xorl %edx, %edx
divl 0x28(%r12)
movl %edx, %r14d
movl $0x148, %edi            # imm = 0x148
addq (%rbx), %rdi
callq 0x2648
shlq $0x4, %r14
leaq (%r12,%r14), %r13
addq $0x150, %r13            # imm = 0x150
movq (%r13), %r14
testq %r14, %r14
sete %al
addq %r13, %r14
sete %cl
orb %al, %cl
je 0x1dfe
addq $0x140, %r12            # imm = 0x140
xorl %r14d, %r14d
jmp 0x1ece
leaq 0x2c(%r14), %rdi
movq %r15, %rsi
callq 0x1090
testl %eax, %eax
je 0x1e1e
movq 0x10(%r14), %r14
testq %r14, %r14
je 0x1def
addq %r13, %r14
jne 0x1dfe
jmp 0x1def
movq (%r14), %rax
movq 0x8(%r14), %rcx
leaq 0x18(%r12), %rdx
leaq 0x10(%r12), %rsi
testq %rax, %rax
leaq 0x18(%rax,%r12), %rax
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq (%r14), %rax
movq %rax, 0x10(%rcx,%r12)
movq 0x10(%r12), %rax
movq %rax, (%r14)
movq %r14, %rcx
subq %rsi, %rcx
testq %rax, %rax
leaq 0x18(%rax,%r12), %rax
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq %rcx, 0x10(%r12)
movq $0x0, 0x8(%r14)
addq $0x100, %r12            # imm = 0x100
movl 0x28(%r14), %ecx
cmpl $0x3ff, %ecx            # imm = 0x3FF
ja 0x1e95
cmpl $0xff, %ecx
ja 0x1eaa
xorl %eax, %eax
cmpl $0x7f, %ecx
seta %al
jmp 0x1ec6
cmpl $0xfff, %ecx            # imm = 0xFFF
ja 0x1eb7
cmpl $0x800, %ecx            # imm = 0x800
movl $0x5, %eax
jmp 0x1ec2
cmpl $0x200, %ecx            # imm = 0x200
movl $0x3, %eax
jmp 0x1ec2
cmpl $0x4000, %ecx           # imm = 0x4000
movl $0x7, %eax
sbbq $0x0, %rax
addq $0x24, %r14
leaq (%r12,%rax,8), %r12
incq (%r12)
movl $0x148, %edi            # imm = 0x148
addq (%rbx), %rdi
callq 0x2668
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_keyvalue_delete
int
shmqueue_keyvalue_delete(struct shmqueue *shmq_header, uint8_t *key)
{
	struct shmqueue_header *header;
	struct shmqueue_item *item;
	uint32_t hashidx;

	header = shmq_header->header;
	hashidx = shmq_header->hash_callback(key) % header->sha_hashnum;

	shmqueue_lock(shmq_header);
	for (item = RTAILQ_FIRST(&header->sha_hashlist[hashidx], shmqueue_item);
	    item != NULL;
	    item = RTAILQ_NEXT(item, &header->sha_hashlist[hashidx], shmqueue_item, shi_hashlist)) {

		if (SHMQUEUE_STRCMP(KEYVALUE_KEY(&item->shi_keyvalue), key) == 0) {
			/* found! */

			/* remove from LRU list */
			RTAILQ_REMOVE(&header->sha_lrulist,
			    item, shmqueue_item, shi_list);
			/* remove from HASH list */
			RTAILQ_REMOVE(&header->sha_hashlist[item->shi_hashidx],
			    item, shmqueue_item, shi_hashlist);

			header->sha_item_inuse--;

			/* insert to FREE list */
			RTAILQ_INSERT_HEAD(&header->sha_freelist,
			    item, shmqueue_item, shi_list);

			shmqueue_unlock(shmq_header);
			return 0;
		}
	}
	shmqueue_unlock(shmq_header);

	return -1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq (%rdi), %r13
movq %rsi, %rdi
callq *0x8(%rbx)
xorl %edx, %edx
divl 0x28(%r13)
movl %edx, %r12d
movl $0x148, %r14d           # imm = 0x148
movq (%rbx), %rdi
addq %r14, %rdi
callq 0x2648
shlq $0x4, %r12
leaq (%r12,%r13), %rbp
addq $0x150, %rbp            # imm = 0x150
movq (%rbp), %r12
testq %r12, %r12
sete %al
addq %rbp, %r12
sete %cl
orb %al, %cl
je 0x2485
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x254b
leaq 0x150(%r13), %rax
movq %rax, (%rsp)
leaq 0x2c(%r12), %rdi
movq %r15, %rsi
callq 0x1090
testl %eax, %eax
je 0x24b2
movq 0x10(%r12), %r12
testq %r12, %r12
je 0x247b
addq %rbp, %r12
jne 0x2490
jmp 0x247b
movq (%r12), %rax
movq 0x8(%r12), %rcx
leaq 0x18(%r13), %rdx
testq %rax, %rax
leaq 0x18(%rax,%r13), %rax
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq (%r12), %rax
movq %rax, 0x10(%rcx,%r13)
movq 0x10(%r12), %rax
movq 0x18(%r12), %rcx
movl 0x20(%r12), %edx
shlq $0x4, %rdx
movq (%rsp), %rdi
leaq (%rdi,%rdx), %rsi
testq %rax, %rax
leaq 0x8(%rdi,%rdx), %rdx
leaq 0x18(%rax,%rsi), %rax
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq 0x10(%r12), %rax
movl 0x20(%r12), %edx
shlq $0x4, %rdx
addq %rdi, %rdx
movq %rax, (%rcx,%rdx)
decl 0x34(%r13)
movq (%r13), %rax
movq %rax, (%r12)
movq %r12, %rcx
subq %r13, %rcx
leaq (%rax,%r13), %rdx
testq %rax, %rax
cmoveq %r13, %rdx
movq %rcx, 0x8(%rdx)
movq %rcx, (%r13)
movq $0x0, 0x8(%r12)
xorl %ebp, %ebp
addq (%rbx), %r14
movq %r14, %rdi
callq 0x2668
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_inuse
int
shmqueue_inuse(struct shmqueue *shmq_header)
{
	int inuse;

	shmqueue_lock(shmq_header);
	inuse = shmq_header->header->sha_item_inuse;
	shmqueue_unlock(shmq_header);

	return inuse;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x148, %r14d           # imm = 0x148
movq (%rdi), %rdi
addq %r14, %rdi
callq 0x2648
movq (%rbx), %rdi
movl 0x34(%rdi), %ebx
addq %r14, %rdi
callq 0x2668
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_watermark
int
shmqueue_watermark(struct shmqueue *shmq_header)
{
	/*
	 * usage rate reaches 87.5%? (7/8)
	 */
	int mark = 0;

	shmqueue_lock(shmq_header);
	if (shmq_header->header->sha_itemnum -
	    (shmq_header->header->sha_itemnum / 8) <
	    shmq_header->header->sha_item_inuse)
		mark = 1;
	shmqueue_unlock(shmq_header);
	return mark;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x148, %r14d           # imm = 0x148
movq (%rdi), %rdi
addq %r14, %rdi
callq 0x2648
movq (%rbx), %rdi
movl 0x30(%rdi), %eax
movl %eax, %ecx
shrl $0x3, %ecx
subl %ecx, %eax
xorl %ebx, %ebx
cmpl 0x34(%rdi), %eax
setb %bl
addq %r14, %rdi
callq 0x2668
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_getoldest
int
shmqueue_getoldest(struct shmqueue *shmq_header, struct keyvalue *keyvalue)
{
	struct shmqueue_item *item;

	item = shmqueue_remove_from_lru(shmq_header);
	if (item == NULL)
		return -1;

	keyvalue->kv_keysize = item->shi_keyvalue.kv_keysize;
	keyvalue->kv_storagesize = item->shi_keyvalue.kv_storagesize;

	memcpy(keyvalue->kv_data, item->shi_keyvalue.kv_data, keyvalue->kv_keysize + keyvalue->kv_storagesize);
	KEYVALUE_STORAGE(keyvalue)[keyvalue->kv_storagesize] = '\0';

	shmqueue_add_to_freelist(shmq_header, item);

	return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
callq 0x1c7c
testq %rax, %rax
je 0x2632
movq %rax, %r15
movl 0x24(%rax), %r12d
movl %r12d, (%r14)
movl 0x28(%rax), %r13d
movl %r13d, 0x4(%r14)
leaq 0x8(%r14), %rdi
movq %rax, %rsi
addq $0x2c, %rsi
leal (%r12,%r13), %edx
callq 0x10a0
leaq (%r14,%r12), %rax
addq $0x8, %rax
movb $0x0, (%r13,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1d3f
xorl %eax, %eax
jmp 0x2637
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/main.c
// Function: print_help
void print_help()
{
    printf("help message\n\n");
    printf("-I\t\tinit oled (128x32 or 128x64 or 64x48)\n");
    printf("-c\t\tclear (line number or all)\n");
    printf("-d\t\t0/display off 1/display on\n");
    printf("-f\t\t0/small font 5x7 1/normal font 8x8 (default normal font)\n");
    printf("-h\t\thelp message\n");
    printf("-i\t\t0/normal oled 1/invert oled\n");
    printf("-l\t\tput your line to display\n");
    printf("-m\t\tput your strings to oled\n");
    printf("-n\t\tI2C device node address (0,1,2..., default 0)\n");
    printf("-r\t\t0/normal 180/rotate\n");
    printf("-x\t\tx position\n");
    printf("-y\t\ty position\n");
}

// Assembly:
pushq %rax
leaq 0xbc777(%rip), %rdi     # 0x4be197
callq 0x41b810
leaq 0xbc779(%rip), %rdi     # 0x4be1a5
callq 0x41b810
leaq 0xbc797(%rip), %rdi     # 0x4be1cf
callq 0x41b810
leaq 0xbc7aa(%rip), %rdi     # 0x4be1ee
callq 0x41b810
leaq 0xbc7bd(%rip), %rdi     # 0x4be20d
callq 0x41b810
leaq 0xbc7ee(%rip), %rdi     # 0x4be24a
callq 0x41b810
leaq 0xbc7f3(%rip), %rdi     # 0x4be25b
callq 0x41b810
leaq 0xbc807(%rip), %rdi     # 0x4be27b
callq 0x41b810
leaq 0xbc818(%rip), %rdi     # 0x4be298
callq 0x41b810
leaq 0xbc829(%rip), %rdi     # 0x4be2b5
callq 0x41b810
leaq 0xbc84f(%rip), %rdi     # 0x4be2e7
callq 0x41b810
leaq 0xbc85b(%rip), %rdi     # 0x4be2ff
callq 0x41b810
leaq 0xbc85e(%rip), %rdi     # 0x4be30e
popq %rax
jmp 0x41b810
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_init
uint8_t ssd1306_init(uint8_t i2c_dev)
{
    uint8_t rc;
    rc = _i2c_init(i2c_dev, SSD1306_I2C_ADDR);
    if (rc > 0)
        return rc;
        
    // test i2c connection
    uint8_t cmd = SSD1306_COMM_CONTROL_BYTE;
    uint8_t result = 0;
    _i2c_write(&cmd, 1);
    _i2c_read(&result, 1);
    if (result == 0)
        return 1;
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl $0x3c, %esi
callq 0x40266c
testb %al, %al
jne 0x401f3c
xorl %ebp, %ebp
leaq 0x7(%rsp), %rdi
movb %bpl, (%rdi)
leaq 0x6(%rsp), %rbx
movb %bpl, (%rbx)
movl $0x1, %esi
callq 0x40270f
movq %rbx, %rdi
movl $0x1, %esi
callq 0x40273b
cmpb %bpl, (%rbx)
sete %al
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_set_X
uint8_t ssd1306_oled_set_X(uint8_t x)
{
    if (x >= max_columns)
        return 1;

    global_x = x;
    
    data_buf[0] = SSD1306_COMM_CONTROL_BYTE;
    data_buf[1] = SSD1306_COMM_LOW_COLUMN | (x & 0x0f);
    data_buf[2] = SSD1306_COMM_HIGH_COLUMN | ((x >> 4) & 0x0f);
    
    return _i2c_write(data_buf, 3);
}

// Assembly:
cmpb %dil, 0xf0662(%rip)     # 0x4f27d0
jbe 0x4021ac
movb %dil, 0xf065a(%rip)     # 0x4f27d1
movb $0x0, 0xf0252(%rip)     # 0x4f23d0
leaq 0xf024b(%rip), %rax     # 0x4f23d0
movl %edi, %ecx
andb $0xf, %cl
movb %cl, 0xf0241(%rip)      # 0x4f23d1
shrb $0x4, %dil
orb $0x10, %dil
movb %dil, 0xf0233(%rip)     # 0x4f23d2
movq %rax, %rdi
movl $0x3, %esi
jmp 0x40270f
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_set_Y
uint8_t ssd1306_oled_set_Y(uint8_t y)
{
    if (y >= (max_lines / 8))
        return 1;

    global_y = y;
    
    data_buf[0] = SSD1306_COMM_CONTROL_BYTE;
    data_buf[1] = SSD1306_COMM_PAGE_NUMBER | (y & 0x0f);

    return _i2c_write(data_buf, 2);
}

// Assembly:
movb 0xf061d(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %dil, %al
jbe 0x4021ee
movb %dil, 0xf060f(%rip)     # 0x4f27d3
movb $0x0, 0xf0205(%rip)     # 0x4f23d0
leaq 0xf01fe(%rip), %rax     # 0x4f23d0
andb $0xf, %dil
orb $-0x50, %dil
movb %dil, 0xf01f0(%rip)     # 0x4f23d1
movq %rax, %rdi
movl $0x2, %esi
jmp 0x40270f
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_set_XY
uint8_t ssd1306_oled_set_XY(uint8_t x, uint8_t y)
{
    if (x >= max_columns || y >= (max_lines / 8))
        return 1;

    global_x = x;
    global_y = y;
    
    data_buf[0] = SSD1306_COMM_CONTROL_BYTE;
    data_buf[1] = SSD1306_COMM_PAGE_NUMBER | (y & 0x0f);

    data_buf[2] = SSD1306_COMM_LOW_COLUMN | (x & 0x0f);
    
    data_buf[3] = SSD1306_COMM_HIGH_COLUMN | ((x >> 4) & 0x0f);
    
    return _i2c_write(data_buf, 4);
}

// Assembly:
cmpb %dil, 0xf05d8(%rip)     # 0x4f27d0
jbe 0x40225a
movb 0xf05d2(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %sil, %al
jbe 0x40225a
movb %dil, 0xf05c2(%rip)     # 0x4f27d1
movb %sil, 0xf05bd(%rip)     # 0x4f27d3
movb $0x0, 0xf01b3(%rip)     # 0x4f23d0
leaq 0xf01ac(%rip), %rax     # 0x4f23d0
andb $0xf, %sil
orb $-0x50, %sil
movb %sil, 0xf019e(%rip)     # 0x4f23d1
movl %edi, %ecx
andb $0xf, %cl
movb %cl, 0xf0194(%rip)      # 0x4f23d2
shrb $0x4, %dil
orb $0x10, %dil
movb %dil, 0xf0186(%rip)     # 0x4f23d3
movq %rax, %rdi
movl $0x4, %esi
jmp 0x40270f
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_save_resolution
uint8_t ssd1306_oled_save_resolution(uint8_t column, uint8_t row)
{
    FILE* fp;
    
    fp = fopen(init_oled_type_file, "w");
    
    if (fp == NULL)
    {
        // file create failed
        return 1;
    }
    
    fprintf(fp, "%hhux%hhu", column, row);
    fclose(fp);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %ebp
movl %edi, %r14d
leaq 0xbc4fc(%rip), %rdi     # 0x4be870
leaq 0xbc510(%rip), %rsi     # 0x4be88b
callq 0x41b5d0
testq %rax, %rax
je 0x4023ad
movq %rax, %rbx
movzbl %r14b, %edx
movzbl %bpl, %ecx
leaq 0xbc4f6(%rip), %rsi     # 0x4be88d
xorl %ebp, %ebp
movq %rax, %rdi
xorl %eax, %eax
callq 0x40cb60
movq %rbx, %rdi
callq 0x41b190
jmp 0x4023b0
movb $0x1, %bpl
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_write_line
uint8_t ssd1306_oled_write_line(uint8_t size, char* ptr)
{
    uint16_t i = 0;
    uint16_t index = 0;
    uint8_t* font_table = 0;
    uint8_t font_table_width = 0;
    
    if (ptr == 0)
        return 1;
    
    if (size == SSD1306_FONT_SMALL) // 5x7
    {
        font_table = (uint8_t*)font5x7;
        font_table_width = 5;
    }
    else if (size == SSD1306_FONT_NORMAL) // 8x8
    {
        font_table = (uint8_t*)font8x8;
        font_table_width = 8;
    }
    else
        return 1;
    
    data_buf[i++] = SSD1306_DATA_CONTROL_BYTE;
    
    // font table range in ascii table is from 0x20(space) to 0x7e(~)
    while (ptr[index] != 0 && i <= 1024)
    {
        if ((ptr[index] < ' ') || (ptr[index] > '~'))
            return 1;

        uint8_t* font_ptr = &font_table[(ptr[index] - 0x20) * font_table_width];
        uint8_t j = 0;
        for (j = 0; j < font_table_width; j++)
        {
            data_buf[i++] = font_ptr[j];
            if (i > 1024)
                return 1;
        }
        // insert 1 col space for small font size)
        if (size == SSD1306_FONT_SMALL)
            data_buf[i++] = 0x00;
        index++;
    }
    
    return _i2c_write(data_buf, i);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rsi, %rsi
je 0x402492
testb %dil, %dil
je 0x4023e1
cmpb $0x1, %dil
jne 0x402492
movl $0x8, %ecx
leaq 0xbc191(%rip), %rax     # 0x4be570
jmp 0x4023ed
movl $0x5, %ecx
leaq 0xbbfa3(%rip), %rax     # 0x4be390
movb $0x40, 0xeffdc(%rip)    # 0x4f23d0
movb (%rsi), %r10b
testb %r10b, %r10b
je 0x402499
movl %ecx, %edx
movw $0x1, %cx
xorl %r8d, %r8d
leaq 0xeffc0(%rip), %r9      # 0x4f23d0
leal -0x7f(%r10), %r11d
cmpb $-0x5f, %r11b
jb 0x402492
addb $-0x20, %r10b
movzbl %r10b, %ebx
imulq %rdx, %rbx
addq %rax, %rbx
movzwl %cx, %r11d
xorl %r10d, %r10d
leaq (%r11,%r10), %r14
movb (%rbx,%r10), %bpl
movb %bpl, (%r9,%r14)
movzwl %r14w, %ebp
cmpl $0x3ff, %ebp            # imm = 0x3FF
ja 0x402492
incq %r10
cmpq %rdx, %r10
jb 0x402430
testb %dil, %dil
je 0x40245d
addq %r10, %r11
movl %r11d, %ecx
jmp 0x402473
leal 0x1(%rcx), %r11d
movzwl %r11w, %r11d
addq %r9, %r11
movb $0x0, -0x1(%r10,%r11)
addl %r10d, %ecx
incl %ecx
incl %r8d
movzwl %r8w, %r10d
movb (%rsi,%r10), %r10b
testb %r10b, %r10b
je 0x40249d
movzwl %cx, %r11d
cmpl $0x401, %r11d           # imm = 0x401
jb 0x402410
jmp 0x40249d
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movw $0x1, %cx
movswl %cx, %esi
leaq 0xeff29(%rip), %rdi     # 0x4f23d0
popq %rbx
popq %r14
popq %rbp
jmp 0x40270f
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_write_string
uint8_t ssd1306_oled_write_string(uint8_t size, char* ptr)
{
    uint8_t rc = 0;
    
    if (ptr == 0)
        return 1;
    
    char* line = 0;
    char* cr = 0;
    char buf[20];
    
    line = ptr;
    do {
        memset(buf, 0, 20);
        cr = strstr(line, "\\n");
        if (cr != NULL)
        {
            strncpy(buf, line, cr - line);
        }
        else
        {
            strcpy(buf, line);
        }
        
        // set cursor position
        ssd1306_oled_set_XY(global_x, global_y);
        rc += ssd1306_oled_write_line(size, buf);
        
        if (cr != NULL)
        {
            line = &cr[2];
            global_x = 0;
            global_y++;
            if (global_y >= (max_lines / 8))
                global_y = 0;
        }
        else
            line = NULL;
                
    }while (line != NULL);
    
    return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rsi, %rsi
je 0x402575
movq %rsi, %r13
leaq 0xbc3b7(%rip), %r14     # 0x4be888
movq %rsp, %r15
movzbl %dil, %ebp
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movl $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x401070
movq %rax, %r12
testq %rax, %rax
je 0x40250f
movq %r12, %rdx
subq %r13, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x401080
jmp 0x40251a
movq %r15, %rdi
movq %r13, %rsi
callq 0x401020
movzbl 0xf02b0(%rip), %edi     # 0x4f27d1
movzbl 0xf02ab(%rip), %esi     # 0x4f27d3
callq 0x4021f1
movl %ebp, %edi
movq %r15, %rsi
callq 0x4023b7
addb %al, %bl
testq %r12, %r12
je 0x402577
addq $0x2, %r12
movb $0x0, 0xf0288(%rip)     # 0x4f27d1
movb 0xf0284(%rip), %al      # 0x4f27d3
incb %al
movb 0xf027b(%rip), %cl      # 0x4f27d2
shrb $0x3, %cl
cmpb %cl, %al
movzbl %al, %eax
movl $0x0, %ecx
cmovael %ecx, %eax
movb %al, 0xf0266(%rip)      # 0x4f27d3
movq %r12, %r13
jmp 0x4024da
movb $0x1, %bl
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_clear_line
uint8_t ssd1306_oled_clear_line(uint8_t row)
{
    uint8_t i;
    if (row >= (max_lines / 8))
        return 1;
        
    ssd1306_oled_set_XY(0, row);
    data_buf[0] = SSD1306_DATA_CONTROL_BYTE;
    for (i = 0; i < max_columns; i++)
        data_buf[i+1] = 0x00;
        
    return _i2c_write(data_buf, 1 + max_columns);
}

// Assembly:
movb 0xf0244(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %dil, %al
jbe 0x4025d7
pushq %rbx
movzbl %dil, %esi
xorl %edi, %edi
callq 0x4021f1
movb $0x40, 0xefe27(%rip)    # 0x4f23d0
movzbl 0xf0220(%rip), %ebx     # 0x4f27d0
testq %rbx, %rbx
je 0x4025c6
leaq 0xefe15(%rip), %rdi     # 0x4f23d1
xorl %esi, %esi
movq %rbx, %rdx
callq 0x4010a0
incl %ebx
leaq 0xefe01(%rip), %rdi     # 0x4f23d0
movl %ebx, %esi
popq %rbx
jmp 0x40270f
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_clear_screen
uint8_t ssd1306_oled_clear_screen()
{
    uint8_t rc = 0;
    uint8_t i;
    
    for (i = 0; i < (max_lines / 8); i++)
    {
        rc += ssd1306_oled_clear_line(i);
    }
    
    return rc;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
cmpb $0x8, 0xf01ee(%rip)     # 0x4f27d2
jae 0x4025ea
xorl %ebx, %ebx
jmp 0x40260c
xorl %ebp, %ebp
xorl %ebx, %ebx
movzbl %bpl, %ebp
movl %ebp, %edi
callq 0x402588
addb %al, %bl
incb %bpl
movb 0xf01ce(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %al, %bpl
jb 0x4025ee
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_load_resolution
uint8_t ssd1306_oled_load_resolution()
{
    FILE* fp;
    
    fp = fopen(init_oled_type_file, "r");
    
    if (fp == NULL)
    {
        // file not exists
        return 1;
    }
    
    // file exists
    fscanf(fp, "%hhux%hhu", &max_columns, &max_lines);
    fclose(fp);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
leaq 0xbc251(%rip), %rdi     # 0x4be870
leaq 0xd7e21(%rip), %rsi     # 0x4da447
callq 0x41b5d0
testq %rax, %rax
je 0x40265e
movq %rax, %rbx
leaq 0xbc253(%rip), %rsi     # 0x4be88d
leaq 0xf018f(%rip), %rdx     # 0x4f27d0
leaq 0xf018a(%rip), %rcx     # 0x4f27d2
xorl %ebp, %ebp
movq %rax, %rdi
xorl %eax, %eax
callq 0x40cf40
movq %rbx, %rdi
callq 0x41b190
jmp 0x402661
movb $0x1, %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O3/armlabs[P]ssd1306_linux/linux_i2c.c
// Function: i2c_init
uint8_t _i2c_init(int i2c, int dev_addr)
{
	if (file_i2c == 0)
	{
		char filename[32];
  		sprintf(filename, "/dev/i2c-%d", i2c); // I2C bus number passed
		file_i2c = open(filename, O_RDWR);
		if (file_i2c < 0)
		{
			file_i2c = 0;
			return 1;
		}
		if (ioctl(file_i2c, I2C_SLAVE, dev_addr) < 0) // set slave address
		{
			close(file_i2c);
			file_i2c = 0;
			return 1;
		}
		return 0;
	}
	
	// assume done init already
	return 0;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
cmpl $0x0, 0xf0159(%rip)     # 0x4f27d4
je 0x402681
xorl %ebp, %ebp
jmp 0x4026e0
movl %esi, %ebx
movl %edi, %edx
leaq 0xbc20b(%rip), %rsi     # 0x4be897
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x40cdb0
movq %r14, %rdi
movl $0x2, %esi
xorl %eax, %eax
callq 0x45f6d0
movl %eax, 0xf0126(%rip)     # 0x4f27d4
testl %eax, %eax
js 0x4026d3
xorl %ebp, %ebp
movl $0x703, %esi            # imm = 0x703
movl %eax, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x4604b0
testl %eax, %eax
jns 0x4026e0
movl 0xf0106(%rip), %edi     # 0x4f27d4
callq 0x45f970
movl $0x0, 0xf00f7(%rip)     # 0x4f27d4
movb $0x1, %bpl
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilesr[P]dotter/./stb/stb_image_write.h
// Function: stbiw__write_run_data
void stbiw__write_run_data(stbi__write_context *s, int length, unsigned char databyte)
{
   unsigned char lengthbyte = STBIW_UCHAR(length+128);
   STBIW_ASSERT(length+128 <= 255);
   s->func(s->context, &lengthbyte, 1);
   s->func(s->context, &databyte, 1);
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movb %dl, 0xf(%rsp)
leal -0x80(%rsi), %eax
movb %al, 0xe(%rsp)
cmpl $0x80, %esi
jge 0x18d9
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
leaq 0xe(%rsp), %rsi
movl $0x1, %edx
callq *(%rbx)
movq 0x8(%rbx), %rdi
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
callq *(%rbx)
addq $0x10, %rsp
popq %rbx
retq
leaq 0x96d8(%rip), %rdi      # 0xafb8
leaq 0x96e3(%rip), %rsi      # 0xafca
leaq 0x96f4(%rip), %rcx      # 0xafe2
movl $0x203, %edx            # imm = 0x203
callq 0x1080
// File: /workspace/github_c_makefile_star2_O3/nilesr[P]dotter/./stb/stb_image_write.h
// Function: stbiw__write_dump_data
void stbiw__write_dump_data(stbi__write_context *s, int length, unsigned char *data)
{
   unsigned char lengthbyte = STBIW_UCHAR(length);
   STBIW_ASSERT(length <= 128); // inconsistent with spec but consistent with official code
   s->func(s->context, &lengthbyte, 1);
   s->func(s->context, data, length);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ebp
movb %bpl, 0xf(%rsp)
cmpl $0x81, %esi
jge 0x1939
movq %rdx, %r14
movq %rdi, %rbx
movq 0x8(%rdi), %rdi
leaq 0xf(%rsp), %rsi
movl $0x1, %edx
callq *(%rbx)
movq 0x8(%rbx), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq *(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x96e8(%rip), %rdi      # 0xb028
leaq 0x9683(%rip), %rsi      # 0xafca
leaq 0x96e8(%rip), %rcx      # 0xb036
movl $0x20b, %edx            # imm = 0x20B
callq 0x1080
// File: /workspace/github_c_makefile_star2_O3/nilesr[P]dotter/./stb/stb_image_write.h
// Function: stbi_write_hdr_core
static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, float *data)
{
   if (y <= 0 || x <= 0 || data == NULL)
      return 0;
   else {
      // Each component is stored separately. Allocate scratch space for full output scanline.
      unsigned char *scratch = (unsigned char *) STBIW_MALLOC(x*4);
      int i, len;
      char buffer[128];
      char header[] = "#?RADIANCE\n# Written by stb_image_write.h\nFORMAT=32-bit_rle_rgbe\n";
      s->func(s->context, header, sizeof(header)-1);

      len = sprintf(buffer, "EXPOSURE=          1.0000000000000\n\n-Y %d +X %d\n", y, x);
      s->func(s->context, buffer, len);

      for(i=0; i < y; i++)
         stbiw__write_hdr_scanline(s, x, comp, scratch, data + comp*i*x);
      STBIW_FREE(scratch);
      return 1;
   }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %ecx, 0x4(%rsp)
movl %edx, %ebp
movq %rdi, 0x8(%rsp)
testl %edx, %edx
setle %al
testl %esi, %esi
setle %cl
orb %al, %cl
testq %r8, %r8
sete %dl
xorl %eax, %eax
orb %cl, %dl
jne 0x1d27
movl %esi, %r14d
leal (,%r14,4), %edi
movq %r8, %r15
callq 0x1100
movq %rax, %r12
leaq 0x9ca9(%rip), %rsi      # 0xb940
leaq 0x90(%rsp), %rax
movl $0x8, %ecx
movq %rax, %rdi
rep  movsq (%rsi), %es:(%rdi)
movw $0xa, 0x40(%rax)
movq 0x8(%rsp), %rbx
movq 0x8(%rbx), %rdi
movq %rax, %rsi
movl $0x41, %edx
callq *(%rbx)
leaq 0x9612(%rip), %rsi      # 0xb2dc
xorl %r13d, %r13d
leaq 0x10(%rsp), %rdi
movl %ebp, %edx
movl %r14d, %ecx
xorl %eax, %eax
callq 0x1180
movq 0x8(%rbx), %rdi
leaq 0x10(%rsp), %rsi
movl %eax, %edx
callq *(%rbx)
movl %ebp, %eax
movl 0x4(%rsp), %ebp
imull %r14d, %ebp
movl %eax, %ebx
movslq %r13d, %r13
leaq (%r15,%r13,4), %r8
movq 0x8(%rsp), %rdi
movl %r14d, %esi
movl 0x4(%rsp), %edx
movq %r12, %rcx
callq 0x1958
addl %ebp, %r13d
decq %rbx
jne 0x1cf7
movq %r12, %rdi
callq 0x1030
movl $0x1, %eax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilesr[P]dotter/./stb/stb_image_write.h
// Function: stbi_write_png
STBIWDEF int stbi_write_png(char const *filename, int x, int y, int comp, const void *data, int stride_bytes)
{
   FILE *f;
   int len;
   unsigned char *png = stbi_write_png_to_mem((unsigned char *) data, stride_bytes, x, y, comp, &len);
   if (png == NULL) return 0;
   f = fopen(filename, "wb");
   if (!f) { STBIW_FREE(png); return 0; }
   fwrite(png, 1, len, f);
   fclose(f);
   STBIW_FREE(png);
   return 1;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %r9d, %r10d
movl %ecx, %eax
movl %edx, %ecx
movl %esi, %edx
movq %rdi, %r14
leaq 0xc(%rsp), %r9
movq %r8, %rdi
movl %r10d, %esi
movl %eax, %r8d
callq 0x268a
testq %rax, %rax
je 0x2cc4
movq %rax, %rbx
leaq 0x84b2(%rip), %rsi      # 0xb142
movq %r14, %rdi
callq 0x1160
testq %rax, %rax
je 0x2cc8
movq %rax, %r14
movslq 0xc(%rsp), %rdx
movl $0x1, %esi
movq %rbx, %rdi
movq %rax, %rcx
callq 0x1190
movq %r14, %rdi
callq 0x1060
movl $0x1, %ebp
jmp 0x2cca
xorl %ebp, %ebp
jmp 0x2cd2
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x1030
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/nilesr[P]dotter/dotter.c
// Function: dist
double dist(uint8_t* a, uint8_t* b, box_t box, int width) {
   double res = 0;
   // Add up the differences in each pixel
   for (int x = box.x1; x < box.x2; x++) {
      for (int y = box.y1; y < box.y2; y++) {
         res += subtract(getpixel(a, x, y, width), getpixel(b, x, y, width));
      }
   }
   // divide by the area (width*height) of the box
   return res / ((box.x2 - box.x1) * (box.y2 - box.y1));
}

// Assembly:
movq %rdx, %rax
shrq $0x20, %rax
movq %rcx, %r9
shrq $0x20, %r9
xorpd %xmm0, %xmm0
movl %ecx, %r10d
subl %edx, %r10d
jle 0x4cde
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %rbx
sarq $0x20, %rbx
movslq %r8d, %r11
movslq %edx, %rdx
movslq %ecx, %r8
sarq $0x20, %rcx
leaq (%r11,%r11,2), %r11
movq %r11, %r14
imulq %rbx, %r14
leaq (%rdx,%rdx,2), %r15
addq %r14, %r15
addq %r15, %rdi
addq $0x2, %rdi
addq %r15, %rsi
addq $0x2, %rsi
subq %rbx, %rcx
xorpd %xmm0, %xmm0
cmpl %eax, %r9d
jle 0x4cc6
movq %rcx, %rbx
xorl %r14d, %r14d
movzbl -0x2(%rdi,%r14), %ebp
movzbl -0x2(%rsi,%r14), %r15d
subl %r15d, %ebp
imull %ebp, %ebp
movzbl -0x1(%rdi,%r14), %r15d
movzbl -0x1(%rsi,%r14), %r12d
subl %r12d, %r15d
imull %r15d, %r15d
addl %ebp, %r15d
movzbl (%rdi,%r14), %ebp
movzbl (%rsi,%r14), %r12d
subl %r12d, %ebp
imull %ebp, %ebp
addl %r15d, %ebp
xorps %xmm1, %xmm1
cvtsi2sd %ebp, %xmm1
sqrtsd %xmm1, %xmm1
addsd %xmm1, %xmm0
addq %r11, %r14
decq %rbx
jne 0x4c74
incq %rdx
addq $0x3, %rdi
addq $0x3, %rsi
cmpq %r8, %rdx
jne 0x4c69
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
subl %eax, %r9d
imull %r10d, %r9d
xorps %xmm1, %xmm1
cvtsi2sd %r9d, %xmm1
divsd %xmm1, %xmm0
retq