LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/teavpn/server/auth.c
// Function: teavpn_auth_check
FILE *teavpn_auth_check(server_config *config, struct teavpn_packet_auth *auth)
{
	size_t len;
	FILE *h1 = NULL, *h2 = NULL;
	char file[512], buffer[255];

	sprintf(file, "%s/users/%s/password", config->data_dir, auth->username);

	// printf("%s\n", file);
	// fflush(stdout);

	h1 = fopen(file, "r");
	if (h1 == NULL) {
		return NULL;
	}

	if (fgets(buffer, 254, h1)) {
		len = strlen(buffer);

		if (buffer[len - 1] == '\n') {
			buffer[len - 1] = '\0';
		}

		// printf("rpassword: \"%s\"\n", buffer);
		// printf("auth_pas: \"%s\"\n", auth->password);
		// fflush(stdout);

		if (!strcmp(auth->password, buffer)) {
			sprintf(file, "%s/users/%s/ip", config->data_dir, auth->username);
			h2 = fopen(file, "r");
		}
	}

	fclose(h1);
	return h2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x308, %rsp            # imm = 0x308
movq %rsi, %r12
movq %rdi, %r15
movq %fs:0x28, %rax
movq %rax, -0x30(%rbp)
movq 0x18(%rdi), %rdx
leaq 0x2(%rsi), %r14
leaq 0x246c(%rip), %rsi      # 0x833a
xorl %r13d, %r13d
leaq -0x230(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2390
leaq 0x11a3(%rip), %rsi      # 0x708f
movq %rbx, %rdi
callq 0x2340
testq %rax, %rax
je 0x5f8c
movq %rax, %rbx
leaq -0x330(%rbp), %r13
movq %r13, %rdi
movl $0xfe, %esi
movq %rax, %rdx
callq 0x21e0
testq %rax, %rax
je 0x5f4e
movq %r13, %rdi
callq 0x2100
cmpb $0xa, -0x1(%rax,%r13)
jne 0x5f34
movb $0x0, -0x331(%rbp,%rax)
addq $0x102, %r12            # imm = 0x102
leaq -0x330(%rbp), %rsi
movq %r12, %rdi
callq 0x2220
testl %eax, %eax
je 0x5f53
xorl %r13d, %r13d
jmp 0x5f84
movq 0x18(%r15), %rdx
leaq 0x23f1(%rip), %rsi      # 0x834f
leaq -0x230(%rbp), %r15
movq %r15, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x2390
leaq 0x1116(%rip), %rsi      # 0x708f
movq %r15, %rdi
callq 0x2340
movq %rax, %r13
movq %rbx, %rdi
callq 0x20f0
movq %fs:0x28, %rax
cmpq -0x30(%rbp), %rax
jne 0x5fb0
movq %r13, %rax
addq $0x308, %rsp            # imm = 0x308
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2110
nopl (%rax)
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/teavpn/teavpn.c
// Function: tun_alloc
int tun_alloc(char *dev, int flags)
{
	struct ifreq ifr;
	int fd, err;

	if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
		perror("Opening /dev/net/tun");
		return fd;
	}

	memset(&ifr, 0, sizeof(ifr));

	ifr.ifr_flags = flags;

	if (*dev) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
		strncpy(ifr.ifr_name, dev, IFNAMSIZ);
#pragma GCC diagnostic pop
	}

	if ((err = ioctl(fd, TUNSETIFF, (void *)&ifr)) < 0) {
		perror("ioctl(TUNSETIFF)");
		close(fd);
		return err;
	}

	strcpy(dev, ifr.ifr_name);
	return fd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movl %esi, %r15d
movq %rdi, %r14
movq %fs:0x28, %rax
movq %rax, -0x20(%rbp)
leaq 0x2272(%rip), %rdi      # 0x836d
movl $0x2, %esi
xorl %eax, %eax
callq 0x2320
movl %eax, %ebx
testl %eax, %eax
js 0x617a
xorps %xmm0, %xmm0
movaps %xmm0, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x30(%rbp)
movw %r15w, -0x40(%rbp)
cmpb $0x0, (%r14)
je 0x613c
leaq -0x50(%rbp), %rdi
movl $0x10, %edx
movq %r14, %rsi
callq 0x2060
leaq -0x50(%rbp), %rdx
movl $0x400454ca, %esi       # imm = 0x400454CA
movl %ebx, %edi
xorl %eax, %eax
callq 0x2190
testl %eax, %eax
js 0x6188
leaq -0x50(%rbp), %rsi
movq %r14, %rdi
callq 0x2070
movq %fs:0x28, %rax
cmpq -0x20(%rbp), %rax
jne 0x61a3
movl %ebx, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21e4(%rip), %rdi      # 0x8365
callq 0x2350
jmp 0x615e
movl %eax, %r15d
leaq 0x21e8(%rip), %rdi      # 0x837a
callq 0x2350
movl %ebx, %edi
callq 0x21a0
movl %r15d, %ebx
jmp 0x615e
callq 0x2110
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_init
struct thpool_* thpool_init(int num_threads){

	threads_on_hold   = 0;
	threads_keepalive = 1;

	if (num_threads < 0){
		num_threads = 0;
	}

	/* Make new thread pool */
	thpool_* thpool_p;
	thpool_p = (struct thpool_*)malloc(sizeof(struct thpool_));
	if (thpool_p == NULL){
		err("thpool_init(): Could not allocate memory for thread pool\n");
		return NULL;
	}
	thpool_p->num_threads_alive   = 0;
	thpool_p->num_threads_working = 0;

	/* Initialise the job queue */
	if (jobqueue_init(&thpool_p->__jobqueue) == -1){
		err("thpool_init(): Could not allocate memory for job queue\n");
		free(thpool_p);
		return NULL;
	}

	/* Make threads in pool */
	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread *));
	if (thpool_p->threads == NULL){
		err("thpool_init(): Could not allocate memory for threads\n");
		jobqueue_destroy(&thpool_p->__jobqueue);
		free(thpool_p);
		return NULL;
	}

	pthread_mutex_init(&(thpool_p->thcount_lock), NULL);
	pthread_cond_init(&thpool_p->threads_all_idle, NULL);

	/* Thread init */
	int n;
	for (n=0; n<num_threads; n++){
		thread_init(thpool_p, &thpool_p->threads[n], n);
#if THPOOL_DEBUG
			printf("THPOOL_DEBUG: Created thread %d in pool \n", n);
#endif
	}

	/* Wait for threads to initialize */
	while (thpool_p->num_threads_alive != num_threads) {}

	return thpool_p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %r14d
