// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/icepole128v2/ref/icepole.c
// Function: initState
void initState(ICESTATE S, const unsigned char * k, const unsigned char * nonce)
{
    ICESTATE T;

    /* init state */
    S[0][0] = 0xFF97A42D7F8E6FD4ULL;
    S[0][1] = 0x90FEE5A0A44647C4ULL;
    S[0][2] = 0x8C5BDA0CD6192E76ULL;
    S[0][3] = 0xAD30A6F71B19059CULL;
    S[0][4] = 0x30935AB7D08FFC64ULL;

    S[1][0] = 0xEB5AA93F2317D635ULL;
    S[1][1] = 0xA9A6E6260D712103ULL;
    S[1][2] = 0x81A57C16DBCF555FULL;
    S[1][3] = 0x43B831CD0347C826ULL;
    S[1][4] = 0x01F22F1A11A5569FULL;

    S[2][0] = 0x05E5635A21D9AE61ULL;
    S[2][1] = 0x64BEFEF28CC970F2ULL;
    S[2][2] = 0x613670957BC46611ULL;
    S[2][3] = 0xB87C5A554FD00ECBULL;
    S[2][4] = 0x8C3EE88A1CCF32C8ULL;

    S[3][0] = 0x940C7922AE3A2614ULL;
    S[3][1] = 0x1841F924A2C509E4ULL;
    S[3][2] = 0x16F53526E70465C2ULL;
    S[3][3] = 0x75F644E97F30A13BULL;
    S[3][4] = 0xEAF1FF7B5CECA249ULL;

    /* xor key, nonce */
    S[0][0] = S[0][0] ^ load64(k, 8);
    S[1][0] = S[1][0] ^ load64(k+8, 8);
    S[2][0] = S[2][0] ^ load64(nonce, 8);
    S[3][0] = S[3][0] ^ load64(nonce+8, 8);

    /* do P_12 */
    oneround(T,S,0);
    oneround(S,T,1);
    oneround(T,S,2);
    oneround(S,T,3);
    oneround(T,S,4);
    oneround(S,T,5);
    oneround(T,S,6);
    oneround(S,T,7);
    oneround(T,S,8);
    oneround(S,T,9);
    oneround(T,S,10);
    oneround(S,T,11);
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xa8, %rsp
movq %rdi, %rbx
vmovaps 0x1417(%rip), %ymm0     # 0x30a0
vmovups %ymm0, (%rdi)
vmovaps 0x142b(%rip), %ymm0     # 0x30c0
vmovups %ymm0, 0x20(%rdi)
vmovaps 0x143e(%rip), %ymm0     # 0x30e0
vmovups %ymm0, 0x40(%rdi)
vmovaps 0x1451(%rip), %ymm0     # 0x3100
vmovups %ymm0, 0x60(%rdi)
vmovaps 0x1464(%rip), %ymm0     # 0x3120
vmovups %ymm0, 0x80(%rdi)
vpmovzxbq (%rsi), %ymm0
vpmovsxbq 0x14ba(%rip), %ymm1 # 0x318c
vpsllvq %ymm1, %ymm0, %ymm0
vpmovzxbq 0x4(%rsi), %ymm2
vpmovsxbq 0x14aa(%rip), %ymm3 # 0x3190
vpsllvq %ymm3, %ymm2, %ymm2
vpor %ymm0, %ymm2, %ymm0
vextracti128 $0x1, %ymm0, %xmm2
vpor %xmm2, %xmm0, %xmm0
vpshufd $0xee, %xmm0, %xmm2     # xmm2 = xmm0[2,3,2,3]
vpxor %xmm2, %xmm0, %xmm0
vmovq %xmm0, %rax
movabsq $-0x685bd28071902c, %rcx # imm = 0xFF97A42D7F8E6FD4
xorq %rax, %rcx
movq %rcx, (%rdi)
vpmovzxbq 0x8(%rsi), %ymm0
vpsllvq %ymm1, %ymm0, %ymm0
vpmovzxbq 0xc(%rsi), %ymm2
vpsllvq %ymm3, %ymm2, %ymm2
vpor %ymm0, %ymm2, %ymm0
vextracti128 $0x1, %ymm0, %xmm2
vpor %xmm2, %xmm0, %xmm0
vpshufd $0xee, %xmm0, %xmm2     # xmm2 = xmm0[2,3,2,3]
vpxor %xmm2, %xmm0, %xmm0
vmovq %xmm0, %rax
movabsq $-0x14a556c0dce829cb, %rcx # imm = 0xEB5AA93F2317D635
xorq %rax, %rcx
movq %rcx, 0x28(%rdi)
vpmovzxbq (%rdx), %ymm0
vpsllvq %ymm1, %ymm0, %ymm0
vpmovzxbq 0x4(%rdx), %ymm2
vpsllvq %ymm3, %ymm2, %ymm2
vpor %ymm0, %ymm2, %ymm0
vextracti128 $0x1, %ymm0, %xmm2
vpor %xmm2, %xmm0, %xmm0
vpshufd $0xee, %xmm0, %xmm2     # xmm2 = xmm0[2,3,2,3]
vpxor %xmm2, %xmm0, %xmm0
vmovq %xmm0, %rax
movabsq $0x5e5635a21d9ae61, %rcx # imm = 0x5E5635A21D9AE61
xorq %rax, %rcx
movq %rcx, 0x50(%rdi)
vpmovzxbq 0x8(%rdx), %ymm0
vpsllvq %ymm1, %ymm0, %ymm0
vpmovzxbq 0xc(%rdx), %ymm1
vpsllvq %ymm3, %ymm1, %ymm1
vpor %ymm0, %ymm1, %ymm0
vextracti128 $0x1, %ymm0, %xmm1
vpor %xmm1, %xmm0, %xmm0
vpshufd $0xee, %xmm0, %xmm1     # xmm1 = xmm0[2,3,2,3]
vpxor %xmm1, %xmm0, %xmm0
vmovq %xmm0, %rax
movabsq $-0x6bf386dd51c5d9ec, %rcx # imm = 0x940C7922AE3A2614
xorq %rax, %rcx
movq %rcx, 0x78(%rdi)
movq %rsp, %r14
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
vzeroupper
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %edx
callq 0x10f0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x3, %edx
callq 0x10f0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x4, %edx
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x10f0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x6, %edx
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x7, %edx
callq 0x10f0
movq %r14, %rdi
movq %rbx, %rsi
movl $0x8, %edx
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0x9, %edx
callq 0x10f0
movq %r14, %rdi
movq %rbx, %rsi
movl $0xa, %edx
callq 0x10f0
movq %rbx, %rdi
movq %r14, %rsi
movl $0xb, %edx
callq 0x10f0
addq $0xa8, %rsp
popq %rbx
popq %r14
retq