// File: /workspace/github_c_makefile_star2_O1/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 0x7b57(%rip), %rsi      # 0xa160
leaq 0x3a88(%rip), %rdi      # 0x6098
leaq 0x3aa0(%rip), %rcx      # 0x60b7
xorl %r15d, %r15d
movl $0xaf, %edx
xorl %eax, %eax
callq 0x27b3
movq 0x7b33(%rip), %rsi      # 0xa160
leaq 0x3a90(%rip), %rdi      # 0x60c4
movl $0xb0, %edx
xorl %eax, %eax
callq 0x27b3
leaq 0x3a96(%rip), %rdi      # 0x60dd
callq 0x2862
movq %rax, %rbx
movq 0x7b0a(%rip), %rsi      # 0xa160
leaq 0x3a8c(%rip), %rdi      # 0x60e9
movl $0xb2, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x27b3
leaq 0x3a92(%rip), %rdi      # 0x6105
callq 0x2862
movq %rax, %r14
movq 0x7ade(%rip), %rsi      # 0xa160
leaq 0x3a87(%rip), %rdi      # 0x6110
movl $0xb5, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0x27b3
leaq 0x3a91(%rip), %rsi      # 0x6130
xorl %edi, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x28a9
xorps %xmm0, %xmm0
leaq -0x4f(%rbp), %rdi
movaps %xmm0, -0x1(%rdi)
movaps %xmm0, 0x1f(%rdi)
movaps %xmm0, 0xf(%rdi)
movb $0x2, -0x1(%rdi)
movl $0x6, %edx
movq %rbx, %rsi
callq 0x2050
leaq -0x48(%rbp), %rdi
movl $0x6, %edx
movq %r14, %rsi
callq 0x2050
movq 0x7a79(%rip), %rsi      # 0xa160
leaq 0x3a62(%rip), %rdi      # 0x6150
movl $0xbe, %edx
xorl %eax, %eax
callq 0x27b3
movl $0xffffffff, 0x7a64(%rip) # imm = 0xFFFFFFFF
movl 0x7a4e(%rip), %edi      # 0xa158
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
leaq (%rax,%rbp), %rsi
addq $-0x50, %rsi
movl $0x30, %edx
subq %r15, %rdx
xorl %ecx, %ecx
callq 0x20a0
addq %rax, %r15
cmpq $0x30, %r15
jb 0x2704
movl 0x7a30(%rip), %eax      # 0xa168
cmpq $0xa, %rax
ja 0x27b1
movl $0x7b0, %ecx            # imm = 0x7B0
btl %eax, %ecx
jae 0x27b1
movq 0x7a11(%rip), %rsi      # 0xa160
leaq 0x73aa(%rip), %rcx      # 0x9b00
movq (%rcx,%rax,8), %rcx
leaq 0x3a18(%rip), %rdi      # 0x6179
movl $0xcb, %edx
xorl %eax, %eax
callq 0x27b3
cmpl $0x4, 0x79f4(%rip)      # 0xa168
jne 0x2787
movl $0x5, %edi
callq 0x25b1
movq %rbx, 0x79d9(%rip)      # 0xa160
movq 0x79d2(%rip), %rsi      # 0xa160
leaq 0x3a02(%rip), %rdi      # 0x6197
movl $0xd3, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x27b3
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x27b1