// File: superblocks[P]superblocks/next.cpp
// Function: Superblocks::getsecondaryreward(int, int)
int Superblocks::getsecondaryreward( int seed, int step ) 
{
	if( debug ) { 
		cout << "getsecondaryreward: seed: " << seed << endl; 
		cout << "getsecondaryreward: step: " << step << endl; 
		cout << "getsecondaryreward: reward: " << reward[step] << endl;
		cout << "getsecondaryreward: secondary_rand_low: " << secondary_rand_low[step] << endl; 
		cout << "getsecondaryreward: secondary_rand_high: " << secondary_rand_high[step] << endl; 
		cout << "getsecondaryreward: secondary_rand_type: " 
			<< getsecondarylucktype( secondary_rand_type[step] ) << endl; 
		cout << "getsecondaryreward: secondary_rand_x: " << secondary_rand_x[step] << endl; 
	}

	int rand1 = Superblocks::generateMTRandom(seed, secondary_rand_low[step], secondary_rand_high[step]);

	int secondary_reward;

	switch( secondary_rand_type[step] ) {
		case 1: // SECONDARY_REWARD_PLUS_RAND_MINUS_X 
			secondary_reward = ( reward[step] + rand1 - secondary_rand_x[step] );
			break;
		default: 
			cout << "getsecondaryreward: error: unknown secondary_rand_type!" << endl;
			return 0;
	}

	if( debug ) {
		cout << "getsecondaryreward: rand1: " << rand1 << endl; 
		cout << "getsecondaryreward: secondary_reward: " << secondary_reward << endl; 
	}
	return secondary_reward;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x58(%rbp)
cmpl $0x0, (%rax)
je 0x2bfe
movq 0x557b(%rip), %rdi      # 0x7fd8
movq %rdi, -0x78(%rbp)
leaq 0x279d(%rip), %rsi      # 0x5205
callq 0x2110
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x21f0
movq %rax, %rdi
movq 0x5546(%rip), %rsi      # 0x7fc8
movq %rsi, -0x80(%rbp)
callq 0x2130
movq -0x78(%rbp), %rdi
leaq 0x278a(%rip), %rsi      # 0x5220
callq 0x2110
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x21f0
movq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x2130
movq -0x78(%rbp), %rdi
leaq 0x277e(%rip), %rsi      # 0x523b
callq 0x2110
movq %rax, %rdi
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl 0xd4(%rax,%rcx,4), %esi
callq 0x21f0
movq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x2130
movq -0x78(%rbp), %rdi
leaq 0x2768(%rip), %rsi      # 0x5258
callq 0x2110
movq %rax, %rdi
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl 0x94(%rax,%rcx,4), %esi
callq 0x21f0
movq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x2130
movq -0x78(%rbp), %rdi
leaq 0x275e(%rip), %rsi      # 0x5281
callq 0x2110
movq %rax, %rdi
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl 0x9c(%rax,%rcx,4), %esi
callq 0x21f0
movq -0x80(%rbp), %rsi
movq %rax, %rdi
callq 0x2130
movq -0x78(%rbp), %rdi
leaq 0x2755(%rip), %rsi      # 0x52ab
callq 0x2110
movq -0x58(%rbp), %rsi
movq %rax, -0x70(%rbp)
movslq -0x18(%rbp), %rax
movl 0x8c(%rsi,%rax,4), %edx
leaq -0x38(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x3090
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x2100
movq %rax, -0x60(%rbp)
jmp 0x2b8e
movq -0x60(%rbp), %rdi
movq 0x542f(%rip), %rsi      # 0x7fc8
callq 0x2130
jmp 0x2ba0
leaq -0x38(%rbp), %rdi
callq 0x2080
movq 0x5428(%rip), %rdi      # 0x7fd8
leaq 0x271e(%rip), %rsi      # 0x52d5
callq 0x2110
movq %rax, %rdi
movq -0x58(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl 0xa4(%rax,%rcx,4), %esi
callq 0x21f0
movq %rax, %rdi
movq 0x53eb(%rip), %rsi      # 0x7fc8
callq 0x2130
jmp 0x2bfe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x2080
jmp 0x2cf9
movq -0x58(%rbp), %rdi
movl -0x14(%rbp), %esi
movslq -0x18(%rbp), %rax
movl 0x94(%rdi,%rax,4), %edx
movl 0x9c(%rdi,%rax,4), %ecx
callq 0x39d0
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, -0x48(%rbp)
movslq -0x18(%rbp), %rcx
movl 0x8c(%rax,%rcx,4), %eax
subl $0x1, %eax
jne 0x2c59
jmp 0x2c37
movq -0x58(%rbp), %rcx
movslq -0x18(%rbp), %rax
movl 0xd4(%rcx,%rax,4), %eax
addl -0x48(%rbp), %eax
movslq -0x18(%rbp), %rdx
subl 0xa4(%rcx,%rdx,4), %eax
movl %eax, -0x4c(%rbp)
jmp 0x2c84
movq 0x5378(%rip), %rdi      # 0x7fd8
leaq 0x2695(%rip), %rsi      # 0x52fc
callq 0x2110
movq %rax, %rdi
movq 0x5352(%rip), %rsi      # 0x7fc8
callq 0x2130
movl $0x0, -0x4(%rbp)
jmp 0x2ced
movq -0x58(%rbp), %rax
cmpl $0x0, (%rax)
je 0x2ce7
movq 0x5344(%rip), %rdi      # 0x7fd8
leaq 0x2699(%rip), %rsi      # 0x5334
callq 0x2110
movq %rax, %rdi
movl -0x48(%rbp), %esi
callq 0x21f0
movq %rax, %rdi
movq 0x5313(%rip), %rsi      # 0x7fc8
callq 0x2130
movq 0x5317(%rip), %rdi      # 0x7fd8
leaq 0x2688(%rip), %rsi      # 0x5350
callq 0x2110
movq %rax, %rdi
movl -0x4c(%rbp), %esi
callq 0x21f0
movq %rax, %rdi
movq 0x52e6(%rip), %rsi      # 0x7fc8
callq 0x2130
movl -0x4c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2200
nopw %cs:(%rax,%rax)