// File: /workspace/github_c_makefile_star2_O0/wierton[P]socket-based-naive-game/server.c
// Function: client_command_user_register
int client_command_user_register(int uid) {
	int ul_index = -1;
	char *user_name = sessions[uid].cm.user_name;
	char *password = sessions[uid].cm.password;
	log("user '%s' tries to register with password '%s'\n", user_name, password);

	for(int i = 0; i < REGISTERED_USER_LIST_SIZE; i++) {
		if(strncmp(user_name, registered_user_list[i].user_name, USERNAME_SIZE - 1) != 0)
			continue;

		log("user '%s'&'%s' has been registered\n", user_name, password);
		send_to_client(uid, SERVER_RESPONSE_YOU_HAVE_REGISTERED);
		return 0;
	}

	pthread_mutex_lock(&userlist_lock);
	if(user_list_size < REGISTERED_USER_LIST_SIZE)
		ul_index = user_list_size ++;
	pthread_mutex_unlock(&userlist_lock);

	log("fetch empty user list index #%d\n", ul_index);
	if(ul_index == -1) {
		log("user '%s' registers fail\n", user_name);
		send_to_client(uid, SERVER_RESPONSE_REGISTER_FAIL);
	}else{
		log("user '%s' registers success\n", user_name);
		strncpy(registered_user_list[ul_index].user_name,
				user_name, USERNAME_SIZE - 1);
		strncpy(registered_user_list[ul_index].password,
				password, PASSWORD_SIZE - 1);
		send_to_client(uid, SERVER_RESPONSE_REGISTER_SUCCESS);
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movl %edi, -0x8(%rbp)
movl $0xffffffff, -0xc(%rbp) # imm = 0xFFFFFFFF
movslq -0x8(%rbp), %rcx
leaq 0x6cd3(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
addq $0x18, %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movslq -0x8(%rbp), %rcx
leaq 0x6cb5(%rip), %rax      # 0xa220
imulq $0x48, %rcx, %rcx
addq %rcx, %rax
addq $0x18, %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq 0x6a73(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
leaq 0x32c4(%rip), %rsi      # 0x685b
leaq 0x3305(%rip), %rdx      # 0x68a3
movl $0x1ff, %ecx            # imm = 0x1FF
movb $0x0, %al
callq 0x10f0
movl $0x0, -0x24(%rbp)
cmpl $0xa, -0x24(%rbp)
jge 0x362e
movq -0x18(%rbp), %rdi
movslq -0x24(%rbp), %rax
leaq 0xa5ca(%rip), %rsi      # 0xdb90
imulq $0xe, %rax, %rax
addq %rax, %rsi
movl $0x6, %edx
callq 0x1050
cmpl $0x0, %eax
je 0x35de
jmp 0x3623
movq 0x6a13(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x20(%rbp), %r9
leaq 0x32c9(%rip), %rsi      # 0x68c0
leaq 0x32a5(%rip), %rdx      # 0x68a3
movl $0x205, %ecx            # imm = 0x205
movb $0x0, %al
callq 0x10f0
movl -0x8(%rbp), %edi
movl $0x3, %esi
callq 0x25e0
movl $0x0, -0x4(%rbp)
jmp 0x3748
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x35b1
leaq 0x6b6b(%rip), %rdi      # 0xa1a0
callq 0x1190
cmpl $0xa, 0xa5db(%rip)      # 0xdc1c
jge 0x3657
movl 0xa5d3(%rip), %eax      # 0xdc1c
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0xa5c8(%rip)      # 0xdc1c
movl %eax, -0xc(%rbp)
leaq 0x6b42(%rip), %rdi      # 0xa1a0
callq 0x1120
movq 0x698e(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movl -0xc(%rbp), %r8d
leaq 0x3284(%rip), %rsi      # 0x68fc
leaq 0x3224(%rip), %rdx      # 0x68a3
movl $0x20f, %ecx            # imm = 0x20F
movb $0x0, %al
callq 0x10f0
cmpl $-0x1, -0xc(%rbp)
jne 0x36c8
movq 0x6960(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x18(%rbp), %r8
leaq 0x328f(%rip), %rsi      # 0x6935
leaq 0x31f6(%rip), %rdx      # 0x68a3
movl $0x211, %ecx            # imm = 0x211
movb $0x0, %al
callq 0x10f0
movl -0x8(%rbp), %edi
movl $0x2, %esi
callq 0x25e0
jmp 0x3741
movq 0x6929(%rip), %rax      # 0x9ff8
movq (%rax), %rdi
movq -0x18(%rbp), %r8
leaq 0x328a(%rip), %rsi      # 0x6967
leaq 0x31bf(%rip), %rdx      # 0x68a3
movl $0x214, %ecx            # imm = 0x214
movb $0x0, %al
callq 0x10f0
movslq -0xc(%rbp), %rax
leaq 0xa495(%rip), %rdi      # 0xdb90
imulq $0xe, %rax, %rax
addq %rax, %rdi
movq -0x18(%rbp), %rsi
movl $0x6, %edx
callq 0x1040
movslq -0xc(%rbp), %rax
leaq 0xa475(%rip), %rdi      # 0xdb90
imulq $0xe, %rax, %rax
addq %rax, %rdi
addq $0x7, %rdi
movq -0x20(%rbp), %rsi
movl $0x6, %edx
callq 0x1040
movl -0x8(%rbp), %edi
movl $0x1, %esi
callq 0x25e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)