// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movl $0x1, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
movq 0x77bb(%rip), %rax      # 0x19ecf
movq %rax, -0x22(%rbp)
movw 0x77b8(%rip), %ax       # 0x19ed7
movw %ax, -0x1a(%rbp)
movb 0x77b0(%rip), %al       # 0x19ed9
movb %al, -0x18(%rbp)
movl $0x7, %edi
movl $0x3c, %esi
movl $0x11, %edx
movl $0x7d, %ecx
callq 0x2130
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
xorl %r9d, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x2120
movq -0x30(%rbp), %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq -0x30(%rbp), %rdi
movl $0x1, %esi
movl $0x1e, %edx
leaq 0x773b(%rip), %rcx      # 0x19eda
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
movl $0x2, %esi
movl $0x1, %edx
leaq 0x7732(%rip), %rcx      # 0x19eed
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
callq 0x2100
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
cmpl $0xa, -0x34(%rbp)
je 0x12868
movq -0x30(%rbp), %rdi
callq 0x21f0
movl %eax, -0x34(%rbp)
cmpl $0x107, -0x34(%rbp)     # imm = 0x107
jne 0x12816
cmpl $0x0, -0x38(%rbp)
jle 0x12816
movl -0x38(%rbp), %eax
subl $0x1, %eax
cltq
movb $0x20, -0x17(%rbp,%rax)
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1283a
cmpl $0xa, -0x34(%rbp)
je 0x12838
cmpl $0xa, -0x38(%rbp)
jge 0x12838
movl -0x34(%rbp), %eax
movb %al, %cl
movslq -0x38(%rbp), %rax
movb %cl, -0x17(%rbp,%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1283a
movq -0x30(%rbp), %rdi
leaq -0x17(%rbp), %r8
movl $0x3, %esi
movl $0x1, %edx
leaq 0x691a(%rip), %rcx      # 0x1916d
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
callq 0x2100
jmp 0x127d9
movl $0x0, -0xc(%rbp)
cmpl $0xa, -0xc(%rbp)
jge 0x128a5
movslq -0xc(%rbp), %rax
movsbl -0x17(%rbp,%rax), %eax
movslq -0xc(%rbp), %rcx
movsbl -0x22(%rbp,%rcx), %ecx
xorl $0xc0, %ecx
cmpl %ecx, %eax
je 0x12898
movl $0x0, -0x4(%rbp)
jmp 0x1289a
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1286f
cmpl $0x0, -0x4(%rbp)
je 0x128f7
movq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1e, %edx
leaq 0x765e(%rip), %rcx      # 0x19f1e
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
leaq 0x765b(%rip), %rcx      # 0x19f37
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
jmp 0x12965
movq -0x30(%rbp), %rdi
movl $0xc500, %esi           # imm = 0xC500
xorl %eax, %eax
movl %eax, %edx
callq 0x21d0
movq -0x30(%rbp), %rdi
movl $0x4, %esi
movl $0x1e, %edx
leaq 0x7691(%rip), %rcx      # 0x19faf
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
movl $0x5, %esi
movl $0x1, %edx
leaq 0x768e(%rip), %rcx      # 0x19fc8
movb $0x0, %al
callq 0x2070
movq -0x30(%rbp), %rdi
movl $0xc500, %esi           # imm = 0xC500
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
movq -0x30(%rbp), %rdi
movl $0x2f00, %esi           # imm = 0x2F00
xorl %eax, %eax
movl %eax, %edx
callq 0x2060
movq -0x30(%rbp), %rdi
callq 0x21f0
movl %eax, -0x8(%rbp)
movq -0x30(%rbp), %rdi
movl $0x20, %r8d
xorl %r9d, %r9d
movl %r8d, %esi
movl %r8d, %edx
movl %r8d, %ecx
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x2120
movq -0x30(%rbp), %rdi
movl $0x20, %r9d
movl %r9d, %esi
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
movl $0x20, (%rsp)
movl $0x20, 0x8(%rsp)
movl $0x20, 0x10(%rsp)
callq 0x2120
movq -0x30(%rbp), %rdi
callq 0x2030
movq -0x30(%rbp), %rdi
callq 0x2100
movq -0x30(%rbp), %rdi
callq 0x2110
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)