// File: tonymugen[P]sampleSNPs/random.cpp
// Function: sampFiles::GenerateMT::ranInt()
volatile uint64_t GenerateMT::ranInt(){
	
	if (_mti == _n) { // do we need to re-run the twister?
		size_t i = 0;
		for (; i < _n - _m; i++) { // first _m words
			_x     = (_mt[i]&_um)|(_mt[i + 1]&_lm);
			_mt[i] = _mt[i + _m]^(_x>>1)^_alt[static_cast<size_t>(_x&1ULL)];
		}
		for (; i < _n - 1; i++) { // rest, except for the last element
			_x     = (_mt[i]&_um)|(_mt[i+1]&_lm);
			_mt[i] = _mt[i + (_m - _n)] ^ (_x>>1)^_alt[static_cast<size_t>(_x&1ULL)];
		}
		// now set the last element
		_x          = (_mt[_n - 1]&_um)|(_mt[0]&_lm);
		_mt[_n - 1] = _mt[_m - 1]^(_x>>1)^_alt[static_cast<size_t>(_x&1ULL)];
		
		_mti = 0;

	}
	// extract pseudo-random number
	_x = _mt[_mti++];
	
	_x ^= ((_x>>_u)&_d);
	_x ^= ((_x<<_s)&_b);
	_x ^= ((_x<<_t)&_c);
	_x ^= (_x>>_l);
	
	return _x;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
cmpq $0x138, 0x9c8(%rax) # imm = 0x138
jne 0x222ba
movq $0x0, -0x10(%rbp)
cmpq $0x9c, -0x10(%rbp)
jae 0x221d7
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rdx
movq 0x10(%rax,%rdx,8), %rdx
andq $-0x80000000, %rdx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x9d0(%rax)
movq -0x10(%rbp), %rcx
movq 0x4e8(%rax,%rcx,8), %rdx
movq 0x9d0(%rax), %rcx
shrq %rcx
xorq %rcx, %rdx
movq 0x9d0(%rax), %rsi
andq $0x1, %rsi
leaq 0x1ff4(%rip), %rcx      # 0x241b0
xorq (%rcx,%rsi,8), %rdx
movq -0x10(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x22159
jmp 0x221d9
cmpq $0x137, -0x10(%rbp)     # imm = 0x137
jae 0x22257
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq -0x10(%rbp), %rdx
movq 0x10(%rax,%rdx,8), %rdx
andq $-0x80000000, %rdx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x9d0(%rax)
movq -0x10(%rbp), %rcx
movq -0x4d8(%rax,%rcx,8), %rdx
movq 0x9d0(%rax), %rcx
shrq %rcx
xorq %rcx, %rdx
movq 0x9d0(%rax), %rsi
andq $0x1, %rsi
leaq 0x1f74(%rip), %rcx      # 0x241b0
xorq (%rcx,%rsi,8), %rdx
movq -0x10(%rbp), %rcx
movq %rdx, 0x8(%rax,%rcx,8)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x221d9
movq -0x18(%rbp), %rax
movq 0x9c0(%rax), %rcx
andq $0x7fffffff, %rcx       # imm = 0x7FFFFFFF
movq 0x8(%rax), %rdx
andq $-0x80000000, %rdx      # imm = 0x80000000
orq %rdx, %rcx
movq %rcx, 0x9d0(%rax)
movq 0x4e0(%rax), %rcx
movq 0x9d0(%rax), %rdx
shrq %rdx
xorq %rdx, %rcx
movq 0x9d0(%rax), %rsi
andq $0x1, %rsi
leaq 0x1f0c(%rip), %rdx      # 0x241b0
xorq (%rdx,%rsi,8), %rcx
movq %rcx, 0x9c0(%rax)
movq $0x0, 0x9c8(%rax)
movq -0x18(%rbp), %rax
movq 0x9c8(%rax), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, 0x9c8(%rax)
movq 0x8(%rax,%rcx,8), %rcx
movq %rcx, 0x9d0(%rax)
movq 0x9d0(%rax), %rcx
shrq $0x1d, %rcx
movabsq $0x5555555555555555, %rdx # imm = 0x5555555555555555
andq %rdx, %rcx
xorq 0x9d0(%rax), %rcx
movq %rcx, 0x9d0(%rax)
movq 0x9d0(%rax), %rcx
shlq $0x11, %rcx
movabsq $0x71d67fffeda60000, %rdx # imm = 0x71D67FFFEDA60000
andq %rdx, %rcx
xorq 0x9d0(%rax), %rcx
movq %rcx, 0x9d0(%rax)
movq 0x9d0(%rax), %rcx
shlq $0x25, %rcx
movabsq $-0x8112000000000, %rdx # imm = 0xFFF7EEE000000000
andq %rdx, %rcx
xorq 0x9d0(%rax), %rcx
movq %rcx, 0x9d0(%rax)
movq 0x9d0(%rax), %rcx
shrq $0x2b, %rcx
xorq 0x9d0(%rax), %rcx
movq %rcx, 0x9d0(%rax)
movq 0x9d0(%rax), %rax
popq %rbp
retq
nopw %cs:(%rax,%rax)