// File: /workspace/github_c_makefile_star2_O1/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
movl $0xffffffff, 0x4(%rsp)  # imm = 0xFFFFFFFF
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
testq %rbx, %rbx
je 0xfe90
movswl (%rbx), %r15d
movq %r14, 0x8(%rsp)
testq %rbx, %rbx
je 0xfea2
movswl 0x2(%rbx), %eax
movl %eax, 0x4(%rsp)
leaq 0x10(%rsp), %r14
leaq 0x22bb2(%rip), %rbp     # 0x32a60
movq %r14, %r12
movq %rbx, %rdi
callq 0x6110
movl %eax, %r13d
cmpl $0x1b, %eax
ja 0xfed0
movl $0x8002400, %eax        # imm = 0x8002400
btl %r13d, %eax
jb 0xffba
movl %r12d, %eax
subl %r14d, %eax
cmpl $0x32, %eax
jge 0x10058
cmpl $-0x1, %r13d
je 0xff76
movzbl 0x13(%rbp), %eax
cmpl %eax, %r13d
jne 0xff29
cmpq %r14, %r12
jbe 0xff76
movsbl -0x1(%r12), %edi
decq %r12
callq 0x6420
movq %rax, %rdi
callq 0x6170
movq %rax, %r13
testl %r13d, %r13d
je 0xff76
movq %rbx, %rdi
movl $0x8, %esi
callq 0x64c0
decl %r13d
jne 0xff15
jmp 0xff76
movzbl 0x14(%rbp), %eax
cmpl %eax, %r13d
jne 0xff46
movq %rbx, %rdi
movl %r15d, %esi
movl 0x4(%rsp), %edx
callq 0x6490
movq %r14, %r12
jmp 0xff76
cmpq %r14, %r12
jne 0xff57
cmpl $0x7e, %r13d
je 0xff8b
cmpl $0x2, %r13d
je 0xffba
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 0xfeb1
movq %r14, %rdi
leaq 0x1e0db(%rip), %r13     # 0x2e070
movq %r13, %rsi
callq 0x60e0
movq %rbx, %rdi
movq %r13, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %r13, %rdi
callq 0x6170
addq %rax, %r12
jmp 0xff76
movb $0x0, (%r12)
leaq 0x10(%rsp), %rax
cmpq %rax, %r12
movq 0x8(%rsp), %rbp
jbe 0xffe8
leaq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x6170
movq %rbp, %rdi
movq %r14, %rsi
movl %eax, %edx
callq 0x100f0
movq %rbx, %rdi
movl %r15d, %esi
movl 0x4(%rsp), %edx
callq 0x6490
movq %rbx, %rdi
movq %rbp, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
leaq 0x136f7(%rip), %rsi     # 0x23705
movq %rbx, %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6550
movq %rbx, %rdi
callq 0x6200
leaq 0x209b6(%rip), %rax     # 0x309e0
cmpq %rbx, (%rax)
jne 0x10041
leaq 0x10(%rsp), %rax
subl %eax, %r12d
leaq 0x1d832(%rip), %rax     # 0x2d870
addl %r12d, (%rax)
xorl %ebp, %ebp
cmpl $0x1b, %r13d
sete %bpl
cmpl $0x2, %r13d
cmovel %r13d, %ebp
jmp 0x100df
movb $0x0, (%r12)
leaq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x6170
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movl %eax, %edx
callq 0x100f0
xorl %ebp, %ebp
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6490
cmpl $-0x1, %eax
je 0x100a0
leaq 0x11371(%rip), %rsi     # 0x21404
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 0xb95e
leaq 0x1135c(%rip), %rcx     # 0x21420
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
movq 0x8(%rsp), %r8
xorl %eax, %eax
callq 0x6210
movq %rbx, %rdi
callq 0x6200
movl %ebp, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq