// File: /workspace/github_cpp_makefile_star2_O2/essarrdee[P]mutantaliens/mutantaliens.cpp
// Function: reconfigure(item*)
bool reconfigure(item* a)
{
	update_device_desciption(a);

	bool unacceptable = true;
	bool cancel = false;
	while(unacceptable)
	{
		std::string s = a->description+" Reconfigure? Space or ("+std::string(1,a->configuration +'a')+
			". Q or ESC to cancel.";
		if(a->configuration != UNCONFIGURED)
		{s += std::string(" (a) remove ")+(a->configuration==ON_TIMER?"timer":"remote control");}
		if(a->configuration != ON_TIMER)
		{s += std::string(" (b) use a timer instead");}
		if(a->configuration != ON_REMOTE)
		{s += std::string(" (c) use a remote control instead");}
		s += ".";
		pretty_print(s);
		/*clear_area(0,0,viewport_width,5);
		mvaddstr(0,0,a->description.c_str());
		mvprintw(1,0,"Reconfigure? Space or (%c) to leave unchanged",a->configuration +'a');
		mvaddstr(2,0,"q or ESC to cancel");
		int i=3;
		if(a->configuration != UNCONFIGURED)
		{
			mvprintw(i,0,"(a) remove %s",a->configuration==ON_TIMER?"timer":"remote control");
			i++;
		}
		if(a->configuration != ON_TIMER)
		{
			mvprintw(i,0,"(b) use a timer instead");
			i++;
		}
		if(a->configuration != ON_REMOTE)
		{
			mvprintw(i,0,"(c) use a remote control instead");
		}*/
		int kp = fgetch();
		draw_scene();
		if(kp == 'q' || kp == 'Q' || kp == KEY_ESC)
		{
			unacceptable = false;
			cancel = true;
		}
		else if(kp == a->configuration + 'a' || kp == ' ')
		{
			unacceptable = false;
		}
		else if(kp == 'a') 
		{
			set_unconfigured(a);
			unacceptable = false;
		}
		else if( kp == 'b')
		{
			draw_scene();
			int t = ask_for_time();
			
			if (t >= 0)
			{
				set_timer(a,t);
				unacceptable = false;
			}
		}
		else if (kp == 'c')
		{
			draw_scene();
			int w = ask_for_wavelength();
			if(w>=0)
			{
				set_remote(a,w);
				unacceptable = false;
			}
		}
	}
	draw_scene();
	return cancel;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %rbx
callq 0xac97
leaq 0x30(%rbx), %rax
movq %rax, 0x10(%rsp)
movb $0x1, %r13b
movl $0x0, 0xc(%rsp)
leaq 0x58(%rsp), %r12
leaq 0x38(%rsp), %r14
leaq 0x18(%rsp), %r15
leaq 0x78(%rsp), %rbp
testb $0x1, %r13b
je 0xf520
movq %r12, %rdi
movq 0x10(%rsp), %rsi
leaq 0x624c(%rip), %rdx      # 0x15564
callq 0x11030
movb 0x8c(%rbx), %al
addb $0x61, %al
leaq 0x48(%rsp), %rcx
movq %rcx, 0x38(%rsp)
movsbl %al, %edx
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0x52a0
movq %r15, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x10ebd
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
leaq 0x621d(%rip), %rdx      # 0x1557d
callq 0x111b3
movq %r15, %rdi
callq 0x5418
movq %r14, %rdi
callq 0x5418
movq %r12, %rdi
callq 0x5418
cmpl $0x0, 0x8c(%rbx)
je 0xf3e0
movq %r12, %rdi
leaq 0x6203(%rip), %rsi      # 0x15593
movq %r14, %rdx
callq 0x5110
cmpl $0x1, 0x8c(%rbx)
leaq 0x61fa(%rip), %rdx      # 0x155a0
leaq 0x7636(%rip), %rax      # 0x169e3
cmoveq %rax, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x111b3
movq %r13, %rdi
movq %r15, %rsi
callq 0x5400
movq %r15, %rdi
callq 0x5418
movq %r12, %rdi
callq 0x5418
cmpl $0x1, 0x8c(%rbx)
je 0xf40e
movq %r15, %rdi
leaq 0x61c5(%rip), %rsi      # 0x155af
movq %r12, %rdx
callq 0x5110
movq %r13, %rdi
movq %r15, %rsi
callq 0x5400
movq %r15, %rdi
callq 0x5418
cmpl $0x2, 0x8c(%rbx)
je 0xf433
movq %r15, %rdi
leaq 0x61b0(%rip), %rsi      # 0x155c8
movq %r12, %rdx
callq 0x5110
movq %r13, %rdi
movq %r15, %rsi
callq 0x5400
movq %r15, %rdi
callq 0x5418
movq %r13, %rdi
leaq 0x7153(%rip), %rsi      # 0x16590
callq 0x53e0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x5330
movq %r14, %r12
movq %rbp, %rdi
callq 0x633b
movq %rbp, %rdi
callq 0x5418
callq 0x11424
movl %eax, %r14d
xorl %edi, %edi
callq 0xcc13
movb $0x1, %bpl
xorl %r13d, %r13d
cmpl $0x1b, %r14d
je 0xf500
cmpl $0x51, %r14d
je 0xf500
cmpl $0x71, %r14d
je 0xf500
xorl %r13d, %r13d
cmpl $0x20, %r14d
je 0xf4fa
movl 0x8c(%rbx), %eax
addl $0x61, %eax
cmpl %eax, %r14d
je 0xf4fa
movb $0x1, %r13b
cmpl $0x63, %r14d
je 0xf4dd
cmpl $0x62, %r14d
je 0xf4c1
cmpl $0x61, %r14d
jne 0xf4fa
movq %rbx, %rdi
callq 0xf15e
jmp 0xf4f7
xorl %edi, %edi
callq 0xcc13
callq 0xefad
testl %eax, %eax
js 0xf4fa
movq %rbx, %rdi
movl %eax, %esi
callq 0xf1f3
jmp 0xf4f7
xorl %edi, %edi
callq 0xcc13
callq 0xf034
testl %eax, %eax
js 0xf4fa
movq %rbx, %rdi
movl %eax, %esi
callq 0xf252
xorl %r13d, %r13d
movl 0xc(%rsp), %eax
movl %eax, %ebp
leaq 0x98(%rsp), %rdi
callq 0x5418
movl %ebp, %eax
movl %eax, 0xc(%rsp)
movq %r12, %r14
leaq 0x58(%rsp), %r12
jmp 0xf2fa
xorl %edi, %edi
callq 0xcc13
movl 0xc(%rsp), %eax
andb $0x1, %al
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xf5a7
jmp 0xf5a7
movq %rax, %rbx
jmp 0xf555
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5418
leaq 0x58(%rsp), %rdi
jmp 0xf58a
jmp 0xf5a7
jmp 0xf564
jmp 0xf5a7
jmp 0xf5a7
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
jmp 0xf58a
movq %rax, %rbx
jmp 0xf59e
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x5418
jmp 0xf594
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x5418
jmp 0xf5aa
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x5418
leaq 0x58(%rsp), %rdi
jmp 0xf5b2
jmp 0xf5a7
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x5418
movq %rbx, %rdi
callq 0x53c0