LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/mati75[P]evilwm/xconfig.c
// Function: unset_option
static void unset_option(struct xconfig_option *option) {
	switch (option->type) {
	case XCONFIG_STRING:
		if (*(char **)option->dest.s) {
			free(*(char **)option->dest.s);
			*(char **)option->dest.s = NULL;
		}
		break;
	case XCONFIG_STR_LIST:
		if (*(char ***)option->dest.sl) {
			if ((*(char ***)option->dest.sl)[0]) {
				free((*(char ***)option->dest.sl)[0]);
			}
			free(*(char ***)option->dest.sl);
			*(char ***)option->dest.sl = NULL;
		}
		break;
	default:
		break;
	}
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %eax
cmpl $0x4, %eax
je 0x998d
cmpl $0x3, %eax
jne 0x99b7
movq 0x10(%rbx), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x99b7
addq $0x10, %rbx
jmp 0x99ab
movq 0x10(%rbx), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x99b7
addq $0x10, %rbx
movq (%rax), %rdi
callq 0x42d0
movq (%rbx), %rax
movq (%rax), %rdi
callq 0x42d0
movq (%rbx), %rax
andq $0x0, (%rax)
popq %rbx
retq
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O2/mati75[P]evilwm/xmalloc.c
// Function: xmalloc
void *xmalloc(size_t s) {
	void *mem = malloc(s);
	if (!mem) {
		perror(NULL);
		exit(EXIT_FAILURE);
	}
	return mem;
}

// Assembly:
pushq %rax
callq 0x41e0
testq %rax, %rax
je 0x99c9
popq %rcx
retq
xorl %edi, %edi
callq 0x46e0
pushq $0x1
popq %rdi
callq 0x4160
// File: /workspace/github_c_makefile_star2_O2/mati75[P]evilwm/xmalloc.c
// Function: xrealloc
void *xrealloc(void *p, size_t s) {
	void *mem = realloc(p, s);
	if (!mem && s != 0) {
		perror(NULL);
		exit(EXIT_FAILURE);
	}
	return mem;
}

// Assembly:
pushq %rbx
movq %rsi, %rbx
callq 0x46c0
testq %rax, %rax
setne %cl
testq %rbx, %rbx
sete %dl
orb %cl, %dl
je 0x9a0a
popq %rbx
retq
xorl %edi, %edi
callq 0x46e0
pushq $0x1
popq %rdi
callq 0x4160
// File: /workspace/github_c_makefile_star2_O2/jacereda[P]fsatrace/src/fsatrace.c
// Function: dump
static void
dump(const char *path, char *p, size_t sz)
{
	int	fd;
	ssize_t r = 0;
	if (strcmp(path, "-"))
		fd = open(path, O_CREAT | O_WRONLY | O_TRUNC, 0777);
	else
		fd = 1;
	if (fd >= 0)
		r = write(fd, p, sz);
	else
		error("Unable to open output file '%s'", path);
	if (r != sz)
		error("Short write (%d/%d)", r, sz);
	if (fd != 1)
		close(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
cmpb $0x2d, (%rdi)
jne 0x1783
cmpb $0x0, 0x1(%r15)
je 0x17b3
movq %r15, %rdi
movl $0x241, %esi            # imm = 0x241
movl $0x1ff, %edx            # imm = 0x1FF
xorl %eax, %eax
callq 0x11a0
movl %eax, %ebp
testl %eax, %eax
jns 0x17b6
leaq 0xab7(%rip), %rdi       # 0x225b
xorl %r14d, %r14d
movq %r15, %rsi
xorl %eax, %eax
callq 0x1800
jmp 0x17c6
pushq $0x1
popq %rbp
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1090
movq %rax, %r14
cmpq %rbx, %r14
je 0x17df
leaq 0xaa9(%rip), %rdi       # 0x227b
movq %r14, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1800
cmpl $0x1, %ebp
jne 0x17ef
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x1110
// File: /workspace/github_c_makefile_star2_O2/jacereda[P]fsatrace/src/fsatrace.c
// Function: errv
static void
errv(const char *fmt, const char *pref, va_list ap)
{
	char fullpath[PATH_MAX];
	char *es = strerror(errno);
	procPath(fullpath);
	fprintf(stderr, "%s(%d): %s", basename(fullpath), getpid(), pref);
	vfprintf(stderr, fmt, ap);
	fprintf(stderr, ": %s\n", es);
	fflush(stderr);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1018, %rsp           # imm = 0x1018
movq %rdx, 0x8(%rsp)
movq %rsi, %r12
movq %rdi, %r14
callq 0x1030
movl (%rax), %edi
callq 0x11f0
movq %rax, %r15
leaq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0x1938
movq 0x272a(%rip), %rbx      # 0x3ff8
movq (%rbx), %rbp
movq %r13, %rdi
callq 0x1160
movq %rax, %r13
callq 0x10a0
leaq 0x962(%rip), %rsi       # 0x224a
movq %rbp, %rdi
movq %r13, %rdx
movl %eax, %ecx
movq %r12, %r8
xorl %eax, %eax
callq 0x1140
movq (%rbx), %rdi
movq %r14, %rsi
movq 0x8(%rsp), %rdx
callq 0x11b0
movq (%rbx), %rdi
leaq 0x941(%rip), %rsi       # 0x2255
movq %r15, %rdx
xorl %eax, %eax
callq 0x1140
movq (%rbx), %rdi
callq 0x1170
addq $0x1018, %rsp           # imm = 0x1018
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/jacereda[P]fsatrace/src/unix/proc.c
// Function: procPath
void
procPath(char *fullpath)
{
#if defined __linux__
	char	exepath[64];
	ssize_t ret;
	snprintf(exepath, sizeof(exepath), "/proc/%d/exe", getpid());
	ret = readlink(exepath, fullpath, PATH_MAX);
	assert(ret != -1);
	fullpath[ret] = 0;
#else
	proc_pidpath(getpid(), fullpath, PATH_MAX);
#endif
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x10a0
leaq 0x941(%rip), %rdx       # 0x228f
movq %rsp, %r14
pushq $0x40
popq %rsi
movq %r14, %rdi
movl %eax, %ecx
xorl %eax, %eax
callq 0x10e0
movl $0x1000, %edx           # imm = 0x1000
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1070
cmpq $-0x1, %rax
je 0x1982
movb $0x0, (%rbx,%rax)
addq $0x48, %rsp
popq %rbx
popq %r14
retq
leaq 0x913(%rip), %rdi       # 0x229c
leaq 0x916(%rip), %rsi       # 0x22a6
leaq 0x91f(%rip), %rcx       # 0x22b6
pushq $0x16
popq %rdx
callq 0x1100
// File: /workspace/github_c_makefile_star2_O2/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 0x1938
leaq 0x8ca(%rip), %rdx       # 0x22d9
leaq 0x1000(%rsp), %r12
movl $0x1003, %esi           # imm = 0x1003
movq %r12, %rdi
movq %r15, %rcx
xorl %eax, %eax
callq 0x10e0
leaq 0x8af(%rip), %rdi       # 0x22df
pushq $0x1
popq %rbp
movq %r12, %rsi
movl %ebp, %edx
callq 0x1080
callq 0x1210
cmpl $-0x1, %eax
je 0x1a99
testl %eax, %eax
je 0x1aab
movl %eax, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x1190
cmpl $-0x1, %eax
je 0x1a7c
movl (%rbx), %ecx
movl %ecx, %eax
andl $0x7f, %eax
je 0x1a80
movl %eax, %edx
shll $0x18, %edx
addl $0x1000000, %edx        # imm = 0x1000000
cmpl $0x1ffffff, %edx        # imm = 0x1FFFFFF
jle 0x1a87
pushq $0x3
jmp 0x1a91
pushq $0x5
jmp 0x1a98
movzbl %ch, %eax
xorl %ebp, %ebp
jmp 0x1a92
cmpb $0x7f, %cl
jne 0x1a96
movzbl %ch, %eax
pushq $0x4
popq %rbp
movl %eax, (%rbx)
jmp 0x1a99
pushq $0x6
popq %rbp
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
pushq $0x1
popq %rdi
callq 0x1050
nop
// File: /workspace/github_c_makefile_star2_O2/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 0x1bc0
movl %ecx, %ebp
movq %rdx, %rbx
movq %rdi, %r14
leaq 0x8(%rdi), %r15
movl $0x1505, %ecx           # imm = 0x1505
movzbl (%rsi), %eax
testq %rax, %rax
je 0x1af6
incq %rsi
imulq $0x21, %rcx, %rcx
addq %rax, %rcx
jmp 0x1ae2
leaq 0x835(%rip), %rdx       # 0x2332
xorl %r12d, %r12d
pushq $0x20
popq %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0x10e0
movq %r15, %rdi
callq 0x10b0
cmpq %r12, %rax
je 0x1b2d
cmpb $0x2f, 0x8(%r14,%r12)
jne 0x1b28
movb $0x5f, 0x8(%r14,%r12)
incq %r12
jmp 0x1b15
testl %ebp, %ebp
je 0x1b39
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 0x1b7a
movl %r15d, %edi
movq %rbx, %rsi
callq 0x10f0
xorl %ecx, %ecx
cmpl $-0x1, %eax
sete %cl
addl %ecx, %ecx
movl 0x1008(%r14), %r8d
jmp 0x1b7f
xorl %ecx, %ecx
movl %r15d, %r8d
xorl %r12d, %r12d
cmpl $-0x1, %r15d
sete %r12b
orl %ecx, %r12d
pushq $0x3
popq %rdx
pushq $0x1
popq %rcx
xorl %edi, %edi
movq %rbx, %rsi
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 0x723(%rip), %rdi       # 0x22ea
leaq 0x720(%rip), %rsi       # 0x22ee
leaq 0x728(%rip), %rcx       # 0x22fd
pushq $0x22
popq %rdx
callq 0x1100
// File: /workspace/github_c_makefile_star2_O2/ryo[P]shmqueue/shmdump.c
// Function: main
int
main(int argc, char *argv[])
{
	int ch, id;
	int opt_t = 0;
	int opt_s = 0;

	while ((ch = getopt(argc, argv, "st")) != -1) {
		switch (ch) {
		case 's':
			opt_s = 1;
			break;
		case 't':
			opt_t = 1;
			break;
		default:
			usage();
			return 1;
		}
	}
	argc -= optind;
	argv += optind;

	id = shmget(MEMID, MEMSIZE, 0);
	if (id == -1)
		err(1, "shmget");

	shmqueue = shmqueue_new(MEMID, 0, 1, 0);

	if (opt_s) {
		shmqueue_dump_statistics(shmqueue);
		return 0;
	}


	if (opt_t) {
		shmqueue_dump_tsv(shmqueue);
	} else {
		shmqueue_dumpall(shmqueue);
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl %edi, %ebp
xorl %r15d, %r15d
movb $0x1, %r12b
leaq 0x1ddf(%rip), %r14      # 0x3004
pushq $0x1
popq %r13
movl %r15d, %ecx
movl %ecx, %r15d
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x10d0
movl %r13d, %ecx
cmpl $0x73, %eax
je 0x122c
cmpl $-0x1, %eax
je 0x1253
cmpl $0x74, %eax
jne 0x1292
xorl %r12d, %r12d
jmp 0x1229
movl $0x10000000, %esi       # imm = 0x10000000
movl $0x186a0, %edi          # imm = 0x186A0
xorl %edx, %edx
callq 0x10f0
cmpl $-0x1, %eax
je 0x12bf
xorl %ebx, %ebx
pushq $0x1
popq %rdx
movl $0x186a0, %edi          # imm = 0x186A0
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x17ac
movq %rax, 0x3e15(%rip)      # 0x5098
movq %rax, %rdi
testl %r15d, %r15d
je 0x12ab
callq 0x16d6
jmp 0x129a
callq 0x11fc
pushq $0x1
popq %rbx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb $0x1, %r12b
je 0x12b8
callq 0x137a
jmp 0x129a
callq 0x1603
jmp 0x129a
leaq 0x1d41(%rip), %rsi      # 0x3007
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x10a0
// File: /workspace/github_c_makefile_star2_O2/ryo[P]shmqueue/shmqueue.c
// Function: shmqueue_dumpitem
void
shmqueue_dumpitem(struct shmqueue_item *item)
{
	printf("      shi_hashidx=%d\n", item->shi_hashidx);
	printf("      shi_keyvalue.keysize=<%d>\n", item->shi_keyvalue.kv_keysize);
	printf("      shi_keyvalue.storagesize=%u\n", item->shi_keyvalue.kv_storagesize);
	printf("      shi_keyvalue.key(%p)=<%s>\n", KEYVALUE_KEY(&item->shi_keyvalue), KEYVALUE_KEY(&item->shi_keyvalue));
	printf("      shi_keyvalue.storage(%p)=<%s>\n", KEYVALUE_STORAGE(&item->shi_keyvalue), KEYVALUE_STORAGE(&item->shi_keyvalue));
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x20(%rdi), %esi
leaq 0x1d5e(%rip), %rdi      # 0x3050
xorl %eax, %eax
callq 0x1070
movl 0x24(%rbx), %esi
leaq 0x1d63(%rip), %rdi      # 0x3066
xorl %eax, %eax
callq 0x1070
movl 0x28(%rbx), %esi
leaq 0x1d73(%rip), %rdi      # 0x3087
xorl %eax, %eax
callq 0x1070
leaq 0x2c(%rbx), %rdx
leaq 0x1d84(%rip), %rdi      # 0x30aa
movq %rdx, %rsi
xorl %eax, %eax
callq 0x1070
movl 0x24(%rbx), %eax
leaq (%rbx,%rax), %rdx
addq $0x2c, %rdx
leaq 0x1d89(%rip), %rdi      # 0x30cb
movq %rdx, %rsi
xorl %eax, %eax
popq %rbx
jmp 0x1070
// File: /workspace/github_c_makefile_star2_O2/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), %rbx
addq $0x10, %rbx
leaq 0x1deb(%rip), %r12      # 0x3407
movabsq $0x40000000000002d, %r14 # imm = 0x40000000000002D
movq %rbx, (%rsp)
movq (%rbx), %rax
movq (%rsp), %rcx
leaq (%rax,%rcx), %rbx
testq %rax, %rax
cmoveq %rax, %rbx
testq %rbx, %rbx
je 0x16c7
leaq 0x2c(%rbx), %rsi
leaq 0x1b98(%rip), %rdi      # 0x31e8
xorl %eax, %eax
callq 0x1070
movl 0x24(%rbx), %eax
movl 0x28(%rbx), %r13d
leaq (%rbx,%rax), %r15
addq $0x2c, %r15
leaq 0x1d95(%rip), %rdi      # 0x3402
movl %r13d, %esi
xorl %eax, %eax
callq 0x1070
xorl %ebp, %ebp
cmpl %ebp, %r13d
je 0x16b2
movb (%r15,%rbp), %al
movzbl %al, %esi
leal -0x7f(%rsi), %eax
cmpb $-0x5f, %al
jb 0x169a
leal -0x22(%rsi), %eax
cmpl $0x3a, %eax
ja 0x16a9
btq %rax, %r14
jae 0x16a9
movq %r12, %rdi
xorl %eax, %eax
callq 0x1070
incq %rbp
jmp 0x1679
movl %esi, %edi
callq 0x1030
jmp 0x16a4
pushq $0x22
popq %rdi
callq 0x1030
pushq $0xa
popq %rdi
callq 0x1030
jmp 0x162a
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1b07(%rip), %r14      # 0x31ec
xorl %r15d, %r15d
cmpq $0x8, %r15
je 0x1708
movq (%rbx), %rax
movq 0x40(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
jmp 0x16e8
leaq 0x1b06(%rip), %r14      # 0x3215
xorl %r15d, %r15d
cmpq $0x8, %r15
je 0x1735
movq (%rbx), %rax
movq 0x80(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
jmp 0x1712
leaq 0x1b02(%rip), %r14      # 0x323e
xorl %r15d, %r15d
cmpq $0x8, %r15
je 0x1762
movq (%rbx), %rax
movq 0xc0(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
jmp 0x173f
leaq 0x1afe(%rip), %r14      # 0x3267
xorl %r15d, %r15d
movq (%rbx), %rax
cmpq $0x8, %r15
je 0x178f
movq 0x100(%rax,%r15,8), %rdx
movq %r14, %rdi
movl %r15d, %esi
xorl %eax, %eax
callq 0x1070
incq %r15
jmp 0x176c
movq 0x140(%rax), %rdx
leaq 0x1af3(%rip), %rdi      # 0x3290
pushq $0x8
popq %rsi
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
jmp 0x1070
// File: /workspace/github_c_makefile_star2_O2/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 0x17d6
movq %rbx, %rsi
movl $0x7b6, %edx            # imm = 0x7B6
callq 0x10f0
movl %eax, %ebp
movb $0x1, %r13b
jmp 0x17eb
movl %edx, %r14d
xorl %esi, %esi
xorl %edx, %edx
callq 0x10f0
movl %eax, %ebp
testl %r14d, %r14d
sete %r13b
cmpl $-0x1, %ebp
je 0x186b
xorl %r14d, %r14d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10e0
testq %rax, %rax
je 0x186e
movq %rax, %r12
testl %r15d, %r15d
je 0x181b
leaq 0x1aa7(%rip), %rdi      # 0x32b9
movl %ebp, %esi
xorl %eax, %eax
callq 0x1070
pushq $0x10
popq %rdi
callq 0x10b0
testq %rax, %rax
je 0x186b
movq %rax, %r14
testb %r13b, %r13b
je 0x1880
testl %r15d, %r15d
je 0x1849
leaq 0x1a89(%rip), %rdi      # 0x32c5
movq %r12, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1070
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x18ab
testl %eax, %eax
jns 0x186e
xorl %r14d, %r14d
movl %ebp, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0x10c0
jmp 0x186e
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 -0x5ba(%rip), %rax      # 0x12d0
movq %rax, 0x8(%r14)
testl %r15d, %r15d
je 0x186e
movq 0x20(%r12), %rdx
leaq 0x1a3f(%rip), %rdi      # 0x32de
movq %r12, %rsi
xorl %eax, %eax
callq 0x1070
jmp 0x186e
// File: /workspace/github_c_makefile_star2_O2/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:
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rdi)
movups %xmm0, (%rdi)
movl 0x28(%rdi), %eax
leaq 0x150(%rdi), %rcx
xorl %edx, %edx
cmpq %rax, %rdx
jae 0x1a69
incq %rdx
movups %xmm0, (%rcx)
addq $0x10, %rcx
jmp 0x1a58
andl $0x0, 0x34(%rdi)
movq %rdi, %rax
negq %rax
xorl %ecx, %ecx
xorl %edx, %edx
movl 0x30(%rdi), %esi
cmpq %rsi, %rdx
jae 0x1ab1
movq 0x38(%rdi), %rsi
andq $0x0, (%rsi,%rcx)
movq 0x8(%rdi), %rsi
movq 0x38(%rdi), %r8
movq %rsi, 0x8(%r8,%rcx)
leaq (%rax,%rcx), %r8
addq 0x38(%rdi), %r8
movq %r8, (%rsi,%rdi)
movq %r8, 0x8(%rdi)
incq %rdx
addq $0x800, %rcx            # imm = 0x800
jmp 0x1a77
retq
// File: /workspace/github_c_makefile_star2_O2/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
callq 0x1b2d
movq (%r15), %rbx
testq %rbx, %rbx
sete %al
addq %r15, %rbx
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x1ae9
movq %r14, %rdi
callq 0x1b3d
xorl %ebx, %ebx
jmp 0x1b24
movq (%rbx), %rax
leaq (%rax,%r15), %rcx
testq %rax, %rax
cmoveq %r15, %rcx
movq 0x8(%rbx), %rax
movq %rax, 0x8(%rcx)
movq (%rbx), %rcx
movq %rcx, (%rax,%r15)
movq %r14, %rdi
callq 0x1b3d
movabsq $0x100000000, %rax      # imm = 0x100000000
movq %rax, 0x20(%rbx)
andl $0x0, 0x28(%rbx)
movb $0x0, 0x2c(%rbx)
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq (%rdi), %r15
movl %edx, 0x20(%rsi)
callq 0x1b2d
leaq 0x10(%r15), %rax
movq 0x10(%r15), %rcx
movq %rcx, (%r14)
movq %r14, %rdx
subq %rax, %rdx
leaq 0x18(%r15), %rax
testq %rcx, %rcx
leaq 0x18(%rcx,%r15), %rcx
cmoveq %rax, %rcx
movq %rdx, (%rcx)
movq %rdx, 0x10(%r15)
andq $0x0, 0x8(%r14)
movl 0x20(%r14), %eax
shlq $0x4, %rax
leaq (%r15,%rax), %rcx
addq $0x150, %rcx            # imm = 0x150
leaq 0x158(%r15,%rax), %rax
movq -0x8(%rax), %rdx
leaq 0x10(%r14), %rsi
movq %rdx, 0x10(%r14)
subq %rcx, %rsi
testq %rdx, %rdx
leaq 0x18(%rdx,%rcx), %rcx
cmoveq %rax, %rcx
movq %rsi, (%rcx)
movl 0x20(%r14), %eax
shlq $0x4, %rax
addq %r15, %rax
addq $0x150, %rax            # imm = 0x150
movq %r14, %rcx
subq %rax, %rcx
movq %rcx, (%rax)
andq $0x0, 0x18(%r14)
incl 0x34(%r15)
movq %rbx, %rdi
callq 0x1b3d
xorl %eax, %eax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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
callq 0x1b2d
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 0x1c33
xorl %r14d, %r14d
jmp 0x1ca2
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)
movq %rbx, %rdi
callq 0x1b3d
movq %r14, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbx
movq %rsi, %rbx
movq %rdi, %r14
movq (%rdi), %r15
callq 0x1b2d
movq (%r15), %rax
movq %rax, (%rbx)
movq %rbx, %rcx
subq %r15, %rcx
leaq (%rax,%r15), %rdx
testq %rax, %rax
cmoveq %r15, %rdx
movq %rcx, 0x8(%rdx)
movq %rcx, (%r15)
andq $0x0, 0x8(%rbx)
movq %r14, %rdi
popq %rbx
popq %r14
popq %r15
jmp 0x1b3d
// File: /workspace/github_c_makefile_star2_O2/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
movq %rbx, %rdi
callq 0x1b2d
shlq $0x4, %r14
leaq (%r12,%r14), %r13
addq $0x150, %r13            # imm = 0x150
movq %r13, %r14
movq (%r14), %r14
testq %r14, %r14
je 0x1d55
addq %r13, %r14
je 0x1d55
leaq 0x2c(%r14), %rdi
movq %r15, %rsi
callq 0x1080
testl %eax, %eax
je 0x1d64
addq $0x10, %r14
jmp 0x1d32
addq $0x140, %r12            # imm = 0x140
xorl %r14d, %r14d
jmp 0x1e09
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)
andq $0x0, 0x8(%r14)
addq $0x100, %r12            # imm = 0x100
movl 0x28(%r14), %ecx
cmpl $0x3ff, %ecx            # imm = 0x3FF
ja 0x1dd8
cmpl $0xff, %ecx
ja 0x1dea
xorl %eax, %eax
cmpl $0x7f, %ecx
seta %al
jmp 0x1e01
cmpl $0xfff, %ecx            # imm = 0xFFF
ja 0x1df4
cmpl $0x800, %ecx            # imm = 0x800
pushq $0x5
jmp 0x1dfc
cmpl $0x200, %ecx            # imm = 0x200
pushq $0x3
jmp 0x1dfc
cmpl $0x4000, %ecx           # imm = 0x4000
pushq $0x7
popq %rax
sbbq $0x0, %rax
addq $0x24, %r14
leaq (%r12,%rax,8), %r12
incq (%r12)
movq %rbx, %rdi
callq 0x1b3d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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, %r14
movq %rdi, %rbx
movq (%rdi), %r12
movq %rsi, %rdi
callq *0x8(%rbx)
xorl %edx, %edx
divl 0x28(%r12)
movl %edx, %r15d
movq %rbx, %rdi
callq 0x1b2d
leaq 0x150(%r12), %rax
movq %rax, (%rsp)
shlq $0x4, %r15
leaq (%r12,%r15), %r13
addq $0x150, %r13            # imm = 0x150
pushq $-0x1
popq %rbp
movq %r13, %r15
movq (%r15), %r15
testq %r15, %r15
je 0x23fa
addq %r13, %r15
je 0x23fa
leaq 0x2c(%r15), %rdi
movq %r14, %rsi
callq 0x1080
testl %eax, %eax
je 0x236c
addq $0x10, %r15
jmp 0x2341
movq (%r15), %rax
movq 0x8(%r15), %rcx
leaq 0x18(%r12), %rdx
testq %rax, %rax
leaq 0x18(%rax,%r12), %rax
cmoveq %rdx, %rax
movq %rcx, (%rax)
movq (%r15), %rax
movq %rax, 0x10(%rcx,%r12)
movq 0x10(%r15), %rax
movq 0x18(%r15), %rcx
movl 0x20(%r15), %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(%r15), %rax
movl 0x20(%r15), %edx
shlq $0x4, %rdx
addq %rdi, %rdx
movq %rax, (%rcx,%rdx)
decl 0x34(%r12)
movq (%r12), %rax
movq %rax, (%r15)
movq %r15, %rcx
subq %r12, %rcx
leaq (%rax,%r12), %rdx
testq %rax, %rax
cmoveq %r12, %rdx
movq %rcx, 0x8(%rdx)
movq %rcx, (%r12)
andq $0x0, 0x8(%r15)
xorl %ebp, %ebp
movq %rbx, %rdi
callq 0x1b3d
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_O2/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 %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x1b2d
movq (%rbx), %rax
movl 0x34(%rax), %ebp
movq %rbx, %rdi
callq 0x1b3d
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x1b2d
movq (%rbx), %rax
movl 0x30(%rax), %ecx
movl %ecx, %edx
shrl $0x3, %edx
subl %edx, %ecx
xorl %ebp, %ebp
cmpl 0x34(%rax), %ecx
setb %bpl
movq %rbx, %rdi
callq 0x1b3d
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x1bfc
testq %rax, %rax
je 0x24c3
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 0x1090
leaq (%r14,%r12), %rax
addq $0x8, %rax
movb $0x0, (%r13,%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1cb3
xorl %eax, %eax
jmp 0x24c6
pushq $-0x1
popq %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x41b7f0
leaq 0xbc779(%rip), %rdi     # 0x4be1a5
callq 0x41b7f0
leaq 0xbc797(%rip), %rdi     # 0x4be1cf
callq 0x41b7f0
leaq 0xbc7aa(%rip), %rdi     # 0x4be1ee
callq 0x41b7f0
leaq 0xbc7bd(%rip), %rdi     # 0x4be20d
callq 0x41b7f0
leaq 0xbc7ee(%rip), %rdi     # 0x4be24a
callq 0x41b7f0
leaq 0xbc7f3(%rip), %rdi     # 0x4be25b
callq 0x41b7f0
leaq 0xbc807(%rip), %rdi     # 0x4be27b
callq 0x41b7f0
leaq 0xbc818(%rip), %rdi     # 0x4be298
callq 0x41b7f0
leaq 0xbc829(%rip), %rdi     # 0x4be2b5
callq 0x41b7f0
leaq 0xbc84f(%rip), %rdi     # 0x4be2e7
callq 0x41b7f0
leaq 0xbc85b(%rip), %rdi     # 0x4be2ff
callq 0x41b7f0
leaq 0xbc85e(%rip), %rdi     # 0x4be30e
popq %rax
jmp 0x41b7f0
// File: /workspace/github_c_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x10, %rsp
pushq $0x3c
popq %rsi
callq 0x402650
testb %al, %al
jne 0x401f6d
xorl %r14d, %r14d
leaq 0xf(%rsp), %rdi
movb %r14b, (%rdi)
leaq 0xe(%rsp), %rbx
movb %r14b, (%rbx)
pushq $0x1
popq %rbp
movl %ebp, %esi
callq 0x4026eb
movq %rbx, %rdi
movl %ebp, %esi
callq 0x402717
cmpb %r14b, (%rbx)
sete %al
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_set_col
uint8_t ssd1306_oled_set_col(uint8_t start, uint8_t end)
{
    data_buf[0] = SSD1306_COMM_CONTROL_BYTE;
    data_buf[1] = SSD1306_COMM_SET_COL_ADDR;
    data_buf[2] = start;
    data_buf[3] = end;
    
    return _i2c_write(data_buf, 4);
}

// Assembly:
movw $0x2100, 0xf02e4(%rip)  # imm = 0x2100
leaq 0xf02dd(%rip), %rax     # 0x4f23d0
movb %dil, 0xf02d8(%rip)     # 0x4f23d2
movb %sil, 0xf02d2(%rip)     # 0x4f23d3
pushq $0x4
popq %rsi
movq %rax, %rdi
jmp 0x4026eb
// File: /workspace/github_c_makefile_star2_O2/armlabs[P]ssd1306_linux/ssd1306.c
// Function: ssd1306_oled_set_page
uint8_t ssd1306_oled_set_page(uint8_t start, uint8_t end)
{
    data_buf[0] = SSD1306_COMM_CONTROL_BYTE;
    data_buf[1] = SSD1306_COMM_SET_PAGE_ADDR;
    data_buf[2] = start;
    data_buf[3] = end;
    
    return _i2c_write(data_buf, 4);
}

// Assembly:
movw $0x2200, 0xf02bb(%rip)  # imm = 0x2200
leaq 0xf02b4(%rip), %rax     # 0x4f23d0
movb %dil, 0xf02af(%rip)     # 0x4f23d2
movb %sil, 0xf02a9(%rip)     # 0x4f23d3
pushq $0x4
popq %rsi
movq %rax, %rdi
jmp 0x4026eb
// File: /workspace/github_c_makefile_star2_O2/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, 0xf064b(%rip)     # 0x4f27d0
jbe 0x4021c1
movb %dil, 0xf0643(%rip)     # 0x4f27d1
movb $0x0, 0xf023b(%rip)     # 0x4f23d0
leaq 0xf0234(%rip), %rax     # 0x4f23d0
movl %edi, %ecx
andb $0xf, %cl
movb %cl, 0xf022a(%rip)      # 0x4f23d1
shrb $0x4, %dil
orb $0x10, %dil
movb %dil, 0xf021c(%rip)     # 0x4f23d2
pushq $0x3
popq %rsi
movq %rax, %rdi
jmp 0x4026eb
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xf0608(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %dil, %al
jbe 0x402201
movb %dil, 0xf05fa(%rip)     # 0x4f27d3
movb $0x0, 0xf01f0(%rip)     # 0x4f23d0
leaq 0xf01e9(%rip), %rax     # 0x4f23d0
andb $0xf, %dil
orb $-0x50, %dil
movb %dil, 0xf01db(%rip)     # 0x4f23d1
pushq $0x2
popq %rsi
movq %rax, %rdi
jmp 0x4026eb
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/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, 0xf05c5(%rip)     # 0x4f27d0
jbe 0x40226b
movb 0xf05bf(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %sil, %al
jbe 0x40226b
movb %dil, 0xf05af(%rip)     # 0x4f27d1
movb %sil, 0xf05aa(%rip)     # 0x4f27d3
movb $0x0, 0xf01a0(%rip)     # 0x4f23d0
leaq 0xf0199(%rip), %rax     # 0x4f23d0
andb $0xf, %sil
orb $-0x50, %sil
movb %sil, 0xf018b(%rip)     # 0x4f23d1
movl %edi, %ecx
andb $0xf, %cl
movb %cl, 0xf0181(%rip)      # 0x4f23d2
shrb $0x4, %dil
orb $0x10, %dil
movb %dil, 0xf0173(%rip)     # 0x4f23d3
pushq $0x4
popq %rsi
movq %rax, %rdi
jmp 0x4026eb
movb $0x1, %al
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xbc4ef(%rip), %rdi     # 0x4be870
leaq 0xbc503(%rip), %rsi     # 0x4be88b
callq 0x41b5b0
testq %rax, %rax
je 0x4023ba
movq %rax, %rbx
movzbl %r14b, %edx
movzbl %bpl, %ecx
leaq 0xbc4e9(%rip), %rsi     # 0x4be88d
xorl %ebp, %ebp
movq %rax, %rdi
xorl %eax, %eax
callq 0x40cb40
movq %rbx, %rdi
callq 0x41b170
jmp 0x4023bd
movb $0x1, %bpl
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0x402489
testb %dil, %dil
je 0x4023ee
cmpb $0x1, %dil
jne 0x402489
movl $0x8, %ecx
leaq 0xbc184(%rip), %rax     # 0x4be570
jmp 0x4023fa
movl $0x5, %ecx
leaq 0xbbf96(%rip), %rax     # 0x4be390
movb $0x40, 0xeffcf(%rip)    # 0x4f23d0
movl %ecx, %ecx
movw $0x1, %r9w
xorl %edx, %edx
leaq 0xeffbf(%rip), %r8      # 0x4f23d0
movzwl %dx, %r10d
movb (%rsi,%r10), %r10b
testb %r10b, %r10b
je 0x402490
cmpw $0x400, %r9w            # imm = 0x400
ja 0x402490
leal -0x7f(%r10), %r11d
cmpb $-0x5f, %r11b
jb 0x402489
addb $-0x20, %r10b
movzbl %r10b, %r11d
imull %ecx, %r11d
addq %rax, %r11
movl $0x401, %ebx            # imm = 0x401
subl %r9d, %ebx
movzwl %r9w, %r10d
movzwl %bx, %r9d
xorl %ebx, %ebx
cmpq %rcx, %rbx
jae 0x40246c
movb (%r11,%rbx), %bpl
leaq (%r10,%rbx), %r14
movb %bpl, (%r8,%r14)
incq %rbx
cmpq %rbx, %r9
jne 0x402451
jmp 0x402489
leaq (%r10,%rbx), %r9
testb %dil, %dil
jne 0x402485
movzwl %r9w, %r9d
movb $0x0, (%r9,%r8)
leal (%r10,%rbx), %r9d
incl %r9d
incl %edx
jmp 0x402411
movb $0x1, %al
popq %rbx
popq %r14
popq %rbp
retq
movswl %r9w, %esi
leaq 0xeff35(%rip), %rdi     # 0x4f23d0
popq %rbx
popq %r14
popq %rbp
jmp 0x4026eb
// File: /workspace/github_c_makefile_star2_O2/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 0x402566
movq %rsi, %r13
leaq 0xbc3c3(%rip), %r14     # 0x4be888
movq %rsp, %r15
movzbl %dil, %ebp
xorl %ebx, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andl $0x0, 0x10(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x401078
movq %rax, %r12
testq %rax, %rax
je 0x402500
movq %r12, %rdx
subq %r13, %rdx
movq %r15, %rdi
movq %r13, %rsi
callq 0x401088
jmp 0x40250b
movq %r15, %rdi
movq %r13, %rsi
callq 0x401020
movzbl 0xf02bf(%rip), %edi     # 0x4f27d1
movzbl 0xf02ba(%rip), %esi     # 0x4f27d3
callq 0x402204
movl %ebp, %edi
movq %r15, %rsi
callq 0x4023c4
addb %al, %bl
testq %r12, %r12
je 0x402568
addq $0x2, %r12
movb $0x0, 0xf0297(%rip)     # 0x4f27d1
movb 0xf0293(%rip), %al      # 0x4f27d3
incb %al
movb 0xf028a(%rip), %cl      # 0x4f27d2
shrb $0x3, %cl
cmpb %cl, %al
movzbl %al, %eax
movl $0x0, %ecx
cmovael %ecx, %eax
movb %al, 0xf0275(%rip)      # 0x4f27d3
movq %r12, %r13
jmp 0x4024ce
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_O2/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 0xf0253(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %dil, %al
jbe 0x4025b9
pushq %rbx
movzbl %dil, %esi
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x402204
movb $0x40, 0xefe34(%rip)    # 0x4f23d0
movzbl 0xf022d(%rip), %esi     # 0x4f27d0
leaq 0xefe26(%rip), %rax     # 0x4f23d0
cmpq %rbx, %rsi
je 0x4025bc
movb $0x0, 0x1(%rbx,%rax)
incq %rbx
jmp 0x4025aa
movb $0x1, %al
retq
incl %esi
leaq 0xefe0b(%rip), %rdi     # 0x4f23d0
popq %rbx
jmp 0x4026eb
// File: /workspace/github_c_makefile_star2_O2/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
xorl %ebx, %ebx
xorl %ebp, %ebp
movb 0xf01fa(%rip), %al      # 0x4f27d2
shrb $0x3, %al
cmpb %al, %bpl
jae 0x4025f0
movzbl %bpl, %edi
callq 0x402579
addb %al, %bl
incb %bpl
jmp 0x4025d2
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/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 0xbc26d(%rip), %rdi     # 0x4be870
leaq 0xd7e3d(%rip), %rsi     # 0x4da447
callq 0x41b5b0
testq %rax, %rax
je 0x402642
movq %rax, %rbx
leaq 0xbc26f(%rip), %rsi     # 0x4be88d
leaq 0xf01ab(%rip), %rdx     # 0x4f27d0
leaq 0xf01a6(%rip), %rcx     # 0x4f27d2
xorl %ebp, %ebp
movq %rax, %rdi
xorl %eax, %eax
callq 0x40cf20
movq %rbx, %rdi
callq 0x41b170
jmp 0x402645
movb $0x1, %bpl
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
nop
// File: /workspace/github_c_makefile_star2_O2/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, 0xf0175(%rip)     # 0x4f27d4
je 0x402665
xorl %ebp, %ebp
jmp 0x4026bf
movl %esi, %ebx
movl %edi, %edx
leaq 0xbc227(%rip), %rsi     # 0x4be897
movq %rsp, %r14
movq %r14, %rdi
xorl %eax, %eax
callq 0x40cd90
pushq $0x2
popq %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0x45f690
movl %eax, 0xf0144(%rip)     # 0x4f27d4
testl %eax, %eax
js 0x4026b5
xorl %ebp, %ebp
movl $0x703, %esi            # imm = 0x703
movl %eax, %edi
movl %ebx, %edx
xorl %eax, %eax
callq 0x460470
testl %eax, %eax
jns 0x4026bf
movl 0xf0124(%rip), %edi     # 0x4f27d4
callq 0x45f930
andl $0x0, 0xf0118(%rip)     # 0x4f27d4
movb $0x1, %bpl
movl %ebp, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq