// File: /workspace/github_c_makefile_star2_O1/S01den[P]Lost_CavernRL/menu.c
// Function: passwordComputer
int passwordComputer()
{
	int ret = 1;
	int k = 0;
	int i = 0;
	char password[11];
	char crypt[] = "\xf4\xb2\xa3\xa8\xf1\xb4\xf3\xa3\xb4\xe1";

	WINDOW *win;
	win = newwin(7,60,LONGUEUR/2-2, LARGEUR/2+60);
	box(win,0,0);
	wattron(win, COLOR_PAIR(47));
	mvwprintw(win,1,30,"*** CORRUPTION ***");
	mvwprintw(win,2,1,"PLEASE ENTER THE PASSWORD TO RECOVER YOUR DATA: ");
	wrefresh(win);

	int keyName = 0;
	int nameLen = 0;
	while(keyName != '\n')
	{
		keyName = wgetch(win);
		if(keyName == KEY_BACKSPACE && nameLen > 0)
		{
			password[nameLen-1] = ' ';
			nameLen--;
		}
		else if(keyName != '\n' && nameLen < 10)
		{
			password[nameLen] = keyName;
			nameLen++;
		}
		mvwprintw(win,3,1,"%s",password);
		wrefresh(win);
	}

	for(i = 0; i < 10; i++)
	{
		if(password[i] != (crypt[i]^0xc0)) // 4rch1t3ct!
			ret = 0;
	}

	if(ret)
	{
		mvwprintw(win,4,30,"*** ACCESS GRANTED ! ***");
		mvwprintw(win,5,1,"- 0x08 -DATA RECOVERED- \"The star-laser is nearly ready... Ask them to raise the price, 1000000000000K is'nt enough...\"");
		wattroff(win,COLOR_PAIR(47));
	}
	else
	{
		wattron(win,COLOR_PAIR(197));
		mvwprintw(win,4,30,"*** ACCESS REFUSED ! ***");
		mvwprintw(win,5,1,"DATA DELETION DONE...");
		wattroff(win,COLOR_PAIR(197));
		wattroff(win,COLOR_PAIR(47));
	}

	k = wgetch(win);
	box(win,' ',' ');
	wborder(win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
	wclear(win);
	wrefresh(win);
	delwin(win);	
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl $0x7, %edi
movl $0x3c, %esi
movl $0x11, %edx
movl $0x7d, %ecx
callq 0x1130
movq %rax, %rbx
subq $0x8, %rsp
xorl %eax, %eax
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %rax
pushq %rax
pushq %rax
callq 0x1120
addq $0x20, %rsp
movq %rbx, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x11c0
leaq 0x5bff(%rip), %rcx      # 0x111af
movq %rbx, %rdi
movl $0x1, %esi
movl $0x1e, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x5bf7(%rip), %rcx      # 0x111c2
movq %rbx, %rdi
movl $0x2, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
leaq 0x4d0f(%rip), %r14      # 0x102fd
leaq 0x5(%rsp), %r15
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x11e0
movl %eax, %ebp
cmpl $0x107, %eax            # imm = 0x107
sete %al
testl %r12d, %r12d
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xb620
decl %r12d
movb $0x20, 0x5(%rsp,%r12)
jmp 0xb63f
cmpl $0xa, %ebp
setne %al
cmpl $0xa, %r12d
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xb63f
movslq %r12d, %rax
movb %bpl, 0x5(%rsp,%rax)
incl %r12d
movq %rbx, %rdi
movl $0x3, %esi
movl $0x1, %edx
movq %r14, %rcx
movq %r15, %r8
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
cmpl $0xa, %ebp
jne 0xb5f6
xorl %r14d, %r14d
movq %rbx, %rdi
movl $0xc500, %esi           # imm = 0xC500
xorl %edx, %edx
callq 0x11c0
leaq 0x5b74(%rip), %rcx      # 0x111f3
movq %rbx, %rdi
movl $0x4, %esi
movl $0x1e, %edx
xorl %eax, %eax
callq 0x1070
leaq 0x5b72(%rip), %rcx      # 0x1120c
movq %rbx, %rdi
movl $0x5, %esi
movl $0x1, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
movl $0xc500, %esi           # imm = 0xC500
xorl %edx, %edx
callq 0x1060
movq %rbx, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x1060
movq %rbx, %rdi
callq 0x11e0
subq $0x8, %rsp
movl $0x20, %r15d
movq %rbx, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
xorl %r9d, %r9d
pushq %r14
pushq %r14
pushq %r14
callq 0x1120
addq $0x18, %rsp
movq %rbx, %rdi
movl $0x20, %esi
movl $0x20, %edx
movl $0x20, %ecx
movl $0x20, %r8d
movl $0x20, %r9d
pushq %r15
pushq %r15
pushq %r15
callq 0x1120
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
callq 0x1110
xorl %eax, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq