// File: /workspace/github_c_makefile_star2_O0/wierton[P]socket-based-naive-game/client.c
// Function: switch_selected_button_respond_to_key
int switch_selected_button_respond_to_key(int st, int ed) {
	int sel = st - 1;
	int old_sel = sel;

	if(st >= ed) return st;

	echo_off();
	disable_buffer();
	wlog("enter select button, [%d, %d)\n", st, ed);
	while(1) {
		int ch = fgetc(stdin);
		wlog("capture key '%c' in button ui\n", ch);
		switch(ch) {
			case 'a':
			case 'w':
				sel --;
				if(sel < st) sel = ed - 1;
				break;
			case 's':
			case 'd':
				sel ++;
				if(sel >= ed) sel = st;
				break;
			case '\t':
				wlog("sel_menu enter command mode\n");
				read_and_execute_command();
				sel = st;
				break;
		}

		if(ch == '\n') {
			if(st <= sel && sel < ed) {
				break;
			}else{
				sel = st;
			}
		}

		if(st <= old_sel && old_sel < ed) {
			draw_button(old_sel);
		}

		if(st <= sel && sel < ed)
			draw_selected_button(sel);
		old_sel = sel;
	}

	echo_on();
	wlogi("return sel: %d\n", sel);
	return sel;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl -0x8(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x8(%rbp), %eax
cmpl -0xc(%rbp), %eax
jl 0x4090
movl -0x8(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x41fc
callq 0x2f10
callq 0x2ea0
movq 0x60d7(%rip), %rsi      # 0xa178
movl -0x8(%rbp), %ecx
movl -0xc(%rbp), %r8d
leaq 0x2820(%rip), %rdi      # 0x68cf
movl $0x338, %edx            # imm = 0x338
movb $0x0, %al
callq 0x2780
movq 0x5f16(%rip), %rax      # 0x9fd8
movq (%rax), %rdi
callq 0x20f0
movl %eax, -0x18(%rbp)
movq 0x60a4(%rip), %rsi      # 0xa178
movl -0x18(%rbp), %ecx
leaq 0x2817(%rip), %rdi      # 0x68f5
xorl %eax, %eax
movl $0x33b, %edx            # imm = 0x33B
callq 0x2780
movl -0x18(%rbp), %eax
movl %eax, -0x1c(%rbp)
subl $0x9, %eax
je 0x4154
jmp 0x40f7
movl -0x1c(%rbp), %eax
subl $0x61, %eax
je 0x411f
jmp 0x4101
movl -0x1c(%rbp), %eax
subl $0x64, %eax
je 0x413b
jmp 0x410b
movl -0x1c(%rbp), %eax
subl $0x73, %eax
je 0x413b
jmp 0x4115
movl -0x1c(%rbp), %eax
subl $0x77, %eax
jne 0x4179
jmp 0x411f
movl -0x10(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x4139
movl -0xc(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x4179
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jl 0x4152
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x4179
movq 0x601d(%rip), %rsi      # 0xa178
leaq 0x27b9(%rip), %rdi      # 0x691b
movl $0x348, %edx            # imm = 0x348
movb $0x0, %al
callq 0x2780
callq 0x3830
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
cmpl $0xa, -0x18(%rbp)
jne 0x4199
movl -0x8(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x4191
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x4191
jmp 0x41d4
movl -0x8(%rbp), %eax
movl %eax, -0x10(%rbp)
jmp 0x4199
movl -0x8(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x41b1
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x41b1
movl -0x14(%rbp), %edi
callq 0x3950
movl -0x8(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x41c9
movl -0x10(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x41c9
movl -0x10(%rbp), %edi
callq 0x3ab0
movl -0x10(%rbp), %eax
movl %eax, -0x14(%rbp)
jmp 0x40bb
callq 0x2f40
movq 0x5f98(%rip), %rsi      # 0xa178
movl -0x10(%rbp), %ecx
leaq 0x2755(%rip), %rdi      # 0x693f
movl $0x360, %edx            # imm = 0x360
movb $0x0, %al
callq 0x2780
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)