// File: /workspace/github_c_makefile_star2_O2/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 0xf3b1
movswl (%rbx), %eax
movl %eax, 0x4(%rsp)
movswl 0x2(%rbx), %eax
jmp 0xf3b8
pushq $-0x1
popq %rax
movl %eax, 0x4(%rsp)
movl %eax, (%rsp)
leaq 0x10(%rsp), %r15
leaq 0x23689(%rip), %rbp     # 0x32a50
pushq $0x8
popq %r13
movq %r15, %r12
movq %rbx, %rdi
callq 0x6110
movl %eax, %r14d
cmpl $0x1b, %eax
ja 0xf3ed
movl $0x8002400, %eax        # imm = 0x8002400
btl %r14d, %eax
jb 0xf4d6
movl %r12d, %eax
subl %r15d, %eax
cmpl $0x32, %eax
jge 0xf50d
cmpl $-0x1, %r14d
je 0xf48f
movzbl 0x13(%rbp), %eax
cmpl %eax, %r14d
jne 0xf440
cmpq %r15, %r12
jbe 0xf48f
movsbl -0x1(%r12), %edi
decq %r12
callq 0x6400
movq %rax, %rdi
callq 0x6170
movq %rax, %r14
subl $0x1, %r14d
jb 0xf48f
movq %rbx, %rdi
movl %r13d, %esi
callq 0x64a0
jmp 0xf42d
movzbl 0x14(%rbp), %eax
cmpl %eax, %r14d
jne 0xf45d
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl (%rsp), %edx
callq 0x6470
movq %r15, %r12
jmp 0xf48f
cmpq %r15, %r12
jne 0xf472
cmpl $0x7e, %r14d
je 0xf4a4
cmpl $0x2, %r14d
je 0xf593
movb %r14b, (%r12)
incq %r12
movl %r14d, %edi
callq 0x6400
movq %rbx, %rdi
movq %rax, %rsi
pushq $-0x1
popq %rdx
callq 0x6530
movq %rbx, %rdi
callq 0x6480
movq %rbx, %rdi
callq 0x6200
jmp 0xf3ce
movq %r15, %rdi
leaq 0x1ebb2(%rip), %r14     # 0x2e060
movq %r14, %rsi
callq 0x60e0
movq %rbx, %rdi
movq %r14, %rsi
pushq $-0x1
popq %rdx
callq 0x6530
movq %r14, %rdi
callq 0x6170
leaq (%rsp,%rax), %r12
addq $0x10, %r12
jmp 0xf48f
movb $0x0, (%r12)
leaq 0x10(%rsp), %rax
cmpq %rax, %r12
jbe 0xf5a1
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x6170
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0xf61f
jmp 0xf5a6
movb $0x0, (%r12)
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x6170
movq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0xf61f
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6470
cmpl $-0x1, %eax
je 0xf556
leaq 0xff31(%rip), %rsi      # 0x1f47c
pushq $-0x1
popq %rdx
movq %rbx, %rdi
callq 0x6530
movq %rbx, %rdi
callq 0x6480
movq %rbx, %rdi
callq 0x6200
pushq $0x20
popq %rsi
movq %rbx, %rdi
callq 0xb399
leaq 0xff20(%rip), %rcx      # 0x1f498
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq %r15, %r8
xorl %eax, %eax
callq 0x6210
movq %rbx, %rdi
callq 0x6200
jmp 0xf60e
leaq 0x10(%rsp), %r12
movb $0x0, (%r12)
pushq $0x2
popq %r14
movq 0x8(%rsp), %r13
movq %rbx, %rdi
movl 0x4(%rsp), %esi
movl (%rsp), %edx
callq 0x6470
pushq $-0x1
popq %rbp
movq %rbx, %rdi
movq %r13, %rsi
movl %ebp, %edx
callq 0x6530
leaq 0x121b1(%rip), %rsi     # 0x2177d
movq %rbx, %rdi
movl %ebp, %edx
callq 0x6530
movq %rbx, %rdi
callq 0x6200
leaq 0x213eb(%rip), %rax     # 0x309d0
cmpq %rbx, (%rax)
jne 0xf5fc
leaq 0x10(%rsp), %rax
subl %eax, %r12d
leaq 0x1e267(%rip), %rax     # 0x2d860
addl %r12d, (%rax)
xorl %ebp, %ebp
cmpl $0x1b, %r14d
sete %bpl
cmpl $0x2, %r14d
cmovel %r14d, %ebp
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq