LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_c_makefile_star2_O3/richarddurbin[P]hash10x/moshmap.c
// Function: referencePack
void referencePack (Reference *ref)
{
  resize (ref->depth, ref->ms->size, ref->ms->max+1, U32) ;
  resize (ref->index, ref->size, ref->max, U32) ;
  resize (ref->offset, ref->size, ref->max, U32) ;
  resize (ref->id, ref->size, ref->max, U32) ;
  ref->size = ref->max ;
  
  ref->rev = new (ref->size, U32) ;			/* now build rev and loc */
  ref->loc = new (ref->ms->max + 1, U32) ; ref->loc[0] = 0 ;
  int i ;
  for (i = 1 ; i <= ref->ms->max ; ++i)
    { ref->loc[i] = ref->loc[i-1] + ref->depth[i-1] ; }
  memset (ref->depth, 0, ref->ms->size*sizeof(U32)) ; /* build this up again in loop below */
  U32 *ri = ref->index ;
  for (i = 0 ; i < ref->max ; ++i, ++ri)
    ref->rev[ref->loc[*ri] + ref->depth[*ri]++] = i ;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rdi), %rax
movl 0x40(%rax), %edi
incl %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, %r14
movq (%rbx), %rax
movq 0x28(%rbx), %rsi
movl 0xc(%rax), %ecx
movl 0x40(%rax), %edx
incl %edx
cmpl %edx, %ecx
cmovbl %ecx, %edx
shlq $0x2, %rdx
movq %r14, %rdi
callq 0x1140
movq 0x28(%rbx), %rdi
callq 0x1040
movq %r14, 0x28(%rbx)
movl 0xc(%rbx), %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, %r14
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %edx
cmpl %edx, %eax
cmovbl %eax, %edx
movq 0x10(%rbx), %rsi
shlq $0x2, %rdx
movq %r14, %rdi
callq 0x1140
movq 0x10(%rbx), %rdi
callq 0x1040
movq %r14, 0x10(%rbx)
movl 0xc(%rbx), %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, %r14
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %edx
cmpl %edx, %eax
cmovbl %eax, %edx
movq 0x18(%rbx), %rsi
shlq $0x2, %rdx
movq %r14, %rdi
callq 0x1140
movq 0x18(%rbx), %rdi
callq 0x1040
movq %r14, 0x18(%rbx)
movl 0xc(%rbx), %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, %r14
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %edx
cmpl %edx, %eax
cmovbl %eax, %edx
movq 0x20(%rbx), %rsi
shlq $0x2, %rdx
movq %r14, %rdi
callq 0x1140
movq 0x20(%rbx), %rdi
callq 0x1040
movq %r14, 0x20(%rbx)
movl 0xc(%rbx), %edi
movl %edi, 0x8(%rbx)
shlq $0x2, %rdi
callq 0x64ac
movq %rax, 0x30(%rbx)
movq (%rbx), %rax
movl 0x40(%rax), %edi
incl %edi
shlq $0x2, %rdi
callq 0x64ac
movq %rax, 0x38(%rbx)
movl $0x0, (%rax)
movq (%rbx), %rcx
movq 0x28(%rbx), %rdi
cmpl $0x0, 0x40(%rcx)
je 0x2049
xorl %edx, %edx
xorl %esi, %esi
addl (%rdi,%rdx,4), %esi
movl %esi, 0x4(%rax,%rdx,4)
movl 0x40(%rcx), %r8d
incq %rdx
cmpq %r8, %rdx
jb 0x2036
movl 0xc(%rcx), %edx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x10d0
cmpl $0x0, 0xc(%rbx)
je 0x208f
movq 0x10(%rbx), %rax
movq 0x28(%rbx), %rcx
movq 0x30(%rbx), %rdx
movq 0x38(%rbx), %rsi
xorl %edi, %edi
movl (%rax,%rdi,4), %r8d
movl (%rcx,%r8,4), %r9d
leal 0x1(%r9), %r10d
addl (%rsi,%r8,4), %r9d
movl %r10d, (%rcx,%r8,4)
movl %edi, (%rdx,%r9,4)
incq %rdi
cmpl 0xc(%rbx), %edi
jb 0x206f
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: user_join_battle
void user_join_battle(uint32_t bid, uint32_t uid) {
	int ux = (rand() & 0x7FFF) % BATTLE_W;
	int uy = (rand() & 0x7FFF) % BATTLE_H;
	battles[bid].users[uid].pos.x = ux;
	battles[bid].users[uid].pos.y = uy;
	log("alloc position (%hhu, %hhu) for launcher #%d@%s\n",
			ux, uy, uid, sessions[uid].user_name);

	sessions[uid].state = USER_STATE_BATTLE;

	if(battles[bid].users[uid].battle_state == BATTLE_STATE_UNJOINED) {
		user_join_battle_common_part(bid, uid, USER_STATE_BATTLE);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %esi, %ebx
movl %edi, %r14d
callq 0x1180
andl $0x7fff, %eax           # imm = 0x7FFF
movw $0x3c, %cx
xorl %edx, %edx
divw %cx
movzwl %dx, %r15d
callq 0x1180
andl $0xf, %eax
movl %r14d, -0x2c(%rbp)
movl %r14d, %ecx
movl %ebx, %edx
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
leaq 0x80e7(%rip), %r12      # 0x92f0
addq %rcx, %r12
imulq $0x14, %rdx, %r13
movb %r15b, 0x20(%r13,%r12)
movb %al, 0x21(%r13,%r12)
movq 0x7dcf(%rip), %rcx      # 0x8ff0
movq (%rcx), %rdi
imulq $0x48, %rdx, %r14
leaq 0x7f51(%rip), %rcx      # 0x9180
leaq (%rcx,%r14), %r10
leaq 0x3fa2(%rip), %rsi      # 0x51dc
leaq 0x3fe4(%rip), %rdx      # 0x5225
movl $0x89, %ecx
movl %r15d, %r8d
movl %eax, %r9d
xorl %eax, %eax
pushq %r10
pushq %rbx
callq 0x10d0
popq %rcx
popq %rdx
leaq 0x7f21(%rip), %rax      # 0x9180
movl $0x3, 0xc(%r14,%rax)
cmpl $0x0, 0x10(%r13,%r12)
je 0x127f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x3
popq %rdx
movl -0x2c(%rbp), %edi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x301d
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: find_uid_by_user_name
int find_uid_by_user_name(const char *user_name) {
	int ret_uid = -1;
	log("find user '%s'\n", user_name);
	for(int i = 0; i < USER_CNT; i++) {
		if(query_session_built(i)) {
			if(strncmp(user_name, sessions[i].user_name, USERNAME_SIZE - 1) == 0) {
				ret_uid = i;
				break;
			}
		}
	}

	if(ret_uid == -1) {
		logi("fail\n");
	}else{
		logi("found: %d@%s\n", ret_uid, sessions[ret_uid].user_name);
	}

	return ret_uid;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
movq 0x7d3e(%rip), %r13      # 0x8ff0
movq (%r13), %rdi
leaq 0x3ff5(%rip), %rsi      # 0x52b2
leaq 0x4016(%rip), %rdx      # 0x52da
xorl %ebx, %ebx
movl $0x9f, %ecx
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
leaq 0x7ea4(%rip), %r15      # 0x9180
pushq $0x6
popq %r12
cmpl $0x2, 0xc(%r15)
jb 0x12f9
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1050
testl %eax, %eax
je 0x1329
incq %rbx
addq $0x48, %r15
cmpq $0x5, %rbx
jne 0x12e0
movq (%r13), %rdi
leaq 0x3fdf(%rip), %rsi      # 0x52f0
leaq 0x3fc2(%rip), %rdx      # 0x52da
movl $0xaa, %ecx
xorl %eax, %eax
callq 0x10d0
pushq $-0x1
popq %rbx
jmp 0x134d
movq (%r13), %rdi
leaq 0x3fde(%rip), %rsi      # 0x5312
leaq 0x3f9f(%rip), %rdx      # 0x52da
movl $0xac, %ecx
movl %ebx, %r8d
movq %r15, %r9
xorl %eax, %eax
callq 0x10d0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: battle_ruler
void *battle_ruler(void *args) {
	int bid = (int)(uintptr_t)args;
	log("battle ruler for battle #%d\n", bid);
	// FIXME: battle re-alloced before exiting loop 
	while(battles[bid].is_alloced) {
		move_bullets(bid);
		check_who_get_blood_vial(bid);
		check_who_traped_in_magma(bid);
		check_who_got_charger(bid);
		check_who_is_shooted(bid);
		check_who_is_dead(bid);
		
		random_generate_items(bid);

		inform_all_user_battle_state(bid);

		usleep(50000);
	}
	return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x7c81(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x439b(%rip), %rsi      # 0x5714
leaq 0x43c9(%rip), %rdx      # 0x5749
movl $0x1ce, %ecx            # imm = 0x1CE
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10d0
movslq %ebx, %rax
imulq $0xb08, %rax, %rax      # imm = 0xB08
leaq 0x7f50(%rip), %r14      # 0x92f0
cmpl $0x0, (%rax,%r14)
je 0x13f2
addq %rax, %r14
movl %ebx, %edi
callq 0x3427
movl %ebx, %edi
callq 0x350a
movl %ebx, %edi
callq 0x3623
movl %ebx, %edi
callq 0x3753
movl %ebx, %edi
callq 0x37dc
movl %ebx, %edi
callq 0x386e
movl %ebx, %edi
callq 0x33b4
movl %ebx, %edi
callq 0x38c8
movl $0xc350, %edi           # imm = 0xC350
callq 0x1190
cmpl $0x0, (%r14)
jne 0x13aa
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: launch_battle
void launch_battle(int bid) {
	pthread_t thread;

	log("try to create battle_ruler thread\n");
	if(pthread_create(&thread, NULL, battle_ruler, (void *)(uintptr_t)bid) == -1) {
		eprintf("fail to launch battle\n");
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %ebx
movq 0x7be3(%rip), %r14      # 0x8ff0
movq (%r14), %rdi
leaq 0x43d8(%rip), %rsi      # 0x57ef
leaq 0x4a1c(%rip), %rdx      # 0x5e3a
movl $0x1f5, %ecx            # imm = 0x1F5
xorl %eax, %eax
callq 0x10d0
movslq %ebx, %rcx
leaq -0xd6(%rip), %rdx       # 0x135e
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x1130
cmpl $-0x1, %eax
je 0x144d
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq (%r14), %rdi
leaq 0x43d3(%rip), %rsi      # 0x582a
leaq 0x49dc(%rip), %rdx      # 0x5e3a
movl $0x1f7, %ecx            # imm = 0x1F7
xorl %eax, %eax
callq 0x10d0
xorl %edi, %edi
callq 0x1150
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: client_command_user_logout
int client_command_user_logout(int uid) {
	if(sessions[uid].state == USER_STATE_BATTLE
	|| sessions[uid].state == USER_STATE_WAIT_TO_BATTLE) {
		log("user %d@%s tries to logout was in battle\n", uid, sessions[uid].user_name);
		user_quit_battle(sessions[uid].bid, uid);
	}

	log("user %d@%s logout\n", uid, sessions[uid].user_name);
	sessions[uid].state = USER_STATE_NOT_LOGIN;
	inform_friends(uid, SERVER_MESSAGE_FRIEND_LOGOUT);
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
movslq %edi, %rax
imulq $0x48, %rax, %rax
leaq 0x793a(%rip), %rcx      # 0x9180
leaq (%rcx,%rax), %r14
movl 0xc(%rax,%rcx), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x188b
movq 0x7793(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x429c(%rip), %rsi      # 0x5b03
leaq 0x42d7(%rip), %rdx      # 0x5b45
movl $0x24d, %ecx            # imm = 0x24D
movl %ebx, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r14), %edi
movl %ebx, %esi
callq 0x2f9c
movq 0x775e(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x42c4(%rip), %rsi      # 0x5b60
leaq 0x42a2(%rip), %rdx      # 0x5b45
movl $0x251, %ecx            # imm = 0x251
movl %ebx, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl $0x1, 0xc(%r14)
pushq $0x15
popq %rsi
movl %ebx, %edi
callq 0x326c
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: client_command_fetch_all_users
int client_command_fetch_all_users(int uid) {
	char *user_name = sessions[uid].user_name;
	log("user %d@'%s' tries to fetch all users' 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.response = SERVER_RESPONSE_ALL_USERS_INFO;

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

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %edi, %r14d
movslq %edi, %r15
imulq $0x48, %r15, %rbx
leaq 0x788d(%rip), %r13      # 0x9180
addq %r13, %rbx
movq 0x76f3(%rip), %r12      # 0x8ff0
movq (%r12), %rdi
leaq 0x42c7(%rip), %rsi      # 0x5bcf
leaq 0x4305(%rip), %rdx      # 0x5c14
movl $0x264, %ecx            # imm = 0x264
movl %r15d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x5, %r15d
jae 0x19d8
movl %r14d, %eax
imulq $0x48, %rax, %rax
cmpl $0x1, 0xc(%rax,%r13)
jbe 0x19a7
leaq -0x1cb(%rbp), %r14
xorl %r15d, %r15d
movl $0x1a3, %r12d           # imm = 0x1A3
movl $0x1a3, %edx            # imm = 0x1A3
movq %r14, %rdi
xorl %esi, %esi
callq 0x10a0
movq %r14, %rdi
callq 0x3ad7
movb $0xb, (%r14)
movl 0x8(%rbx), %ebx
imulq $0x1a3, %r15, %rax      # imm = 0x1A3
leaq (%rax,%rbp), %rsi
addq $-0x1cb, %rsi           # imm = 0xFE35
movl $0x1a3, %edx            # imm = 0x1A3
subq %r15, %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x1070
addq %rax, %r15
cmpq %r12, %r15
jb 0x1968
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rdi
leaq 0x4281(%rip), %rsi      # 0x5c33
leaq 0x425b(%rip), %rdx      # 0x5c14
movl $0x267, %ecx            # imm = 0x267
movl %r14d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
pushq $0x6
popq %rsi
movl %r14d, %edi
callq 0x359e
jmp 0x1993
leaq 0x3672(%rip), %rdi      # 0x5051
leaq 0x362e(%rip), %rsi      # 0x5014
leaq 0x3630(%rip), %rcx      # 0x501d
pushq $0x4a
popq %rdx
callq 0x1090
// File: /workspace/github_c_makefile_star2_O3/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 %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movl %edi, %r14d
movslq %edi, %r15
imulq $0x48, %r15, %rbx
leaq 0x7766(%rip), %r13      # 0x9180
addq %r13, %rbx
movq 0x75cc(%rip), %r12      # 0x8ff0
movq (%r12), %rdi
leaq 0x4253(%rip), %rsi      # 0x5c82
leaq 0x4293(%rip), %rdx      # 0x5cc9
movl $0x278, %ecx            # imm = 0x278
movl %r15d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x5, %r15d
jae 0x1b08
movl %r14d, %eax
imulq $0x48, %rax, %rax
cmpl $0x1, 0xc(%rax,%r13)
jbe 0x1ad7
leaq -0x1cb(%rbp), %r14
xorl %r12d, %r12d
movl $0x1a3, %r13d           # imm = 0x1A3
movl $0x1a3, %edx            # imm = 0x1A3
movq %r14, %rdi
xorl %esi, %esi
callq 0x10a0
movq %r14, %rdi
callq 0x3ad7
movb $0x0, -0x1c3(%rbp,%r15,8)
movb $0xc, (%r14)
movl 0x8(%rbx), %ebx
imulq $0x1a3, %r12, %rax      # imm = 0x1A3
leaq (%rax,%rbp), %rsi
addq $-0x1cb, %rsi           # imm = 0xFE35
movl $0x1a3, %edx            # imm = 0x1A3
subq %r12, %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x1070
addq %rax, %r12
cmpq %r13, %r12
jb 0x1a98
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r12), %rdi
leaq 0x4151(%rip), %rsi      # 0x5c33
leaq 0x41e0(%rip), %rdx      # 0x5cc9
movl $0x27b, %ecx            # imm = 0x27B
movl %r14d, %r8d
movq %rbx, %r9
xorl %eax, %eax
callq 0x10d0
pushq $0x6
popq %rsi
movl %r14d, %edi
callq 0x359e
jmp 0x1ac3
leaq 0x3542(%rip), %rdi      # 0x5051
leaq 0x34fe(%rip), %rsi      # 0x5014
leaq 0x3500(%rip), %rcx      # 0x501d
pushq $0x4a
popq %rdx
callq 0x1090
// File: /workspace/github_c_makefile_star2_O3/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 0x129a
cmpl $-0x1, %eax
jne 0x1b76
movq 0x74a1(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x4191(%rip), %rsi      # 0x5cea
leaq 0x41c0(%rip), %rdx      # 0x5d20
movl $0x290, %ecx            # imm = 0x290
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x18
jmp 0x1bfe
movl %eax, %r12d
cmpl %ebx, %eax
jne 0x1bbf
movq 0x746c(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movslq %ebx, %rax
imulq $0x48, %rax, %r14
leaq 0x75eb(%rip), %r12      # 0x9180
leaq (%r12,%r14), %r9
leaq 0x4198(%rip), %rsi      # 0x5d38
leaq 0x4179(%rip), %rdx      # 0x5d20
movl $0x293, %ecx            # imm = 0x293
movl %r15d, %r8d
xorl %eax, %eax
callq 0x10d0
movl %ebx, 0x14(%r14,%r12)
pushq $0x11
jmp 0x1bfe
movslq %r12d, %rax
imulq $0x48, %rax, %r13
leaq 0x75b3(%rip), %rcx      # 0x9180
cmpl $0x3, 0xc(%r13,%rcx)
movq 0x7416(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
jne 0x1c17
leaq 0x4187(%rip), %rsi      # 0x5d6d
leaq 0x4133(%rip), %rdx      # 0x5d20
movl $0x298, %ecx            # imm = 0x298
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x19
popq %rsi
movl %ebx, %edi
callq 0x359e
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %rcx, %r13
leaq 0x4187(%rip), %rsi      # 0x5da8
leaq 0x40f8(%rip), %rdx      # 0x5d20
movl $0x29c, %ecx            # imm = 0x29C
movl %r12d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl %r15d, %edi
movl %r12d, %esi
callq 0x3057
movl %ebx, 0x14(%r13)
movslq %ebx, %rax
imulq $0x48, %rax, %rdx
leaq 0x7529(%rip), %rax      # 0x9180
addq %rax, %rdx
pushq $0x1a
popq %rsi
movl %r12d, %edi
callq 0x309f
jmp 0x1c06
// File: /workspace/github_c_makefile_star2_O3/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 0x7372(%rip), %r15      # 0x8ff0
movq (%r15), %rdi
movslq %ebx, %r8
imulq $0x48, %r8, %r12
leaq 0x74f1(%rip), %r13      # 0x9180
leaq (%r12,%r13), %r14
leaq 0x4299(%rip), %rsi      # 0x5f33
leaq 0x42cb(%rip), %rdx      # 0x5f6c
movl $0x2c6, %ecx            # imm = 0x2C6
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x3, 0xc(%r12,%r13)
movq (%r15), %rdi
jne 0x1ce2
leaq 0x42fc(%rip), %rsi      # 0x5fbe
leaq 0x42a3(%rip), %rdx      # 0x5f6c
movl $0x2cb, %ecx            # imm = 0x2CB
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r14), %edi
movl %ebx, %esi
callq 0x2f9c
jmp 0x1d06
leaq 0x429e(%rip), %rsi      # 0x5f87
leaq 0x427c(%rip), %rdx      # 0x5f6c
movl $0x2c8, %ecx            # imm = 0x2C8
xorl %eax, %eax
callq 0x10d0
pushq $0xf
popq %rsi
movl %ebx, %edi
callq 0x359e
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_O3/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 0x7447(%rip), %r12      # 0x9180
leaq (%r12,%rax), %r13
leaq (%rax,%r12), %r14
addq $0x19, %r14
movl -0x9(%r14), %eax
movl %eax, -0x34(%rbp)
movq %r14, %rdi
callq 0x129a
movl %eax, -0x30(%rbp)
movq 0x7292(%rip), %r15      # 0x8ff0
movq (%r15), %rdi
leaq 0x4291(%rip), %rsi      # 0x5ff9
leaq 0x42c5(%rip), %rdx      # 0x6034
movl $0x2d5, %ecx            # imm = 0x2D5
movl %ebx, %r8d
movq %r13, %r9
xorl %eax, %eax
callq 0x10d0
cmpl $0x3, -0xd(%r14)
movq (%r15), %rdi
jne 0x1dc8
movslq -0x30(%rbp), %rax
imulq $0x48, %rax, %rax
addq %rax, %r12
leaq 0x42fa(%rip), %rsi      # 0x6097
leaq 0x4290(%rip), %rdx      # 0x6034
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 0x1b25
jmp 0x1df3
leaq 0x4280(%rip), %rsi      # 0x604f
leaq 0x425e(%rip), %rdx      # 0x6034
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 0x359e
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_O3/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 0x71d5(%rip), %r13      # 0x8ff0
movq (%r13), %rdi
movslq %ebx, %rax
imulq $0x48, %rax, %r12
leaq 0x7353(%rip), %r15      # 0x9180
leaq (%r15,%r12), %r14
movl 0x10(%r12,%r15), %r9d
leaq 0x4373(%rip), %rsi      # 0x61b0
leaq 0x439f(%rip), %rdx      # 0x61e3
movl $0x304, %ecx            # imm = 0x304
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
movl 0xc(%r12,%r15), %eax
cmpl $0x4, %eax
je 0x1e82
cmpl $0x3, %eax
jne 0x1ebf
movq (%r13), %rdi
leaq 0x4393(%rip), %rsi      # 0x6200
leaq 0x436f(%rip), %rdx      # 0x61e3
movl $0x307, %ecx            # imm = 0x307
xorl %eax, %eax
callq 0x10d0
jmp 0x1ebb
movslq 0x10(%r14), %r12
imulq $0xb08, %r12, %rax      # imm = 0xB08
leaq 0x745c(%rip), %rcx      # 0x92f0
cmpl $0x0, (%rax,%rcx)
jne 0x1ef8
movq (%r13), %rdi
leaq 0x43b6(%rip), %rsi      # 0x625b
leaq 0x4337(%rip), %rdx      # 0x61e3
movl $0x312, %ecx            # imm = 0x312
movq %r14, %r8
xorl %eax, %eax
callq 0x10d0
pushq $0x10
jmp 0x1edf
movq (%r13), %rdi
leaq 0x43d7(%rip), %rsi      # 0x62a1
leaq 0x4312(%rip), %rdx      # 0x61e3
movl $0x317, %ecx            # imm = 0x317
xorl %eax, %eax
callq 0x10d0
pushq $0x12
popq %rsi
movl %ebx, %edi
callq 0x359e
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 0x309f
movl %r12d, %edi
movl %ebx, %esi
callq 0x11c0
movq (%r13), %rdi
leaq 0x430c(%rip), %rsi      # 0x622f
leaq 0x42b9(%rip), %rdx      # 0x61e3
movl $0x310, %ecx            # imm = 0x310
xorl %eax, %eax
callq 0x10d0
jmp 0x1ee7
// File: /workspace/github_c_makefile_star2_O3/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 0x70a1(%rip), %r12      # 0x8ff0
movq (%r12), %rdi
movslq %ebx, %rax
movq %rax, -0x30(%rbp)
imulq $0x48, %rax, %r13
leaq 0x721b(%rip), %r15      # 0x9180
leaq (%r15,%r13), %r14
movl 0x10(%r13,%r15), %r9d
leaq 0x435d(%rip), %rsi      # 0x62d2
leaq 0x4389(%rip), %rdx      # 0x6305
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 0x1fbc
cmpl $0x3, %eax
jne 0x200b
leaq 0x437d(%rip), %rsi      # 0x6322
leaq 0x4359(%rip), %rdx      # 0x6305
movl $0x321, %ecx            # imm = 0x321
xorl %eax, %eax
callq 0x10d0
pushq $0x10
jmp 0x2027
leaq 0x4393(%rip), %rsi      # 0x6356
leaq 0x433b(%rip), %rdx      # 0x6305
movl $0x324, %ecx            # imm = 0x324
xorl %eax, %eax
callq 0x10d0
movslq 0x10(%r14), %rbx
movl 0x14(%r14), %edi
pushq $0x17
popq %rsi
callq 0x359e
movl $0x2, 0xc(%r14)
imulq $0xb08, %rbx, %rax      # imm = 0xB08
leaq 0x72f4(%rip), %rcx      # 0x92f0
addq %rax, %rcx
imulq $0x14, -0x30(%rbp), %rax
andl $0x0, 0x10(%rax,%rcx)
jmp 0x202f
leaq 0x428f(%rip), %rsi      # 0x62a1
leaq 0x42ec(%rip), %rdx      # 0x6305
movl $0x32a, %ecx            # imm = 0x32A
xorl %eax, %eax
callq 0x10d0
pushq $0x12
popq %rsi
movl %ebx, %edi
callq 0x359e
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_O3/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 0x7125(%rip), %rcx      # 0x9180
leaq (%rcx,%rax), %r14
movl 0x8(%rax,%rcx), %ebx
movl 0xc(%rax,%rcx), %eax
addl $-0x3, %eax
cmpl $0x1, %eax
ja 0x20a5
movq 0x6f7a(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x4302(%rip), %rsi      # 0x6382
leaq 0x4342(%rip), %rdx      # 0x63c9
movl $0x334, %ecx            # imm = 0x334
movl %r15d, %r8d
movq %r14, %r9
xorl %eax, %eax
callq 0x10d0
movl 0x10(%r14), %edi
movl %r15d, %esi
callq 0x2f9c
orl $-0x1, 0x8(%r14)
movq 0x6f3f(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x4322(%rip), %rsi      # 0x63dd
leaq 0x4307(%rip), %rdx      # 0x63c9
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_O3/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 0x6ef1(%rip), %rax      # 0x8ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x7070(%rip), %r15      # 0x9180
leaq (%r15,%r14), %r8
leaq 0x42eb(%rip), %rsi      # 0x6406
leaq 0x430d(%rip), %rdx      # 0x642f
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 0x71ac(%rip), %rax      # 0x92f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
andl $0x0, 0x18(%rdx,%rax)
movb 0x21(%rdx,%rax), %cl
testb %cl, %cl
je 0x2164
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_O3/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 0x6e6e(%rip), %rax      # 0x8ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x6fed(%rip), %r15      # 0x9180
leaq (%r15,%r14), %r8
leaq 0x42a8(%rip), %rsi      # 0x6446
leaq 0x42cc(%rip), %rdx      # 0x6471
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 0x7129(%rip), %rax      # 0x92f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x1, 0x18(%rdx,%rax)
movb 0x21(%rdx,%rax), %cl
cmpb $0xe, %cl
ja 0x21eb
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_O3/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 0x6de7(%rip), %rax      # 0x8ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x6f66(%rip), %r15      # 0x9180
leaq (%r15,%r14), %r8
leaq 0x4265(%rip), %rsi      # 0x648a
leaq 0x4289(%rip), %rdx      # 0x64b5
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 0x70a2(%rip), %rax      # 0x92f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x2, 0x18(%rdx,%rax)
movb 0x20(%rdx,%rax), %cl
testb %cl, %cl
je 0x2271
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_O3/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 0x6d61(%rip), %rax      # 0x8ff0
movq (%rax), %rax
movslq %edi, %rbx
imulq $0x48, %rbx, %r14
leaq 0x6ee0(%rip), %r15      # 0x9180
leaq (%r15,%r14), %r8
leaq 0x4223(%rip), %rsi      # 0x64ce
leaq 0x4248(%rip), %rdx      # 0x64fa
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 0x701c(%rip), %rax      # 0x92f0
addq %rcx, %rax
imulq $0x14, %rbx, %rdx
movl $0x3, 0x18(%rdx,%rax)
movb 0x20(%rdx,%rax), %cl
cmpb $0x3a, %cl
ja 0x22f8
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_O3/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 0x6cd1(%rip), %rbx      # 0x8ff0
movq (%rbx), %rdi
movl %eax, -0x2c(%rbp)
movslq %eax, %r14
imulq $0x48, %r14, %r15
leaq 0x6e4d(%rip), %r12      # 0x9180
leaq (%r12,%r15), %r8
leaq 0x41d6(%rip), %rsi      # 0x6514
leaq 0x41f5(%rip), %r13      # 0x653a
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 0x3348
movl %eax, %r15d
movq (%rbx), %rdi
leaq 0x41dc(%rip), %rsi      # 0x654e
movq %r13, %rdx
movl $0x36b, %ecx            # imm = 0x36B
movl %eax, %r8d
xorl %eax, %eax
callq 0x10d0
cmpl $-0x1, %r15d
je 0x23b5
movslq %r12d, %rax
imulq $0xb08, %rax, %rax      # imm = 0xB08
leaq 0x6f55(%rip), %r13      # 0x92f0
addq %rax, %r13
imulq $0x14, %r14, %rax
cmpl $0x0, 0x14(%rax,%r13)
jg 0x23c6
pushq $0x24
popq %rsi
movl -0x2c(%rbp), %edi
callq 0x359e
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 0x6c09(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x418f(%rip), %rsi      # 0x6580
leaq 0x4142(%rip), %rdx      # 0x653a
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 0x23b5
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: query_session_built
int query_session_built(uint32_t uid) {
	assert(uid < USER_CNT);

	if(sessions[uid].state == USER_STATE_UNUSED
	|| sessions[uid].state == USER_STATE_NOT_LOGIN) {
		return false;
	}else{
		return true;
	}
}

// Assembly:
cmpl $0x5, %edi
jae 0x2f79
movl %edi, %eax
leaq (%rax,%rax,8), %rcx
leaq 0x6212(%rip), %rdx      # 0x9180
xorl %eax, %eax
cmpl $0x2, 0xc(%rdx,%rcx,8)
setae %al
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x20cd(%rip), %rdi      # 0x5051
leaq 0x2089(%rip), %rsi      # 0x5014
leaq 0x208b(%rip), %rcx      # 0x501d
movl $0x4a, %edx
callq 0x1090
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: wrap_send
void wrap_send(int conn, server_message_t *psm) {
	size_t total_len = 0;
	while(total_len < sizeof(server_message_t)) {
		size_t len = send(conn, psm + total_len, sizeof(server_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
movl $0x1a3, %r12d           # imm = 0x1A3
imulq $0x1a3, %r15, %rsi      # imm = 0x1A3
addq %rbx, %rsi
movl $0x1a3, %edx            # imm = 0x1A3
subq %r15, %rdx
movl %r14d, %edi
xorl %ecx, %ecx
callq 0x1070
addq %rax, %r15
cmpq %r12, %r15
jb 0x2ff0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: user_invited_to_join_battle
void user_invited_to_join_battle(uint32_t bid, uint32_t uid) {
	if(sessions[uid].state == USER_STATE_WAIT_TO_BATTLE
	&& bid != sessions[uid].bid) {
		log("user %d@%s rejects old battle #%d since he was invited to a new battle\n", uid, sessions[uid].user_name, sessions[uid].bid);

		send_to_client_with_username(sessions[uid].inviter_id, SERVER_MESSAGE_FRIEND_REJECT_BATTLE, sessions[uid].user_name);
	}

	user_join_battle_common_part(bid, uid, USER_STATE_WAIT_TO_BATTLE);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movl %esi, %ebx
movl %edi, %r14d
movl %esi, %eax
leaq (%rax,%rax,8), %rax
leaq 0x6110(%rip), %rcx      # 0x9180
cmpl $0x4, 0xc(%rcx,%rax,8)
jne 0x3083
leaq (%rcx,%rax,8), %rsi
movl 0x10(%rsi), %edx
cmpl %r14d, %edx
jne 0x3096
movl %r14d, %edi
movl %ebx, %esi
movl $0x4, %edx
popq %rbx
popq %r14
popq %rbp
jmp 0x301d
movl %ebx, %edi
callq 0x268e
jmp 0x3083
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: send_to_client_with_username
void send_to_client_with_username(int uid, int message, char *user_name) {
	int conn = sessions[uid].conn;
	server_message_t sm;
	memset(&sm, 0, sizeof(server_message_t));
	sm.response = message;
	strncpy(sm.friend_name, user_name, USERNAME_SIZE - 1);
	wrap_send(conn, &sm);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
movq %rdx, %r14
movl %esi, %r15d
movslq %edi, %rax
leaq (%rax,%rax,8), %rax
leaq 0x60b9(%rip), %rcx      # 0x9180
movl 0x8(%rcx,%rax,8), %ebx
leaq -0x1c4(%rbp), %r12
xorl %r13d, %r13d
movl $0x19c, %edx            # imm = 0x19C
movq %r12, %rdi
xorl %esi, %esi
callq 0x10a0
movb %r15b, -0x7(%r12)
leaq -0x1ca(%rbp), %rdi
movl $0x6, %edx
movq %r14, %rsi
callq 0x1040
movl $0x1a3, %r14d           # imm = 0x1A3
imulq $0x1a3, %r13, %rax      # imm = 0x1A3
leaq (%rax,%rbp), %rsi
addq $-0x1cb, %rsi           # imm = 0xFE35
movl $0x1a3, %edx            # imm = 0x1A3
subq %r13, %rdx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x1070
addq %rax, %r13
cmpq %r14, %r13
jb 0x3103
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: get_unalloced_battle
int get_unalloced_battle() {
	int ret_bid = -1;
	pthread_mutex_lock(&battles_lock);
	for(int i = 0; i < USER_CNT; i++) {
		if(battles[i].is_alloced == false) {
			memset(&battles[i], 0, sizeof(struct battle_t));
			battles[i].is_alloced = true;
			ret_bid = i;
			break;
		}
	}
	pthread_mutex_unlock(&battles_lock);
	if(ret_bid == -1) {
		loge("check here, returned battle id should not be -1\n");
	}else{
		log("alloc unalloced battle id #%d\n", ret_bid);
	}
	return ret_bid;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
leaq 0x6002(%rip), %rdi      # 0x9150
callq 0x1170
leaq 0x6196(%rip), %r14      # 0x92f0
xorl %ebx, %ebx
cmpl $0x0, (%r14)
je 0x317e
incq %rbx
addq $0xb08, %r14            # imm = 0xB08
cmpq $0x5, %rbx
jne 0x315c
callq 0x26d8
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x31c7
movl $0xb08, %edx            # imm = 0xB08
movq %r14, %rdi
xorl %esi, %esi
callq 0x10a0
movl $0x1, (%r14)
leaq 0x5fb5(%rip), %rdi      # 0x9150
callq 0x1100
movq 0x5e49(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x21eb(%rip), %rsi      # 0x539c
leaq 0x21cf(%rip), %rdx      # 0x5387
movl $0xc1, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10d0
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: get_unused_session
int get_unused_session() {
	int ret_uid = -1;
	pthread_mutex_lock(&sessions_lock);
	for(int i = 0; i < USER_CNT; i++) {
		if(sessions[i].state == USER_STATE_UNUSED) {
			memset(&sessions[i], 0, sizeof(struct session_t));
			sessions[i].conn = -1;
			sessions[i].state = USER_STATE_NOT_LOGIN;
			ret_uid = i;
			break;
		}
	}
	pthread_mutex_unlock(&sessions_lock);
	if(ret_uid == -1) {
		log("fail to alloc session id\n");
	}else{
		log("alloc unused session id #%d\n", ret_uid);
	}
	return ret_uid;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
leaq 0x5f4d(%rip), %rdi      # 0x9128
callq 0x1170
leaq 0x5fa5(%rip), %rax      # 0x918c
xorl %ebx, %ebx
cmpl $0x0, (%rax)
je 0x3207
incq %rbx
addq $0x48, %rax
cmpq $0x5, %rbx
jne 0x31e9
callq 0x270d
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
jmp 0x3263
xorps %xmm0, %xmm0
movups %xmm0, -0xc(%rax)
movups %xmm0, 0x24(%rax)
movups %xmm0, 0x14(%rax)
movups %xmm0, 0x4(%rax)
movq $0x0, 0x34(%rax)
movabsq $0x1ffffffff, %rcx      # imm = 0x1FFFFFFFF
movq %rcx, -0x4(%rax)
leaq 0x5ef1(%rip), %rdi      # 0x9128
callq 0x1100
movq 0x5dad(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
leaq 0x21cb(%rip), %rsi      # 0x5418
leaq 0x21b1(%rip), %rdx      # 0x5405
movl $0xd6, %ecx
movl %ebx, %r8d
xorl %eax, %eax
callq 0x10d0
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: inform_friends
void inform_friends(int uid, int message) {
	server_message_t sm;
	char *user_name = sessions[uid].user_name;
	memset(&sm, 0, sizeof(server_message_t));
	sm.message = message;
	for(int i = 0; i < USER_CNT; i++) {
		if(i == uid || !query_session_built(i))
			continue;
		strncpy(sm.friend_name, user_name, USERNAME_SIZE - 1);
		wrap_send(sessions[i].conn, &sm);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movl %esi, %r14d
movslq %edi, %rbx
leaq (%rbx,%rbx,8), %rax
leaq 0x5eef(%rip), %rcx      # 0x9180
leaq (%rcx,%rax,8), %rax
movq %rax, -0x30(%rbp)
leaq -0x1cc(%rbp), %r15
xorl %r13d, %r13d
movl $0x19c, %edx            # imm = 0x19C
movq %r15, %rdi
xorl %esi, %esi
callq 0x10a0
movb %r14b, -0x7(%r15)
movl %ebx, %r14d
movl $0x1a3, %ebx            # imm = 0x1A3
cmpq %r14, %r13
je 0x332d
leaq (,%r13,8), %r15
addq %r13, %r15
leaq 0x5eab(%rip), %rax      # 0x9180
cmpl $0x2, 0xc(%rax,%r15,8)
jb 0x332d
movl $0x6, %edx
leaq -0x1d2(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1040
leaq 0x5e87(%rip), %rax      # 0x9180
movl 0x8(%rax,%r15,8), %r15d
xorl %r12d, %r12d
imulq $0x1a3, %r12, %rax      # imm = 0x1A3
leaq (%rax,%rbp), %rsi
addq $-0x1d3, %rsi           # imm = 0xFE2D
movl $0x1a3, %edx            # imm = 0x1A3
subq %r12, %rdx
movl %r15d, %edi
xorl %ecx, %ecx
callq 0x1070
addq %rax, %r12
cmpq %rbx, %r12
jb 0x3301
incq %r13
cmpq $0x5, %r13
jne 0x32be
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: get_unused_item
int get_unused_item(int bid) {
	int ret_item_id = -1;
	pthread_mutex_lock(&items_lock[bid]);
	for(int i = 0; i < MAX_ITEM; i++) {
		if(!(battles[bid].items[i].is_used)) {
			ret_item_id = i;
			battles[bid].items[i].is_used = true;
			break;
		}
	}
	pthread_mutex_unlock(&items_lock[bid]);
	return ret_item_id;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movslq %edi, %r14
leaq (%r14,%r14,4), %rax
leaq 0x96c3(%rip), %rcx      # 0xca20
leaq (%rcx,%rax,8), %rbx
movq %rbx, %rdi
callq 0x1170
imulq $0xb08, %r14, %rax      # imm = 0xB08
leaq 0x5f79(%rip), %rcx      # 0x92f0
addq %rcx, %rax
addq $0x78, %rax
xorl %r14d, %r14d
cmpl $0x0, (%rax)
je 0x339e
incq %r14
addq $0x14, %rax
cmpq $0x87, %r14
jne 0x3381
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x33a4
movl $0x1, (%rax)
movq %rbx, %rdi
callq 0x1100
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: random_generate_items
void random_generate_items(int bid) {
	if(rand() % 200 != 9) return;

	if(battles[bid].num_of_other >= MAX_OTHER) return;

	int item_id = get_unused_item(bid);
	if(item_id == -1) return;

	int random_kind = rand() % (ITEM_END - 1) + 1;

	battles[bid].items[item_id].kind = random_kind;
	battles[bid].items[item_id].pos.x = (rand() & 0x7FFF) % BATTLE_W;
	battles[bid].items[item_id].pos.y = (rand() & 0x7FFF) % BATTLE_H;
	log("new item: #%dk%d(%d,%d)\n", item_id,
			battles[bid].items[item_id].kind,
			battles[bid].items[item_id].pos.x,
			battles[bid].items[item_id].pos.y);
	if(random_kind == ITEM_MAGMA) {
		battles[bid].items[item_id].times = MAGMA_INIT_TIMES;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
callq 0x1180
cltq
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x26, %rcx
addl %edx, %ecx
imull $0xc8, %ecx, %ecx
subl %ecx, %eax
cmpl $0x9, %eax
jne 0x340d
movslq %ebx, %rax
imulq $0xb08, %rax, %r15      # imm = 0xB08
leaq 0x5ef7(%rip), %r14      # 0x92f0
cmpl $0xe, 0x74(%r15,%r14)
jg 0x340d
movl %ebx, %edi
callq 0x3348
cmpl $-0x1, %eax
jne 0x3418
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
addq %r15, %r14
movq %r14, %rdi
movl %eax, %esi
callq 0x2742
jmp 0x340d
// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/server.c
// Function: move_bullets
void move_bullets(int bid) {
	for(int i = 0; i < MAX_ITEM; i++) {
		if(battles[bid].items[i].is_used == false
		|| battles[bid].items[i].kind != ITEM_BULLET)
			continue;
		uint8_t *px = &(battles[bid].items[i].pos.x);
		uint8_t *py = &(battles[bid].items[i].pos.y);

		// log("try to move bullet %d with dir %d\n", i, battles[bid].items[i].dir);

		switch(battles[bid].items[i].dir) {
			case DIR_UP:	(*py)--;break;
			case DIR_DOWN:	(*py)++;break;
			case DIR_LEFT:	(*px)--;break;
			case DIR_RIGHT:	(*px)++;break;
		}

		if(*px >= BATTLE_W || *py >= BATTLE_H) {
			log("free bullet #%d\n", i);
			battles[bid].items[i].is_used = false;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movslq %edi, %rax
imulq $0xb08, %rax, %rax      # imm = 0xB08
leaq 0x5eaa(%rip), %rcx      # 0x92f0
leaq (%rax,%rcx), %r12
addq $0x89, %r12
leaq 0x203c(%rip), %rbx      # 0x5494
leaq 0x205e(%rip), %r14      # 0x54bd
leaq 0x1b9e(%rip), %r13      # 0x5004
xorl %r15d, %r15d
cmpl $0x0, -0x11(%r12)
je 0x34bf
cmpl $0x6, -0x5(%r12)
jne 0x34bf
movl -0xd(%r12), %eax
cmpq $0x3, %rax
ja 0x34af
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movb $-0x1, %al
jmp 0x34ab
movb -0x1(%r12), %al
decb %al
jmp 0x34a2
movb -0x1(%r12), %al
incb %al
movb %al, -0x1(%r12)
jmp 0x34b4
movb $0x1, %al
addb %al, (%r12)
movb -0x1(%r12), %al
cmpb $0x3b, %al
ja 0x34d1
cmpb $0x10, (%r12)
jae 0x34d1
incq %r15
addq $0x14, %r12
cmpq $0x87, %r15
jne 0x3469
jmp 0x34fb
movq 0x5b18(%rip), %rax      # 0x8ff0
movq (%rax), %rdi
movq %rbx, %rsi
movq %r14, %rdx
movl $0x11e, %ecx            # imm = 0x11E
movl %r15d, %r8d
xorl %eax, %eax
callq 0x10d0
movl $0x0, -0x11(%r12)
jmp 0x34bf
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq