// File: /workspace/github_c_makefile_star2_O0/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
subq $0x20, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1a80
movl %eax, -0x14(%rbp)
cmpl $-0x1, -0x14(%rbp)
jne 0x3e8e
movq 0x619d(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %r8
leaq 0x2e81(%rip), %rsi      # 0x6cea
leaq 0x2eb0(%rip), %rdx      # 0x6d20
movl $0x290, %ecx            # imm = 0x290
movb $0x0, %al
callq 0x10f0
movl -0x8(%rbp), %edi
movl $0x18, %esi
callq 0x25e0
jmp 0x3fbb
movl -0x14(%rbp), %eax
cmpl -0x8(%rbp), %eax
jne 0x3efa
movq 0x615b(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x4(%rbp), %r8d
movslq -0x8(%rbp), %rax
leaq 0x6371(%rip), %r9       # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %r9
leaq 0x2e7b(%rip), %rsi      # 0x6d38
leaq 0x2e5c(%rip), %rdx      # 0x6d20
movl $0x293, %ecx            # imm = 0x293
movb $0x0, %al
callq 0x10f0
movl -0x8(%rbp), %ecx
movslq -0x8(%rbp), %rdx
leaq 0x6342(%rip), %rax      # 0xa220
imulq $0x48, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movl -0x8(%rbp), %edi
movl $0x11, %esi
callq 0x25e0
jmp 0x3fb9
movslq -0x14(%rbp), %rcx
leaq 0x631b(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x3, 0xc(%rax)
jne 0x3f49
movq 0x60df(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x10(%rbp), %r8
leaq 0x2e46(%rip), %rsi      # 0x6d6d
leaq 0x2df2(%rip), %rdx      # 0x6d20
movl $0x298, %ecx            # imm = 0x298
movb $0x0, %al
callq 0x10f0
movl -0x8(%rbp), %edi
movl $0x19, %esi
callq 0x25e0
jmp 0x3fb7
movq 0x60a8(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0x14(%rbp), %r8d
movq -0x10(%rbp), %r9
leaq 0x2e46(%rip), %rsi      # 0x6da8
leaq 0x2db7(%rip), %rdx      # 0x6d20
movl $0x29c, %ecx            # imm = 0x29C
movb $0x0, %al
callq 0x10f0
movl -0x4(%rbp), %edi
movl -0x14(%rbp), %esi
callq 0x1910
movl -0x8(%rbp), %ecx
movslq -0x14(%rbp), %rdx
leaq 0x6292(%rip), %rax      # 0xa220
imulq $0x48, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x14(%rax)
movl -0x14(%rbp), %edi
movslq -0x8(%rbp), %rax
leaq 0x627a(%rip), %rdx      # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %rdx
movl $0x1a, %esi
callq 0x1a00
jmp 0x3fb9
jmp 0x3fbb
xorl %eax, %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)