// File: /workspace/github_c_makefile_star2_O2/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 0x6cc4(%rip), %rsi      # 0x9160
leaq 0x2bf5(%rip), %rdi      # 0x5098
leaq 0x2c0d(%rip), %rcx      # 0x50b7
movl $0xaf, %edx
xorl %eax, %eax
callq 0x261e
movq 0x6ca3(%rip), %rsi      # 0x9160
leaq 0x2c00(%rip), %rdi      # 0x50c4
movl $0xb0, %edx
xorl %eax, %eax
callq 0x261e
leaq 0x2c06(%rip), %rdi      # 0x50dd
callq 0x26cd
movq %rax, %rbx
movq 0x6c7a(%rip), %rsi      # 0x9160
leaq 0x2bfc(%rip), %rdi      # 0x50e9
movl $0xb2, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x261e
leaq 0x2c02(%rip), %rdi      # 0x5105
callq 0x26cd
movq %rax, %r14
movq 0x6c4e(%rip), %rsi      # 0x9160
leaq 0x2bf7(%rip), %rdi      # 0x5110
movl $0xb5, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x261e
leaq 0x2c01(%rip), %rsi      # 0x5130
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x2702
xorps %xmm0, %xmm0
leaq -0x47(%rbp), %rdi
movups %xmm0, 0x1f(%rdi)
movups %xmm0, 0x16(%rdi)
movups %xmm0, 0x6(%rdi)
movb $0x2, -0x1(%rdi)
pushq $0x6
popq %r15
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2050
leaq -0x40(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2050
movq 0x6be9(%rip), %rsi      # 0x9160
leaq 0x2bd2(%rip), %rdi      # 0x5150
movl $0xbe, %edx
xorl %eax, %eax
callq 0x261e
orl $-0x1, 0x6bd7(%rip)     # 0x9168
leaq -0x48(%rbp), %rdi
callq 0x23e8
movl 0x6bc8(%rip), %eax      # 0x9168
cmpq $0xa, %rax
ja 0x25f2
movl $0x7b0, %ecx            # imm = 0x7B0
btl %eax, %ecx
jae 0x25f2
movq 0x6ba9(%rip), %rsi      # 0x9160
leaq 0x6542(%rip), %rcx      # 0x8b00
movq (%rcx,%rax,8), %rcx
leaq 0x2bb0(%rip), %rdi      # 0x5179
movl $0xcb, %edx
xorl %eax, %eax
callq 0x261e
cmpl $0x4, 0x6b8c(%rip)      # 0x9168
jne 0x25f4
pushq $0x5
popq %rdi
callq 0x246b
movq %rbx, 0x6b73(%rip)      # 0x9160
movq %rbx, %rsi
jmp 0x25fb
jmp 0x25f2
movq 0x6b65(%rip), %rsi      # 0x9160
leaq 0x2b95(%rip), %rdi      # 0x5197
movl $0xd3, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x261e
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq