LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_env_info
int ESECT
mdb_env_info(MDB_env *env, MDB_envinfo *arg)
{
	MDB_meta *meta;

	if (env == NULL || arg == NULL)
		return EINVAL;

	meta = mdb_env_pick_meta(env);
	arg->me_mapaddr = meta->mm_address;
	arg->me_last_pgno = meta->mm_last_pg;
	arg->me_last_txnid = meta->mm_txnid;

	arg->me_mapsize = env->me_mapsize;
	arg->me_maxreaders = env->me_maxreaders;
	arg->me_numreaders = env->me_txns ? env->me_txns->mti_numreaders : 0;
	return MDB_SUCCESS;
}

// Assembly:
testq %rdi, %rdi
sete %al
testq %rsi, %rsi
sete %cl
orb %al, %cl
movl $0x16, %eax
jne 0xd9a4
movq 0x48(%rdi), %rax
movq 0x80(%rax), %rax
movq 0x50(%rdi), %rcx
xorl %edx, %edx
cmpq 0x80(%rcx), %rax
setb %dl
movq 0x48(%rdi,%rdx,8), %rax
movq 0x8(%rax), %rcx
movq %rcx, (%rsi)
movq 0x78(%rax), %rcx
movq %rcx, 0x10(%rsi)
movq 0x80(%rax), %rax
movq %rax, 0x18(%rsi)
movq 0x70(%rdi), %rax
movq %rax, 0x8(%rsi)
movl 0x18(%rdi), %eax
movl %eax, 0x20(%rsi)
movq 0x40(%rdi), %rcx
xorl %eax, %eax
movl $0x0, %edx
testq %rcx, %rcx
je 0xd9a1
movl 0x38(%rcx), %edx
movl %edx, 0x24(%rsi)
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_stat
int ESECT
mdb_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *arg)
{
	if (!arg || !TXN_DBI_EXIST(txn, dbi, DB_VALID))
		return EINVAL;

	if (txn->mt_flags & MDB_TXN_BLOCKED)
		return MDB_BAD_TXN;

	if (txn->mt_dbflags[dbi] & DB_STALE) {
		MDB_cursor mc;
		MDB_xcursor mx;
		/* Stale, must read the DB's root. cursor_init does it for us. */
		mdb_cursor_init(&mc, txn, dbi, &mx);
	}
	return mdb_stat0(txn->mt_env, &txn->mt_dbs[dbi], arg);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x380, %rsp            # imm = 0x380
movq %rdx, %rbx
movl %esi, %edx
testq %rbx, %rbx
sete %cl
testq %rdi, %rdi
sete %sil
movl $0x16, %eax
orb %cl, %sil
jne 0xda53
movq %rdi, %r14
cmpl %edx, 0x78(%rdi)
jbe 0xda53
movq 0x70(%r14), %rcx
movl %edx, %r15d
movzbl (%rcx,%r15), %ecx
testb $0x8, %cl
je 0xda53
movl $0xffff87c2, %eax       # imm = 0xFFFF87C2
testb $0x13, 0x7c(%r14)
jne 0xda53
testb $0x2, %cl
je 0xda10
leaq 0x8(%rsp), %rdi
leaq 0x190(%rsp), %rcx
movq %r14, %rsi
callq 0x4177
movq 0x20(%r14), %rax
movq 0x58(%r14), %rcx
leaq (%r15,%r15,2), %rdx
shlq $0x4, %rdx
movl 0x10(%rax), %eax
movl %eax, (%rbx)
movzwl 0x6(%rcx,%rdx), %eax
movl %eax, 0x4(%rbx)
movq 0x8(%rcx,%rdx), %rax
movq %rax, 0x8(%rbx)
movq 0x10(%rcx,%rdx), %rax
movq %rax, 0x10(%rbx)
movq 0x18(%rcx,%rdx), %rax
movq %rax, 0x18(%rbx)
movq 0x20(%rcx,%rdx), %rax
movq %rax, 0x20(%rbx)
xorl %eax, %eax
addq $0x380, %rsp            # imm = 0x380
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_reader_list
int ESECT
mdb_reader_list(MDB_env *env, MDB_msg_func *func, void *ctx)
{
	unsigned int i, rdrs;
	MDB_reader *mr;
	char buf[64];
	int rc = 0, first = 1;

	if (!env || !func)
		return -1;
	if (!env->me_txns) {
		return func("(no reader locks)\n", ctx);
	}
	rdrs = env->me_txns->mti_numreaders;
	mr = env->me_txns->mti_readers;
	for (i=0; i<rdrs; i++) {
		if (mr[i].mr_pid) {
			txnid_t	txnid = mr[i].mr_txnid;
			sprintf(buf, txnid == (txnid_t)-1 ?
				"%10d %"Z"x -\n" : "%10d %"Z"x %"Z"u\n",
				(int)mr[i].mr_pid, (size_t)mr[i].mr_tid, txnid);
			if (first) {
				first = 0;
				rc = func("    pid     thread     txnid\n", ctx);
				if (rc < 0)
					break;
			}
			rc = func(buf, ctx);
			if (rc < 0)
				break;
		}
	}
	if (first) {
		rc = func("(no active readers)\n", ctx);
	}
	return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdx, %r14
testq %rdi, %rdi
sete %cl
testq %rsi, %rsi
sete %dl
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
orb %cl, %dl
jne 0xdb5a
movq %rsi, %rbx
movq 0x40(%rdi), %r13
testq %r13, %r13
je 0xdb3d
movl 0x38(%r13), %ebp
testq %rbp, %rbp
je 0xdb46
shlq $0x6, %rbp
movl $0x1, %r15d
xorl %r12d, %r12d
xorl %eax, %eax
cmpl $0x0, 0x88(%r13,%r12)
je 0xdb2c
movq 0x80(%r13,%r12), %r8
cmpq $-0x1, %r8
leaq 0x1976(%rip), %rsi      # 0xf450
leaq 0x1963(%rip), %rax      # 0xf444
cmoveq %rax, %rsi
movl 0x88(%r13,%r12), %edx
movq 0x90(%r13,%r12), %rcx
movq %rsp, %rdi
xorl %eax, %eax
callq 0x2370
testl %r15d, %r15d
je 0xdb14
leaq 0x1953(%rip), %rdi      # 0xf45e
movq %r14, %rsi
callq *%rbx
testl %eax, %eax
js 0xdb23
movq %rsp, %rdi
movq %r14, %rsi
callq *%rbx
testl %eax, %eax
setns %cl
jmp 0xdb25
xorl %ecx, %ecx
xorl %r15d, %r15d
testb %cl, %cl
je 0xdb35
addq $0x40, %r12
cmpq %r12, %rbp
jne 0xdabc
testl %r15d, %r15d
sete %cl
jmp 0xdb4a
leaq 0x18ed(%rip), %rdi      # 0xf431
jmp 0xdb55
xorl %eax, %eax
xorl %ecx, %ecx
testb %cl, %cl
jne 0xdb5a
leaq 0x1927(%rip), %rdi      # 0xf47c
movq %r14, %rsi
callq *%rbx
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_reader_check
int ESECT
mdb_reader_check(MDB_env *env, int *dead)
{
	if (!env)
		return EINVAL;
	if (dead)
		*dead = 0;
	return env->me_txns ? mdb_reader_check0(env, 0, dead) : MDB_SUCCESS;
}

// Assembly:
testq %rdi, %rdi
je 0xdb87
movq %rsi, %rdx
testq %rsi, %rsi
je 0xdb7c
movl $0x0, (%rdx)
cmpq $0x0, 0x40(%rdi)
je 0xdb8d
xorl %esi, %esi
jmp 0xdb90
movl $0x16, %eax
retq
xorl %eax, %eax
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_mutex_failed
static int ESECT
mdb_mutex_failed(MDB_env *env, mdb_mutexref_t mutex, int rc)
{
	int rlocked, rc2;
	MDB_meta *meta;

	if (rc == MDB_OWNERDEAD) {
		/* We own the mutex. Clean up after dead previous owner. */
		rc = MDB_SUCCESS;
		rlocked = (mutex == env->me_rmutex);
		if (!rlocked) {
			/* Keep mti_txnid updated, otherwise next writer can
			 * overwrite data which latest meta page refers to.
			 */
			meta = mdb_env_pick_meta(env);
			env->me_txns->mti_txnid = meta->mm_txnid;
			/* env is hosed if the dead thread was ours */
			if (env->me_txn) {
				env->me_flags |= MDB_FATAL_ERROR;
				env->me_txn = NULL;
				rc = MDB_PANIC;
			}
		}
		DPRINTF(("%cmutex owner died, %s", (rlocked ? 'r' : 'w'),
			(rc ? "this process' env is hosed" : "recovering")));
		rc2 = mdb_reader_check0(env, rlocked, NULL);
		if (rc2 == 0)
			rc2 = mdb_mutex_consistent(mutex);
		if (rc || (rc = rc2)) {
			DPRINTF(("LOCK_MUTEX recovery failed, %s", mdb_strerror(rc)));
			UNLOCK_MUTEX(mutex);
		}
	} else {
#ifdef _WIN32
		rc = ErrCode();
#endif
		DPRINTF(("LOCK_MUTEX failed, %s", mdb_strerror(rc)));
	}

	return rc;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebx
cmpl $0x82, %edx
jne 0xde49
movq %rsi, %r14
movq 0x40(%rdi), %rax
leaq 0x8(%rax), %rcx
xorl %ebx, %ebx
xorl %esi, %esi
movb $0x1, %bpl
cmpq %r14, %rcx
sete %sil
je 0xde23
movq 0x48(%rdi), %rcx
movq 0x80(%rcx), %rcx
movq 0x50(%rdi), %rdx
xorl %r8d, %r8d
cmpq 0x80(%rdx), %rcx
setb %r8b
movq 0x48(%rdi,%r8,8), %rcx
movq 0x80(%rcx), %rcx
movq %rcx, 0x30(%rax)
cmpq $0x0, 0x60(%rdi)
je 0xde23
orb $-0x80, 0xf(%rdi)
movq $0x0, 0x60(%rdi)
movl $0xffff87b5, %ebx       # imm = 0xFFFF87B5
xorl %ebp, %ebp
xorl %edx, %edx
callq 0xdb90
testl %eax, %eax
jne 0xde36
movq %r14, %rdi
callq 0x2210
testb %bpl, %bpl
je 0xde41
movl %eax, %ebx
testl %eax, %eax
je 0xde50
movq %r14, %rdi
callq 0x2260
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
xorl %ebx, %ebx
jmp 0xde49
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_env_init_meta
static int ESECT
mdb_env_init_meta(MDB_env *env, MDB_meta *meta)
{
	MDB_page *p, *q;
	int rc;
	unsigned int	 psize;
#ifdef _WIN32
	DWORD len;
	OVERLAPPED ov;
	memset(&ov, 0, sizeof(ov));
#define DO_PWRITE(rc, fd, ptr, size, len, pos)	do { \
	ov.Offset = pos;	\
	rc = WriteFile(fd, ptr, size, &len, &ov);	} while(0)
#else
	int len;
#define DO_PWRITE(rc, fd, ptr, size, len, pos)	do { \
	len = pwrite(fd, ptr, size, pos);	\
	if (len == -1 && ErrCode() == EINTR) continue; \
	rc = (len >= 0); break; } while(1)
#endif

	DPUTS("writing new meta page");

	psize = env->me_psize;

	p = calloc(NUM_METAS, psize);
	p->mp_pgno = 0;
	p->mp_flags = P_META;
	*(MDB_meta *)METADATA(p) = *meta;

	q = (MDB_page *)((char *)p + psize);
	q->mp_pgno = 1;
	q->mp_flags = P_META;
	*(MDB_meta *)METADATA(q) = *meta;

	DO_PWRITE(rc, env->me_fd, p, psize * NUM_METAS, len, 0);
	if (!rc)
		rc = ErrCode();
	else if ((unsigned) len == psize * NUM_METAS)
		rc = MDB_SUCCESS;
	else
		rc = ENOSPC;
	free(p);
	return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %r12
movq %rdi, %r14
movl 0x10(%rdi), %r15d
movl $0x2, %edi
movq %r15, %rsi
callq 0x2200
movq %rax, %rbx
movq $0x0, (%rax)
movw $0x8, %bp
movw %bp, 0xa(%rax)
leaq 0x10(%rax), %rdi
movl $0x88, %edx
movq %r12, %rsi
callq 0x2240
leaq (%rbx,%r15), %rdi
addq $0x10, %rdi
movq $0x1, -0x10(%rdi)
movw %bp, -0x6(%rdi)
movl $0x88, %edx
movq %r12, %rsi
callq 0x2240
addl %r15d, %r15d
movl (%r14), %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x22a0
movq %rax, %r12
cmpl $-0x1, %r12d
jne 0xdedd
callq 0x2050
cmpl $0x4, (%rax)
je 0xdeba
testl %r12d, %r12d
js 0xdef1
xorl %eax, %eax
cmpl %r12d, %r15d
movl $0x1c, %ebp
cmovel %eax, %ebp
jmp 0xdef8
callq 0x2050
movl (%rax), %ebp
movq %rbx, %rdi
callq 0x2030
movl %ebp, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_env_copythr
static THREAD_RET ESECT
mdb_env_copythr(void *arg)
{
	mdb_copy *my = arg;
	char *ptr;
	int toggle = 0, wsize, rc;
#ifdef _WIN32
	DWORD len;
#define DO_WRITE(rc, fd, ptr, w2, len)	rc = WriteFile(fd, ptr, w2, &len, NULL)
#else
	int len;
#define DO_WRITE(rc, fd, ptr, w2, len)	len = write(fd, ptr, w2); rc = (len >= 0)
#endif

	pthread_mutex_lock(&my->mc_mutex);
	my->mc_new = 0;
	pthread_cond_signal(&my->mc_cond);
	for(;;) {
		while (!my->mc_new)
			pthread_cond_wait(&my->mc_cond, &my->mc_mutex);
		if (my->mc_new < 0) {
			my->mc_new = 0;
			break;
		}
		my->mc_new = 0;
		wsize = my->mc_wlen[toggle];
		ptr = my->mc_wbuf[toggle];
again:
		while (wsize > 0) {
			DO_WRITE(rc, my->mc_fd, ptr, wsize, len);
			if (!rc) {
				rc = ErrCode();
				break;
			} else if (len > 0) {
				rc = MDB_SUCCESS;
				ptr += len;
				wsize -= len;
				continue;
			} else {
				rc = EIO;
				break;
			}
		}
		if (rc) {
			my->mc_status = rc;
			break;
		}
		/* If there's an overflow page tail, write it too */
		if (my->mc_olen[toggle]) {
			wsize = my->mc_olen[toggle];
			ptr = my->mc_over[toggle];
			my->mc_olen[toggle] = 0;
			goto again;
		}
		my->mc_wlen[toggle] = 0;
		toggle ^= 1;
		pthread_cond_signal(&my->mc_cond);
	}
	pthread_cond_signal(&my->mc_cond);
	pthread_mutex_unlock(&my->mc_mutex);
	return (THREAD_RET)0;
#undef DO_WRITE
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x2410
movl $0x0, 0xa8(%rbx)
leaq 0x28(%rbx), %r14
movq %r14, %rdi
callq 0x21f0
xorl %ebp, %ebp
cmpl $0x0, 0xa8(%rbx)
jne 0xdf4c
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
jmp 0xdf36
cmpl $0x0, 0xa8(%rbx)
movl $0x0, 0xa8(%rbx)
js 0xdfff
movl %ebp, 0x4(%rsp)
movl %ebp, %r12d
movl 0x88(%rbx,%r12,4), %r13d
movq 0x58(%rbx,%r12,8), %r15
xorl %ebp, %ebp
testl %r13d, %r13d
jle 0xdfb5
movl 0xa0(%rbx), %edi
movl %r13d, %edx
movq %r15, %rsi
callq 0x20d0
testl %eax, %eax
js 0xdfa7
je 0xdfb0
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %r15
subl %eax, %r13d
jg 0xdf7e
jmp 0xdfb5
callq 0x2050
movl (%rax), %ebp
jmp 0xdfb5
movl $0x5, %ebp
testl %ebp, %ebp
jne 0xdff9
movl 0x90(%rbx,%r12,4), %r13d
testl %r13d, %r13d
je 0xdfd9
movq 0x68(%rbx,%r12,8), %r15
movl $0x0, 0x90(%rbx,%r12,4)
jmp 0xdf77
movl $0x0, 0x88(%rbx,%r12,4)
movl 0x4(%rsp), %ebp
xorl $0x1, %ebp
movq %r14, %rdi
callq 0x21f0
jmp 0xdf36
movl %ebp, 0xa4(%rbx)
movq %r14, %rdi
callq 0x21f0
movq %rbx, %rdi
callq 0x2260
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/jvanns[P]verbatim/sub/lmdb/libraries/liblmdb/mdb.c
// Function: mdb_env_cthr_toggle
static int ESECT
mdb_env_cthr_toggle(mdb_copy *my, int st)
{
	int toggle = my->mc_toggle ^ 1;
	pthread_mutex_lock(&my->mc_mutex);
	if (my->mc_status) {
		pthread_mutex_unlock(&my->mc_mutex);
		return my->mc_status;
	}
	while (my->mc_new == 1)
		pthread_cond_wait(&my->mc_cond, &my->mc_mutex);
	my->mc_new = st;
	my->mc_toggle = toggle;
	pthread_cond_signal(&my->mc_cond);
	pthread_mutex_unlock(&my->mc_mutex);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %ebp
movq %rdi, %rbx
movl 0xac(%rdi), %r15d
callq 0x2410
cmpl $0x0, 0xa4(%rbx)
je 0xe66d
movq %rbx, %rdi
callq 0x2260
movl 0xa4(%rbx), %eax
jmp 0xe6b6
xorl $0x1, %r15d
movl 0xa8(%rbx), %eax
cmpl $0x1, %eax
jne 0xe696
leaq 0x28(%rbx), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x20f0
movl 0xa8(%rbx), %eax
cmpl $0x1, %eax
je 0xe680
movl %ebp, 0xa8(%rbx)
movl %r15d, 0xac(%rbx)
leaq 0x28(%rbx), %rdi
callq 0x21f0
movq %rbx, %rdi
callq 0x2260
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/hkbu-victor[P]SFastLDA/doc_uci_to_word_uci.cpp
// Function: show_help()
void show_help(){
	printf("\nUCI data set conversion tool:\n");
	printf("\n doc-by-doc UCI data set ---> word-by-word data set\n");
	printf("=====================================\n");
	printf("Command line usage:\n");
	printf("doc_uci_to_w_uci -inputFile <string> -outputFile <string>\n");
	printf("=====================================\n");
}

// Assembly:
pushq %rbx
leaq 0xf82(%rip), %rdi       # 0x2166
callq 0x10b0
leaq 0xf95(%rip), %rdi       # 0x2185
callq 0x10b0
leaq 0x100c(%rip), %rbx      # 0x2208
movq %rbx, %rdi
callq 0x10b0
leaq 0xfaf(%rip), %rdi       # 0x21ba
callq 0x10b0
leaq 0xfb7(%rip), %rdi       # 0x21ce
callq 0x10b0
movq %rbx, %rdi
popq %rbx
jmp 0x10b0
// File: /workspace/github_cpp_makefile_star2_O1/hkbu-victor[P]SFastLDA/doc_uci_to_word_uci.cpp
// Function: parse_args(int, char**)
int parse_args(int argc, char **argv){
	char *arg;

	inputFile = NULL;
	outputFile = NULL;

	if (argc < 5){
		show_help();
		return -1;
	}

	int i = 0;
	while (i < argc){
		arg = argv[i];

		if (strcmp(arg,"-inputFile")==0){
			inputFile = argv[++i];
		} else if (strcmp(arg,"-outputFile")==0){
			outputFile = argv[++i];
		} else {
            // any more
		}
		i++;
	}
	if (strcmp(inputFile, outputFile) == 0){
		printf("\n***Input file and output file have the same path and name !!!\n");
		return -1;
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %r13d, %r13d
movq %r13, 0x2e4e(%rip)      # 0x4088
movq %r13, 0x2e4f(%rip)      # 0x4090
cmpl $0x5, %edi
jge 0x124d
callq 0x11dc
jmp 0x12cb
movq %rsi, %rbx
movl %edi, %ebp
leaq 0x2e2f(%rip), %r15      # 0x4088
movslq %r13d, %r14
movq (%rbx,%r14,8), %r12
movq %r12, %rdi
leaq 0xd9a(%rip), %rsi       # 0x2004
callq 0x1090
movq %r15, %rcx
testl %eax, %eax
je 0x1290
movq %r12, %rdi
leaq 0xd8f(%rip), %rsi       # 0x200f
callq 0x1090
leaq 0x2e04(%rip), %rcx      # 0x4090
testl %eax, %eax
jne 0x129c
leal 0x1(%r14), %r13d
movq 0x8(%rbx,%r14,8), %rax
movq %rax, (%rcx)
incl %r13d
cmpl %ebp, %r13d
jl 0x1259
movq 0x2ddd(%rip), %rdi      # 0x4088
movq 0x2dde(%rip), %rsi      # 0x4090
callq 0x1090
movl %eax, %ecx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x12d0
leaq 0xf68(%rip), %rdi       # 0x222e
callq 0x10b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::MP1Node(Member*, Params*, EmulNet*, Log*, Address*)
MP1Node::MP1Node(Member *member, Params *params, EmulNet *emul, Log *log, Address *address) {
	for( int i = 0; i < 6; i++ ) {
		NULLADDR[i] = 0;
	}
	this->memberNode = member;
	this->emulNet = emul;
	this->log = log;
	this->par = params;
	this->memberNode->addr = *address;
}

// Assembly:
leaq 0x86a3(%rip), %rax      # 0xaca0
movq %rax, (%rdi)
movl $0x0, 0x28(%rdi)
movw $0x0, 0x2c(%rdi)
movq %rsi, 0x20(%rdi)
movq %rcx, 0x8(%rdi)
movq %r8, 0x10(%rdi)
movq %rdx, 0x18(%rdi)
leaq 0x8(%rsi), %rdi
movq %r9, %rsi
jmp 0x4d6a
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::nodeStart(char*, short)
void MP1Node::nodeStart(char *servaddrstr, short servport) {
    Address joinaddr;
    joinaddr = getJoinAddress();

    // Self booting routines
    if( initThisNode(&joinaddr) == -1 ) {
#ifdef DEBUGLOG
        log->LOG(&memberNode->addr, "init_thisnode failed. Exit.");
#endif
        exit(1);
    }

    if( !introduceSelfToGroup(&joinaddr) ) {
        finishUpThisNode();
#ifdef DEBUGLOG
        log->LOG(&memberNode->addr, "Unable to join self to group. Exiting.");
#endif
        exit(1);
    }

    return;
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
leaq 0x8(%rsp), %rsi
movw $0x0, 0x4(%rsi)
movl $0x1, (%rsi)
leaq 0x2(%rsp), %rdi
callq 0x4d6a
movq 0x20(%rbx), %rax
movb $0x0, 0x10(%rax)
movw $0x1, 0xe(%rax)
movl $0x0, 0x14(%rax)
movq $0x0, 0x18(%rax)
movabsq $-0xfffffffb, %rcx      # imm = 0xFFFFFFFF00000005
movq %rcx, 0x20(%rax)
movq 0x28(%rax), %rcx
cmpq %rcx, 0x30(%rax)
je 0x26f0
movq %rcx, 0x30(%rax)
leaq 0x2(%rsp), %rsi
movq %rbx, %rdi
callq 0x2750
addq $0x10, %rsp
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::introduceSelfToGroup(Address*)
int MP1Node::introduceSelfToGroup(Address *joinaddr) {
	MessageHdr *msg;
#ifdef DEBUGLOG
    static char s[1024];
#endif

    if ( 0 == memcmp((char *)&(memberNode->addr.addr), (char *)&(joinaddr->addr), sizeof(memberNode->addr.addr))) {
        // I am the group booter (first process to join the group). Boot up the group
#ifdef DEBUGLOG
        log->LOG(&memberNode->addr, "Starting up group...");
#endif
        memberNode->inGroup = true;
        addOrUpdateMember(memberNode->addr, memberNode->heartbeat);
    }
    else {
        size_t msgsize = sizeof(MessageHdr) + sizeof(joinaddr->addr) + sizeof(long) + 1;
        msg = (MessageHdr *) malloc(msgsize * sizeof(char));

        // create JOINREQ message: format of data is {struct Address myaddr}
        msg->msgType = JOINREQ;
        memcpy((char *)(msg+1), &memberNode->addr.addr, sizeof(memberNode->addr.addr));
        memcpy((char *)(msg+1) + 1 + sizeof(memberNode->addr.addr), &memberNode->heartbeat, sizeof(long));

#ifdef DEBUGLOG
        sprintf(s, "Trying to join...");
        log->LOG(&memberNode->addr, s);
#endif

        // send JOINREQ message to introducer member
        emulNet->ENsend(&memberNode->addr, joinaddr, (char *)msg, msgsize);

        free(msg);
    }

    return 1;

}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x20(%rdi), %r13
leaq 0x8(%r13), %r15
movl 0x8(%r13), %eax
xorl (%rsi), %eax
movzwl 0xc(%r13), %ecx
xorw 0x4(%rsi), %cx
movzwl %cx, %ecx
orl %eax, %ecx
je 0x2807
movq %rsi, %r14
movl $0x13, %edi
callq 0x2240
movq %rax, %r12
movl $0x0, (%rax)
movl (%r15), %eax
movl %eax, 0x4(%r12)
movzwl 0x4(%r15), %eax
movw %ax, 0x8(%r12)
movq 0x18(%r13), %rax
movq %rax, 0xb(%r12)
movups 0x485e(%rip), %xmm0     # 0x7019
movaps %xmm0, 0x8a1e(%rip)     # 0xb1e0
movw $0x2e, 0x8a25(%rip)     # 0xb1f0
leaq 0x8a0e(%rip), %rdx      # 0xb1e0
movq 0x10(%rbx), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x4800
movq 0x8(%rbx), %rdi
movq 0x20(%rbx), %rsi
addq $0x8, %rsi
movq %r14, %rdx
movq %r12, %rcx
movl $0x13, %r8d
callq 0x3554
movq %r12, %rdi
callq 0x2210
jmp 0x2848
movq 0x10(%rbx), %rdi
leaq 0x47f2(%rip), %rdx      # 0x7004
movq %r15, %rsi
xorl %eax, %eax
callq 0x4800
movq 0x20(%rbx), %rsi
movb $0x1, 0xf(%rsi)
addq $0x8, %rsi
leaq 0xa(%rsp), %r14
movq %r14, %rdi
callq 0x4d5c
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2886
movl $0x1, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::finishUpThisNode()
int MP1Node::finishUpThisNode(){
   /*
    * Your code goes here
    */
    initMemberListTable(memberNode);
    memberNode->inGroup = false;
    return 0;
}

// Assembly:
movq 0x20(%rdi), %rax
movq 0x28(%rax), %rcx
cmpq %rcx, 0x30(%rax)
je 0x286e
movq %rcx, 0x30(%rax)
movb $0x0, 0xf(%rax)
xorl %eax, %eax
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::addOrUpdateMember(Address, long)
void MP1Node::addOrUpdateMember(Address memberAddr, long heartbeat)
{
	int id = *(int*)(&memberAddr.addr[0]);
	int port = *(short*)(&memberAddr.addr[4]);
    bool memberFound = false;

    for (vector<MemberListEntry>::iterator iter = memberNode->memberList.begin();
            iter != memberNode->memberList.end(); ++iter)
    {
        if (iter->id == id && iter->port == port)
        {
            memberFound = true;
            if (iter->heartbeat < heartbeat)
            {
                iter->heartbeat = heartbeat;
                iter->timestamp = par->getcurrtime();
            }
            break;
        }
    }

    if (!memberFound)
    {
        memberNode->memberList.push_back(
            MemberListEntry(id, port, heartbeat, par->getcurrtime()));
        memberNode->nnb += 1;
        log->logNodeAdd(&memberNode->addr, &memberAddr);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
movl (%rsi), %ebp
movzwl 0x4(%rsi), %r13d
movq 0x20(%rdi), %rax
movq 0x28(%rax), %r12
movq 0x30(%rax), %rax
cmpq %rax, %r12
je 0x28c9
cmpl %ebp, (%r12)
jne 0x28c3
cmpw %r13w, 0x4(%r12)
je 0x2922
addq $0x18, %r12
jmp 0x28b0
movq 0x20(%r14), %r12
addq $0x28, %r12
movq 0x18(%r14), %rdi
callq 0x4d50
movslq %eax, %r8
movswl %r13w, %edx
movq %rsp, %r13
movq %r13, %rdi
movl %ebp, %esi
movq %r15, %rcx
callq 0x4d90
movq %r12, %rdi
movq %r13, %rsi
callq 0x30be
movq 0x20(%r14), %rsi
incl 0x14(%rsi)
movq 0x10(%r14), %rdi
addq $0x8, %rsi
movq %rbx, %rdx
callq 0x4b04
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpq %r15, 0x8(%r12)
jge 0x2913
movq %r15, 0x8(%r12)
movq 0x18(%r14), %rdi
callq 0x4d50
cltq
movq %rax, 0x10(%r12)
jmp 0x2913
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::nodeLoop()
void MP1Node::nodeLoop() {
    if (memberNode->bFailed) {
    	return;
    }

    // Check my messages
    checkMessages();

    // Wait until you're in the group...
    if( !memberNode->inGroup ) {
    	return;
    }

    // ...then jump in and share your responsibilites!
    nodeLoopOps();

    return;
}

// Assembly:
pushq %rbx
movq 0x20(%rdi), %rax
cmpb $0x0, 0x10(%rax)
jne 0x2976
movq %rdi, %rbx
callq 0x2978
movq 0x20(%rbx), %rax
cmpb $0x1, 0xf(%rax)
jne 0x2976
movq %rbx, %rdi
callq 0x2b18
movq %rbx, %rdi
callq 0x2ba2
movq %rbx, %rdi
popq %rbx
jmp 0x2c4c
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::checkMessages()
void MP1Node::checkMessages() {
    void *ptr;
    int size;

    // Pop waiting messages from memberNode's mp1q
    while ( !memberNode->mp1q.empty() ) {
    	ptr = memberNode->mp1q.front().elt;
    	size = memberNode->mp1q.front().size;
    	memberNode->mp1q.pop();
    	recvCallBack((void *)memberNode, (char *)ptr, size);
    }
    return;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x20(%rdi), %rdi
movq 0x58(%rdi), %rax
cmpq %rax, 0x78(%rdi)
je 0x29aa
addq $0x48, %rdi
movq (%rax), %r14
callq 0x3070
movq %rbx, %rdi
movq %r14, %rdx
callq 0x29cc
movq 0x20(%rbx), %rdi
jmp 0x2983
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::recvCallBack(void*, char*, int)
bool MP1Node::recvCallBack(void *env, char *data, int size ) {
	/*
	 * Your code goes here
	 */
    MessageHdr *msg = (MessageHdr *) data;
    char *msgBody = (char *)(msg+1);
    Address senderAddr;
    long senderHeartbeat;
    switch (msg->msgType) {
        case JOINREQ:
            // create JOINREP message
            memcpy(&senderAddr, (char *)(msg+1), sizeof(memberNode->addr.addr));
            memcpy(&senderHeartbeat, (char *)(msg+1) + 1 + sizeof(memberNode->addr.addr), sizeof(long));
            addOrUpdateMember(senderAddr, senderHeartbeat);
            sendJoinRepMsg(senderAddr);
            break;
        case JOINREP:
            memberNode->inGroup = true;
            updateMemberList(msgBody);
            break;
        case UPDATEMEMLIST:
            updateMemberList(msgBody);
            break;
        default:
            return false;
    }
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x4(%rdx), %rsi
movl (%rdx), %eax
cmpl $0x2, %eax
je 0x2a5b
cmpl $0x1, %eax
je 0x2a53
testl %eax, %eax
jne 0x2a67
movzwl 0x4(%rsi), %eax
movq %rsp, %r14
movw %ax, 0x4(%r14)
movl (%rsi), %eax
movl %eax, (%r14)
movq 0xb(%rdx), %r15
leaq 0xc(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4d5c
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x2886
leaq 0x6(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x4d5c
leaq 0x12(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x4d5c
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x2d3e
jmp 0x2a63
movq 0x20(%rbx), %rax
movb $0x1, 0xf(%rax)
movq %rbx, %rdi
callq 0x2aa2
movb $0x1, %al
jmp 0x2a69
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::updateMemberList(char*)
void MP1Node::updateMemberList(char *data)
{
    int numOfMembers;
    memcpy(&numOfMembers, (char *)data, sizeof(int));
    MemberListEntry* memberListEntries = (MemberListEntry*) (data + sizeof(int));
    for (int i = 0; i < numOfMembers; ++i)
    {
        Address address = getAddressFromIPAndPort(memberListEntries[i].id,
                                                  memberListEntries[i].port);
        addOrUpdateMember(address, memberListEntries[i].heartbeat);
    }
}

// Assembly:
movslq (%rsi), %rax
testq %rax, %rax
jle 0x2b16
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movq %rdi, %r14
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
xorl %ebp, %ebp
leaq 0x12(%rsp), %r15
leaq 0xc(%rsp), %r12
movl 0x4(%rbx,%rbp), %eax
movzwl 0x8(%rbx,%rbp), %ecx
movl %eax, 0xc(%rsp)
movw %cx, 0x10(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4d5c
movq 0xc(%rbx,%rbp), %rdx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2886
addq $0x18, %rbp
cmpq %rbp, %r13
jne 0x2ad2
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::increaseSelfHeartbeat()
void MP1Node::increaseSelfHeartbeat()
{
    ++memberNode->heartbeat;
    for (vector<MemberListEntry>::iterator iter = memberNode->memberList.begin();
            iter != memberNode->memberList.end(); ++iter)
    {
        Address addr = getAddressFromIPAndPort(iter->id, iter->port);
        if (addr == memberNode->addr)
        {
            iter->heartbeat = memberNode->heartbeat;
            iter->timestamp = par->getcurrtime();
            break;
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq 0x20(%rdi), %rax
incq 0x18(%rax)
movq 0x28(%rax), %r15
movq 0x20(%rdi), %rsi
cmpq 0x30(%rsi), %r15
je 0x2b97
movq %rdi, %rbx
addq $0x10, %r15
leaq 0x8(%rsp), %r14
movl -0x10(%r15), %eax
movzwl -0xc(%r15), %ecx
movl %eax, 0x8(%rsp)
movw %cx, 0xc(%rsp)
addq $0x8, %rsi
movq %r14, %rdi
callq 0x4d7a
testb %al, %al
jne 0x2b7d
leaq -0x10(%r15), %rax
movq 0x20(%rbx), %rsi
addq $0x18, %r15
addq $0x18, %rax
cmpq 0x30(%rsi), %rax
jne 0x2b43
jmp 0x2b97
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rax
movq %rax, -0x8(%r15)
movq 0x18(%rbx), %rdi
callq 0x4d50
cltq
movq %rax, (%r15)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::deleteFailedNodes()
void MP1Node::deleteFailedNodes()
{
    long currentTime = par->getcurrtime();
    for (int i = memberNode->memberList.size() - 1; i >= 0; i--)
    {
        if (currentTime - memberNode->memberList[i].timestamp >= TREMOVE)
        {
            Address addr = getAddressFromIPAndPort(memberNode->memberList[i].id,
				memberNode->memberList[i].port);
            log->logNodeRemove(&memberNode->addr, &addr);
            memberNode->memberList.erase(begin(memberNode->memberList) + i);
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x4d50
movq 0x20(%rbx), %rcx
movq 0x30(%rcx), %rdx
subq 0x28(%rcx), %rdx
shrq $0x3, %rdx
imull $0xaaaaaaab, %edx, %ecx # imm = 0xAAAAAAAB
decl %ecx
js 0x2c3e
movslq %eax, %r15
addq $-0x13, %r15
movl %ecx, %eax
leaq 0x1(%rax), %r12
shlq $0x3, %rax
leaq (%rax,%rax,2), %r13
leaq 0x8(%rsp), %r14
movq 0x20(%rbx), %rsi
movq 0x28(%rsi), %rax
cmpq %r15, 0x10(%rax,%r13)
jge 0x2c35
movl (%rax,%r13), %ecx
movzwl 0x4(%rax,%r13), %eax
movl %ecx, 0x8(%rsp)
movw %ax, 0xc(%rsp)
movq 0x10(%rbx), %rdi
addq $0x8, %rsi
movq %r14, %rdx
callq 0x4b82
movq 0x20(%rbx), %rdi
movq 0x28(%rdi), %rsi
addq %r13, %rsi
addq $0x28, %rdi
callq 0x32e0
addq $-0x18, %r13
decq %r12
jg 0x2bef
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::sendMemberListToGroup()
void MP1Node::sendMemberListToGroup()
{
    long currentTime = par->getcurrtime();

	for (int i = 0; i < TPROP; i++) {

		/* initialize random seed: */
		srand (currentTime);

		/* generate secret number between 1 and 10: */
		int idx = rand() % memberNode->memberList.size();

	    if (currentTime - memberNode->memberList[idx].timestamp >= TFAIL)
	    {
	        continue;
	    }
	    Address addr = getAddressFromIPAndPort(memberNode->memberList[idx].id,
			memberNode->memberList[idx].port);
	    sendMemberListToMember(addr, UPDATEMEMLIST);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
callq 0x4d50
movl %eax, %ebp
movslq %eax, %r12
addq $-0x4, %r12
movl $0x1, %r13d
movabsq $-0x5555555555555555, %r15 # imm = 0xAAAAAAAAAAAAAAAB
leaq 0x12(%rsp), %r14
movl %ebp, %edi
callq 0x2170
callq 0x2060
cltq
movq 0x20(%rbx), %rdx
movq 0x28(%rdx), %rcx
movq 0x30(%rdx), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %r15, %rsi
xorl %edx, %edx
divq %rsi
movslq %edx, %rax
leaq (%rax,%rax,2), %rax
cmpq %r12, 0x10(%rcx,%rax,8)
jl 0x2cec
leaq (%rcx,%rax,8), %rax
movl (%rax), %ecx
movzwl 0x4(%rax), %eax
movl %ecx, 0xc(%rsp)
movw %ax, 0x10(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0x4d5c
movq %rbx, %rdi
movq %r14, %rsi
movl $0x2, %edx
callq 0x2d3e
decl %r13d
je 0x2c84
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/MP1Node.cpp
// Function: MP1Node::sendMemberListToMember(Address, MsgTypes)
void MP1Node::sendMemberListToMember(Address toAddress, MsgTypes msgType)
{
    int numOfMembers = memberNode->memberList.size();
    size_t msgsize = sizeof(MessageHdr) + sizeof(long) + numOfMembers * sizeof(MemberListEntry);
    MessageHdr *msg = (MessageHdr *) malloc(msgsize * sizeof(char));

    // create JOINREP message: format of data is {struct MemberListEntry}
    msg->msgType = msgType;
    memcpy((char *)(msg+1), &numOfMembers, sizeof(int));
    char *p = (char *)(msg+1) + sizeof(int);
    for (vector<MemberListEntry>::const_iterator iter = memberNode->memberList.begin();
            iter != memberNode->memberList.end(); ++iter)
    {
        memcpy(p, &(*iter), sizeof(MemberListEntry));
        p += sizeof(MemberListEntry);
    }

    // send JOINREQ message to introducer member
    emulNet->ENsend(&memberNode->addr, &toAddress, (char *)msg, msgsize);

    free(msg);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movq %rsi, (%rsp)
movq %rdi, %r15
movq 0x20(%rdi), %r14
movq 0x30(%r14), %rax
subq 0x28(%r14), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
movslq %ecx, %rbx
leaq (%rbx,%rbx,2), %rax
leaq 0xc(,%rax,8), %r12
movq %r12, %rdi
callq 0x2240
movq %rax, %r13
movl %ebp, (%rax)
movl %ebx, 0x4(%rax)
movq 0x28(%r14), %rax
cmpq 0x30(%r14), %rax
je 0x2dbc
movq %r13, %rcx
addq $0x8, %rcx
movq 0x10(%rax), %rdx
movq %rdx, 0x10(%rcx)
movups (%rax), %xmm0
movups %xmm0, (%rcx)
addq $0x18, %rcx
addq $0x18, %rax
cmpq 0x30(%r14), %rax
jne 0x2da0
movq 0x8(%r15), %rdi
addq $0x8, %r14
movq %r14, %rsi
movq (%rsp), %rdx
movq %r13, %rcx
movl %r12d, %r8d
callq 0x3554
movq %r13, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2210
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::EmulNet(Params*)
EmulNet::EmulNet(Params *p)
{
	//trace.funcEntry("EmulNet::EmulNet");
	int i,j;
	par = p;
	emulnet.setNextId(1);
	emulnet.settCurrBuffSize(0);
	enInited=0;
	for ( i = 0; i < MAX_NODES; i++ ) {
		for ( j = 0; j < MAX_TIME; j++ ) {
			sent_msgs[i][j] = 0;
			recv_msgs[i][j] = 0;
		}
	}
	//trace.funcExit("EmulNet::EmulNet", SUCCESS);
}

// Assembly:
leaq 0x797d(%rip), %rax      # 0xacd0
movq %rax, (%rdi)
leaq 0x79a3(%rip), %rax      # 0xad00
movq %rax, 0x1b7e498(%rdi)
movq %rsi, 0x8(%rdi)
movq $0x1, 0x1b7e4a0(%rdi)
movl $0x0, 0x1b7e490(%rdi)
addq $0xdbf250, %rdi         # imm = 0xDBF250
xorl %eax, %eax
xorl %ecx, %ecx
xorl %edx, %edx
movl %eax, -0xdbf240(%rdi,%rdx,4)
movl %eax, (%rdi,%rdx,4)
incq %rdx
cmpq $0xe10, %rdx            # imm = 0xE10
jne 0x338a
incq %rcx
addq $0x3840, %rdi           # imm = 0x3840
cmpq $0x3e8, %rcx            # imm = 0x3E8
jne 0x3388
retq
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::EmulNet(EmulNet&)
EmulNet::EmulNet(EmulNet &anotherEmulNet) {
	int i, j;
	this->par = anotherEmulNet.par;
	this->enInited = anotherEmulNet.enInited;
	for ( i = 0; i < MAX_NODES; i++ ) {
		for ( j = 0; j < MAX_TIME; j++ ) {
			this->sent_msgs[i][j] = anotherEmulNet.sent_msgs[i][j];
			this->recv_msgs[i][j] = anotherEmulNet.recv_msgs[i][j];
		}
	}
	this->emulnet = anotherEmulNet.emulnet;
}

// Assembly:
leaq 0x7915(%rip), %rax      # 0xacd0
movq %rax, (%rdi)
leaq 0x793b(%rip), %rax      # 0xad00
movq %rax, 0x1b7e498(%rdi)
movq 0x8(%rsi), %rax
movq %rax, 0x8(%rdi)
movl 0x1b7e490(%rsi), %eax
movl %eax, 0x1b7e490(%rdi)
movl $0xdbf250, %eax         # imm = 0xDBF250
leaq (%rsi,%rax), %rcx
addq %rdi, %rax
xorl %edx, %edx
movl $0x3840, %r8d           # imm = 0x3840
xorl %r9d, %r9d
movl -0xdbf240(%rcx,%r9,4), %r10d
movl %r10d, -0xdbf240(%rax,%r9,4)
movl (%rcx,%r9,4), %r10d
movl %r10d, (%rax,%r9,4)
incq %r9
cmpq $0xe10, %r9             # imm = 0xE10
jne 0x33f7
incq %rdx
addq %r8, %rcx
addq %r8, %rax
cmpq $0x3e8, %rdx            # imm = 0x3E8
jne 0x33f4
movl 0x1b7e4a0(%rsi), %eax
movl %eax, 0x1b7e4a0(%rdi)
movslq 0x1b7e4a4(%rsi), %rax
movl %eax, 0x1b7e4a4(%rdi)
movl 0x1b7e4a8(%rsi), %ecx
movl %ecx, 0x1b7e4a8(%rdi)
testq %rax, %rax
jle 0x3478
addq $0x36fc96, %rax         # imm = 0x36FC96
movq (%rsi,%rax,8), %rcx
movq %rcx, (%rdi,%rax,8)
leaq -0x1(%rax), %rcx
addq $-0x36fc96, %rax        # imm = 0xFFC9036A
cmpq $0x1, %rax
movq %rcx, %rax
jg 0x345d
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::operator=(EmulNet&)
EmulNet& EmulNet::operator =(EmulNet &anotherEmulNet) {
	int i, j;
	this->par = anotherEmulNet.par;
	this->enInited = anotherEmulNet.enInited;
	for ( i = 0; i < MAX_NODES; i++ ) {
		for ( j = 0; j < MAX_TIME; j++ ) {
			this->sent_msgs[i][j] = anotherEmulNet.sent_msgs[i][j];
			this->recv_msgs[i][j] = anotherEmulNet.recv_msgs[i][j];
		}
	}
	this->emulnet = anotherEmulNet.emulnet;
	return *this;
}

// Assembly:
movq %rdi, %rax
movq 0x8(%rsi), %rcx
movq %rcx, 0x8(%rdi)
movl 0x1b7e490(%rsi), %ecx
movl %ecx, 0x1b7e490(%rdi)
leaq 0x10(%rdi), %rcx
leaq 0xdbf250(%rsi), %rdx
xorl %edi, %edi
movl $0x3840, %r8d           # imm = 0x3840
xorl %r9d, %r9d
movl -0xdbf240(%rdx,%r9,4), %r10d
movl %r10d, (%rcx,%r9,4)
movl (%rdx,%r9,4), %r10d
movl %r10d, 0xdbf240(%rcx,%r9,4)
incq %r9
cmpq $0xe10, %r9             # imm = 0xE10
jne 0x34a7
incq %rdi
addq %r8, %rdx
addq %r8, %rcx
cmpq $0x3e8, %rdi            # imm = 0x3E8
jne 0x34a4
movl 0x1b7e4a0(%rsi), %ecx
movl %ecx, 0x1b7e4a0(%rax)
movslq 0x1b7e4a4(%rsi), %rcx
movl %ecx, 0x1b7e4a4(%rax)
movl 0x1b7e4a8(%rsi), %edx
movl %edx, 0x1b7e4a8(%rax)
testq %rcx, %rcx
jle 0x352a
addq $0x36fc96, %rcx         # imm = 0x36FC96
movq (%rsi,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
leaq -0x1(%rcx), %rdx
addq $-0x36fc96, %rcx        # imm = 0xFFC9036A
cmpq $0x1, %rcx
movq %rdx, %rcx
jg 0x350e
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::ENinit(Address*, short)
void *EmulNet::ENinit(Address *myaddr, short port) {
	// Initialize data structures for this member
	*(int *)(myaddr->addr) = emulnet.nextid++;
    *(short *)(&myaddr->addr[4]) = 0;
	return myaddr;
}

// Assembly:
movq %rsi, %rax
movl 0x1b7e4a0(%rdi), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x1b7e4a0(%rdi)
movl %ecx, (%rsi)
movw $0x0, 0x4(%rsi)
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::ENsend(Address*, Address*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int EmulNet::ENsend(Address *myaddr, Address *toaddr, string data) {
	char * str = (char *) malloc(data.length() * sizeof(char));
	memcpy(str, data.c_str(), data.size());
	int ret = this->ENsend(myaddr, toaddr, str, (data.length() * sizeof(char)));
	free(str);
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %r12
movq 0x8(%rcx), %r13
movq %r13, %rdi
callq 0x2240
movq %rax, %rbp
movq (%rbx), %rsi
movq %rax, %rdi
movq %r13, %rdx
callq 0x2130
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
movq %rbp, %rcx
movl %r13d, %r8d
callq 0x3554
movl %eax, %ebx
movq %rbp, %rdi
callq 0x2210
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::ENrecv(Address*, int (*)(void*, char*, int), timeval*, int, void*)
int EmulNet::ENrecv(Address *myaddr, int (* enq)(void *, char *, int), struct timeval *t, int times, void *queue){
	// times is always assumed to be 1
	int i;
	char* tmp;
	int sz;
	en_msg *emsg;

	for( i = emulnet.currbuffsize - 1; i >= 0; i-- ) {
		emsg = emulnet.buff[i];

		if ( 0 == strcmp(emsg->to.addr, myaddr->addr) ) {
			sz = emsg->size;
			tmp = (char *) malloc(sz * sizeof(char));
			memcpy(tmp, (char *)(emsg+1), sz);

			emulnet.buff[i] = emulnet.buff[emulnet.currbuffsize-1];
			emulnet.currbuffsize--;

			(*enq)(queue, (char *)tmp, sz);

			free(emsg);

			int dst = *(int *)(myaddr->addr);
			int time = par->getcurrtime();

			assert(dst <= MAX_NODES);
			assert(time < MAX_TIME);

			recv_msgs[dst][time]++;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x10(%rsp)
movq %rdx, 0x8(%rsp)
movslq 0x1b7e4a4(%rdi), %r14
testq %r14, %r14
jle 0x3855
movq %rsi, %r15
movq %rdi, %r12
leaq 0xdbf250(%rdi), %rax
movq %rax, (%rsp)
movq 0x1b7e4a8(%r12,%r14,8), %r13
leaq 0xa(%r13), %rdi
movq %r15, %rsi
callq 0x2250
testl %eax, %eax
jne 0x3844
movl (%r13), %eax
movslq %eax, %rbp
movq %rbp, %rdi
callq 0x2240
movq %rax, %rbx
leaq 0x10(%r13), %rsi
movq %rax, %rdi
movq %rbp, %rdx
callq 0x2130
movslq 0x1b7e4a4(%r12), %rax
leal -0x1(%rax), %ecx
movq 0x1b7e4a8(%r12,%rax,8), %rax
movq %rax, 0x1b7e4a8(%r12,%r14,8)
movl %ecx, 0x1b7e4a4(%r12)
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq *0x8(%rsp)
movq %r13, %rdi
callq 0x2210
movslq (%r15), %rbx
movq 0x8(%r12), %rdi
callq 0x4d50
cmpq $0x3e9, %rbx            # imm = 0x3E9
jge 0x3885
cmpl $0xe10, %eax            # imm = 0xE10
jge 0x3866
cltq
imulq $0x3840, %rbx, %rcx     # imm = 0x3840
addq (%rsp), %rcx
incl (%rcx,%rax,4)
decq %r14
leaq 0x1(%r14), %rax
cmpq $0x1, %rax
jg 0x37a1
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x387f(%rip), %rdi      # 0x70ec
leaq 0x3835(%rip), %rsi      # 0x70a9
leaq 0x38c0(%rip), %rcx      # 0x713b
movl $0xaa, %edx
callq 0x20f0
leaq 0x389e(%rip), %rdi      # 0x712a
leaq 0x3816(%rip), %rsi      # 0x70a9
leaq 0x38a1(%rip), %rcx      # 0x713b
movl $0xa9, %edx
callq 0x20f0
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/EmulNet.cpp
// Function: EmulNet::ENcleanup()
int EmulNet::ENcleanup() {
	emulnet.nextid=0;
	int i, j;
	int sent_total, recv_total;

	FILE* file = fopen("msgcount.log", "w+");

	while(emulnet.currbuffsize > 0) {
		free(emulnet.buff[--emulnet.currbuffsize]);
	}

	for ( i = 1; i <= par->EN_GPSZ; i++ ) {
		fprintf(file, "node %3d ", i);
		sent_total = 0;
		recv_total = 0;

		for (j = 0; j < par->getcurrtime(); j++) {

			sent_total += sent_msgs[i][j];
			recv_total += recv_msgs[i][j];
			if (i != 67) {
				fprintf(file, " (%4d, %4d)", sent_msgs[i][j], recv_msgs[i][j]);
				if (j % 10 == 9) {
					fprintf(file, "\n         ");
				}
			}
			else {
				fprintf(file, "special %4d %4d %4d\n", j, sent_msgs[i][j], recv_msgs[i][j]);
			}
		}
		fprintf(file, "\n");
		fprintf(file, "node %3d sent_total %6u  recv_total %6u\n\n", i, sent_total, recv_total);
	}

	fclose(file);
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r12
movl $0x0, 0x1b7e4a0(%rdi)
leaq 0x38d1(%rip), %rdi      # 0x7197
leaq 0x38d7(%rip), %rsi      # 0x71a4
callq 0x2200
movq %rax, %rbx
movl 0x1b7e4a4(%r12), %eax
testl %eax, %eax
jle 0x38fa
decl %eax
movl %eax, 0x1b7e4a4(%r12)
movq 0x1b7e4b0(%r12,%rax,8), %rdi
callq 0x2210
jmp 0x38d5
movq 0x8(%r12), %rax
cmpl $0x0, 0x18(%rax)
jle 0x3a64
leaq 0xdc2a90(%r12), %rax
movq %rax, 0x10(%rsp)
movl $0x1, %eax
movq %r12, 0x20(%rsp)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x3878(%rip), %rsi      # 0x71a7
movq %rax, 0x18(%rsp)
movq %rax, %rdx
xorl %eax, %eax
callq 0x2260
movq 0x8(%r12), %rdi
callq 0x4d50
movl $0x0, %r13d
movl $0x0, %r15d
testl %eax, %eax
jle 0x3a14
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %rbp, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
movq 0x10(%rsp), %rax
movl -0xdbf240(%rax,%rbp,4), %r14d
movl (%rax,%rbp,4), %ebx
cmpq $0x43, 0x18(%rsp)
jne 0x39a9
movq 0x8(%rsp), %rdi
leaq 0x3830(%rip), %rsi      # 0x71c8
movl %ebp, %edx
movl %r14d, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x2260
jmp 0x39f6
shrq $0x3, %rdx
leaq (%rdx,%rdx,4), %rax
leaq 0x9(,%rax,2), %r12
movq 0x8(%rsp), %rdi
leaq 0x37ec(%rip), %rsi      # 0x71b1
movl %r14d, %edx
movl %ebx, %ecx
xorl %eax, %eax
callq 0x2260
cmpl %ebp, %r12d
movq 0x20(%rsp), %r12
jne 0x39f6
movl $0xa, %esi
movl $0x1, %edx
leaq 0x37d1(%rip), %rdi      # 0x71bd
movq 0x8(%rsp), %rcx
callq 0x2330
addl %r14d, %r13d
addl %ebx, %r15d
incq %rbp
movq 0x8(%r12), %rdi
callq 0x4d50
cltq
cmpq %rax, %rbp
jl 0x3964
movl $0xa, %edi
movq 0x8(%rsp), %rbx
movq %rbx, %rsi
callq 0x2230
movq %rbx, %rdi
leaq 0x37ad(%rip), %rsi      # 0x71dd
movq 0x18(%rsp), %r14
movl %r14d, %edx
movl %r13d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0x2260
leaq 0x1(%r14), %rax
movq 0x8(%r12), %rcx
movslq 0x18(%rcx), %rcx
addq $0x3840, 0x10(%rsp)     # imm = 0x3840
cmpq %rcx, %r14
jl 0x3925
movq %rbx, %rdi
callq 0x2190
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/Application.cpp
// Function: handler(int)
void handler(int sig) {
	void *array[10];
	size_t size;

	// get void*'s for all entries on the stack
	size = backtrace(array, 10);

	// print out all the frames to stderr
	fprintf(stderr, "Error: signal %d:\n", sig);
	backtrace_symbols_fd(array, size, STDERR_FILENO);
	exit(1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x50, %rsp
movl %edi, %ebx
movq %rsp, %r14
movq %r14, %rdi
movl $0xa, %esi
callq 0x2280
movl %eax, %ebp
movq 0x7529(%rip), %rax      # 0xafd8
movq (%rax), %rdi
leaq 0x375b(%rip), %rsi      # 0x7214
movl %ebx, %edx
xorl %eax, %eax
callq 0x2260
movq %r14, %rdi
movl %ebp, %esi
movl $0x2, %edx
callq 0x22b0
movl $0x1, %edi
callq 0x2220
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/Application.cpp
// Function: main
int main(int argc, char *argv[]) {
	//signal(SIGSEGV, handler);
	if ( argc != ARGS_COUNT ) {
		cout<<"Configuration (i.e., *.conf) file File Required"<<endl;
		return FAILURE;
	}

	// Create a new application object
	Application *app = new Application(argv[1]);
	// Call the run function
	app->run();
	// When done delete the application object
	delete(app);

	return SUCCESS;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x2, %edi
jne 0x3b15
movq %rsi, %r14
movl $0x48, %edi
callq 0x21a0
movq %rax, %rbx
movq 0x8(%r14), %rsi
movq %rax, %rdi
callq 0x3bfe
movq %rbx, %rdi
callq 0x3b7c
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %eax, %eax
jmp 0x3b5c
movq 0x74b4(%rip), %rbx      # 0xafd0
leaq 0x3704(%rip), %rsi      # 0x7227
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x21d0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2180
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2100
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rax, %r14
movl $0x48, %esi
movq %rbx, %rdi
callq 0x21b0
movq %r14, %rdi
callq 0x22f0
// File: /workspace/github_cpp_makefile_star2_O1/csMOOC[P]UIUC/Application.cpp
// Function: Application::run()
int Application::run()
{
	int i;
	int timeWhenAllNodesHaveJoined = 0;
	// boolean indicating if all nodes have joined
	bool allNodesJoined = false;
	srand(time(NULL));

	// As time runs along
	for( par->globaltime = 0; par->globaltime < TOTAL_RUNNING_TIME; ++par->globaltime ) {
		// Run the membership protocol
		mp1Run();
		// Fail some nodes
		fail();
	}

	// Clean up
	en->ENcleanup();

	for(i=0;i<=par->EN_GPSZ-1;i++) {
		 mp1[i]->finishUpThisNode();
	}

	return SUCCESS;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
xorl %edi, %edi
callq 0x2150
movl %eax, %edi
callq 0x2170
movq 0x40(%rbx), %rax
movl $0x0, 0x28(%rax)
movq %rbx, %rdi
callq 0x3e8c
movq %rbx, %rdi
callq 0x40d4
movq 0x40(%rbx), %rax
movl 0x28(%rax), %ecx
leal 0x1(%rcx), %edx
movl %edx, 0x28(%rax)
cmpl $0x2bb, %ecx            # imm = 0x2BB
jl 0x3b9c
movq 0x28(%rbx), %rdi
callq 0x38a4
movq 0x40(%rbx), %rax
cmpl $0x0, 0x18(%rax)
jle 0x3bf4
xorl %r14d, %r14d
movq 0x38(%rbx), %rax
movq (%rax,%r14,8), %rdi
callq 0x285c
incq %r14
movq 0x40(%rbx), %rax
movslq 0x18(%rax), %rax
cmpq %rax, %r14
jl 0x3bd7
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq