// File: /workspace/github_c_makefile_star2_O0/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
subq $0x10, %rsp
movl %edi, -0x4(%rbp)
movq 0x59a6(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movslq -0x4(%rbp), %rax
leaq 0x5bc0(%rip), %r8       # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %r8
movslq -0x4(%rbp), %rcx
leaq 0x5bae(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %r9d
leaq 0x2b2c(%rip), %rsi      # 0x71b0
leaq 0x2b58(%rip), %rdx      # 0x71e3
movl $0x304, %ecx            # imm = 0x304
movb $0x0, %al
callq 0x10f0
movslq -0x4(%rbp), %rcx
leaq 0x5b7e(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x3, 0xc(%rax)
jne 0x46e5
movq 0x5942(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2b40(%rip), %rsi      # 0x7200
leaq 0x2b1c(%rip), %rdx      # 0x71e3
movl $0x307, %ecx            # imm = 0x307
movb $0x0, %al
callq 0x10f0
movl -0x4(%rbp), %edi
movl $0x10, %esi
callq 0x25e0
jmp 0x4813
movslq -0x4(%rbp), %rcx
leaq 0x5b30(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
cmpl $0x4, 0xc(%rax)
jne 0x47e0
movslq -0x4(%rbp), %rcx
leaq 0x5b14(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl %eax, -0x8(%rbp)
movslq -0x4(%rbp), %rcx
leaq 0x5afc(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, -0xc(%rbp)
movslq -0xc(%rbp), %rcx
leaq 0x5c54(%rip), %rax      # 0xa390
imulq $0xb08, %rcx, %rcx      # imm = 0xB08
addq %rcx, %rax
cmpl $0x0, (%rax)
je 0x479b
movl -0x8(%rbp), %edi
movslq -0x8(%rbp), %rax
leaq 0x5ac7(%rip), %rdx      # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %rdx
movl $0x16, %esi
callq 0x1a00
movl -0xc(%rbp), %edi
movl -0x4(%rbp), %esi
callq 0x17d0
movq 0x587c(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2aa9(%rip), %rsi      # 0x722f
leaq 0x2a56(%rip), %rdx      # 0x71e3
movl $0x310, %ecx            # imm = 0x310
movb $0x0, %al
callq 0x10f0
jmp 0x47de
movq 0x5856(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movslq -0x4(%rbp), %rax
leaq 0x5a70(%rip), %r8       # 0xa220
imulq $0x48, %rax, %rax
addq %rax, %r8
leaq 0x2a9d(%rip), %rsi      # 0x725b
leaq 0x2a1e(%rip), %rdx      # 0x71e3
movl $0x312, %ecx            # imm = 0x312
movb $0x0, %al
callq 0x10f0
movl -0x4(%rbp), %edi
movl $0x10, %esi
callq 0x25e0
jmp 0x4811
movq 0x5811(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
leaq 0x2ab0(%rip), %rsi      # 0x72a1
leaq 0x29eb(%rip), %rdx      # 0x71e3
movl $0x317, %ecx            # imm = 0x317
movb $0x0, %al
callq 0x10f0
movl -0x4(%rbp), %edi
movl $0x12, %esi
callq 0x25e0
jmp 0x4813
xorl %eax, %eax
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax,%rax)