// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sha3

import (
	
	
	
	
)

// rc stores the round constants for use in the ι step.
var rc = [24]uint64{
	0x0000000000000001,
	0x0000000000008082,
	0x800000000000808A,
	0x8000000080008000,
	0x000000000000808B,
	0x0000000080000001,
	0x8000000080008081,
	0x8000000000008009,
	0x000000000000008A,
	0x0000000000000088,
	0x0000000080008009,
	0x000000008000000A,
	0x000000008000808B,
	0x800000000000008B,
	0x8000000000008089,
	0x8000000000008003,
	0x8000000000008002,
	0x8000000000000080,
	0x000000000000800A,
	0x800000008000000A,
	0x8000000080008081,
	0x8000000000008080,
	0x0000000080000001,
	0x8000000080008008,
}

// keccakF1600Generic applies the Keccak permutation.
func keccakF1600Generic( *[200]byte) {
	var  *[25]uint64
	if cpu.BigEndian {
		 = new([25]uint64)
		for  := range  {
			[] = byteorder.LEUint64([*8:])
		}
		defer func() {
			for  := range  {
				byteorder.LEPutUint64([*8:], [])
			}
		}()
	} else {
		 = (*[25]uint64)(unsafe.Pointer())
	}

	// Implementation translated from Keccak-inplace.c
	// in the keccak reference code.
	var , , , , , , , , , ,  uint64

	for  := 0;  < 24;  += 4 {
		// Combines the 5 steps in each round into 2 steps.
		// Unrolls 4 rounds per loop and spreads some steps across rounds.

		// Round 1
		 = [0] ^ [5] ^ [10] ^ [15] ^ [20]
		 = [1] ^ [6] ^ [11] ^ [16] ^ [21]
		 = [2] ^ [7] ^ [12] ^ [17] ^ [22]
		 = [3] ^ [8] ^ [13] ^ [18] ^ [23]
		 = [4] ^ [9] ^ [14] ^ [19] ^ [24]
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)

		 = [0] ^ 
		 = [6] ^ 
		 = bits.RotateLeft64(, 44)
		 = [12] ^ 
		 = bits.RotateLeft64(, 43)
		 = [18] ^ 
		 = bits.RotateLeft64(, 21)
		 = [24] ^ 
		 = bits.RotateLeft64(, 14)
		[0] =  ^ ( &^ ) ^ rc[]
		[6] =  ^ ( &^ )
		[12] =  ^ ( &^ )
		[18] =  ^ ( &^ )
		[24] =  ^ ( &^ )

		 = [10] ^ 
		 = bits.RotateLeft64(, 3)
		 = [16] ^ 
		 = bits.RotateLeft64(, 45)
		 = [22] ^ 
		 = bits.RotateLeft64(, 61)
		 = [3] ^ 
		 = bits.RotateLeft64(, 28)
		 = [9] ^ 
		 = bits.RotateLeft64(, 20)
		[10] =  ^ ( &^ )
		[16] =  ^ ( &^ )
		[22] =  ^ ( &^ )
		[3] =  ^ ( &^ )
		[9] =  ^ ( &^ )

		 = [20] ^ 
		 = bits.RotateLeft64(, 18)
		 = [1] ^ 
		 = bits.RotateLeft64(, 1)
		 = [7] ^ 
		 = bits.RotateLeft64(, 6)
		 = [13] ^ 
		 = bits.RotateLeft64(, 25)
		 = [19] ^ 
		 = bits.RotateLeft64(, 8)
		[20] =  ^ ( &^ )
		[1] =  ^ ( &^ )
		[7] =  ^ ( &^ )
		[13] =  ^ ( &^ )
		[19] =  ^ ( &^ )

		 = [5] ^ 
		 = bits.RotateLeft64(, 36)
		 = [11] ^ 
		 = bits.RotateLeft64(, 10)
		 = [17] ^ 
		 = bits.RotateLeft64(, 15)
		 = [23] ^ 
		 = bits.RotateLeft64(, 56)
		 = [4] ^ 
		 = bits.RotateLeft64(, 27)
		[5] =  ^ ( &^ )
		[11] =  ^ ( &^ )
		[17] =  ^ ( &^ )
		[23] =  ^ ( &^ )
		[4] =  ^ ( &^ )

		 = [15] ^ 
		 = bits.RotateLeft64(, 41)
		 = [21] ^ 
		 = bits.RotateLeft64(, 2)
		 = [2] ^ 
		 = bits.RotateLeft64(, 62)
		 = [8] ^ 
		 = bits.RotateLeft64(, 55)
		 = [14] ^ 
		 = bits.RotateLeft64(, 39)
		[15] =  ^ ( &^ )
		[21] =  ^ ( &^ )
		[2] =  ^ ( &^ )
		[8] =  ^ ( &^ )
		[14] =  ^ ( &^ )

		// Round 2
		 = [0] ^ [5] ^ [10] ^ [15] ^ [20]
		 = [1] ^ [6] ^ [11] ^ [16] ^ [21]
		 = [2] ^ [7] ^ [12] ^ [17] ^ [22]
		 = [3] ^ [8] ^ [13] ^ [18] ^ [23]
		 = [4] ^ [9] ^ [14] ^ [19] ^ [24]
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)

		 = [0] ^ 
		 = [16] ^ 
		 = bits.RotateLeft64(, 44)
		 = [7] ^ 
		 = bits.RotateLeft64(, 43)
		 = [23] ^ 
		 = bits.RotateLeft64(, 21)
		 = [14] ^ 
		 = bits.RotateLeft64(, 14)
		[0] =  ^ ( &^ ) ^ rc[+1]
		[16] =  ^ ( &^ )
		[7] =  ^ ( &^ )
		[23] =  ^ ( &^ )
		[14] =  ^ ( &^ )

		 = [20] ^ 
		 = bits.RotateLeft64(, 3)
		 = [11] ^ 
		 = bits.RotateLeft64(, 45)
		 = [2] ^ 
		 = bits.RotateLeft64(, 61)
		 = [18] ^ 
		 = bits.RotateLeft64(, 28)
		 = [9] ^ 
		 = bits.RotateLeft64(, 20)
		[20] =  ^ ( &^ )
		[11] =  ^ ( &^ )
		[2] =  ^ ( &^ )
		[18] =  ^ ( &^ )
		[9] =  ^ ( &^ )

		 = [15] ^ 
		 = bits.RotateLeft64(, 18)
		 = [6] ^ 
		 = bits.RotateLeft64(, 1)
		 = [22] ^ 
		 = bits.RotateLeft64(, 6)
		 = [13] ^ 
		 = bits.RotateLeft64(, 25)
		 = [4] ^ 
		 = bits.RotateLeft64(, 8)
		[15] =  ^ ( &^ )
		[6] =  ^ ( &^ )
		[22] =  ^ ( &^ )
		[13] =  ^ ( &^ )
		[4] =  ^ ( &^ )

		 = [10] ^ 
		 = bits.RotateLeft64(, 36)
		 = [1] ^ 
		 = bits.RotateLeft64(, 10)
		 = [17] ^ 
		 = bits.RotateLeft64(, 15)
		 = [8] ^ 
		 = bits.RotateLeft64(, 56)
		 = [24] ^ 
		 = bits.RotateLeft64(, 27)
		[10] =  ^ ( &^ )
		[1] =  ^ ( &^ )
		[17] =  ^ ( &^ )
		[8] =  ^ ( &^ )
		[24] =  ^ ( &^ )

		 = [5] ^ 
		 = bits.RotateLeft64(, 41)
		 = [21] ^ 
		 = bits.RotateLeft64(, 2)
		 = [12] ^ 
		 = bits.RotateLeft64(, 62)
		 = [3] ^ 
		 = bits.RotateLeft64(, 55)
		 = [19] ^ 
		 = bits.RotateLeft64(, 39)
		[5] =  ^ ( &^ )
		[21] =  ^ ( &^ )
		[12] =  ^ ( &^ )
		[3] =  ^ ( &^ )
		[19] =  ^ ( &^ )

		// Round 3
		 = [0] ^ [5] ^ [10] ^ [15] ^ [20]
		 = [1] ^ [6] ^ [11] ^ [16] ^ [21]
		 = [2] ^ [7] ^ [12] ^ [17] ^ [22]
		 = [3] ^ [8] ^ [13] ^ [18] ^ [23]
		 = [4] ^ [9] ^ [14] ^ [19] ^ [24]
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)

		 = [0] ^ 
		 = [11] ^ 
		 = bits.RotateLeft64(, 44)
		 = [22] ^ 
		 = bits.RotateLeft64(, 43)
		 = [8] ^ 
		 = bits.RotateLeft64(, 21)
		 = [19] ^ 
		 = bits.RotateLeft64(, 14)
		[0] =  ^ ( &^ ) ^ rc[+2]
		[11] =  ^ ( &^ )
		[22] =  ^ ( &^ )
		[8] =  ^ ( &^ )
		[19] =  ^ ( &^ )

		 = [15] ^ 
		 = bits.RotateLeft64(, 3)
		 = [1] ^ 
		 = bits.RotateLeft64(, 45)
		 = [12] ^ 
		 = bits.RotateLeft64(, 61)
		 = [23] ^ 
		 = bits.RotateLeft64(, 28)
		 = [9] ^ 
		 = bits.RotateLeft64(, 20)
		[15] =  ^ ( &^ )
		[1] =  ^ ( &^ )
		[12] =  ^ ( &^ )
		[23] =  ^ ( &^ )
		[9] =  ^ ( &^ )

		 = [5] ^ 
		 = bits.RotateLeft64(, 18)
		 = [16] ^ 
		 = bits.RotateLeft64(, 1)
		 = [2] ^ 
		 = bits.RotateLeft64(, 6)
		 = [13] ^ 
		 = bits.RotateLeft64(, 25)
		 = [24] ^ 
		 = bits.RotateLeft64(, 8)
		[5] =  ^ ( &^ )
		[16] =  ^ ( &^ )
		[2] =  ^ ( &^ )
		[13] =  ^ ( &^ )
		[24] =  ^ ( &^ )

		 = [20] ^ 
		 = bits.RotateLeft64(, 36)
		 = [6] ^ 
		 = bits.RotateLeft64(, 10)
		 = [17] ^ 
		 = bits.RotateLeft64(, 15)
		 = [3] ^ 
		 = bits.RotateLeft64(, 56)
		 = [14] ^ 
		 = bits.RotateLeft64(, 27)
		[20] =  ^ ( &^ )
		[6] =  ^ ( &^ )
		[17] =  ^ ( &^ )
		[3] =  ^ ( &^ )
		[14] =  ^ ( &^ )

		 = [10] ^ 
		 = bits.RotateLeft64(, 41)
		 = [21] ^ 
		 = bits.RotateLeft64(, 2)
		 = [7] ^ 
		 = bits.RotateLeft64(, 62)
		 = [18] ^ 
		 = bits.RotateLeft64(, 55)
		 = [4] ^ 
		 = bits.RotateLeft64(, 39)
		[10] =  ^ ( &^ )
		[21] =  ^ ( &^ )
		[7] =  ^ ( &^ )
		[18] =  ^ ( &^ )
		[4] =  ^ ( &^ )

		// Round 4
		 = [0] ^ [5] ^ [10] ^ [15] ^ [20]
		 = [1] ^ [6] ^ [11] ^ [16] ^ [21]
		 = [2] ^ [7] ^ [12] ^ [17] ^ [22]
		 = [3] ^ [8] ^ [13] ^ [18] ^ [23]
		 = [4] ^ [9] ^ [14] ^ [19] ^ [24]
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)
		 =  ^ (<<1 | >>63)

		 = [0] ^ 
		 = [1] ^ 
		 = bits.RotateLeft64(, 44)
		 = [2] ^ 
		 = bits.RotateLeft64(, 43)
		 = [3] ^ 
		 = bits.RotateLeft64(, 21)
		 = [4] ^ 
		 = bits.RotateLeft64(, 14)
		[0] =  ^ ( &^ ) ^ rc[+3]
		[1] =  ^ ( &^ )
		[2] =  ^ ( &^ )
		[3] =  ^ ( &^ )
		[4] =  ^ ( &^ )

		 = [5] ^ 
		 = bits.RotateLeft64(, 3)
		 = [6] ^ 
		 = bits.RotateLeft64(, 45)
		 = [7] ^ 
		 = bits.RotateLeft64(, 61)
		 = [8] ^ 
		 = bits.RotateLeft64(, 28)
		 = [9] ^ 
		 = bits.RotateLeft64(, 20)
		[5] =  ^ ( &^ )
		[6] =  ^ ( &^ )
		[7] =  ^ ( &^ )
		[8] =  ^ ( &^ )
		[9] =  ^ ( &^ )

		 = [10] ^ 
		 = bits.RotateLeft64(, 18)
		 = [11] ^ 
		 = bits.RotateLeft64(, 1)
		 = [12] ^ 
		 = bits.RotateLeft64(, 6)
		 = [13] ^ 
		 = bits.RotateLeft64(, 25)
		 = [14] ^ 
		 = bits.RotateLeft64(, 8)
		[10] =  ^ ( &^ )
		[11] =  ^ ( &^ )
		[12] =  ^ ( &^ )
		[13] =  ^ ( &^ )
		[14] =  ^ ( &^ )

		 = [15] ^ 
		 = bits.RotateLeft64(, 36)
		 = [16] ^ 
		 = bits.RotateLeft64(, 10)
		 = [17] ^ 
		 = bits.RotateLeft64(, 15)
		 = [18] ^ 
		 = bits.RotateLeft64(, 56)
		 = [19] ^ 
		 = bits.RotateLeft64(, 27)
		[15] =  ^ ( &^ )
		[16] =  ^ ( &^ )
		[17] =  ^ ( &^ )
		[18] =  ^ ( &^ )
		[19] =  ^ ( &^ )

		 = [20] ^ 
		 = bits.RotateLeft64(, 41)
		 = [21] ^ 
		 = bits.RotateLeft64(, 2)
		 = [22] ^ 
		 = bits.RotateLeft64(, 62)
		 = [23] ^ 
		 = bits.RotateLeft64(, 55)
		 = [24] ^ 
		 = bits.RotateLeft64(, 39)
		[20] =  ^ ( &^ )
		[21] =  ^ ( &^ )
		[22] =  ^ ( &^ )
		[23] =  ^ ( &^ )
		[24] =  ^ ( &^ )
	}
}