xoroshiro64:

;;;
;;; xoroshiro64.s
;;; group4.s
;;;
section .data

s0:			dd		137546
s1:			dd		729

buffer:		dd		0

section .text

global _start
_start:

	push rbp
	mov  rbp, rsp

.loop:

	call next
	mov dword [buffer], eax ; Return value from next in eax

	mov	rax, 1
	mov rdi, 1
	mov rsi, buffer
	mov rdx, 4
	syscall

	jmp .loop

	pop rbp

	mov rax, 60
	mov rdi, 0
	syscall

next:
	; Next function here.

	; Setting up the result
	mov rax, 0
	mov eax, [s0]

	; result = rol(s0 * 0x9E3779BB, 5)*5
	mov r15, 0
	mov r15d, 0x9E3779BB
	mul r15d				; No need to worry about the high part of
							; the mul stored in edx.
	rol eax, 5                 
	mov r15d, 5
	mul r15d


	; s1 ^= s0
	mov r13d, [s0]			
	mov r14d, [s1] 
	xor r14d, r13d			

	; s[0] = rol(s0,26) ^ s1 ^(s1 << 9)
	mov r12d, 0
	mov r12d, r13d			; r12 now contains s0
	rol r12d, 26 ; 

	xor r12d, r14d

	shl r14, 9
	xor r12d, r14d          

	mov dword[s0], r12d	    ; Update s[2] value


	; s[1] = rol(s1,13)
	rol r14d, 13

	mov dword[s1], r14d		; Update s[1] value

	; Return results in eax.	
	ret