// File: /workspace/github_c_makefile_star2_O3/wierton[P]socket-based-naive-game/client.c
// Function: button_login
int button_login() {
	wlog("call button handler %s\n", __func__);
	wlogi("require name\n");
	char *name = accept_input("your name: ");
	wlogi("input name '%s'\n", name);

	char *password = accept_input("password: ");
	wlogi("input password '%s'\n", password);

	bottom_bar_output(0, "try to login with name '%s' ...", name);

	client_message_t cm;
	memset(&cm, 0, sizeof(client_message_t));
	cm.command = CLIENT_COMMAND_USER_LOGIN;
	strncpy(cm.user_name, name, USERNAME_SIZE - 1);
	strncpy(cm.password, password, PASSWORD_SIZE - 1);
	wlogi("send login message to server\n");
	global_serv_message = -1;
	wrap_send(&cm);

	do {
		if(global_serv_message == SERVER_RESPONSE_LOGIN_SUCCESS
		|| global_serv_message == SERVER_RESPONSE_YOU_HAVE_LOGINED
		|| global_serv_message == SERVER_RESPONSE_LOGIN_FAIL_UNREGISTERED_USERID
		|| global_serv_message == SERVER_RESPONSE_LOGIN_FAIL_ERROR_PASSWORD
		|| global_serv_message == SERVER_RESPONSE_LOGIN_FAIL_DUP_USERID
		|| global_serv_message == SERVER_RESPONSE_LOGIN_FAIL_SERVER_LIMITS)
			break;
	} while(1);
	wlog("wait until message=%s\n", server_message_s[global_serv_message]);

	if(global_serv_message == SERVER_RESPONSE_LOGIN_SUCCESS)
	{
		send_command(CLIENT_COMMAND_FETCH_ALL_FRIENDS);
		user_name = name;
	}

	wlogi("set user name to '%s'\n", name);

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
movq 0x7b56(%rip), %rsi      # 0xa160
leaq 0x3a87(%rip), %rdi      # 0x6098
leaq 0x3a9f(%rip), %rcx      # 0x60b7
xorl %r15d, %r15d
movl $0xaf, %edx
xorl %eax, %eax
callq 0x27b9
movq 0x7b32(%rip), %rsi      # 0xa160
leaq 0x3a8f(%rip), %rdi      # 0x60c4
movl $0xb0, %edx
xorl %eax, %eax
callq 0x27b9
leaq 0x3a95(%rip), %rdi      # 0x60dd
callq 0x2868
movq %rax, %rbx
movq 0x7b09(%rip), %rsi      # 0xa160
leaq 0x3a8b(%rip), %rdi      # 0x60e9
movl $0xb2, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x27b9
leaq 0x3a91(%rip), %rdi      # 0x6105
callq 0x2868
movq %rax, %r14
movq 0x7add(%rip), %rsi      # 0xa160
leaq 0x3a86(%rip), %rdi      # 0x6110
movl $0xb5, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x27b9
leaq 0x3a90(%rip), %rsi      # 0x6130
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x28af
xorps %xmm0, %xmm0
leaq -0x47(%rbp), %rdi
movups %xmm0, 0x1f(%rdi)
movups %xmm0, 0x16(%rdi)
movups %xmm0, 0x6(%rdi)
movb $0x2, -0x1(%rdi)
movl $0x6, %edx
movq %rbx, %rsi
callq 0x2050
leaq -0x40(%rbp), %rdi
movl $0x6, %edx
movq %r14, %rsi
callq 0x2050
movq 0x7a78(%rip), %rsi      # 0xa160
leaq 0x3a61(%rip), %rdi      # 0x6150
movl $0xbe, %edx
xorl %eax, %eax
callq 0x27b9
movl $0xffffffff, 0x7a63(%rip) # imm = 0xFFFFFFFF
movl 0x7a4d(%rip), %edi      # 0xa158
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
leaq (%rax,%rbp), %rsi
addq $-0x48, %rsi
movl $0x30, %edx
subq %r15, %rdx
xorl %ecx, %ecx
callq 0x20a0
addq %rax, %r15
cmpq $0x30, %r15
jb 0x2705
movl 0x7a2f(%rip), %eax      # 0xa168
cmpq $0xa, %rax
ja 0x278d
movl $0x7b0, %ecx            # imm = 0x7B0
btl %eax, %ecx
jae 0x278d
movq 0x7a10(%rip), %rsi      # 0xa160
leaq 0x73a9(%rip), %rcx      # 0x9b00
movq (%rcx,%rax,8), %rcx
leaq 0x3a17(%rip), %rdi      # 0x6179
movl $0xcb, %edx
xorl %eax, %eax
callq 0x27b9
cmpl $0x4, 0x79f3(%rip)      # 0xa168
jne 0x278f
movl $0x5, %edi
callq 0x25b2
movq %rbx, 0x79d8(%rip)      # 0xa160
movq %rbx, %rsi
jmp 0x2796
jmp 0x278d
movq 0x79ca(%rip), %rsi      # 0xa160
leaq 0x39fa(%rip), %rdi      # 0x6197
movl $0xd3, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x27b9
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq