// File: /workspace/github_c_makefile_star2_O3/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 0xb6c5(%rip), %rdi      # 0x11810
callq 0x3050
movq 0xb6b9(%rip), %rdi      # 0x11810
movq 0xb50a(%rip), %rsi      # 0x11668
callq 0x4cbc
movq 0xb6a6(%rip), %rdi      # 0x11810
callq 0x31b0
leaq 0xb6ca(%rip), %rax      # 0x11840
movq 0x18(%rax), %rax
xorl %r12d, %r12d
cmpq 0xae24(%rip), %rax      # 0x10fa8
sete %r12b
leaq 0x7840(%rip), %rbx      # 0xd9cf
xorl %r13d, %r13d
leaq 0xb64f(%rip), %r15      # 0x117e8
movl %r12d, %ebp
orl $0x4, %ebp
movq 0xb682(%rip), %rdi      # 0x11828
callq 0x3050
movq 0xb676(%rip), %rdi      # 0x11828
movl $0x2, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb65b(%rip), %rdi      # 0x11828
movl $0x3, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb640(%rip), %rdi      # 0x11828
leaq 0xb5e1(%rip), %rax      # 0x117d0
movq (%rax), %r8
movl $0x4, %esi
movl $0x2, %edx
leaq 0x6048(%rip), %r14      # 0xc24b
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb614(%rip), %rdi      # 0x11828
movq (%r15), %r8
movl $0x5, %esi
movl $0x2, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb5f6(%rip), %rdi      # 0x11828
movl $0x6, %esi
movl $0x2, %edx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb5db(%rip), %rdi      # 0x11828
movl %ebp, %esi
movl $0x2, %edx
callq 0x33b0
cmpl $-0x1, %eax
je 0x6277
movq 0xb5c3(%rip), %rdi      # 0x11828
movq 0xad2c(%rip), %rax      # 0x10f98
movl 0xac(%rax), %esi
callq 0x33f0
movq 0xb5aa(%rip), %rdi      # 0x11828
movl $0x2, %esi
movl $0x1e, %edx
testl %r12d, %r12d
je 0x6309
leaq 0x6210(%rip), %rcx      # 0xc4a4
xorl %eax, %eax
callq 0x31c0
movq 0xb586(%rip), %rdi      # 0x11828
movl $0x7, %esi
movl $0x2, %edx
leaq 0x621a(%rip), %rcx      # 0xc4cd
xorl %eax, %eax
callq 0x31c0
movq 0xb567(%rip), %rdi      # 0x11828
movl $0x8, %esi
movl $0x2, %edx
leaq 0x6248(%rip), %rcx      # 0xc51a
xorl %eax, %eax
callq 0x31c0
movq 0xb548(%rip), %rdi      # 0x11828
movl $0x9, %esi
movl $0x2, %edx
leaq 0x6276(%rip), %rcx      # 0xc567
xorl %eax, %eax
callq 0x31c0
movl $0xa, %esi
leaq 0x669e(%rip), %r14      # 0xc9a2
jmp 0x63ba
leaq 0x6035(%rip), %rcx      # 0xc345
xorl %eax, %eax
callq 0x31c0
movq 0xb50a(%rip), %rdi      # 0x11828
movl $0x7, %esi
movl $0x2, %edx
leaq 0x6041(%rip), %rcx      # 0xc370
xorl %eax, %eax
callq 0x31c0
movq 0xb4eb(%rip), %rdi      # 0x11828
movl $0x8, %esi
movl $0x2, %edx
leaq 0x606f(%rip), %rcx      # 0xc3bd
xorl %eax, %eax
callq 0x31c0
movq 0xb4cc(%rip), %rdi      # 0x11828
movl $0x9, %esi
movl $0x2, %edx
leaq 0x609d(%rip), %rcx      # 0xc40a
xorl %eax, %eax
callq 0x31c0
movq 0xb4ad(%rip), %rdi      # 0x11828
movl $0xa, %esi
movl $0x2, %edx
leaq 0x6616(%rip), %r14      # 0xc9a2
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb48b(%rip), %rdi      # 0x11828
movl $0xb, %esi
movl $0x2, %edx
leaq 0x60a9(%rip), %rcx      # 0xc457
xorl %eax, %eax
callq 0x31c0
movl $0xc, %esi
movq 0xb467(%rip), %rdi      # 0x11828
movl $0x2, %edx
movq %r14, %rcx
xorl %eax, %eax
callq 0x31c0
movq 0xb451(%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 0xb42b(%rip), %rdi      # 0x11828
leaq 0x61b0(%rip), %rsi      # 0xc5b4
callq 0x4cbc
movq 0xb418(%rip), %rdi      # 0x11828
callq 0x31b0
movq 0xab84(%rip), %rax      # 0x10fa0
movq (%rax), %rdi
callq 0x3120
cmpl $0x6a, %eax
jg 0x6443
cmpl $0x49, %eax
jle 0x645e
cmpl $0x4a, %eax
je 0x6480
cmpl $0x4b, %eax
je 0x648b
cmpl $0x6a, %eax
jne 0x619f
jmp 0x6480
leal -0x101(%rax), %ecx
cmpl $0x6, %ecx
ja 0x646e
leaq 0x5bf7(%rip), %rdx      # 0xc04c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
cmpl $0xa, %eax
je 0x6493
cmpl $0x20, %eax
jne 0x619f
jmp 0x6493
cmpl $0x6b, %eax
je 0x648b
cmpl $0x157, %eax            # imm = 0x157
jne 0x619f
jmp 0x6493
movl $0x1, %r12d
jmp 0x6199
xorl %r12d, %r12d
jmp 0x6199
testl %r12d, %r12d
jne 0x649f
leaq 0xb331(%rip), %r15      # 0x117d0
leaq 0xb39a(%rip), %rax      # 0x11840
movq %r15, 0x18(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq