// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
pushq $0x7
popq %rdi
pushq $0x3c
popq %rsi
pushq $0x11
popq %rdx
pushq $0x7d
popq %rcx
callq 0x1130
movq %rax, %rbx
subq $0x20, %rsp
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
movq %rax, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x1120
addq $0x20, %rsp
movq %rbx, %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %edx, %edx
callq 0x11c0
leaq 0x51c2(%rip), %rcx      # 0xf24f
pushq $0x1
popq %rbp
pushq $0x1e
popq %rdx
movq %rbx, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x1070
leaq 0x51bc(%rip), %rcx      # 0xf262
pushq $0x2
popq %rsi
movq %rbx, %rdi
movl %ebp, %edx
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
leaq 0x4255(%rip), %r14      # 0xe319
pushq $0x3
popq %r15
leaq 0xd(%rsp), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
movq %rbx, %rdi
cmpl $0xa, %r13d
je 0xa13e
callq 0x11e0
movl %eax, %r13d
cmpl $0x107, %eax            # imm = 0x107
sete %al
testl %ebp, %ebp
setg %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa100
decl %ebp
movb $0x20, 0xd(%rsp,%rbp)
jmp 0xa11e
cmpl $0xa, %r13d
setne %al
cmpl $0xa, %ebp
setl %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xa11e
movslq %ebp, %rax
movb %r13b, 0xd(%rsp,%rax)
incl %ebp
movq %rbx, %rdi
movl %r15d, %esi
pushq $0x1
popq %rdx
movq %r14, %rcx
movq %r12, %r8
xorl %eax, %eax
callq 0x1070
movq %rbx, %rdi
callq 0x1100
jmp 0xa0d2
movl $0xc500, %esi           # imm = 0xC500
xorl %edx, %edx
callq 0x11c0
leaq 0x5142(%rip), %rcx      # 0xf293
pushq $0x4
popq %rsi
pushq $0x1e
popq %rdx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x1070
leaq 0x5144(%rip), %rcx      # 0xf2ac
pushq $0x5
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
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
pushq $0x20
popq %r14
movq %rbx, %rdi
movl %r14d, %esi
movl %r14d, %edx
movl %r14d, %ecx
movl %r14d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
pushq $0x0
callq 0x1120
addq $0x18, %rsp
movq %rbx, %rdi
movl %r14d, %esi
movl %r14d, %edx
movl %r14d, %ecx
movl %r14d, %r8d
movl %r14d, %r9d
pushq %r14
pushq %r14
pushq %r14
callq 0x1120
addq $0x20, %rsp
movq %rbx, %rdi
callq 0x1030
movq %rbx, %rdi
callq 0x1100
movq %rbx, %rdi
callq 0x1110
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)