// File: /workspace/github_c_makefile_star2_O2/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 0xabb2(%rip), %rdi      # 0x10810
callq 0x3050
movq 0xaba6(%rip), %rdi      # 0x10810
movq 0xa9f7(%rip), %rsi      # 0x10668
callq 0x4974
movq 0xab93(%rip), %rdi      # 0x10810
callq 0x31b0
leaq 0xabb7(%rip), %rax      # 0x10840
movq 0x18(%rax), %rax
xorl %r12d, %r12d
cmpq 0xa311(%rip), %rax      # 0xffa8
sete %r12b
leaq 0x6cf9(%rip), %rbx      # 0xc99b
pushq $0x2
popq %rbp
leaq 0xab3c(%rip), %rax      # 0x107e8
movq %rax, (%rsp)
leaq 0x5ceb(%rip), %r13      # 0xb9a2
movl %r12d, %r14d
orl $0x4, %r14d
movq 0xab63(%rip), %rdi      # 0x10828
callq 0x3050
movq 0xab57(%rip), %rdi      # 0x10828
movl %ebp, %esi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xab42(%rip), %rdi      # 0x10828
pushq $0x3
popq %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xab2c(%rip), %rdi      # 0x10828
leaq 0xaacd(%rip), %rax      # 0x107d0
movq (%rax), %r8
pushq $0x4
popq %rsi
movl %ebp, %edx
leaq 0x5539(%rip), %r15      # 0xb24b
movq %r15, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xab05(%rip), %rdi      # 0x10828
leaq 0xaabe(%rip), %rax      # 0x107e8
movq (%rax), %r8
pushq $0x5
popq %rsi
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xaae5(%rip), %rdi      # 0x10828
pushq $0x6
popq %rsi
movl %ebp, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xaacf(%rip), %rdi      # 0x10828
movl %r14d, %esi
movl %ebp, %edx
callq 0x33b0
cmpl $-0x1, %eax
je 0x5d81
movq 0xaab9(%rip), %rdi      # 0x10828
movq 0xa222(%rip), %rax      # 0xff98
movl 0xac(%rax), %esi
callq 0x33f0
movq 0xaaa0(%rip), %rdi      # 0x10828
movl %ebp, %esi
pushq $0x1e
popq %rdx
testl %r12d, %r12d
je 0x5df9
leaq 0x570b(%rip), %rcx      # 0xb4a4
xorl %eax, %eax
callq 0x31c0
movq 0xaa81(%rip), %rdi      # 0x10828
pushq $0x7
popq %rsi
movl %ebp, %edx
leaq 0x571a(%rip), %rcx      # 0xb4cd
xorl %eax, %eax
callq 0x31c0
movq 0xaa67(%rip), %rdi      # 0x10828
pushq $0x8
popq %rsi
movl %ebp, %edx
leaq 0x574d(%rip), %rcx      # 0xb51a
xorl %eax, %eax
callq 0x31c0
movq 0xaa4d(%rip), %rdi      # 0x10828
pushq $0x9
popq %rsi
movl %ebp, %edx
leaq 0x5780(%rip), %rcx      # 0xb567
xorl %eax, %eax
callq 0x31c0
pushq $0xa
popq %rsi
movq %r13, %r15
jmp 0x5e8b
leaq 0x5545(%rip), %rcx      # 0xb345
xorl %eax, %eax
callq 0x31c0
movq 0xaa1a(%rip), %rdi      # 0x10828
pushq $0x7
popq %rsi
movl %ebp, %edx
leaq 0x5556(%rip), %rcx      # 0xb370
xorl %eax, %eax
callq 0x31c0
movq 0xaa00(%rip), %rdi      # 0x10828
pushq $0x8
popq %rsi
movl %ebp, %edx
leaq 0x5589(%rip), %rcx      # 0xb3bd
xorl %eax, %eax
callq 0x31c0
movq 0xa9e6(%rip), %rdi      # 0x10828
pushq $0x9
popq %rsi
movl %ebp, %edx
leaq 0x55bc(%rip), %rcx      # 0xb40a
xorl %eax, %eax
callq 0x31c0
movq 0xa9cc(%rip), %rdi      # 0x10828
pushq $0xa
popq %rsi
movl %ebp, %edx
movq %r13, %r15
movq %r13, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xa9b3(%rip), %rdi      # 0x10828
pushq $0xb
popq %rsi
movl %ebp, %edx
leaq 0x55d6(%rip), %rcx      # 0xb457
xorl %eax, %eax
callq 0x31c0
pushq $0xc
popq %rsi
movq 0xa996(%rip), %rdi      # 0x10828
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xa983(%rip), %rdi      # 0x10828
subq $0x8, %rsp
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
pushq $0x0
callq 0x3100
addq $0x20, %rsp
movq 0xa95d(%rip), %rdi      # 0x10828
leaq 0x56e2(%rip), %rsi      # 0xb5b4
callq 0x4974
movq 0xa94a(%rip), %rdi      # 0x10828
callq 0x31b0
movq 0xa0b6(%rip), %rax      # 0xffa0
movq (%rax), %rdi
callq 0x3120
leal -0x101(%rax), %ecx
cmpl $0x6, %ecx
jbe 0x5f28
cmpl $0xa, %eax
je 0x5f49
cmpl $0x20, %eax
je 0x5f49
cmpl $0x4a, %eax
je 0x5f38
cmpl $0x4b, %eax
je 0x5f41
cmpl $0x157, %eax            # imm = 0x157
je 0x5f49
cmpl $0x6b, %eax
je 0x5f41
cmpl $0x6a, %eax
jne 0x5cbe
jmp 0x5f38
leaq 0x511d(%rip), %rdx      # 0xb04c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
pushq $0x1
popq %r12
jmp 0x5cb7
xorl %r12d, %r12d
jmp 0x5cb7
testl %r12d, %r12d
jne 0x5f59
leaq 0xa87b(%rip), %r13      # 0x107d0
movq %r13, (%rsp)
leaq 0xa8e0(%rip), %rax      # 0x10840
movq (%rsp), %rcx
movq %rcx, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq