// File: essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: select_configuration(int)
int select_configuration(int dev_type)
{
	attron(COLOR_PAIR(COLOR_WHITE));
	clear_area(0,0,viewport_width,2);
	mvaddstr(0,0,padmsg("Use a preconfigured device? Q or ESC to cancel.").c_str());
	mvaddstr(1,0,std::string(viewport_width,' ').c_str());
	mvprintw(1,0,"(a) %d unconfigured, (b) %d timer, (c) %d remote",dev_inv[dev_type][UNCONFIGURED].size(),
		dev_inv[dev_type][ON_TIMER].size(),dev_inv[dev_type][ON_REMOTE].size());
	
	bool unacceptable = true;
	int config;
	while(unacceptable)
	{
		int kp = fgetch();
		config = kp - 'a';
		if(0 <= config && config <= DEVICE_CONFIGURATIONS)
		{
			if(dev_inv[dev_type][config].size()) unacceptable = false;
		}
		else if(kp == 'q' || kp == 'Q' || kp == KEY_ESC)
		{
			config = -1; unacceptable = false;
		}
	}
	draw_scene();
	return config;
}

// Assembly:
subq $0xc8, %rsp
movl %edi, 0xc4(%rsp)
movq 0x1f56b(%rip), %rax     # 0x3afe0
movq (%rax), %rdi
movl $0x700, %esi            # imm = 0x700
xorl %eax, %eax
movl %eax, %edx
callq 0x51a0
xorl %esi, %esi
movl $0x31, %edx
movl $0x2, %ecx
movl %esi, %edi
callq 0x8b80
movq 0x1f540(%rip), %rax     # 0x3afe0
movq (%rax), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x52f0
movb $0x0, 0x7e(%rsp)
movb $0x0, 0x6b(%rsp)
movb $0x0, 0x6a(%rsp)
cmpl $-0x1, %eax
jne 0x1bac5
jmp 0x1bb47
movq 0x1f514(%rip), %rax     # 0x3afe0
movq (%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x5490
movq 0x30(%rsp), %rdx
movb $0x1, 0x7e(%rsp)
leaq 0x12bdb(%rip), %rsi     # 0x2e6cf
leaq 0x80(%rsp), %rdi
callq 0x53d0
jmp 0x1bb03
movb $0x1, 0x6b(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x219d0
jmp 0x1bb1f
movb $0x1, 0x6a(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x5160
movq 0x28(%rsp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5100
jmp 0x1bb45
jmp 0x1bb47
testb $0x1, 0x6a(%rsp)
jne 0x1bb50
jmp 0x1bb5d
leaq 0xa0(%rsp), %rdi
callq 0x54f8
testb $0x1, 0x6b(%rsp)
jne 0x1bb66
jmp 0x1bb73
leaq 0x80(%rsp), %rdi
callq 0x54f8
testb $0x1, 0x7e(%rsp)
jne 0x1bb7c
jmp 0x1bb86
leaq 0x7f(%rsp), %rdi
callq 0x5310
movq 0x1f453(%rip), %rax     # 0x3afe0
movq (%rax), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x52f0
movb $0x0, 0x46(%rsp)
movb $0x0, 0x45(%rsp)
cmpl $-0x1, %eax
jne 0x1bbad
jmp 0x1bc10
movq 0x1f42c(%rip), %rax     # 0x3afe0
movq (%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x47(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x5490
movq 0x20(%rsp), %rcx
movb $0x1, 0x46(%rsp)
leaq 0x48(%rsp), %rdi
movl $0x31, %esi
movl $0x20, %edx
callq 0x5210
jmp 0x1bbeb
movb $0x1, 0x45(%rsp)
leaq 0x48(%rsp), %rdi
callq 0x5160
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5100
jmp 0x1bc0e
jmp 0x1bc10
testb $0x1, 0x45(%rsp)
jne 0x1bc19
jmp 0x1bc23
leaq 0x48(%rsp), %rdi
callq 0x54f8
testb $0x1, 0x46(%rsp)
jne 0x1bc2c
jmp 0x1bc36
leaq 0x47(%rsp), %rdi
callq 0x5310
movslq 0xc4(%rsp), %rsi
leaq 0xc486b(%rip), %rdi     # 0xe04b0
callq 0x20ad0
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x20af0
movq %rax, %rdi
callq 0x20b10
movq %rax, 0x8(%rsp)
movslq 0xc4(%rsp), %rsi
leaq 0xc483e(%rip), %rdi     # 0xe04b0
callq 0x20ad0
movq %rax, %rdi
movl $0x1, %esi
callq 0x20af0
movq %rax, %rdi
callq 0x20b10
movq %rax, 0x10(%rsp)
movslq 0xc4(%rsp), %rsi
leaq 0xc4810(%rip), %rdi     # 0xe04b0
callq 0x20ad0
movq %rax, %rdi
movl $0x2, %esi
callq 0x20af0
movq %rax, %rdi
callq 0x20b10
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %rax, %r9
movl $0x1, %edi
xorl %esi, %esi
leaq 0x12a2a(%rip), %rdx     # 0x2e6ff
movb $0x0, %al
callq 0x53a0
movb $0x1, 0x44(%rsp)
testb $0x1, 0x44(%rsp)
je 0x1be3d
callq 0x21710
movl %eax, 0x3c(%rsp)
movl 0x3c(%rsp), %eax
subl $0x61, %eax
movl %eax, 0x40(%rsp)
xorl %eax, %eax
cmpl 0x40(%rsp), %eax
jg 0x1be14
cmpl $0x3, 0x40(%rsp)
jg 0x1be14
movslq 0xc4(%rsp), %rsi
leaq 0xc478a(%rip), %rdi     # 0xe04b0
callq 0x20ad0
movq %rax, %rdi
movslq 0x40(%rsp), %rsi
callq 0x20af0
movq %rax, %rdi
callq 0x20b10
cmpq $0x0, %rax
je 0x1be12
movb $0x0, 0x44(%rsp)
jmp 0x1be12
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
jmp 0x1bdb2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
jmp 0x1bd9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
testb $0x1, 0x6a(%rsp)
jne 0x1bd8b
jmp 0x1bd98
leaq 0xa0(%rsp), %rdi
callq 0x54f8
jmp 0x1bd9a
testb $0x1, 0x6b(%rsp)
jne 0x1bda3
jmp 0x1bdb0
leaq 0x80(%rsp), %rdi
callq 0x54f8
jmp 0x1bdb2
testb $0x1, 0x7e(%rsp)
jne 0x1bdbb
jmp 0x1bdc5
leaq 0x7f(%rsp), %rdi
callq 0x5310
jmp 0x1be50
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
jmp 0x1bdfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
testb $0x1, 0x45(%rsp)
jne 0x1bdf1
jmp 0x1bdfb
leaq 0x48(%rsp), %rdi
callq 0x54f8
jmp 0x1bdfd
testb $0x1, 0x46(%rsp)
jne 0x1be06
jmp 0x1be10
leaq 0x47(%rsp), %rdi
callq 0x5310
jmp 0x1be50
jmp 0x1be38
cmpl $0x71, 0x3c(%rsp)
je 0x1be29
cmpl $0x51, 0x3c(%rsp)
je 0x1be29
cmpl $0x1b, 0x3c(%rsp)
jne 0x1be36
movl $0xffffffff, 0x40(%rsp) # imm = 0xFFFFFFFF
movb $0x0, 0x44(%rsp)
jmp 0x1be38
jmp 0x1bce1
xorl %edi, %edi
callq 0x176d0
movl 0x40(%rsp), %eax
addq $0xc8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x5480
nopw (%rax,%rax)