xorl %r15d, %r15d
movl %r15d, 0x5265(%rip)     # 0xb428
movl $0x1, 0x525f(%rip)      # 0xb42c
testl %edi, %edi
movl $0x0, %r13d
cmovgl %edi, %r13d
movl $0xb0, %edi
callq 0x22c0
testq %rax, %rax
je 0x62ee
movq %rax, %rbx
movl %r15d, 0x8(%rax)
movl %r15d, 0xc(%rax)
movl %r15d, 0xa8(%rax)
movl $0x60, %edi
callq 0x22c0
xorps %xmm0, %xmm0
movups %xmm0, 0x90(%rbx)
movq %rax, 0xa0(%rbx)
testq %rax, %rax
je 0x62f5
leaq 0x68(%rbx), %r15
movq %r15, %rdi
xorl %esi, %esi
callq 0x23d0
movq 0xa0(%rbx), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x23d0
leaq 0x28(%r12), %rdi
xorl %esi, %esi
callq 0x22a0
movl $0x0, 0x58(%r12)
movl %r13d, %edi
shlq $0x3, %rdi
callq 0x22c0
movq %rax, (%rbx)
testq %rax, %rax
je 0x62ff
leaq 0x10(%rbx), %rdi
xorl %esi, %esi
callq 0x23d0
movq %rbx, %rdi
addq $0x38, %rdi
xorl %esi, %esi
callq 0x22a0
testl %r14d, %r14d
jle 0x62d4
movl %r14d, %r15d
xorl %r12d, %r12d
movq (%rbx), %r14
movl $0x18, %edi
callq 0x22c0
movq %rax, (%r14,%r12,8)
movq %rbx, 0x10(%rax)
movl %r12d, (%rax)
leaq 0x8(%rax), %rdi
xorl %esi, %esi
leaq 0x30c(%rip), %rdx       # 0x65c3
movq %rax, %rcx
callq 0x2310
movq (%r14,%r12,8), %rax
movq 0x8(%rax), %rdi
callq 0x22e0
incq %r12
cmpq %r12, %r15
jne 0x6292
movl 0x8(%rbx), %eax
cmpl %r13d, %eax
jne 0x62d4
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2890
jmp 0x630a
movq %rbx, %rdi
callq 0x285d
jmp 0x630a
movq %r15, %rdi
movq %rbx, %rsi
callq 0x2820
xorl %ebx, %ebx
jmp 0x62dc
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_add_work
int thpool_add_work(thpool_* thpool_p, void* (*function_p)(void*), void* arg_p){
	job* newjob;

	newjob=(struct job*)malloc(sizeof(struct job));
	if (newjob==NULL){
		err("thpool_add_work(): Could not allocate memory for new job\n");
		return -1;
	}

	/* add function and argument */
	newjob->function=function_p;
	newjob->arg=arg_p;

	/* add job to queue */
	jobqueue_push(&thpool_p->__jobqueue, newjob);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, %rbx
movl $0x18, %edi
callq 0x22c0
testq %rax, %rax
je 0x6401
movq %rax, %r15
movq %r12, 0x8(%rax)
movq %r14, 0x10(%rax)
leaq 0x68(%rbx), %r14
movq %r14, %rdi
callq 0x23f0
movq $0x0, (%r15)
movl 0xa8(%rbx), %eax
testl %eax, %eax
je 0x63cc
movq 0x98(%rbx), %rcx
movq %r15, (%rcx)
jmp 0x63d3
movq %r15, 0x90(%rbx)
movq %r15, 0x98(%rbx)
incl %eax
movl %eax, 0xa8(%rbx)
movq 0xa0(%rbx), %rdi
callq 0x682b
movq %r14, %rdi
callq 0x22b0
xorl %eax, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
callq 0x28bf
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
jmp 0x63f8
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_wait
void thpool_wait(thpool_* thpool_p){
	pthread_mutex_lock(&thpool_p->thcount_lock);
	while (thpool_p->__jobqueue.len || thpool_p->num_threads_working) {
		pthread_cond_wait(&thpool_p->threads_all_idle, &thpool_p->thcount_lock);
	}
	pthread_mutex_unlock(&thpool_p->thcount_lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %r14
leaq 0x10(%rdi), %rbx
movq %rbx, %rdi
callq 0x23f0
leaq 0x38(%r14), %r15
cmpl $0x0, 0xa8(%r14)
jne 0x643b
cmpl $0x0, 0xc(%r14)
je 0x6448
movq %r15, %rdi
movq %rbx, %rsi
callq 0x20e0
jmp 0x642a
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x22b0
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thpool_destroy
void thpool_destroy(thpool_* thpool_p){
	/* No need to destory if it's NULL */
	if (thpool_p == NULL) return ;

	volatile int threads_total = thpool_p->num_threads_alive;

	/* End each thread 's infinite loop */
	threads_keepalive = 0;

	/* Give one second to kill idle threads */
	double TIMEOUT = 1.0;
	time_t start, end;
	double tpassed = 0.0;
	time (&start);
	while (tpassed < TIMEOUT && thpool_p->num_threads_alive){
		bsem_post_all(thpool_p->__jobqueue.has_jobs);
		time (&end);
		tpassed = difftime(end,start);
	}

	/* Poll remaining threads */
	while (thpool_p->num_threads_alive){
		bsem_post_all(thpool_p->__jobqueue.has_jobs);
		sleep(1);
	}

	/* Job queue cleanup */
	jobqueue_destroy(&thpool_p->__jobqueue);
	/* Deallocs */
	int n;
	for (n=0; n < threads_total; n++){
		thread_destroy(thpool_p->threads[n]);
	}
	free(thpool_p->threads);
	free(thpool_p);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %fs:0x28, %rax
movq %rax, -0x18(%rbp)
testq %rdi, %rdi
je 0x6528
movq %rdi, %rbx
movl 0x8(%rdi), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, 0x4f9e(%rip)      # 0xb42c
leaq -0x20(%rbp), %rdi
callq 0x2280
leaq -0x28(%rbp), %r14
cmpl $0x0, 0x8(%rbx)
je 0x64e8
movq 0xa0(%rbx), %rdi
callq 0x6545
movq %r14, %rdi
callq 0x2280
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2160
movsd 0x1ec6(%rip), %xmm1     # 0x8390
ucomisd %xmm0, %xmm1
ja 0x649b
jmp 0x64e8
movq 0xa0(%rbx), %rdi
callq 0x6545
movl $0x1, %edi
callq 0x23c0
cmpl $0x0, 0x8(%rbx)
jne 0x64d2
leaq 0x68(%rbx), %rdi
callq 0x630e
cmpl $0x0, -0x2c(%rbp)
jle 0x6518
xorl %r14d, %r14d
movq (%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x2030
incq %r14
movslq -0x2c(%rbp), %rax
cmpq %rax, %r14
jl 0x6500
movq (%rbx), %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movq %fs:0x28, %rax
cmpq -0x18(%rbp), %rax
jne 0x6540
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
callq 0x2110
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: thread_hold
static void thread_hold(int sig_id) {
    (void)sig_id;
	threads_on_hold = 1;
	while (threads_on_hold){
		sleep(1);
	}
}

// Assembly:
movl $0x1, 0x4c76(%rip)      # 0xb428
cmpl $0x0, 0x4c6f(%rip)      # 0xb428
je 0x67d3
pushq %rbp
movq %rsp, %rbp
movl $0x1, %edi
callq 0x23c0
cmpl $0x0, 0x4c58(%rip)      # 0xb428
jne 0x67bf
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/TeaInside[P]teavpn/src/third_party/thpool/thpool.c
// Function: jobqueue_pull
static struct job* jobqueue_pull(jobqueue* jobqueue_p){

	pthread_mutex_lock(&jobqueue_p->rwmutex);
	job* job_p = jobqueue_p->front;

	switch(jobqueue_p->len){

		case 0:  /* if no jobs in queue */
		  			break;

		case 1:  /* if one job in queue */
					jobqueue_p->front = NULL;
					jobqueue_p->rear  = NULL;
					jobqueue_p->len = 0;
					break;

		default: /* if >1 jobs in queue */
					jobqueue_p->front = job_p->prev;
					jobqueue_p->len--;
					/* more than one job in queue -> post it */
					bsem_post(jobqueue_p->has_jobs);

	}

	pthread_mutex_unlock(&jobqueue_p->rwmutex);
	return job_p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
callq 0x23f0
movq 0x28(%rbx), %r14
movl 0x40(%rbx), %eax
testl %eax, %eax
je 0x681b
cmpl $0x1, %eax
jne 0x6806
leaq 0x28(%rbx), %rax
movl $0x0, 0x40(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
jmp 0x681b
movq (%r14), %rcx
movq %rcx, 0x28(%rbx)
decl %eax
movl %eax, 0x40(%rbx)
movq 0x38(%rbx), %rdi
callq 0x682b
movq %rbx, %rdi
callq 0x22b0
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test_kstring.c
// Function: test_kputuw_from_to
static int test_kputuw_from_to(kstring_t *str, unsigned int s, unsigned int e) {
    unsigned int i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputuw(i, str) < 0 || !str->s) {
            perror("kputuw");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputuw\n");
            return -1;
        }
        if (i != strtoul(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputuw wrote the wrong value, expected %u, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movq $0x0, (%rdi)
movq 0x8(%rdi), %rdx
movq 0x10(%rdi), %rdi
movl $0xff, %esi
callq 0x10a0
movl %r14d, %edi
movq %rbx, %rsi
callq 0x2717
testl %eax, %eax
js 0x26cf
movl %r14d, %r15d
cmpl %r14d, %ebp
cmoval %ebp, %r14d
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x26cf
movq (%rbx), %rax
cmpq 0x8(%rbx), %rax
jae 0x26e1
cmpb $0x0, (%rdi,%rax)
jne 0x26e1
xorl %esi, %esi
movl $0xa, %edx
callq 0x1070
cmpq %rax, %r15
jne 0x26e8
cmpq %r15, %r14
je 0x26dd
incq %r15
movq $0x0, (%rbx)
movq 0x8(%rbx), %rdx
movq 0x10(%rbx), %rdi
movl $0xff, %esi
callq 0x10a0
movl %r15d, %edi
movq %rbx, %rsi
callq 0x2717
testl %eax, %eax
jns 0x2676
leaq 0x19a0(%rip), %rdi      # 0x4076
callq 0x10e0
jmp 0x2707
xorl %eax, %eax
jmp 0x270c
callq 0x13ca
jmp 0x2707
movq 0x48e9(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%rbx), %rcx
leaq 0x1a99(%rip), %rsi      # 0x4196
movl %r15d, %edx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test_kstring.c
// Function: test_kputw_from_to
static int test_kputw_from_to(kstring_t *str, int s, int e) {
    int i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputw(i, str) < 0 || !str->s) {
            perror("kputw");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputw\n");
            return -1;
        }
        if (i != strtol(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputw wrote the wrong value, expected %d, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movslq %esi, %r12
cmpl %r12d, %edx
cmovlel %r12d, %edx
movslq %edx, %r13
incq %r13
movl %r12d, %ebx
negl %ebx
xorl %ebp, %ebp
movq $0x0, (%r14)
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rdi
movl $0xff, %esi
callq 0x10a0
movl %r12d, %edi
testq %r12, %r12
jns 0x2922
movq (%r14), %rcx
leaq 0x3(%rcx), %rax
cmpq %rax, 0x8(%r14)
jae 0x2911
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r15
shrq %r15
testq %rcx, %rcx
cmovneq %rbp, %r15
addq %rax, %r15
movq 0x10(%r14), %rdi
movq %r15, %rsi
callq 0x1190
testq %rax, %rax
je 0x2969
movq %rax, 0x10(%r14)
movq %r15, 0x8(%r14)
movq (%r14), %rcx
jmp 0x2915
movq 0x10(%r14), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, (%r14)
movb $0x2d, (%rax,%rcx)
movl %ebx, %edi
movq %r14, %rsi
callq 0x2717
testl %eax, %eax
js 0x2969
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x2969
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x2977
cmpb $0x0, (%rdi,%rax)
jne 0x2977
xorl %esi, %esi
movl $0xa, %edx
callq 0x1140
cmpq %rax, %r12
jne 0x297e
incq %r12
decl %ebx
cmpq %r12, %r13
jne 0x28ae
xorl %eax, %eax
jmp 0x29a3
leaq 0x170d(%rip), %rdi      # 0x407d
callq 0x10e0
jmp 0x299e
callq 0x13e6
jmp 0x299e
movq 0x4653(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%r14), %rcx
negl %ebx
leaq 0x185d(%rip), %rsi      # 0x41f2
movl %ebx, %edx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/test/test_kstring.c
// Function: test_kputll_from_to
static int test_kputll_from_to(kstring_t *str, long long s, long long e) {
    long long i = s;

    for (;;) {
        str->l = 0;
        memset(str->s, 0xff, str->m);
        if (kputll(i, str) < 0 || !str->s) {
            perror("kputll");
            return -1;
        }
        if (str->l >= str->m || str->s[str->l] != '\0') {
            fprintf(stderr, "No NUL termination on string from kputll\n");
            return -1;
        }
        if (i != strtoll(str->s, NULL, 10)) {
            fprintf(stderr,
                    "kputll wrote the wrong value, expected %lld, got %s\n",
                    i, str->s);
            return -1;
        }
        if (i >= e) break;
        i++;
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1b83(%rip), %rbp      # 0x4550
movabsq $0x28f5c28f5c28f5c3, %r13 # imm = 0x28F5C28F5C28F5C3
movq $0x0, (%r14)
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rdi
movl $0xff, %esi
callq 0x10a0
movq (%r14), %rax
addq $0x17, %rax
cmpq %rax, 0x8(%r14)
jae 0x2a36
movq %rax, %rcx
shrq $0x3e, %rcx
movq %rax, %r12
shrq %r12
testq %rcx, %rcx
movl $0x0, %ecx
cmovneq %rcx, %r12
addq %rax, %r12
movq 0x10(%r14), %rdi
movq %r12, %rsi
callq 0x1190
testq %rax, %rax
je 0x2b20
movq %rax, 0x10(%r14)
movq %r12, 0x8(%r14)
movq %rbx, %rdx
testq %rbx, %rbx
jns 0x2a56
movq %rbx, %rdx
negq %rdx
movq (%r14), %rax
movq 0x10(%r14), %rcx
leaq 0x1(%rax), %rsi
movq %rsi, (%r14)
movb $0x2d, (%rcx,%rax)
movq %rdx, %rax
shrq $0x20, %rax
jne 0x2a72
movl %edx, %edi
movq %r14, %rsi
callq 0x2717
testl %eax, %eax
jns 0x2ae6
jmp 0x2b20
movl $0x1, %eax
xorl %ecx, %ecx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %edi, %esi
incl %ecx
addq %rax, %rax
leaq (%rax,%rax,4), %rax
leal 0x1(%rsi), %edi
cmpq %rax, %rdx
jae 0x2a7e
movq 0x10(%r14), %rdi
addq (%r14), %rdi
movq %rdx, %r8
movq %rdx, %rax
shrq $0x2, %rax
mulq %r13
shrq $0x2, %rdx
imulq $0x64, %rdx, %rax
movq %r8, %r9
subq %rax, %r9
movl %esi, %eax
movzwl (%rbp,%r9,2), %r9d
movw %r9w, (%rdi,%rax)
addl $-0x2, %esi
cmpq $0x3e7, %r8             # imm = 0x3E7
ja 0x2a98
cmpl $-0x1, %esi
jne 0x2ad6
orb $0x30, %dl
movb %dl, (%rdi)
movl %ecx, %eax
addq (%r14), %rax
movq %rax, (%r14)
movq 0x10(%r14), %rcx
movb $0x0, (%rcx,%rax)
movq 0x10(%r14), %rdi
testq %rdi, %rdi
je 0x2b20
movq (%r14), %rax
cmpq 0x8(%r14), %rax
jae 0x2b2e
cmpb $0x0, (%rdi,%rax)
jne 0x2b2e
xorl %esi, %esi
movl $0xa, %edx
callq 0x1050
cmpq %rax, %rbx
jne 0x2b35
cmpq %r15, %rbx
jge 0x2b1c
incq %rbx
jmp 0x29d7
xorl %eax, %eax
jmp 0x2b59
leaq 0x155c(%rip), %rdi      # 0x4083
callq 0x10e0
jmp 0x2b54
callq 0x1402
jmp 0x2b54
movq 0x449c(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
movq 0x10(%r14), %rcx
leaq 0x1704(%rip), %rsi      # 0x424e
movq %rbx, %rdx
xorl %eax, %eax
callq 0x1160
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/lib/ae/ae.c
// Function: aeMain
void aeMain(aeEventLoop *eventLoop) {
    eventLoop->stop = 0;
    while (!eventLoop->stop) {
        if (eventLoop->beforesleep != NULL)
            eventLoop->beforesleep(eventLoop);
        aeProcessEvents(eventLoop, AE_ALL_EVENTS|AE_CALL_AFTER_SLEEP);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0x0, 0x30(%rdi)
movq 0x40(%rbx), %rax
testq %rax, %rax
je 0x3708
movq %rbx, %rdi
callq *%rax
movq %rbx, %rdi
movl $0xb, %esi
callq 0x3285
cmpl $0x0, 0x30(%rbx)
je 0x36fa
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/lib/utf8_decode.c
// Function: utf8_decode_init
void utf8_decode_init(char p[], int length) {
    the_index = 0;
    the_input = p;
    the_length = length;
    the_char = 0;
    the_byte = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
xorl %eax, %eax
movl %eax, 0xcab0(%rip)      # 0x10200
movq %rdi, 0xcab1(%rip)      # 0x10208
movl %esi, 0xcab3(%rip)      # 0x10210
movl %eax, 0xcab1(%rip)      # 0x10214
movl %eax, 0xcaaf(%rip)      # 0x10218
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/lib/cJSON.c
// Function: cJSON_AddItemToObject
CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item)
{
    if (item == NULL)
    {
        return;
    }

    /* call cJSON_AddItemToObjectCS for code reuse */
    cJSON_AddItemToObjectCS(object, (char*)cJSON_strdup((const unsigned char*)string, &global_hooks), item);
    /* remove cJSON_StringIsConst flag */
    item->type &= ~cJSON_StringIsConst;
}

// Assembly:
testq %rdx, %rdx
je 0x49f8
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
testq %rsi, %rsi
je 0x49d5
movq %r15, %rdi
callq 0x20d0
movq %rax, %r13
incq %r13
movq %r13, %rdi
callq *0xb823(%rip)           # 0x101e0
testq %rax, %rax
je 0x49d5
movq %rax, %r12
movq %rax, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2200
jmp 0x49d8
xorl %r12d, %r12d
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x49f9
andb $-0x3, 0x19(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/lib/cJSON.c
// Function: cJSON_AddItemToObjectCS
CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item)
{
    if ((item == NULL) || (string == NULL))
    {
        return;
    }
    if (!(item->type & cJSON_StringIsConst) && item->string)
    {
        global_hooks.deallocate(item->string);
    }
    item->string = (char*)string;
    item->type |= cJSON_StringIsConst;
    cJSON_AddItemToArray(object, item);
}

// Assembly:
testq %rdx, %rdx
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
jne 0x4a73
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, %r14
movl 0x18(%rdx), %eax
btl $0x9, %eax
jb 0x4a37
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x4a37
callq *0xb7b4(%rip)           # 0x101e8
movl 0x18(%rbx), %eax
movq %r15, 0x38(%rbx)
orl $0x200, %eax            # imm = 0x200
movl %eax, 0x18(%rbx)
testq %r14, %r14
je 0x4a69
movq 0x10(%r14), %rax
testq %rax, %rax
je 0x4a65
movq %rax, %rcx
movq (%rax), %rax
testq %rax, %rax
jne 0x4a51
movq %rbx, (%rcx)
movq %rcx, 0x8(%rbx)
jmp 0x4a69
movq %rbx, 0x10(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_create_ex
struct buffer *buf_create_ex(size_t size, size_t prepend_size)
{
    assert(size > 0);
    assert(prepend_size >= 0);

    size_t sz = size + prepend_size;
    struct buffer *buf = calloc(1, sizeof(*buf));
    if (buf == NULL)
    {
        return NULL;
    }
    buf->buf = calloc(1, sz);
    if (buf->buf == NULL)
    {
        free(buf);
        return NULL;
    }
    buf->sz = sz;
    buf->read_idx = prepend_size;
    buf->write_idx = prepend_size;
    buf->p_sz = prepend_size;
    buf->refcount = 0;
    buf->src = NULL;
    return buf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x625e
movq %rsi, %r14
movq %rdi, %r15
movl $0x1, %edi
movl $0x40, %esi
callq 0x21b0
testq %rax, %rax
je 0x624e
movq %rax, %rbx
addq %r14, %r15
movl $0x1, %edi
movq %r15, %rsi
callq 0x21b0
movq %rax, 0x20(%rbx)
testq %rax, %rax
je 0x6246
movq %r15, 0x10(%rbx)
movq %r14, (%rbx)
movq %r14, 0x8(%rbx)
movq %r14, 0x18(%rbx)
jmp 0x6250
movq %rbx, %rdi
callq 0x23a0
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e4b(%rip), %rdi      # 0xa0b0
leaq 0x3e4d(%rip), %rsi      # 0xa0b9
leaq 0x3e4f(%rip), %rcx      # 0xa0c2
movl $0x20, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_release
void buf_release(struct buffer *buf)
{
    // 可以嵌套创建readonlyView, 都要检查 refcount
    assert(buf->refcount == 0);

    if (buf->src)
    {
        // 只读视图
        buf->src->refcount--;

        // 缓存 只读视图, 为 mysql 协议解析做的优化
        if (!buf->src->cache)
        {
            buf->src->cache = buf;
        }
        else
        {
            free(buf);
        }
    }
    else
    {
        // 常规 buffer
        free(buf->buf);
        if (buf->cache)
        {
            free(buf->cache);
        }
        free(buf);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
cmpq $0x0, 0x28(%rdi)
jne 0x62d1
movq %rdi, %rbx
movq 0x30(%rdi), %rax
testq %rax, %rax
je 0x62ac
decq 0x28(%rax)
cmpq $0x0, 0x38(%rax)
jne 0x62c3
movq %rbx, 0x38(%rax)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq 0x20(%rbx), %rdi
callq 0x23a0
movq 0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x62c3
callq 0x23a0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x23a0
leaq 0x3e17(%rip), %rdi      # 0xa0ef
leaq 0x3dda(%rip), %rsi      # 0xa0b9
leaq 0x3e1c(%rip), %rcx      # 0xa102
movl $0x3b, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_retrieveAsString
void buf_retrieveAsString(struct buffer *buf, size_t len, char *str)
{
    assert(str != NULL);
    memcpy(str, buf_peek(buf), len);
    str[len] = 0;
    buf_retrieve(buf, len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0x64da
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0x20(%rdi), %rsi
addq (%rdi), %rsi
movq %rdx, %rdi
movq %rbx, %rdx
callq 0x2200
movb $0x0, (%r14,%rbx)
movq %r15, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x64f9
leaq 0x3ce6(%rip), %rdi      # 0xa1c7
leaq 0x3bd1(%rip), %rsi      # 0xa0b9
leaq 0x3ce4(%rip), %rcx      # 0xa1d3
movl $0x99, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_retrieve
void buf_retrieve(struct buffer *buf, size_t len)
{
    assert(len <= buf_readable(buf));
    if (len < buf_readable(buf))
    {
        buf->read_idx += len;
    }
    else
    {
        buf_retrieveAll(buf);
    }
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq %rsi, %rcx
jb 0x651b
jbe 0x650f
addq %rsi, %rax
jmp 0x6517
movq 0x18(%rdi), %rax
movq %rax, 0x8(%rdi)
movq %rax, (%rdi)
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3c85(%rip), %rdi      # 0xa1ab
leaq 0x3b8c(%rip), %rsi      # 0xa0b9
leaq 0x3cda(%rip), %rcx      # 0xa20e
movl $0xa7, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_ensureWritable
void buf_ensureWritable(struct buffer *buf, size_t len)
{
    ASSERT_WRITE(buf);
    if (buf_writable(buf) < len)
    {
        buf_makeSpace(buf, len);
    }
    assert(buf_writable(buf) >= len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpq $0x0, 0x30(%rdi)
jne 0x668a
movq %rdi, %r14
cmpq $0x0, 0x28(%rdi)
jne 0x668a
movq %rsi, %rbx
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rcx
movq %rcx, %rax
subq %rsi, %rax
cmpq %rbx, %rax
jae 0x667a
movq (%r14), %rax
movq 0x18(%r14), %rdi
movq %rsi, %r15
subq %rax, %r15
addq %rax, %rcx
subq %rsi, %rcx
subq %rdi, %rcx
cmpq %rbx, %rcx
jae 0x664b
addq %rbx, %rsi
movq %r14, %rdi
callq 0x67fe
jmp 0x6665
cmpq %rax, %rdi
jae 0x66c8
movq 0x20(%r14), %rcx
addq %rcx, %rdi
addq %rcx, %rax
movq %rax, %rsi
movq %r15, %rdx
callq 0x2290
movq 0x10(%r14), %rax
movq 0x18(%r14), %rcx
movq %rcx, (%r14)
addq %rcx, %r15
movq %r15, 0x8(%r14)
subq %r15, %rax
cmpq %rbx, %rax
jb 0x66a9
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3ada(%rip), %rdi      # 0xa16b
leaq 0x3a21(%rip), %rsi      # 0xa0b9
leaq 0x3c00(%rip), %rcx      # 0xa29f
movl $0xee, %edx
callq 0x2150
leaq 0x3c20(%rip), %rdi      # 0xa2d0
leaq 0x3a02(%rip), %rsi      # 0xa0b9
leaq 0x3be1(%rip), %rcx      # 0xa29f
movl $0xf3, %edx
callq 0x2150
leaq 0x3fb7(%rip), %rdi      # 0xa686
leaq 0x39e3(%rip), %rsi      # 0xa0b9
leaq 0x3fc3(%rip), %rcx      # 0xa6a0
movl $0xe3, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_append
void buf_append(struct buffer *buf, const char *data, size_t len)
{
    ASSERT_WRITE(buf);
    buf_ensureWritable(buf, len);
    memcpy(buf_beginWrite(buf), data, len);
    buf_has_written(buf, len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpq $0x0, 0x30(%rdi)
jne 0x6748
movq %rdi, %r14
cmpq $0x0, 0x28(%rdi)
jne 0x6748
movq %rdx, %rbx
movq %rsi, %r15
movq %r14, %rdi
movq %rdx, %rsi
callq 0x65ee
movq 0x20(%r14), %rdi
addq 0x8(%r14), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x2200
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
subq %rax, %rcx
cmpq %rbx, %rcx
jb 0x6767
addq %rbx, %rax
movq %rax, 0x8(%r14)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3a1c(%rip), %rdi      # 0xa16b
leaq 0x3963(%rip), %rsi      # 0xa0b9
leaq 0x3b8c(%rip), %rcx      # 0xa2e9
movl $0xf8, %edx
callq 0x2150
leaq 0x39b6(%rip), %rdi      # 0xa124
leaq 0x3944(%rip), %rsi      # 0xa0b9
leaq 0x39c1(%rip), %rcx      # 0xa13d
movl $0x78, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_swap
static void buf_swap(struct buffer *buf, size_t nsz)
{
    // TODO nsz > buf->size realloc ?
    assert(nsz >= buf_readable(buf));
    void *nbuf = calloc(1, nsz);
    assert(nbuf);
    memcpy(nbuf + buf->p_sz, buf_peek(buf), buf_readable(buf));
    free(buf->buf);
    buf->buf = nbuf;
    buf->sz = nsz;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %r15
movq 0x8(%rdi), %r12
subq %r15, %r12
cmpq %rsi, %r12
ja 0x6870
movq %rdi, %r14
movl $0x1, %edi
movq %rsi, -0x30(%rbp)
callq 0x21b0
testq %rax, %rax
je 0x688f
movq %rax, %r13
movq 0x18(%r14), %rdi
addq %rax, %rdi
movq 0x20(%r14), %rbx
addq %rbx, %r15
movq %r15, %rsi
movq %r12, %rdx
callq 0x2200
movq %rbx, %rdi
callq 0x23a0
movq %r13, 0x20(%r14)
movq -0x30(%rbp), %rax
movq %rax, 0x10(%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3e55(%rip), %rdi      # 0xa6cc
leaq 0x383b(%rip), %rsi      # 0xa0b9
leaq 0x3e60(%rip), %rcx      # 0xa6e5
movl $0xd0, %edx
callq 0x2150
leaq 0x3e76(%rip), %rdi      # 0xa70c
leaq 0x381c(%rip), %rsi      # 0xa0b9
leaq 0x3e41(%rip), %rcx      # 0xa6e5
movl $0xd2, %edx
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt64
int64_t buf_peekInt64(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int64_t));
    int64_t be64 = 0;
    memcpy(&be64, buf_peek(buf), sizeof(int64_t));
    return be64toh(be64);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x7, %rcx
jbe 0x6b70
movq 0x20(%rdi), %rcx
movq (%rcx,%rax), %rax
bswapq %rax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3822(%rip), %rdi      # 0xa39d
leaq 0x3537(%rip), %rsi      # 0xa0b9
leaq 0x3839(%rip), %rcx      # 0xa3c2
movl $0x15f, %edx            # imm = 0x15F
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt32
int32_t buf_peekInt32(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int32_t));
    int32_t be32 = 0;
    memcpy(&be32, buf_peek(buf), sizeof(int32_t));
    return be32toh(be32);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x3, %rcx
jbe 0x6bad
movq 0x20(%rdi), %rcx
movl (%rcx,%rax), %eax
bswapl %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3837(%rip), %rdi      # 0xa3ef
leaq 0x34fa(%rip), %rsi      # 0xa0b9
leaq 0x384e(%rip), %rcx      # 0xa414
movl $0x167, %edx            # imm = 0x167
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt16
int16_t buf_peekInt16(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int16_t));
    int16_t be16 = 0;
    memcpy(&be16, buf_peek(buf), sizeof(int16_t));
    return be16toh(be16);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x1, %rcx
jbe 0x6bed
movq 0x20(%rdi), %rcx
movzwl (%rcx,%rax), %eax
rolw $0x8, %ax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3849(%rip), %rdi      # 0xa441
leaq 0x34ba(%rip), %rsi      # 0xa0b9
leaq 0x3860(%rip), %rcx      # 0xa466
movl $0x16f, %edx            # imm = 0x16F
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt64LE
int64_t buf_peekInt64LE(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int64_t));
    int64_t le64 = 0;
    memcpy(&le64, buf_peek(buf), sizeof(int64_t));
    return le64toh(le64);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x7, %rcx
jbe 0x6c5d
movq 0x20(%rdi), %rcx
movq (%rcx,%rax), %rax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3735(%rip), %rdi      # 0xa39d
leaq 0x344a(%rip), %rsi      # 0xa0b9
leaq 0x386c(%rip), %rcx      # 0xa4e2
movl $0x17d, %edx            # imm = 0x17D
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt32LE
int32_t buf_peekInt32LE(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int32_t));
    int32_t le32 = 0;
    memcpy(&le32, buf_peek(buf), sizeof(int32_t));
    return le32toh(le32);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x3, %rcx
jbe 0x6c98
movq 0x20(%rdi), %rcx
movl (%rcx,%rax), %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x374c(%rip), %rdi      # 0xa3ef
leaq 0x340f(%rip), %rsi      # 0xa0b9
leaq 0x3860(%rip), %rcx      # 0xa511
movl $0x185, %edx            # imm = 0x185
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt32LE24
int32_t buf_peekInt32LE24(const struct buffer *buf)
{
    assert(buf_readable(buf) >= 3);
    int32_t le32 = 0x00000000; /* 0x000000{00 小端高位未使用} */
    memcpy(&le32, buf_peek(buf), 3);
    return le32toh(le32);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x2, %rcx
jbe 0x6cde
movq 0x20(%rdi), %rcx
movzwl (%rcx,%rax), %edx
movzbl 0x2(%rcx,%rax), %eax
shll $0x10, %eax
orl %edx, %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x3857(%rip), %rdi      # 0xa540
leaq 0x33c9(%rip), %rsi      # 0xa0b9
leaq 0x3860(%rip), %rcx      # 0xa557
movl $0x18d, %edx            # imm = 0x18D
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_peekInt16LE
int16_t buf_peekInt16LE(const struct buffer *buf)
{
    assert(buf_readable(buf) >= sizeof(int16_t));
    int16_t le16 = 0;
    memcpy(&le16, buf_peek(buf), sizeof(int16_t));
    return le16toh(le16);
}

// Assembly:
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
subq %rax, %rcx
cmpq $0x1, %rcx
jbe 0x6d1a
movq 0x20(%rdi), %rcx
movzwl (%rcx,%rax), %eax
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x371c(%rip), %rdi      # 0xa441
leaq 0x338d(%rip), %rsi      # 0xa0b9
leaq 0x3855(%rip), %rcx      # 0xa588
movl $0x195, %edx            # imm = 0x195
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_readCStr
char *buf_readCStr(struct buffer *buf, char *str, int sz)
{
    int sz1;
    const char *eos = buf_findChar(buf, '\0');

    if (eos == NULL)
    {
        sz1 = buf_readable(buf) + 1;
    }
    else
    {
        sz1 = eos - buf_peek(buf) + 1;
    }

    if (sz < sz1)
    {
        return NULL;
    }

    memcpy(str, buf_peek(buf), sz);
    if (eos == NULL)
    {
        buf_retrieve(buf, sz1 - 1);
    }
    else
    {
        buf_retrieve(buf, sz1);
    }
    return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, -0x30(%rbp)
movq %rdi, %r14
movq (%rdi), %rax
movq 0x8(%rdi), %r13
movq 0x20(%rdi), %r15
addq %rax, %r15
subq %rax, %r13
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
callq 0x2180
testq %rax, %rax
je 0x6ef5
movq %rax, %rbx
subl %r15d, %ebx
incl %ebx
cmpl %r12d, %ebx
jg 0x6efe
movslq %r12d, %rdx
movq -0x30(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2200
movslq %ebx, %rsi
jmp 0x6f18
leal 0x1(%r13), %eax
cmpl %r12d, %eax
jle 0x6f03
xorl %r12d, %r12d
jmp 0x6f20
movslq %r12d, %rdx
movq -0x30(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x2200
movslq %r13d, %rsi
movq %r14, %rdi
callq 0x64f9
movq %r12, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_dupCStr
char *buf_dupCStr(struct buffer *buf)
{
    int sz;
    const char *eos = buf_findChar(buf, '\0');

    if (eos == NULL)
    {
        sz = buf_readable(buf) + 1;
    }
    else
    {
        sz = eos - buf_peek(buf) + 1;
    }

    char *str = calloc(sz, 1);
    if (str == NULL)
    {
        return NULL;
    }

    memcpy(str, buf_peek(buf), sz);
    if (eos == NULL)
    {
        buf_retrieve(buf, sz - 1);
    }
    else
    {
        buf_retrieve(buf, sz);
    }
    return str;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq (%rdi), %rax
movq 0x8(%rdi), %rbx
movq %rdi, -0x30(%rbp)
movq 0x20(%rdi), %r14
addq %rax, %r14
subq %rax, %rbx
movq %r14, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x2180
movq %rax, %r12
movl %r12d, %r15d
subl %r14d, %r15d
testq %rax, %rax
cmoveq %rbx, %r15
shlq $0x20, %r15
movabsq $0x100000000, %r13      # imm = 0x100000000
addq %r15, %r13
sarq $0x20, %r13
movl $0x1, %esi
movq %r13, %rdi
callq 0x21b0
movq %rax, %rbx
testq %rax, %rax
je 0x7017
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x2200
sarq $0x20, %r15
testq %r12, %r12
cmovneq %r13, %r15
movq -0x30(%rbp), %rdi
movq %r15, %rsi
callq 0x64f9
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_readFd
ssize_t buf_readFd(struct buffer *buf, int fd, int *errno_)
{
    ASSERT_WRITE(buf);
    char extrabuf[65535];
    struct iovec vec[2];
    size_t writable = buf_writable(buf);
    vec[0].iov_base = buf_beginWrite(buf);
    vec[0].iov_len = writable;
    vec[1].iov_base = extrabuf;
    vec[1].iov_len = sizeof(extrabuf);

    int iovcnt = writable < sizeof(extrabuf) ? 2 : 1;
    ssize_t n = readv(fd, vec, iovcnt);
    if (n < 0)
    {
        *errno_ = n;
    }
    else if (n <= writable)
    {
        buf->write_idx += n;
    }
    else
    {
        buf->write_idx = buf->sz;
        buf_append(buf, (char *)(&extrabuf[0]), n - writable);
    }

    return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10020, %rsp          # imm = 0x10020
cmpq $0x0, 0x30(%rdi)
jne 0x7144
movq %rdi, %rbx
cmpq $0x0, 0x28(%rdi)
jne 0x7144
movq %rdx, %r14
movq 0x8(%rbx), %rcx
movq 0x10(%rbx), %r12
subq %rcx, %r12
addq 0x20(%rbx), %rcx
leaq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq %r12, 0x8(%rax)
leaq -0x10040(%rbp), %rcx
movq %rcx, 0x10(%rax)
movl $0xffff, %ecx           # imm = 0xFFFF
movq %rcx, 0x18(%rax)
xorl %edx, %edx
cmpq %rcx, %r12
adcl $0x1, %edx
movl %esi, %edi
movq %rax, %rsi
callq 0x2280
movq %rax, %r15
testq %rax, %rax
js 0x7128
movq %r15, %rdx
subq %r12, %rdx
jbe 0x712d
movq 0x10(%rbx), %rax
movq %rax, 0x8(%rbx)
leaq -0x10040(%rbp), %rsi
movq %rbx, %rdi
callq 0x66e7
jmp 0x7131
movl %r15d, (%r14)
jmp 0x7131
addq %r15, 0x8(%rbx)
movq %r15, %rax
addq $0x10020, %rsp          # imm = 0x10020
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3020(%rip), %rdi      # 0xa16b
leaq 0x2f67(%rip), %rsi      # 0xa0b9
leaq 0x345e(%rip), %rcx      # 0xa5b7
movl $0x235, %edx            # imm = 0x235
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/buffer.c
// Function: buf_readonlyView
struct buffer *buf_readonlyView(struct buffer *buf, int sz)
{
    assert(sz > 0);
    if (sz > buf_readable(buf))
    {
        sz = buf_readable(buf);
    }

    struct buffer *rbuf;

    if (buf->cache)
    {
        memset(buf->cache, 0, sizeof(*(buf->cache)));
        rbuf = buf->cache;
        buf->cache = NULL;
    }
    else
    {
        rbuf = calloc(1, sizeof(*buf));
        if (rbuf == NULL)
        {
            return NULL;
        }
    }

    rbuf->buf = buf->buf + buf->read_idx; // buf_peek(buf)
    rbuf->sz = sz;
    rbuf->read_idx = 0;
    rbuf->write_idx = sz;
    rbuf->p_sz = 0;
    rbuf->refcount = 0;
    rbuf->src = buf;
    buf->refcount++;
    return rbuf;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
testl %esi, %esi
jle 0x7210
movq %rdi, %rbx
movl %esi, %eax
movq (%rdi), %r15
movq 0x8(%rdi), %r14
subq %r15, %r14
cmpq %rax, %r14
cmovael %esi, %r14d
movq 0x38(%rdi), %rax
testq %rax, %rax
je 0x71c5
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, (%rax)
movq (%rbx), %r15
movq 0x38(%rbx), %rax
movq $0x0, 0x38(%rbx)
jmp 0x71d9
movl $0x1, %edi
movl $0x40, %esi
callq 0x21b0
testq %rax, %rax
je 0x720c
addq 0x20(%rbx), %r15
movq %r15, 0x20(%rax)
movl %r14d, %ecx
movq %rcx, 0x10(%rax)
xorl %edx, %edx
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
movq %rdx, 0x18(%rax)
movq %rdx, 0x28(%rax)
movq %rbx, 0x30(%rax)
incq 0x28(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x7201
leaq 0x33d0(%rip), %rdi      # 0xa5e7
leaq 0x2e9b(%rip), %rsi      # 0xa0b9
leaq 0x33c9(%rip), %rcx      # 0xa5ee
movl $0x25d, %edx            # imm = 0x25D
callq 0x2150
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/socket.c
// Function: socket_create_
static int socket_create_(bool nonblock)
{
#ifdef __APPLE__
    int sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
#else
    int sockfd = socket(PF_INET, SOCK_STREAM | (nonblock ? SOCK_NONBLOCK : 0) | SOCK_CLOEXEC, IPPROTO_TCP);
#endif

    if (sockfd < 0)
    {
        perror("ERROR socket");
        return -1;
    }

#ifdef __APPLE__
    if (nonblock)
    {
        socket_setNonblock(sockfd);
    }
#endif

    int yes = 1;
    setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
#ifdef SO_REUSEPORT
    setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT, &yes, sizeof(yes));
#endif
    setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &yes, sizeof(yes));

    // !! for server
    signal(SIGPIPE, SIG_IGN);
    return sockfd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
shll $0xb, %edi
leal 0x80001(%rdi), %esi
movl $0x2, %edi
movl $0x6, %edx
callq 0x2390
testl %eax, %eax
js 0x75d0
movl %eax, %ebx
leaq -0x14(%rbp), %r14
movl $0x1, (%r14)
movl %eax, %edi
movl $0x6, %esi
movl $0x1, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x2090
movl %ebx, %edi
movl $0x1, %esi
movl $0x2, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x2090
movl %ebx, %edi
movl $0x1, %esi
movl $0xf, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x2090
movl %ebx, %edi
movl $0x1, %esi
movl $0x9, %edx
movq %r14, %rcx
movl $0x4, %r8d
callq 0x2090
movl $0x1, %esi
movl $0xd, %edi
callq 0x21d0
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x3183(%rip), %rdi      # 0xa75a
callq 0x22a0
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x75c5
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/socket.c
// Function: socket_sendAllSync
size_t socket_sendAllSync(int sockfd, const char *buf, size_t size)
{
    size_t sent = 0;
    while (sent < size)
    {
        ssize_t n = send(sockfd, buf + sent, size - sent, 0);
        if (n == -1)
        {
            if (errno == EINTR)
            {
                continue;
            }
            else
            {
                perror("ERROR send");
                break;
            }
        }
        sent += n;
    }

    return sent;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdx, %rdx
je 0x779f
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %r12d
xorl %ebx, %ebx
leaq (%r15,%rbx), %rsi
movq %r14, %rdx
subq %rbx, %rdx
movl %r12d, %edi
xorl %ecx, %ecx
callq 0x20f0
cmpq $-0x1, %rax
je 0x778e
addq %rax, %rbx
jmp 0x7798
callq 0x2050
cmpl $0x4, (%rax)
jne 0x77ad
cmpq %r14, %rbx
jb 0x776f
jmp 0x77a1
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f90(%rip), %rdi      # 0xa744
callq 0x22a0
jmp 0x77a1
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/socket.c
// Function: socket_recvAllSync
size_t socket_recvAllSync(int sockfd, char *buf, size_t size)
{
    size_t recved = 0;
    while (recved < size)
    {
        ssize_t n = recv(sockfd, buf + recved, size - recved, 0);
        if (n == -1)
        {
            if (errno == EINTR)
            {
                continue;
            }
            else
            {
                perror("ERROR recv");
                recved = -1;
                break;
            }
        }
        else if (n == 0)
        {
            break; // EOF
        }
        else
        {
            recved += n;
        }
    }

    return recved;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testq %rdx, %rdx
je 0x780b
movq %rdx, %r14
movq %rsi, %r15
movl %edi, %r12d
xorl %ebx, %ebx
leaq (%r15,%rbx), %rsi
movq %r14, %rdx
subq %rbx, %rdx
movl %r12d, %edi
xorl %ecx, %ecx
callq 0x2040
cmpq $-0x1, %rax
je 0x77fa
testq %rax, %rax
je 0x780d
addq %rax, %rbx
jmp 0x7804
callq 0x2050
cmpl $0x4, (%rax)
jne 0x7819
cmpq %r14, %rbx
jb 0x77d6
jmp 0x780d
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2f2f(%rip), %rdi      # 0xa74f
callq 0x22a0
movq $-0x1, %rbx
jmp 0x780d
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/sa.c
// Function: sa_create
union sockaddr_all
sa_create(uint16_t port, bool loopback_only)
{
    union sockaddr_all u;
    memset(&u, 0, sizeof(u));
    u.v4.sin_family = AF_INET;
    in_addr_t addr = loopback_only ? INADDR_LOOPBACK : INADDR_ANY;
    u.v4.sin_addr.s_addr = htonl(addr);
    u.v4.sin_port = htons(port);
    return u;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rdi)
movl $0x0, 0x18(%rdi)
movw $0x2, (%rdi)
testl %edx, %edx
movl $0x7f000001, %ecx       # imm = 0x7F000001
cmovel %edx, %ecx
bswapl %ecx
movl %ecx, 0x4(%rdi)
rolw $0x8, %si
movw %si, 0x2(%rdi)
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/goghcrow[P]dubbo_ab/sa.c
// Function: sa_createV6
union sockaddr_all
sa_createV6(uint16_t port, bool loopback_only)
{
    union sockaddr_all u;
    memset(&u, 0, sizeof(u));
    u.v6.sin6_family = AF_INET6;
    u.v6.sin6_addr = loopback_only ? in6addr_loopback : in6addr_any;
    u.v6.sin6_port = htons(port);
    return u;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, %rax
xorps %xmm0, %xmm0
movups %xmm0, 0x4(%rdi)
movq $0x0, 0x14(%rdi)
movw $0xa, (%rdi)
leaq 0x8(%rdi), %rcx
testl %edx, %edx
je 0x78cb
movq 0x86f7(%rip), %rdx      # 0xffc0
jmp 0x78d2
movq 0x86e6(%rip), %rdx      # 0xffb8
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
rolw $0x8, %si
movw %si, 0x2(%rax)
popq %rbp
retq