LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_fetch_all_friends
int client_command_fetch_all_friends(int uid) {
	char *user_name = sessions[uid].user_name;
	log("user %d@'%s' tries to fetch all friends' info\n", uid, user_name);

	if(!query_session_built(uid)) {
		logi("user %d@'%s' who tries to list users hasn't login\n", uid, user_name);
		send_to_client(uid, SERVER_RESPONSE_YOU_HAVE_NOT_LOGIN);
		return 0;
	}

	server_message_t sm;
	memset(&sm, 0, sizeof(server_message_t));
	list_all_users(&sm);
	sm.all_users[uid].user_state = USER_STATE_UNUSED;
	sm.response = SERVER_RESPONSE_ALL_FRIENDS_INFO;

	wrap_send(sessions[uid].conn, &sm);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x1b0, %rsp            # imm = 0x1B0
movl %edi, %r14d
movslq %edi, %r15
imulq $0x48, %r15, %rax
leaq 0x55a6(%rip), %rbx      # 0x8180
addq %rax, %rbx
movq 0x540c(%rip), %r12      # 0x7ff0
movq (%r12), %rdi
leaq 0x2093(%rip), %rsi      # 0x4c82
leaq 0x20d3(%rip), %rdx      # 0x4cc9
movl $0x278, %ecx            # imm = 0x278
movl %r15d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
movl %r15d, %edi
callq 0x12ac
testl %eax, %eax
je 0x2c5c
leaq -0x1c3(%rbp), %r14
movl $0x1a3, %edx            # imm = 0x1A3
movq %r14, %rdi
xorl %esi, %esi
callq 0x10a0
movq %r14, %rdi
callq 0x2a3b
movb $0x0, -0x1bb(%rbp,%r15,8)
movb $0xc, (%r14)
movl 0x8(%rbx), %edi
movq %r14, %rsi
callq 0x143b
xorl %eax, %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rdi
leaq 0x1fcc(%rip), %rsi      # 0x4c33
leaq 0x205b(%rip), %rdx      # 0x4cc9
movl $0x27b, %ecx            # imm = 0x27B
movl %r14d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
pushq $0x6
popq %rsi
movl %r14d, %edi
callq 0x1e05
jmp 0x2c4a
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: invite_friend_to_battle
int invite_friend_to_battle(int bid, int uid, char *friend_name) {
	int friend_id = find_uid_by_user_name(friend_name);
	if(friend_id == -1) {
		// fail to find friend
		logi("friend '%s' hasn't login\n", friend_name);
		send_to_client(uid, SERVER_MESSAGE_FRIEND_NOT_LOGIN);
	}else if(friend_id == uid){
		logi("launch battle %d for %s\n", bid, sessions[uid].user_name);
		sessions[uid].inviter_id = uid;
		send_to_client(uid, SERVER_RESPONSE_INVITATION_SENT);
	}else if(sessions[friend_id].state == USER_STATE_BATTLE) {
		// friend already in battle
		logi("friend '%s' already in battle\n", friend_name);
		send_to_client(uid, SERVER_MESSAGE_FRIEND_ALREADY_IN_BATTLE);
	}else{
		// invite friend
		logi("friend %d@'%s' found\n", friend_id, friend_name);

		user_invited_to_join_battle(bid, friend_id);
		// WARNING: can't move this statement
		sessions[friend_id].inviter_id = uid;

		send_to_client_with_username(friend_id, SERVER_MESSAGE_INVITE_TO_BATTLE, sessions[uid].user_name);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %ebx
movl %edi, %r15d
movq %rdx, %rdi
callq 0x176d
cmpl $-0x1, %eax
jne 0x2cde
movq 0x5339(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x2029(%rip), %rsi      # 0x4cea
leaq 0x2058(%rip), %rdx      # 0x4d20
movl $0x290, %ecx            # imm = 0x290
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x18
jmp 0x2d66
movl %eax, %r12d
cmpl %ebx, %eax
jne 0x2d27
movq 0x5304(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
movslq %ebx, %rax
imulq $0x48, %rax, %r14
leaq 0x5483(%rip), %r12      # 0x8180
leaq (%r12,%r14), %r9
leaq 0x2030(%rip), %rsi      # 0x4d38
leaq 0x2011(%rip), %rdx      # 0x4d20
movl $0x293, %ecx            # imm = 0x293
movl %r15d, %r8d
xorl %eax, %eax
callq 0x10d0
movl %ebx, 0x14(%r14,%r12)
pushq $0x11
jmp 0x2d66
movslq %r12d, %rax
imulq $0x48, %rax, %r13
leaq 0x544b(%rip), %rcx      # 0x8180
cmpl $0x3, 0xc(%r13,%rcx)
movq 0x52ae(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
jne 0x2d7f
leaq 0x201f(%rip), %rsi      # 0x4d6d
leaq 0x1fcb(%rip), %rdx      # 0x4d20
movl $0x298, %ecx            # imm = 0x298
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x19
popq %rsi
movl %ebx, %edi
callq 0x1e05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rcx, %r13
leaq 0x201f(%rip), %rsi      # 0x4da8
leaq 0x1f90(%rip), %rdx      # 0x4d20
movl $0x29c, %ecx            # imm = 0x29C
movl %r12d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl %r15d, %edi
movl %r12d, %esi
callq 0x1671
movl %ebx, 0x14(%r13)
movslq %ebx, %rax
imulq $0x48, %rax, %rdx
leaq 0x53c1(%rip), %rax      # 0x8180
addq %rax, %rdx
pushq $0x1a
popq %rsi
movl %r12d, %edi
callq 0x16f6
jmp 0x2d6e
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_launch_battle
int client_command_launch_battle(int uid) {
	if(sessions[uid].state == USER_STATE_BATTLE) {
		log("user '%s' who tries to launch battle has been in battle\n", sessions[uid].user_name);
		send_to_client(uid, SERVER_RESPONSE_YOURE_ALREADY_IN_BATTLE);
		return 0;
	}else{
		log("user '%s' tries to launch battle\n", sessions[uid].user_name);
	}

	int bid = get_unalloced_battle();
	client_message_t *pcm = &sessions[uid].cm;

	log("%s launch battle with %s\n", sessions[uid].user_name, pcm->user_name);

	if(bid == -1) {
		loge("fail to create battle for %s and %s\n", sessions[uid].user_name, pcm->user_name);
		send_to_client(uid, SERVER_RESPONSE_LAUNCH_BATTLE_FAIL);
		return 0;
	}else{
		logi("launch battle %d for %s, invite %s\n", bid, sessions[uid].user_name, pcm->user_name);
		user_join_battle(bid, uid);
		invite_friend_to_battle(bid, uid, pcm->user_name);
		launch_battle(bid);
		send_to_client(uid, SERVER_RESPONSE_LAUNCH_BATTLE_SUCCESS);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movslq %edi, %rax
imulq $0x48, %rax, %rax
leaq 0x5393(%rip), %rcx      # 0x8180
leaq (%rcx,%rax), %r14
cmpl $0x3, 0xc(%rax,%rcx)
movq 0x51f3(%rip), %r13      # 0x7ff0
movq (%r13), %rdi
jne 0x2e27
leaq 0x1fd0(%rip), %rsi      # 0x4dda
leaq 0x201a(%rip), %rdx      # 0x4e2b
movl $0x2aa, %ecx            # imm = 0x2AA
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x10
jmp 0x2ee7
leaq 0x201a(%rip), %rsi      # 0x4e48
leaq 0x1ff6(%rip), %rdx      # 0x4e2b
movl $0x2ae, %ecx            # imm = 0x2AE
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
callq 0x1837
movl %eax, %r12d
movq (%r13), %rdi
leaq 0x19(%r14), %r15
leaq 0x2027(%rip), %rsi      # 0x4e82
leaq 0x1fc9(%rip), %rdx      # 0x4e2b
movl $0x2b4, %ecx            # imm = 0x2B4
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x10d0
movq (%r13), %rdi
cmpl $-0x1, %r12d
jne 0x2ea2
leaq 0x202f(%rip), %rsi      # 0x4eb4
leaq 0x1f9f(%rip), %rdx      # 0x4e2b
movl $0x2b7, %ecx            # imm = 0x2B7
movq %r14, %r8
movq %r15, %r9
xorl %eax, %eax
callq 0x10d0
pushq $0xd
jmp 0x2ee7
movq %r15, (%rsp)
leaq 0x2046(%rip), %rsi      # 0x4ef3
leaq 0x1f77(%rip), %rdx      # 0x4e2b
movl $0x2bb, %ecx            # imm = 0x2BB
movl %r12d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl %r12d, %edi
movl %ebx, %esi
callq 0x1597
movl %r12d, %edi
movl %ebx, %esi
movq %r15, %rdx
callq 0x2c8d
movl %r12d, %edi
callq 0x2580
pushq $0xe
popq %rsi
movl %ebx, %edi
callq 0x1e05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_quit_battle
int client_command_quit_battle(int uid) {
	log("user %d@%s tries to quit battle\n", uid, sessions[uid].user_name);
	if(sessions[uid].state != USER_STATE_BATTLE) {
		logi("but he hasn't join battle\n");
		send_to_client(uid, SERVER_RESPONSE_YOURE_NOT_IN_BATTLE);
	}else{
		logi("call user_quit_battle to quit\n");
		user_quit_battle(sessions[uid].bid, uid);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x50d9(%rip), %r15      # 0x7ff0
movq (%r15), %rdi
movslq %ebx, %r8
imulq $0x48, %r8, %r12
leaq 0x5258(%rip), %r13      # 0x8180
leaq (%r12,%r13), %r14
leaq 0x2000(%rip), %rsi      # 0x4f33
leaq 0x2032(%rip), %rdx      # 0x4f6c
movl $0x2c6, %ecx            # imm = 0x2C6
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x3, 0xc(%r12,%r13)
movq (%r15), %rdi
jne 0x2f7b
leaq 0x2063(%rip), %rsi      # 0x4fbe
leaq 0x200a(%rip), %rdx      # 0x4f6c
movl $0x2cb, %ecx            # imm = 0x2CB
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r14), %edi
movl %ebx, %esi
callq 0x12ea
jmp 0x2f9f
leaq 0x2005(%rip), %rsi      # 0x4f87
leaq 0x1fe3(%rip), %rdx      # 0x4f6c
movl $0x2c8, %ecx            # imm = 0x2C8
xorl %eax, %eax
callq 0x10d0
pushq $0xf
popq %rsi
movl %ebx, %edi
callq 0x1e05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_invite_user
int client_command_invite_user(int uid) {
	client_message_t *pcm = &sessions[uid].cm;
	int bid = sessions[uid].bid;
	int friend_id = find_uid_by_user_name(pcm->user_name);
	log("user %d@%s tries to invite friend\n", uid, sessions[uid].user_name);

	if(sessions[uid].state != USER_STATE_BATTLE) {
		log("user %s who invites friend %s wasn't in battle\n", sessions[uid].user_name, pcm->user_name);
		send_to_client(uid, SERVER_RESPONSE_YOURE_NOT_IN_BATTLE);
	}else{
		logi("invite user %s to battle #%d\n", sessions[friend_id].user_name, bid);
		invite_friend_to_battle(bid, uid, pcm->user_name);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, -0x2c(%rbp)
movslq %edi, %rbx
imulq $0x48, %rbx, %rax
leaq 0x51ae(%rip), %r12      # 0x8180
leaq (%r12,%rax), %r13
leaq (%rax,%r12), %r14
addq $0x19, %r14
movl -0x9(%r14), %eax
movl %eax, -0x34(%rbp)
movq %r14, %rdi
callq 0x176d
movl %eax, -0x30(%rbp)
movq 0x4ff9(%rip), %r15      # 0x7ff0
movq (%r15), %rdi
leaq 0x1ff8(%rip), %rsi      # 0x4ff9
leaq 0x202c(%rip), %rdx      # 0x5034
movl $0x2d5, %ecx            # imm = 0x2D5
movl %ebx, %r8d
movq %r13, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x3, -0xd(%r14)
movq (%r15), %rdi
jne 0x3061
movslq -0x30(%rbp), %rax
imulq $0x48, %rax, %rax
addq %rax, %r12
leaq 0x2061(%rip), %rsi      # 0x5097
leaq 0x1ff7(%rip), %rdx      # 0x5034
movl $0x2db, %ecx            # imm = 0x2DB
movq %r12, %r8
movl -0x34(%rbp), %ebx
movl %ebx, %r9d
xorl %eax, %eax
callq 0x10d0
movl %ebx, %edi
movl -0x2c(%rbp), %esi
movq %r14, %rdx
callq 0x2c8d
jmp 0x308c
leaq 0x1fe7(%rip), %rsi      # 0x504f
leaq 0x1fc5(%rip), %rdx      # 0x5034
movl $0x2d8, %ecx            # imm = 0x2D8
movq %r13, %r8
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
pushq $0xf
popq %rsi
movl -0x2c(%rbp), %edi
callq 0x1e05
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_send_message
int client_command_send_message(int uid) 
{
	client_message_t *pcm = &sessions[uid].cm;
	server_message_t sm;
	memset(&sm,0,sizeof(server_message_t));
	sm.message=SERVER_MESSAGE_FRIEND_MESSAGE;
	strncpy(sm.from_user,sessions[uid].user_name,USERNAME_SIZE);
	strncpy(sm.msg,pcm->message,MSG_SIZE);
	if(pcm->user_name[0]=='\0')
	{
		logi("user %d:%s yells at all users: %s\n", uid, sessions[uid].user_name, pcm->message);
		int i;
		for(i=0;i<USER_CNT;i++)
		{
			if(uid==i)continue;
			wrap_send(sessions[i].conn,&sm);
		}
	}
	else
	{
		int friend_id=find_uid_by_user_name(pcm->user_name);
		if(friend_id==-1||friend_id==uid)
		{
			logi("user %d:%s fails to speak to '%s':\"%s\"\n",uid,sessions[uid].user_name,pcm->user_name,pcm->message);
		}
		else
		{
			logi("uiser %d:%s speaks to %d:%s : \"%s\"\n",uid,sessions[uid].user_name,friend_id,pcm->user_name,pcm->message);
			wrap_send(sessions[friend_id].conn,&sm);
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %edi, %ebx
movslq %edi, %rax
imulq $0x48, %rax, %r13
leaq 0x50bf(%rip), %r12      # 0x8180
leaq (%r12,%r13), %r14
leaq -0x1a3(%rbp), %r15
movl $0x173, %edx            # imm = 0x173
movq %r15, %rdi
xorl %esi, %esi
callq 0x10a0
movb $0x1b, -0x30(%r15)
leaq -0x1d2(%rbp), %rdi
pushq $0x7
popq %rdx
movq %r14, %rsi
callq 0x1040
leaq -0x1cb(%rbp), %rdi
leaq (%r12,%r13), %r15
addq $0x20, %r15
pushq $0x28
popq %rdx
movq %r15, %rsi
callq 0x1040
cmpb $0x0, -0x7(%r15)
jne 0x317c
movq 0x4ed6(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
subq $0x8, %rsp
leaq 0x1fa9(%rip), %rsi      # 0x50d1
leaq 0x1fe1(%rip), %rdx      # 0x5110
xorl %r13d, %r13d
movl $0x2eb, %ecx            # imm = 0x2EB
movl %ebx, %r8d
movq %r14, %r9
xorl %eax, %eax
pushq %r15
callq 0x10d0
addq $0x10, %rsp
movl %ebx, %eax
imulq $0x48, %rax, %r14
leaq -0x1d3(%rbp), %rbx
cmpq $0x168, %r13            # imm = 0x168
je 0x321a
cmpq %r13, %r14
je 0x3176
movl 0x8(%r13,%r12), %edi
movq %rbx, %rsi
callq 0x143b
addq $0x48, %r13
jmp 0x3157
leaq (%r12,%r13), %rdi
addq $0x19, %rdi
movq %rdi, -0x30(%rbp)
callq 0x176d
movl %eax, %r13d
cmpl $-0x1, %eax
setne %al
cmpl %ebx, %r13d
setne %cl
movq 0x4e4d(%rip), %rdx      # 0x7ff0
movq (%rdx), %rdi
testb %cl, %al
jne 0x31d3
leaq 0x1f7b(%rip), %rsi      # 0x512c
leaq 0x1f58(%rip), %rdx      # 0x5110
movl $0x2f8, %ecx            # imm = 0x2F8
movl %ebx, %r8d
movq %r14, %r9
xorl %eax, %eax
pushq %r15
pushq -0x30(%rbp)
callq 0x10d0
popq %rcx
popq %rdx
jmp 0x321a
subq $0x8, %rsp
leaq 0x1f92(%rip), %rsi      # 0x5170
leaq 0x1f2b(%rip), %rdx      # 0x5110
movl $0x2fc, %ecx            # imm = 0x2FC
movl %ebx, %r8d
movq %r14, %r9
xorl %eax, %eax
pushq %r15
pushq -0x30(%rbp)
pushq %r13
callq 0x10d0
addq $0x20, %rsp
movslq %r13d, %rax
imulq $0x48, %rax, %rax
movl 0x8(%rax,%r12), %edi
leaq -0x1d3(%rbp), %rsi
callq 0x143b
xorl %eax, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_accept_battle
int client_command_accept_battle(int uid) {
	log("user %s accept battle #%d\n", sessions[uid].user_name, sessions[uid].bid);

	if(sessions[uid].state == USER_STATE_BATTLE) {
		logi("already in battle\n");
		send_to_client(uid, SERVER_RESPONSE_YOURE_ALREADY_IN_BATTLE);
	}else if(sessions[uid].state == USER_STATE_WAIT_TO_BATTLE) {
		int inviter_id = sessions[uid].inviter_id;
		int bid = sessions[uid].bid;

		if(battles[bid].is_alloced) {
			send_to_client_with_username(inviter_id, SERVER_MESSAGE_FRIEND_ACCEPT_BATTLE, sessions[inviter_id].user_name);
			user_join_battle(bid, uid);
			logi("accept success\n");
		}else{
			logi("user %s accept battle which didn't exist\n", sessions[uid].user_name);
			send_to_client(uid, SERVER_RESPONSE_YOURE_ALREADY_IN_BATTLE);
		}

	}else{
		logi("hasn't been invited\n");
		send_to_client(uid, SERVER_RESPONSE_NOBODY_INVITE_YOU);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x4dab(%rip), %r13      # 0x7ff0
movq (%r13), %rdi
movslq %ebx, %rax
imulq $0x48, %rax, %r12
leaq 0x4f29(%rip), %r15      # 0x8180
leaq (%r15,%r12), %r14
movl 0x10(%r12,%r15), %r9d
leaq 0x1f49(%rip), %rsi      # 0x51b0
leaq 0x1f75(%rip), %rdx      # 0x51e3
movl $0x304, %ecx            # imm = 0x304
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
movl 0xc(%r12,%r15), %eax
cmpl $0x4, %eax
je 0x32ac
cmpl $0x3, %eax
jne 0x32e9
movq (%r13), %rdi
leaq 0x1f69(%rip), %rsi      # 0x5200
leaq 0x1f45(%rip), %rdx      # 0x51e3
movl $0x307, %ecx            # imm = 0x307
xorl %eax, %eax
callq 0x10d0
jmp 0x32e5
movslq 0x10(%r14), %r12
imulq $0xb08, %r12, %rax      # imm = 0xB08
leaq 0x5032(%rip), %rcx      # 0x82f0
cmpl $0x0, (%rax,%rcx)
jne 0x3322
movq (%r13), %rdi
leaq 0x1f8c(%rip), %rsi      # 0x525b
leaq 0x1f0d(%rip), %rdx      # 0x51e3
movl $0x312, %ecx            # imm = 0x312
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x10
jmp 0x3309
movq (%r13), %rdi
leaq 0x1fad(%rip), %rsi      # 0x52a1
leaq 0x1ee8(%rip), %rdx      # 0x51e3
movl $0x317, %ecx            # imm = 0x317
xorl %eax, %eax
callq 0x10d0
pushq $0x12
popq %rsi
movl %ebx, %edi
callq 0x1e05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq 0x14(%r14), %rdi
imulq $0x48, %rdi, %rax
addq %rax, %r15
pushq $0x16
popq %rsi
movq %r15, %rdx
callq 0x16f6
movl %r12d, %edi
movl %ebx, %esi
callq 0x1597
movq (%r13), %rdi
leaq 0x1ee2(%rip), %rsi      # 0x522f
leaq 0x1e8f(%rip), %rdx      # 0x51e3
movl $0x310, %ecx            # imm = 0x310
xorl %eax, %eax
callq 0x10d0
jmp 0x3311
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_reject_battle
int client_command_reject_battle(int uid) {
	log("user %s reject battle #%d\n", sessions[uid].user_name, sessions[uid].bid);
	if(sessions[uid].state == USER_STATE_BATTLE) {
		logi("user already in battle\n");
		send_to_client(uid, SERVER_RESPONSE_YOURE_ALREADY_IN_BATTLE);
	}else if(sessions[uid].state == USER_STATE_WAIT_TO_BATTLE) {
		logi("reject success\n");
		int bid = sessions[uid].bid;
		send_to_client(sessions[uid].inviter_id, SERVER_MESSAGE_FRIEND_REJECT_BATTLE);
		sessions[uid].state = USER_STATE_LOGIN;
		battles[bid].users[uid].battle_state = BATTLE_STATE_UNJOINED;
	}else{
		logi("hasn't been invited\n");
		send_to_client(uid, SERVER_RESPONSE_NOBODY_INVITE_YOU);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebx
movq 0x4c77(%rip), %r12      # 0x7ff0
movq (%r12), %rdi
movslq %ebx, %rax
movq %rax, -0x30(%rbp)
imulq $0x48, %rax, %r13
leaq 0x4df1(%rip), %r15      # 0x8180
leaq (%r15,%r13), %r14
movl 0x10(%r13,%r15), %r9d
leaq 0x1f33(%rip), %rsi      # 0x52d2
leaq 0x1f5f(%rip), %rdx      # 0x5305
movl $0x31f, %ecx            # imm = 0x31F
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
movl 0xc(%r13,%r15), %eax
movq (%r12), %rdi
cmpl $0x4, %eax
je 0x33e6
cmpl $0x3, %eax
jne 0x3435
leaq 0x1f53(%rip), %rsi      # 0x5322
leaq 0x1f2f(%rip), %rdx      # 0x5305
movl $0x321, %ecx            # imm = 0x321
xorl %eax, %eax
callq 0x10d0
pushq $0x10
jmp 0x3451
leaq 0x1f69(%rip), %rsi      # 0x5356
leaq 0x1f11(%rip), %rdx      # 0x5305
movl $0x324, %ecx            # imm = 0x324
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14), %rbx
movl 0x14(%r14), %edi
pushq $0x17
popq %rsi
callq 0x1e05
movl $0x2, 0xc(%r14)
imulq $0xb08, %rbx, %rax      # imm = 0xB08
leaq 0x4eca(%rip), %rcx      # 0x82f0
addq %rax, %rcx
imulq $0x14, -0x30(%rbp), %rax
andl $0x0, 0x10(%rax,%rcx)
jmp 0x3459
leaq 0x1e65(%rip), %rsi      # 0x52a1
leaq 0x1ec2(%rip), %rdx      # 0x5305
movl $0x32a, %ecx            # imm = 0x32A
xorl %eax, %eax
callq 0x10d0
pushq $0x12
popq %rsi
movl %ebx, %edi
callq 0x1e05
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_quit
int client_command_quit(int uid) {
	int conn = sessions[uid].conn;
	if(sessions[uid].state == USER_STATE_BATTLE
	|| sessions[uid].state == USER_STATE_WAIT_TO_BATTLE) {
		log("user %d@%s tries to quit client was in battle\n", uid, sessions[uid].user_name);
		user_quit_battle(sessions[uid].bid, uid);
	}

	sessions[uid].conn = -1;
	log("user %d@%s quit\n", uid, sessions[uid].user_name);
	sessions[uid].state = USER_STATE_UNUSED;
	close(conn);
	return -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %r15d
movslq %edi, %rax
imulq $0x48, %rax, %rax
leaq 0x4cfb(%rip), %rcx      # 0x8180
leaq (%rcx,%rax), %r14
movl 0x8(%rax,%rcx), %ebx
movl 0xc(%rax,%rcx), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x34cf
movq 0x4b50(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1ed8(%rip), %rsi      # 0x5382
leaq 0x1f18(%rip), %rdx      # 0x53c9
movl $0x334, %ecx            # imm = 0x334
movl %r15d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r14), %edi
movl %r15d, %esi
callq 0x12ea
orl $-0x1, 0x8(%r14)
movq 0x4b15(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1ef8(%rip), %rsi      # 0x53dd
leaq 0x1edd(%rip), %rdx      # 0x53c9
movl $0x339, %ecx            # imm = 0x339
movl %r15d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
andl $0x0, 0xc(%r14)
movl %ebx, %edi
callq 0x10b0
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_move_up
int client_command_move_up(int uid) {
	log("user %s move up\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	battles[bid].users[uid].dir = DIR_UP;
	if(battles[bid].users[uid].pos.y > 0) {
		battles[bid].users[uid].pos.y --;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x4ac7(%rip), %rax      # 0x7ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x4c46(%rip), %r15      # 0x8180
leaq (%r15,%r14), %r8
leaq 0x1ec1(%rip), %rsi      # 0x5406
leaq 0x1ee3(%rip), %rdx      # 0x542f
movq %rax, %rdi
movl $0x340, %ecx            # imm = 0x340
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14,%r15), %rax
imulq $0xb08, %rax, %rcx      # imm = 0xB08
leaq 0x4d82(%rip), %rax      # 0x82f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
andl $0x0, 0x18(%rdx,%rax)
movb 0x21(%rdx,%rax), %cl
testb %cl, %cl
je 0x358e
addq %rdx, %rax
addq $0x10, %rax
decb %cl
movb %cl, 0x11(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_move_down
int client_command_move_down(int uid) {
	log("user %s move down\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	battles[bid].users[uid].dir = DIR_DOWN;
	if(battles[bid].users[uid].pos.y < BATTLE_H - 1) {
		battles[bid].users[uid].pos.y ++;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x4a44(%rip), %rax      # 0x7ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x4bc3(%rip), %r15      # 0x8180
leaq (%r15,%r14), %r8
leaq 0x1e7e(%rip), %rsi      # 0x5446
leaq 0x1ea2(%rip), %rdx      # 0x5471
movq %rax, %rdi
movl $0x34a, %ecx            # imm = 0x34A
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14,%r15), %rax
imulq $0xb08, %rax, %rcx      # imm = 0xB08
leaq 0x4cff(%rip), %rax      # 0x82f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x1, 0x18(%rdx,%rax)
movb 0x21(%rdx,%rax), %cl
cmpb $0xe, %cl
ja 0x3615
addq %rdx, %rax
addq $0x10, %rax
incb %cl
movb %cl, 0x11(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_move_left
int client_command_move_left(int uid) {
	log("user %s move left\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	battles[bid].users[uid].dir = DIR_LEFT;
	if(battles[bid].users[uid].pos.x > 0) {
		battles[bid].users[uid].pos.x --;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x49bd(%rip), %rax      # 0x7ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x4b3c(%rip), %r15      # 0x8180
leaq (%r15,%r14), %r8
leaq 0x1e3b(%rip), %rsi      # 0x548a
leaq 0x1e5f(%rip), %rdx      # 0x54b5
movq %rax, %rdi
movl $0x354, %ecx            # imm = 0x354
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14,%r15), %rax
imulq $0xb08, %rax, %rcx      # imm = 0xB08
leaq 0x4c78(%rip), %rax      # 0x82f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x2, 0x18(%rdx,%rax)
movb 0x20(%rdx,%rax), %cl
testb %cl, %cl
je 0x369b
addq %rdx, %rax
addq $0x10, %rax
decb %cl
movb %cl, 0x10(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_move_right
int client_command_move_right(int uid) {
	log("user %s move right\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	battles[bid].users[uid].dir = DIR_RIGHT;
	if(battles[bid].users[uid].pos.x < BATTLE_W - 1) {
		battles[bid].users[uid].pos.x ++;
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq 0x4937(%rip), %rax      # 0x7ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x4ab6(%rip), %r15      # 0x8180
leaq (%r15,%r14), %r8
leaq 0x1df9(%rip), %rsi      # 0x54ce
leaq 0x1e1e(%rip), %rdx      # 0x54fa
movq %rax, %rdi
movl $0x35e, %ecx            # imm = 0x35E
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14,%r15), %rax
imulq $0xb08, %rax, %rcx      # imm = 0xB08
leaq 0x4bf2(%rip), %rax      # 0x82f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x3, 0x18(%rdx,%rax)
movb 0x20(%rdx,%rax), %cl
cmpb $0x3a, %cl
ja 0x3722
addq %rdx, %rax
addq $0x10, %rax
incb %cl
movb %cl, 0x10(%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: client_command_fire
int client_command_fire(int uid) {
	log("user %s fire\n", sessions[uid].user_name);
	int bid = sessions[uid].bid;
	int item_id = get_unused_item(bid);
	log("alloc item %d for bullet\n", item_id);
	if(item_id == -1) return 0;

	if(battles[bid].users[uid].nr_bullets <= 0) {
		send_to_client(uid, SERVER_MESSAGE_YOUR_MAGAZINE_IS_EMPTY);
		return 0;
	}

	int dir = battles[bid].users[uid].dir;
	int x = battles[bid].users[uid].pos.x;
	int y = battles[bid].users[uid].pos.y;
	log("bullet, %s@(%d, %d), direct to %d\n",
			sessions[uid].user_name, x, y, dir);
	battles[bid].items[item_id].kind = ITEM_BULLET;
	battles[bid].items[item_id].dir = dir;
	battles[bid].items[item_id].owner = uid;
	battles[bid].items[item_id].pos.x = x;
	battles[bid].items[item_id].pos.y = y;

	battles[bid].users[uid].nr_bullets --;

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %edi, %eax
movq 0x48a7(%rip), %rbx      # 0x7ff0
movq (%rbx), %rdi
movl %eax, -0x2c(%rbp)
movslq %eax, %r14
imulq $0x48, %r14, %r15
leaq 0x4a23(%rip), %r12      # 0x8180
leaq (%r12,%r15), %r8
leaq 0x1dac(%rip), %rsi      # 0x5514
leaq 0x1dcb(%rip), %r13      # 0x553a
movq %r13, %rdx
movl $0x368, %ecx            # imm = 0x368
movq %r8, -0x38(%rbp)
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r15,%r12), %r12d
movl %r12d, %edi
callq 0x1a49
movl %eax, %r15d
movq (%rbx), %rdi
leaq 0x1db2(%rip), %rsi      # 0x554e
movq %r13, %rdx
movl $0x36b, %ecx            # imm = 0x36B
movl %eax, %r8d
xorl %eax, %eax
callq 0x10d0
cmpl $-0x1, %r15d
je 0x37df
movslq %r12d, %rax
imulq $0xb08, %rax, %rax      # imm = 0xB08
leaq 0x4b2b(%rip), %r13      # 0x82f0
addq %rax, %r13
imulq $0x14, %r14, %rax
cmpl $0x0, 0x14(%rax,%r13)
jg 0x37f0
pushq $0x24
popq %rsi
movl -0x2c(%rbp), %edi
callq 0x1e05
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rax,%r13), %r14
addq $0x10, %r14
movl 0x8(%r14), %r12d
movzbl 0x10(%r14), %r9d
movl %r9d, -0x30(%rbp)
movzbl 0x11(%r14), %ebx
movq 0x47df(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1d65(%rip), %rsi      # 0x5580
leaq 0x1d18(%rip), %rdx      # 0x553a
movl $0x377, %ecx            # imm = 0x377
movq -0x38(%rbp), %r8
xorl %eax, %eax
pushq %r12
pushq %rbx
callq 0x10d0
popq %rcx
popq %rdx
movslq %r15d, %rax
imulq $0x14, %rax, %rax
movl $0x6, 0x84(%r13,%rax)
movl %r12d, 0x7c(%r13,%rax)
movl -0x2c(%rbp), %ecx
movl %ecx, 0x80(%r13,%rax)
movl -0x30(%rbp), %ecx
movb %cl, 0x88(%r13,%rax)
movb %bl, 0x89(%r13,%rax)
decl 0x4(%r14)
jmp 0x37df
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: wrap_recv
void wrap_recv(int conn, client_message_t *pcm) {
	size_t total_len = 0;
	while(total_len < sizeof(client_message_t)) {
		size_t len = recv(conn, pcm + total_len, sizeof(client_message_t) - total_len, 0);
		if(len < 0) {
			loge("broken pipe\n");
		}

		total_len += len;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %r14d
xorl %r15d, %r15d
pushq $0x30
popq %r12
cmpq $0x2f, %r15
ja 0x38b0
imulq $0x30, %r15, %rsi
addq %rbx, %rsi
movq %r12, %rdx
subq %r15, %rdx
movl %r14d, %edi
xorl %ecx, %ecx
callq 0x1030
addq %rax, %r15
jmp 0x388e
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: session_start
void *session_start(void *args) {
	int uid = -1;
	int conn = (int)(uintptr_t)args;
	client_message_t *pcm = NULL;
	if((uid = get_unused_session()) < 0) {
		close_session(conn, SERVER_RESPONSE_LOGIN_FAIL_SERVER_LIMITS);
		return NULL;
	}else{
		sessions[uid].conn = conn;
		pcm = &sessions[uid].cm;
		memset(pcm, 0, sizeof(client_message_t));
		log("build session #%d\n", uid);
	}

	while(1) {
		wrap_recv(conn, pcm);
		if(pcm->command >= CLIENT_COMMAND_END)
			continue;

		int ret_code = handler[pcm->command](uid);
		log("state of user '%s': %d\n", sessions[uid].user_name, sessions[uid].state);
		if(ret_code < 0) {
			log("close session #%d\n", uid);
			break;
		}
	}
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
callq 0x18ec
testl %eax, %eax
jns 0x3909
pushq $0xa
popq %rsi
movl %r14d, %edi
callq 0x38b9
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %ebx
movl %eax, %eax
imulq $0x48, %rax, %rax
leaq 0x4868(%rip), %rcx      # 0x8180
leaq (%rcx,%rax), %r15
leaq (%rax,%rcx), %r12
addq $0x18, %r12
movl %r14d, -0x10(%r12)
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, 0x20(%r12)
movq 0x46ac(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1c6d(%rip), %rsi      # 0x55bb
leaq 0x1c91(%rip), %rdx      # 0x55e6
movl $0x3d0, %ecx            # imm = 0x3D0
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10d0
movl %r14d, %edi
movq %r12, %rsi
callq 0x3876
movzbl (%r12), %eax
cmpq $0x10, %rax
ja 0x3964
movl %ebx, %edi
leaq 0x43dd(%rip), %rcx      # 0x7d60
callq *(%rcx,%rax,8)
movl %eax, %r13d
movq 0x4660(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
movl 0xc(%r15), %r9d
leaq 0x1c56(%rip), %rsi      # 0x55f4
leaq 0x1c41(%rip), %rdx      # 0x55e6
movl $0x3d9, %ecx            # imm = 0x3D9
movq %r15, %r8
xorl %eax, %eax
callq 0x10d0
testl %r13d, %r13d
jns 0x3964
movq 0x4630(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1c5a(%rip), %rsi      # 0x5624
leaq 0x1c15(%rip), %rdx      # 0x55e6
movl $0x3db, %ecx            # imm = 0x3DB
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10d0
jmp 0x38f8
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: server_start
int server_start() {
	int sockfd = socket(AF_INET, SOCK_STREAM, 0);

	if(sockfd < 0) {
		eprintf("Create Socket Failed!\n");
	}

	struct sockaddr_in servaddr;
	memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(PORT);
    servaddr.sin_addr.s_addr = htonl(INADDR_ANY);

	if(bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) {
		eprintf("Can not bind to port %d!\n", PORT);
	}

	if(listen(sockfd, USER_CNT) == -1) {
		eprintf("fail to listen on socket.\n");
	}

	return sockfd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x11a0
testl %eax, %eax
js 0x3a40
movl %eax, %ebx
leaq -0x18(%rbp), %rsi
andq $0x0, 0x8(%rsi)
movq $0x50c30002, (%rsi)     # imm = 0x50C30002
pushq $0x10
popq %rdx
movl %eax, %edi
callq 0x1120
cmpl $-0x1, %eax
je 0x3a5f
pushq $0x5
popq %rsi
movl %ebx, %edi
callq 0x1110
cmpl $-0x1, %eax
je 0x3a8b
movl %ebx, %eax
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0x45a9(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1bfe(%rip), %rsi      # 0x564f
leaq 0x1c28(%rip), %rdx      # 0x5680
movl $0x3eb, %ecx            # imm = 0x3EB
jmp 0x3aa8
movq 0x458a(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1c1d(%rip), %rsi      # 0x568d
leaq 0x1c09(%rip), %rdx      # 0x5680
movl $0x3f5, %ecx            # imm = 0x3F5
movl $0xc350, %r8d           # imm = 0xC350
xorl %eax, %eax
callq 0x10d0
jmp 0x3aaf
movq 0x455e(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1c25(%rip), %rsi      # 0x56c1
leaq 0x1bdd(%rip), %rdx      # 0x5680
movl $0x3f9, %ecx            # imm = 0x3F9
xorl %eax, %eax
callq 0x10d0
xorl %edi, %edi
callq 0x1150
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: terminate_process
void terminate_process(int recved_signal) {
	for(int i = 0; i < USER_CNT; i++) {
		if(sessions[i].conn >= 0) {
			close(sessions[i].conn);
			log("close conn:%d\n", sessions[i].conn);
		}
	}

	if(server_fd) {
		close(server_fd);
		log("close server fd:%d\n", server_fd);
	}

	pthread_mutex_destroy(&sessions_lock);
	pthread_mutex_destroy(&battles_lock);
	for(int i = 0; i < USER_CNT; i++) {
		pthread_mutex_destroy(&items_lock[i]);
	}

	log("receive terminate signal and exit(0)\n");
	exit(0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
pushq $0x8
popq %r12
leaq 0x46b1(%rip), %r13      # 0x8180
movq 0x451a(%rip), %r15      # 0x7ff0
leaq 0x1c19(%rip), %rbx      # 0x56f6
leaq 0x1c39(%rip), %r14      # 0x571d
cmpq $0x170, %r12            # imm = 0x170
je 0x3b1b
movl (%r12,%r13), %edi
testl %edi, %edi
jns 0x3afb
addq $0x48, %r12
jmp 0x3ae4
callq 0x10b0
movq (%r15), %rdi
movl (%r12,%r13), %r8d
movq %rbx, %rsi
movq %r14, %rdx
movl $0x403, %ecx            # imm = 0x403
xorl %eax, %eax
callq 0x10d0
jmp 0x3af5
movl 0x4657(%rip), %edi      # 0x8178
testl %edi, %edi
je 0x3b4e
callq 0x10b0
movq (%r15), %rdi
movl 0x4644(%rip), %r8d      # 0x8178
leaq 0x1bf4(%rip), %rsi      # 0x572f
leaq 0x1bdb(%rip), %rdx      # 0x571d
movl $0x409, %ecx            # imm = 0x409
xorl %eax, %eax
callq 0x10d0
leaq 0x45d3(%rip), %rdi      # 0x8128
callq 0x1080
leaq 0x45ef(%rip), %rdi      # 0x8150
callq 0x1080
xorl %ebx, %ebx
leaq 0x7eb1(%rip), %r14      # 0xba20
cmpq $0xc8, %rbx
je 0x3b87
leaq (%r14,%rbx), %rdi
callq 0x1080
addq $0x28, %rbx
jmp 0x3b6f
movq (%r15), %rdi
leaq 0x1bca(%rip), %rsi      # 0x575b
leaq 0x1b85(%rip), %rdx      # 0x571d
movl $0x412, %ecx            # imm = 0x412
xorl %eax, %eax
callq 0x10d0
xorl %edi, %edi
callq 0x1150
// File: /workspace/github_c_makefile_star2_O2/wierton[P]socket-based-naive-game/server.c
// Function: main
int main() {
	srand(time(NULL));

	pthread_t thread;

	if(signal(SIGINT, terminate_process) == SIG_ERR) {
		eprintf("An error occurred while setting a signal handler.\n");
	}

	for(int i = 0; i < USER_CNT; i++) {
		pthread_mutex_init(&items_lock[i], NULL);
	}

	server_fd = server_start();

	for(int i = 0; i < USER_CNT; i++)
		sessions[i].conn = -1;

	struct sockaddr_in client_addr;
	socklen_t length = sizeof(client_addr);
	while(1) {
		int conn = accept(server_fd, (struct sockaddr*)&client_addr, &length);
		log("connected by %s:%d, conn:%d\n", inet_ntoa(client_addr.sin_addr), client_addr.sin_port, conn);
		if(conn < 0) {
			loge("fail to accept client.\n");
		}else if(pthread_create(&thread, NULL, session_start, (void *)(uintptr_t)conn) != 0) {
			loge("fail to create thread.\n");
		}
		logi("bind thread #%lu\n", thread);
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %edi, %edi
callq 0x10f0
movl %eax, %edi
callq 0x10c0
leaq -0x11b(%rip), %rsi      # 0x3ab6
pushq $0x2
popq %rdi
callq 0x10e0
cmpq $-0x1, %rax
je 0x3cf9
xorl %ebx, %ebx
leaq 0x7e34(%rip), %r14      # 0xba20
cmpq $0xc8, %rbx
je 0x3c06
leaq (%r14,%rbx), %rdi
xorl %esi, %esi
callq 0x1160
addq $0x28, %rbx
jmp 0x3bec
callq 0x39ed
movl %eax, %edi
movl %eax, 0x4565(%rip)      # 0x8178
pushq $0x8
popq %rax
leaq 0x4563(%rip), %rcx      # 0x8180
cmpq $0x170, %rax            # imm = 0x170
je 0x3c2f
orl $-0x1, (%rax,%rcx)
addq $0x48, %rax
jmp 0x3c1d
leaq -0x2c(%rbp), %rax
movl $0x10, (%rax)
movq 0x43b0(%rip), %r15      # 0x7ff0
leaq 0x1b9f(%rip), %r12      # 0x57e6
leaq 0x1c36(%rip), %r13      # 0x5884
leaq -0x48(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
callq 0x1140
movl %eax, %ebx
movq (%r15), %r14
movl -0x44(%rbp), %edi
callq 0x1060
movzwl -0x46(%rbp), %r9d
movl %ebx, (%rsp)
movq %r14, %rdi
leaq 0x1b71(%rip), %rsi      # 0x57eb
movq %r12, %rdx
movl $0x42c, %ecx            # imm = 0x42C
movq %rax, %r8
xorl %eax, %eax
callq 0x10d0
testl %ebx, %ebx
jns 0x3ca4
movq (%r15), %rdi
leaq 0x1b86(%rip), %rsi      # 0x5820
movq %r12, %rdx
movl $0x42e, %ecx            # imm = 0x42E
jmp 0x3cce
movl %ebx, %ecx
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
leaq -0x3e0(%rip), %rdx      # 0x38d3
callq 0x1130
testl %eax, %eax
je 0x3cd5
movq (%r15), %rdi
leaq 0x1b8c(%rip), %rsi      # 0x5852
movq %r12, %rdx
movl $0x430, %ecx            # imm = 0x430
xorl %eax, %eax
callq 0x10d0
movq (%r15), %rdi
movq -0x38(%rbp), %r8
movq %r13, %rsi
movq %r12, %rdx
movl $0x432, %ecx            # imm = 0x432
xorl %eax, %eax
callq 0x10d0
movl 0x4484(%rip), %edi      # 0x8178
jmp 0x3c4e
movq 0x42f0(%rip), %rax      # 0x7ff0
movq (%rax), %rdi
leaq 0x1a8f(%rip), %rsi      # 0x5799
leaq 0x1ad5(%rip), %rdx      # 0x57e6
movl $0x41c, %ecx            # imm = 0x41C
xorl %eax, %eax
callq 0x10d0
xorl %edi, %edi
callq 0x1150
// File: /workspace/github_c_makefile_star2_O2/umbrant[P]Non-blocking-Buffers/service.c
// Function: main
int main() 
{
  char* service_name = (char*)malloc(sizeof(char)*50);
  char* service_name_other = (char*)malloc(sizeof(char)*50);

  strcpy(service_name, GUI);
  strcpy(service_name_other, "GUI2");

	if(nbb_init_service(NUM_CHANNELS, service_name)) {
		printf("Error initializing as service, failing!\n");
		return -1;
	}

  sleep(1);

  if(nbb_init_service(NUM_CHANNELS, service_name_other)) {
 		printf("Error initializing as service, failing!\n");
		return -1;
	}

  nbb_set_cb_new_connection(service_name, on_new_connection, NULL);
  nbb_set_cb_new_connection(service_name_other, on_new_conn_other, NULL);

  int counter = 0;

  while(1) {
    sleep(1);

/*
    if(is_client == 2 && !(counter % 5)) {
      nbb_send("Client", "Test message", sizeof("Test message"));
      nbb_send("Client2", "Test message", sizeof("Test message"));
    }*/
    counter++;
  }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
pushq $0x32
popq %rbx
movq %rbx, %rdi
callq 0x1160
movq %rax, %r14
movq %rbx, %rdi
callq 0x1160
movq %rax, %rbx
movl $0x495547, (%r14)       # imm = 0x495547
movl $0x32495547, (%rax)     # imm = 0x32495547
movb $0x0, 0x4(%rax)
pushq $0x5
popq %rdi
movq %r14, %rsi
callq 0x1a1a
testl %eax, %eax
jne 0x1390
pushq $0x1
popq %rdi
callq 0x1230
pushq $0x5
popq %rdi
movq %rbx, %rsi
callq 0x1a1a
testl %eax, %eax
je 0x13a7
leaq 0x1cb9(%rip), %rdi      # 0x3050
callq 0x1070
pushq $-0x1
popq %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0x27(%rip), %rsi        # 0x13d5
movq %r14, %rdi
xorl %edx, %edx
callq 0x21f9
leaq 0x2f(%rip), %rsi        # 0x13ee
movq %rbx, %rdi
xorl %edx, %edx
callq 0x21f9
pushq $0x1
popq %rbx
movl %ebx, %edi
callq 0x1230
jmp 0x13cc
// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/cmd/cmd.c
// Function: inform
static void inform(const char *msg, va_list ap)
{
   int my_errno = errno;

   fprintf(stderr, "%s: ", g_progname);
   vfprintf(stderr, msg, ap);

   size_t len = strlen(msg);
   if (len && msg[len - 1] == ':')
      fprintf(stderr, " %s", my_errno ? strerror(my_errno) : "<unknown error>");

   putc('\n', stderr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %r14
callq 0x2060
movl (%rax), %ebx
movq 0x10ddd8(%rip), %r12    # 0x110ff8
movq (%r12), %rdi
movq 0x10df1d(%rip), %rdx    # 0x111148
leaq 0x608c(%rip), %rsi      # 0x92be
xorl %eax, %eax
callq 0x21b0
movq (%r12), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2230
movq %r14, %rdi
callq 0x20e0
testq %rax, %rax
je 0x325d
cmpb $0x3a, -0x1(%r14,%rax)
je 0x3274
movq (%r12), %rsi
pushq $0xa
popq %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2190
movq (%r12), %r14
testl %ebx, %ebx
jne 0x3285
leaq 0x6040(%rip), %rdx      # 0x92c3
jmp 0x328f
movl %ebx, %edi
callq 0x2250
movq %rax, %rdx
leaq 0x6201(%rip), %rsi      # 0x9497
movq %r14, %rdi
xorl %eax, %eax
callq 0x21b0
jmp 0x325d
// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/cmd/cmd.c
// Function: parse_command
noreturn void parse_command(struct command *commands, const char *help,
                            int argc, char **argv)
{
   set_progname(*argv);
   set_help(help);

   if (argc == 1)
      display_help();

   const char *arg = argv[1];
   for (struct command *cmd = commands; cmd->name; cmd++) {
      if (!strcmp(cmd->name, arg)) {
         cmd->func(argc - 2, argv + 2);
         exit(EXIT_SUCCESS);
      }
   }
   if (*arg == '-') {
      arg++;
      if (*arg == '-') {
         arg++;
         if (!strcmp(arg, help_option.name))
            display_help();
      } else if (*arg == help_option.letter && !arg[1]) {
         display_help();
      }
   }
   die("unknown command: '%s'", argv[1]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rcx, %r14
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r15
movq (%rcx), %rdi
callq 0x33d2
movq %rbx, %rdi
callq 0x33f8
cmpl $0x1, %ebp
jne 0x3356
callq 0x347d
movq 0x8(%r14), %rbx
addq $0x8, %r15
movq -0x8(%r15), %rdi
testq %rdi, %rdi
je 0x3379
movq %rbx, %rsi
callq 0x2180
testl %eax, %eax
je 0x339d
addq $0x10, %r15
jmp 0x335e
cmpb $0x2d, (%rbx)
jne 0x33c1
movsbl 0x1(%rbx), %eax
cmpl $0x2d, %eax
jne 0x33b3
leaq 0x2(%rbx), %rdi
movq 0x10ddc6(%rip), %rsi    # 0x111158
callq 0x2180
testl %eax, %eax
je 0x3351
jmp 0x33c1
addl $-0x2, %ebp
addq $0x10, %r14
movl %ebp, %edi
movq %r14, %rsi
callq *(%r15)
xorl %edi, %edi
callq 0x2240
cmpl %eax, 0x10dd97(%rip)    # 0x111150
jne 0x33c1
cmpb $0x0, 0x2(%rbx)
je 0x3351
leaq 0x5e09(%rip), %rdi      # 0x91d1
movq %rbx, %rsi
xorl %eax, %eax
callq 0x317c
// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/cmd/cmd.c
// Function: set_help
static void check_help(const char *help)
{
   assert(help);
   bool legit = false;

   for (;;) {
      help = strchr(help, '%');
      if (!help)
         break;
      switch (*++help) {
      case 's':
         if (legit) {
            legit = false;
            goto fini;
         }
         legit = true;
         break;
      case '%':
         help++;
         break;
      default:
         legit = false;
         goto fini;
      }
   }

fini:
   if (!legit)
      die("invalid help screen");
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x345e
movq %rdi, %rbx
xorl %r14d, %r14d
pushq $0x25
popq %rbp
movq %rdi, %rax
movq %rax, %rdi
movl %ebp, %esi
callq 0x20f0
testq %rax, %rax
je 0x343e
movzbl 0x1(%rax), %ecx
cmpl $0x25, %ecx
jne 0x342b
addq $0x2, %rax
jmp 0x340d
cmpl $0x73, %ecx
jne 0x3450
incq %rax
testb $0x1, %r14b
movb $0x1, %r14b
je 0x340d
jmp 0x3450
testb $0x1, %r14b
je 0x3450
movq %rbx, 0x10dd75(%rip)    # 0x1111c0
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x5e9f(%rip), %rdi      # 0x92f6
xorl %eax, %eax
callq 0x317c
leaq 0x5e6e(%rip), %rdi      # 0x92d3
leaq 0x5d84(%rip), %rsi      # 0x91f0
leaq 0x5e65(%rip), %rcx      # 0x92d8
movl $0x96, %edx
callq 0x2130
// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/cmd/cmd.c
// Function: short_option
static struct option *short_option(struct option *options, int letter)
{
   assert(letter);

   while (options->name) {
      if (options->letter == letter)
         return options;
      options++;
   }
   if (letter == help_option.letter)
      return &help_option;

   die("unknown option: -%c", letter);
}

// Assembly:
pushq %rax
testl %esi, %esi
je 0x3746
cmpq $0x0, 0x8(%rdi)
je 0x3732
cmpl %esi, (%rdi)
je 0x3741
addq $0x20, %rdi
jmp 0x3721
cmpl %esi, 0x10da18(%rip)    # 0x111150
jne 0x3763
leaq 0x10da0f(%rip), %rdi    # 0x111150
movq %rdi, %rax
popq %rcx
retq
leaq 0x5bbd(%rip), %rdi      # 0x930a
leaq 0x5a9c(%rip), %rsi      # 0x91f0
leaq 0x5bb6(%rip), %rcx      # 0x9311
pushq $0x48
popq %rdx
callq 0x2130
leaq 0x5bd9(%rip), %rdi      # 0x9343
xorl %eax, %eax
callq 0x317c
// File: /workspace/github_c_makefile_star2_O2/michaelnmmeyer[P]gourgandine/cmd/cmd.c
// Function: handle_option
static void handle_option(struct option *opt, const char *arg)
{
   bool legit = true;

   switch (opt->type) {
   case OPT_STR:
      *opt->s = arg;
      break;
   case OPT_BOOL:
      *opt->b = true;
      break;
   case OPT_FUNC:
      opt->f();
      break;
   case OPT_DOUBLE: {
      char *end;
      errno = 0;
      *opt->d = strtod(arg, &end);
      if (errno || *end)
         legit = false;
      break;
   }
   case OPT_SIZE_T:
      if (!strcmp(arg, "inf")) {
         *opt->z = SIZE_MAX;
      } else {
         char *end;
         errno = 0;
         long long num = strtoll(arg, &end, 10);
         if (errno || *end || num < 0 || (uintmax_t)num > SIZE_MAX)
            legit = false;
         else
            *opt->z = num;
      }
      break;
   default:       // NUM_OPTS handled in switch.
      break;
   }

   if (!legit)
      die("invalid argument '%s' for option --%s", arg, opt->name);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl 0x10(%rdi), %eax
cmpq $0x4, %rax
ja 0x385e
movq %rsi, %rbx
leaq 0x5a1f(%rip), %rcx      # 0x91b0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x18(%rdi), %rax
movq %rbx, (%rax)
jmp 0x385e
movq %rdi, %r15
leaq 0x5ba7(%rip), %rsi      # 0x9357
movq %rbx, %rdi
callq 0x2180
testl %eax, %eax
je 0x3856
callq 0x2060
movq %rax, %r14
andl $0x0, (%rax)
leaq 0x8(%rsp), %rsi
pushq $0xa
popq %rdx
movq %rbx, %rdi
callq 0x21a0
cmpl $0x0, (%r14)
jne 0x3838
movq 0x8(%rsp), %rcx
cmpb $0x0, (%rcx)
jne 0x3838
testq %rax, %rax
js 0x3838
movq 0x18(%r15), %rcx
movq %rax, (%rcx)
jmp 0x385e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmpq *0x18(%rdi)
movq %rdi, %r15
callq 0x2060
movq %rax, %r14
andl $0x0, (%rax)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x20b0
movq 0x18(%r15), %rax
movsd %xmm0, (%rax)
cmpl $0x0, (%r14)
jne 0x3838
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x385e
movq 0x8(%r15), %rdx
leaq 0x5b18(%rip), %rdi      # 0x935b
movq %rbx, %rsi
xorl %eax, %eax
callq 0x317c
movq 0x18(%rdi), %rax
movb $0x1, (%rax)
jmp 0x385e
movq 0x18(%r15), %rax
orq $-0x1, (%rax)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq