// File: 5hubh4m[P]snake-ncurses/snake_ncurses.cpp
// Function: fun_snake_game()
void fun_snake_game(void) {
	Snake S;
	int ch, d;
	initscr();
	keypad(stdscr, TRUE);
	noecho();
	timeout(TIMEOUT);
	curs_set(0);
	while(1) {
		ch=getch();
		if(ch=='q') {
			return;
		}
		else if(ch==KEY_UP || ch==KEY_DOWN || ch==KEY_RIGHT || ch==KEY_LEFT) {
			switch(ch) {
				case KEY_UP:
					d=UP;
					break;
				case KEY_DOWN:
					d=DOWN;
					break;
				case KEY_RIGHT:
					d=RIGHT;
					break;
				case KEY_LEFT:
					d=LEFT;
					break;
			}
			if(diff(S.getfdir(), d)!=2 && d!=S.getfdir()) {
				S.createNode(d);
			}
		}
		S.movesnake();
		S.render();
		attron(A_STANDOUT);
		mvprintw(23, 25, "PRESS 'Q' to EXIT BACK TO MENU.");
		attroff(A_STANDOUT);
		refresh();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
leaq -0xb0(%rbp), %rdi
movl $0x19, %esi
callq 0x2580
callq 0x2270
jmp 0x7523
movq 0x5aae(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x20c0
jmp 0x7539
callq 0x21d0
jmp 0x7540
movq 0x5a91(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
movl $0x64, %esi
callq 0x21e0
jmp 0x7556
xorl %edi, %edi
callq 0x2130
jmp 0x755f
jmp 0x7561
jmp 0x7563
movq 0x5a6e(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
callq 0x20b0
movl %eax, -0xc8(%rbp)
jmp 0x757a
movl -0xc8(%rbp), %eax
movl %eax, -0xb4(%rbp)
cmpl $0x71, -0xb4(%rbp)
jne 0x75c7
leaq -0xb0(%rbp), %rdi
callq 0x7950
addq $0xe0, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0xc0(%rbp)
movl %eax, -0xc4(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7950
jmp 0x7751
cmpl $0x103, -0xb4(%rbp)     # imm = 0x103
je 0x75fb
cmpl $0x102, -0xb4(%rbp)     # imm = 0x102
je 0x75fb
cmpl $0x105, -0xb4(%rbp)     # imm = 0x105
je 0x75fb
cmpl $0x104, -0xb4(%rbp)     # imm = 0x104
jne 0x76d9
movl -0xb4(%rbp), %eax
addl $0xfffffefe, %eax       # imm = 0xFFFFFEFE
movl %eax, %ecx
movq %rcx, -0xd0(%rbp)
subl $0x3, %eax
ja 0x7659
movq -0xd0(%rbp), %rax
leaq 0xaae(%rip), %rcx       # 0x80d0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, -0xb8(%rbp)
jmp 0x7659
movl $0x2, -0xb8(%rbp)
jmp 0x7659
movl $0x1, -0xb8(%rbp)
jmp 0x7659
movl $0x3, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x28e0
movl %eax, -0xd4(%rbp)
jmp 0x766d
movl -0xd4(%rbp), %edi
movl -0xb8(%rbp), %esi
callq 0x74d0
movl %eax, -0xd8(%rbp)
jmp 0x7686
movl -0xd8(%rbp), %eax
cmpl $0x2, %eax
je 0x76d7
movl -0xb8(%rbp), %eax
movl %eax, -0xe0(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x28e0
movl %eax, -0xdc(%rbp)
jmp 0x76b1
movl -0xe0(%rbp), %eax
movl -0xdc(%rbp), %ecx
cmpl %ecx, %eax
je 0x76d7
movl -0xb8(%rbp), %esi
leaq -0xb0(%rbp), %rdi
callq 0x2670
jmp 0x76d5
jmp 0x76d7
jmp 0x76d9
jmp 0x76db
leaq -0xb0(%rbp), %rdi
callq 0x27a0
jmp 0x76e9
leaq -0xb0(%rbp), %rdi
callq 0x26d0
jmp 0x76f7
movq 0x58da(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x10000, %esi          # imm = 0x10000
callq 0x20e0
jmp 0x7711
leaq 0x975(%rip), %rdx       # 0x808d
xorl %eax, %eax
movl $0x17, %edi
movl $0x19, %esi
callq 0x2220
jmp 0x772b
movq 0x58a6(%rip), %rax      # 0xcfd8
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x10000, %esi          # imm = 0x10000
callq 0x2210
jmp 0x7745
callq 0x22d0
jmp 0x774c
jmp 0x7561
movq -0xc0(%rbp), %rdi
callq 0x22e0
nopl (%rax)