// File: /workspace/github_c_makefile_star2_O3/ajpaulson[P]srogue11/options.c
// Function: get_str
int get_str(char *opt,WINDOW *awin)
{
	char *sp;
	int c, oy, ox;
	char buf[LINLEN];

	draw(awin);
	getyx(awin, oy, ox);
	/*
	 * loop reading in the string, and put it in a temporary buffer
	 */
	for (sp = buf; (c=wgetch(awin)) != '\n' && c != '\r' && c != ESCAPE;
	  wclrtoeol(awin), draw(awin)) {
		if (( (int)sp - (int)buf ) >= 50) {
			*sp = '\0';			/* line was too long */
			strucpy(opt,buf,strlen(buf));
			mvwaddstr(awin, 0, 0, "Name was truncated --More--");
			wclrtoeol(awin);
			draw(awin);
			wait_for(awin, ' ');
			mvwprintw(awin, 0, 0, "Called: %s",opt);
			draw(awin);
			return NORM;
		}
		if (c == -1)
			continue;
		else if(c == terminal.c_cc[VERASE])	{	/* process erase char */
			if (sp > buf) {
				int i;
	
				sp--;
				for (i = strlen(unctrl(*sp)); i; i--)
					waddch(awin, '\b');
			}
			continue;
		}
		else if (c == terminal.c_cc[VKILL]) {   /* process kill character */
			sp = buf;
			wmove(awin, oy, ox);
			continue;
		}
		else if (sp == buf) {
			if (c == CTRLB)			/* CTRL - B */
				break;
			if (c == '~') {
				strcpy(buf, home);
				waddstr(awin, home);
				sp += strlen(home);
				continue;
			}
		}
		*sp++ = c;
		waddstr(awin, unctrl(c));
	}
	*sp = '\0';
	if (sp > buf)	/* only change option if something was typed */
		strucpy(opt, buf, strlen(buf));
	wmove(awin, oy, ox);
	waddstr(awin, opt);
	waddstr(awin, "\n\r");
	draw(awin);
	if (awin == cw)
		mpos += sp - buf;
	if (c == CTRLB)
		return MINUS;
	if (c == ESCAPE)
		return QUIT;
	return NORM;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movq %rsi, %rdi
callq 0x6200
testq %rbx, %rbx
movq %r14, 0x8(%rsp)
je 0xfd67
movswl (%rbx), %eax
movl %eax, 0x4(%rsp)
movswl 0x2(%rbx), %eax
movl %eax, (%rsp)
jmp 0xfd76
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, (%rsp)     # imm = 0xFFFFFFFF
leaq 0x10(%rsp), %r14
leaq 0x22cde(%rip), %rbp     # 0x32a60
movl $0x8002400, %r15d       # imm = 0x8002400
movq %r14, %r12
movq %rbx, %rdi
callq 0x6110
movl %eax, %r13d
cmpl $0x1b, %eax
ja 0xfda5
btl %r13d, %r15d
jb 0xfe9c
movl %r12d, %eax
subl %r14d, %eax
cmpl $0x32, %eax
jge 0xfed3
cmpl $-0x1, %r13d
je 0xfe53
movzbl 0x13(%rbp), %eax
cmpl %eax, %r13d
jne 0xfe02
cmpq %r14, %r12
jbe 0xfe53
movsbl -0x1(%r12), %edi
decq %r12
callq 0x6420
movq %rax, %rdi
callq 0x6170
movq %rax, %r13
testl %r13d, %r13d
je 0xfe53
movq %rbx, %rdi
movl $0x8, %esi
callq 0x64c0
decl %r13d
jne 0xfdee
jmp 0xfe53
movzbl 0x14(%rbp), %eax
cmpl %eax, %r13d
jne 0xfe1f
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl (%rsp), %edx
callq 0x6490
movq %r14, %r12
jmp 0xfe53
cmpq %r14, %r12
jne 0xfe34
cmpl $0x7e, %r13d
je 0xfe68
cmpl $0x2, %r13d
je 0xff5f
movb %r13b, (%r12)
incq %r12
movl %r13d, %edi
callq 0x6420
movq %rbx, %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %rbx, %rdi
callq 0x64a0
movq %rbx, %rdi
callq 0x6200
jmp 0xfd8b
movq %r14, %rdi
leaq 0x1e1fe(%rip), %r12     # 0x2e070
movq %r12, %rsi
callq 0x60e0
movq %rbx, %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %r12, %rdi
callq 0x6170
leaq (%rsp,%rax), %r12
addq $0x10, %r12
jmp 0xfe53
movb $0x0, (%r12)
leaq 0x10(%rsp), %rax
cmpq %rax, %r12
jbe 0xff6f
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x6170
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0xfff0
jmp 0xff74
movb $0x0, (%r12)
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x6170
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0xfff0
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0xff1b
leaq 0x1156e(%rip), %rsi     # 0x2147c
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %rbx, %rdi
callq 0x64a0
movq %rbx, %rdi
callq 0x6200
movq %rbx, %rdi
movl $0x20, %esi
callq 0xb89e
leaq 0x11559(%rip), %rcx     # 0x21498
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x6210
movq %rbx, %rdi
callq 0x6200
jmp 0xffdf
leaq 0x10(%rsp), %r12
movb $0x0, (%r12)
movl $0x2, %r13d
movq 0x8(%rsp), %r15
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl (%rsp), %edx
callq 0x6490
movq %rbx, %rdi
movq %r15, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
leaq 0x137e3(%rip), %rsi     # 0x2377d
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %rbx, %rdi
callq 0x6200
leaq 0x20a2a(%rip), %rax     # 0x309e0
cmpq %rbx, (%rax)
jne 0xffcd
leaq 0x10(%rsp), %rax
subl %eax, %r12d
leaq 0x1d8a6(%rip), %rax     # 0x2d870
addl %r12d, (%rax)
xorl %ebp, %ebp
cmpl $0x1b, %r13d
sete %bpl
cmpl $0x2, %r13d
cmovel %r13d, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq