// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq 0x7bc9(%rip), %rsi      # 0xa178
leaq 0x3b1d(%rip), %rdi      # 0x60d3
movl $0xaf, %edx
leaq 0x3b30(%rip), %rcx      # 0x60f2
movb $0x0, %al
callq 0x2780
movq 0x7ba8(%rip), %rsi      # 0xa178
leaq 0x3b28(%rip), %rdi      # 0x60ff
movl $0xb0, %edx
movb $0x0, %al
callq 0x2780
leaq 0x3b2e(%rip), %rdi      # 0x6118
callq 0x2840
movq %rax, -0x8(%rbp)
movq 0x7b7e(%rip), %rsi      # 0xa178
movq -0x8(%rbp), %rcx
leaq 0x3b1f(%rip), %rdi      # 0x6124
movl $0xb2, %edx
movb $0x0, %al
callq 0x2780
leaq 0x3b28(%rip), %rdi      # 0x6140
callq 0x2840
movq %rax, -0x10(%rbp)
movq 0x7b50(%rip), %rsi      # 0xa178
movq -0x10(%rbp), %rcx
leaq 0x3b18(%rip), %rdi      # 0x614b
movl $0xb5, %edx
movb $0x0, %al
callq 0x2780
movq -0x8(%rbp), %rdx
xorl %edi, %edi
leaq 0x3b1f(%rip), %rsi      # 0x616b
movb $0x0, %al
callq 0x2890
leaq -0x40(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x20d0
movb $0x2, -0x40(%rbp)
leaq -0x40(%rbp), %rdi
addq $0x1, %rdi
movq -0x8(%rbp), %rsi
movl $0x6, %edx
callq 0x2040
leaq -0x40(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
movl $0x6, %edx
callq 0x2040
movq 0x7ade(%rip), %rsi      # 0xa178
leaq 0x3aea(%rip), %rdi      # 0x618b
movl $0xbe, %edx
movb $0x0, %al
callq 0x2780
movl $0xffffffff, 0x7ac9(%rip) # imm = 0xFFFFFFFF
leaq -0x40(%rbp), %rdi
callq 0x2470
cmpl $0x4, 0x7ab9(%rip)      # 0xa180
je 0x26f6
cmpl $0x5, 0x7ab0(%rip)      # 0xa180
je 0x26f6
cmpl $0x7, 0x7aa7(%rip)      # 0xa180
je 0x26f6
cmpl $0x8, 0x7a9e(%rip)      # 0xa180
je 0x26f6
cmpl $0x9, 0x7a95(%rip)      # 0xa180
je 0x26f6
cmpl $0xa, 0x7a8c(%rip)      # 0xa180
jne 0x26f8
jmp 0x2702
jmp 0x26fa
movb $0x1, %al
testb $0x1, %al
jne 0x26c0
jmp 0x2702
movq 0x7a6f(%rip), %rsi      # 0xa178
movslq 0x7a70(%rip), %rcx      # 0xa180
leaq 0x7a79(%rip), %rax      # 0xa190
movq (%rax,%rcx,8), %rcx
leaq 0x3a92(%rip), %rdi      # 0x61b4
movl $0xcb, %edx
movb $0x0, %al
callq 0x2780
cmpl $0x4, 0x7a4b(%rip)      # 0xa180
jne 0x274c
movl $0x5, %edi
callq 0x2580
movq -0x8(%rbp), %rax
movq %rax, 0x7a2c(%rip)      # 0xa178
movq 0x7a25(%rip), %rsi      # 0xa178
movq -0x8(%rbp), %rcx
leaq 0x3a74(%rip), %rdi      # 0x61d2
movl $0xd3, %edx
movb $0x0, %al
callq 0x2780
xorl %eax, %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)