// File: /workspace/github_c_makefile_star2_O1/sTeeLM[P]dwipe/gui.c
// Function: dwipe_gui_prng
void dwipe_gui_prng( void )
{
/**
 * Allows the user to change the PRNG.
 *
 * @modifies  dwipe_options.prng
 * @modifies  main_window
 *
 */

	extern dwipe_prng_t dwipe_twister;
	extern dwipe_prng_t dwipe_isaac;

	/* The number of implemented PRNGs. */
	const int count = 2;

	/* The first tabstop. */
	const int tab1 = 2;

	/* The second tabstop. */
	const int tab2 = 30;

	/* Set the initial focus. */
	int focus = 0;

	/* The current working row. */
	int yy;

	/* Input buffer. */
	int keystroke;

	/* Update the footer window. */
	werase( footer_window );
	dwipe_gui_title( footer_window, dwipe_buttons2 );
	wrefresh( footer_window );

	if( dwipe_options.prng == &dwipe_twister ) { focus = 0; }
	if( dwipe_options.prng == &dwipe_isaac   ) { focus = 1; }


	while( 1 )
	{
		/* Clear the main window. */
		werase( main_window );

		/* Initialize the working row. */
		yy = 2;

		/* Print the options. */
		mvwprintw( main_window, yy++, tab1, ""                  );
		mvwprintw( main_window, yy++, tab1, ""                  );
		mvwprintw( main_window, yy++, tab1, "  %s", dwipe_twister.label );
		mvwprintw( main_window, yy++, tab1, "  %s", dwipe_isaac.label   );
		mvwprintw( main_window, yy++, tab1, ""                  );

		/* Print the cursor. */
		mvwaddch( main_window, 4 + focus, tab1, ACS_RARROW );


		switch( focus )
		{
			case 0:

				mvwprintw( main_window, 2, tab2, "syslinux.cfg:  nuke=\"dwipe --prng twister\"" );

				/*                                 0         1         2         3         4         5         6         7        8  */
				mvwprintw( main_window, yy++, tab1, "The Mersenne Twister, by Makoto Matsumoto and Takuji Nishimura, is a        " );
				mvwprintw( main_window, yy++, tab1, "generalized feedback shift register PRNG that is uniform and                " );
				mvwprintw( main_window, yy++, tab1, "equidistributed in 623-dimensions with a proven period of 2^19937-1.        " );
				mvwprintw( main_window, yy++, tab1, "                                                                            " );
				mvwprintw( main_window, yy++, tab1, "This implementation passes the Marsaglia Diehard test suite.                " );
				mvwprintw( main_window, yy++, tab1, "                                                                            " );
				break;

			case 1:

				mvwprintw( main_window, 2, tab2, "syslinux.cfg:  nuke=\"dwipe --prng isaac\"" );

				/*                                 0         1         2         3         4         5         6         7        8  */
				mvwprintw( main_window, yy++, tab1, "ISAAC, by Bob Jenkins, is a PRNG derived from RC4 with a minimum period of  " );
				mvwprintw( main_window, yy++, tab1, "2^40 and an expected period of 2^8295.  It is difficult to recover the      " );
				mvwprintw( main_window, yy++, tab1, "initial PRNG state by cryptanalysis of the ISAAC stream.                    " );
				mvwprintw( main_window, yy++, tab1, "                                                                            " );
				break;

		} /* switch */

		/* Add a border. */
		box( main_window, 0, 0 );

		/* Add a title. */
		dwipe_gui_title( main_window, " Pseudo Random Number Generator " );

		/* Refresh the window. */
		wrefresh( main_window );

		/* Get a keystroke. */
		keystroke = getch();

		switch( keystroke )
		{
			case KEY_DOWN:
			case 'j':
			case 'J':

				if( focus < count -1 ) { focus += 1; } 
				break;

			case KEY_UP:
			case 'k':
			case 'K':

				if( focus > 0 ) { focus -= 1; } 
				break;

			case KEY_ENTER:
			case ' ':
			case 10:

				if( focus == 0 ) { dwipe_options.prng = &dwipe_twister; }
				if( focus == 1 ) { dwipe_options.prng = &dwipe_isaac;   }
				return;

			case KEY_BACKSPACE:
			case KEY_BREAK:

				return;

		} /* switch */
		
	} /* while */

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0xb732(%rip), %rdi      # 0x11810
callq 0x3050
movq 0xb726(%rip), %rdi      # 0x11810
movq 0xb577(%rip), %rsi      # 0x11668
callq 0x4c4c
movq 0xb713(%rip), %rdi      # 0x11810
callq 0x31b0
leaq 0xb737(%rip), %rax      # 0x11840
movq 0x18(%rax), %rax
xorl %r12d, %r12d
cmpq 0xae91(%rip), %rax      # 0x10fa8
sete %r12b
leaq 0x78ad(%rip), %rbx      # 0xd9cf
xorl %r13d, %r13d
leaq 0xb6bc(%rip), %r15      # 0x117e8
movl %r12d, %ebp
orl $0x4, %ebp
movq 0xb6ef(%rip), %rdi      # 0x11828
callq 0x3050
movq 0xb6e3(%rip), %rdi      # 0x11828
movl $0x2, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb6c8(%rip), %rdi      # 0x11828
movl $0x3, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb6ad(%rip), %rdi      # 0x11828
leaq 0xb64e(%rip), %rax      # 0x117d0
movq (%rax), %r8
movl $0x4, %esi
movl $0x2, %edx
leaq 0x60b5(%rip), %r14      # 0xc24b
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb681(%rip), %rdi      # 0x11828
movq (%r15), %r8
movl $0x5, %esi
movl $0x2, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb663(%rip), %rdi      # 0x11828
movl $0x6, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb648(%rip), %rdi      # 0x11828
movl %ebp, %esi
movl $0x2, %edx
callq 0x33a0
cmpl $-0x1, %eax
je 0x620a
movq 0xb630(%rip), %rdi      # 0x11828
movq 0xad99(%rip), %rax      # 0x10f98
movl 0xac(%rax), %esi
callq 0x33e0
movq 0xb617(%rip), %rdi      # 0x11828
movl $0x2, %esi
movl $0x1e, %edx
testl %r12d, %r12d
je 0x629c
leaq 0x627d(%rip), %rcx      # 0xc4a4
xorl %eax, %eax
callq 0x31c0
movq 0xb5f3(%rip), %rdi      # 0x11828
movl $0x7, %esi
movl $0x2, %edx
leaq 0x6287(%rip), %rcx      # 0xc4cd
xorl %eax, %eax
callq 0x31c0
movq 0xb5d4(%rip), %rdi      # 0x11828
movl $0x8, %esi
movl $0x2, %edx
leaq 0x62b5(%rip), %rcx      # 0xc51a
xorl %eax, %eax
callq 0x31c0
movq 0xb5b5(%rip), %rdi      # 0x11828
movl $0x9, %esi
movl $0x2, %edx
leaq 0x62e3(%rip), %rcx      # 0xc567
xorl %eax, %eax
callq 0x31c0
movl $0xa, %esi
leaq 0x670b(%rip), %r14      # 0xc9a2
jmp 0x634d
leaq 0x60a2(%rip), %rcx      # 0xc345
xorl %eax, %eax
callq 0x31c0
movq 0xb577(%rip), %rdi      # 0x11828
movl $0x7, %esi
movl $0x2, %edx
leaq 0x60ae(%rip), %rcx      # 0xc370
xorl %eax, %eax
callq 0x31c0
movq 0xb558(%rip), %rdi      # 0x11828
movl $0x8, %esi
movl $0x2, %edx
leaq 0x60dc(%rip), %rcx      # 0xc3bd
xorl %eax, %eax
callq 0x31c0
movq 0xb539(%rip), %rdi      # 0x11828
movl $0x9, %esi
movl $0x2, %edx
leaq 0x610a(%rip), %rcx      # 0xc40a
xorl %eax, %eax
callq 0x31c0
movq 0xb51a(%rip), %rdi      # 0x11828
movl $0xa, %esi
movl $0x2, %edx
leaq 0x6683(%rip), %r14      # 0xc9a2
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb4f8(%rip), %rdi      # 0x11828
movl $0xb, %esi
movl $0x2, %edx
leaq 0x6116(%rip), %rcx      # 0xc457
xorl %eax, %eax
callq 0x31c0
movl $0xc, %esi
movq 0xb4d4(%rip), %rdi      # 0x11828
movl $0x2, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb4be(%rip), %rdi      # 0x11828
subq $0x8, %rsp
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r13
pushq %r13
pushq %r13
callq 0x3100
addq $0x20, %rsp
movq 0xb498(%rip), %rdi      # 0x11828
leaq 0x621d(%rip), %rsi      # 0xc5b4
callq 0x4c4c
movq 0xb485(%rip), %rdi      # 0x11828
callq 0x31b0
movq 0xabf1(%rip), %rax      # 0x10fa0
movq (%rax), %rdi
callq 0x3120
cmpl $0x6a, %eax
jg 0x63d6
cmpl $0x49, %eax
jle 0x63f1
cmpl $0x4a, %eax
je 0x6413
cmpl $0x4b, %eax
je 0x641e
cmpl $0x6a, %eax
jne 0x6132
jmp 0x6413
leal -0x101(%rax), %ecx
cmpl $0x6, %ecx
ja 0x6401
leaq 0x5c64(%rip), %rdx      # 0xc04c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
cmpl $0xa, %eax
je 0x6426
cmpl $0x20, %eax
jne 0x6132
jmp 0x6426
cmpl $0x6b, %eax
je 0x641e
cmpl $0x157, %eax            # imm = 0x157
jne 0x6132
jmp 0x6426
movl $0x1, %r12d
jmp 0x612c
xorl %r12d, %r12d
jmp 0x612c
testl %r12d, %r12d
jne 0x6432
leaq 0xb39e(%rip), %r15      # 0x117d0
leaq 0xb407(%rip), %rax      # 0x11840
movq %r15, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq