// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/aegis128l/aesnic/encrypt.c
// Function: aegis128L_enc_aut_step
void aegis128L_enc_aut_step(const unsigned char *plaintextblk, unsigned char *ciphertextblk, __m128i *state)
{
        __m128i ct0,ct1;
        __m128i tmp;
        __m128i msg0 = _mm_load_si128((__m128i*)plaintextblk);
        __m128i msg1 = _mm_load_si128((__m128i*)(plaintextblk+16));

        //encryption
        ct0 = _mm_xor_si128(msg0, state[6]);
        ct0 = _mm_xor_si128(ct0,  state[1]);
        ct1 = _mm_xor_si128(msg1, state[2]);
        ct1 = _mm_xor_si128(ct1,  state[5]);
        ct0 = _mm_xor_si128(ct0,  _mm_and_si128(state[2], state[3]));
        ct1 = _mm_xor_si128(ct1,  _mm_and_si128(state[6], state[7]));
    	_mm_store_si128((__m128i*)ciphertextblk, ct0);
    	_mm_store_si128((__m128i*)(ciphertextblk+16), ct1);

        //state update function
        tmp = state[7];
        state[7] = _mm_aesenc_si128(state[6],state[7]);
        state[6] = _mm_aesenc_si128(state[5],state[6]);
        state[5] = _mm_aesenc_si128(state[4],state[5]);
        state[4] = _mm_aesenc_si128(state[3],state[4]);
        state[3] = _mm_aesenc_si128(state[2],state[3]);
        state[2] = _mm_aesenc_si128(state[1],state[2]);
        state[1] = _mm_aesenc_si128(state[0],state[1]);
        state[0] = _mm_aesenc_si128(tmp,state[0]);

        //message is used to update the state.
        state[0] = _mm_xor_si128(state[0],msg0);
        state[4] = _mm_xor_si128(state[4],msg1);
}

// Assembly:
subq $0x288, %rsp            # imm = 0x288
movq %rdi, -0x18(%rsp)
movq %rsi, -0x20(%rsp)
movq %rdx, -0x28(%rsp)
movq -0x18(%rsp), %rax
movq %rax, -0x8(%rsp)
movq -0x8(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x70(%rsp)
movq -0x18(%rsp), %rax
addq $0x10, %rax
movq %rax, -0x10(%rsp)
movq -0x10(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x80(%rsp)
vmovdqa -0x70(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x60(%rax), %xmm0
vmovdqa %xmm1, 0xf0(%rsp)
vmovdqa %xmm0, 0xe0(%rsp)
vmovdqa 0xf0(%rsp), %xmm0
vpxor 0xe0(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x40(%rsp)
vmovdqa -0x40(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x10(%rax), %xmm0
vmovdqa %xmm1, 0xd0(%rsp)
vmovdqa %xmm0, 0xc0(%rsp)
vmovdqa 0xd0(%rsp), %xmm0
vpxor 0xc0(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x40(%rsp)
vmovdqa -0x80(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x20(%rax), %xmm0
vmovdqa %xmm1, 0xb0(%rsp)
vmovdqa %xmm0, 0xa0(%rsp)
vmovdqa 0xb0(%rsp), %xmm0
vpxor 0xa0(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x50(%rsp)
vmovdqa -0x50(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x50(%rax), %xmm0
vmovdqa %xmm1, 0x90(%rsp)
vmovdqa %xmm0, 0x80(%rsp)
vmovdqa 0x90(%rsp), %xmm0
vpxor 0x80(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x50(%rsp)
vmovdqa -0x40(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x20(%rax), %xmm2
movq -0x28(%rsp), %rax
vmovdqa 0x30(%rax), %xmm0
vmovdqa %xmm2, 0x270(%rsp)
vmovdqa %xmm0, 0x260(%rsp)
vmovdqa 0x270(%rsp), %xmm0
vpand 0x260(%rsp), %xmm0, %xmm0
vmovdqa %xmm1, 0x70(%rsp)
vmovdqa %xmm0, 0x60(%rsp)
vmovdqa 0x70(%rsp), %xmm0
vpxor 0x60(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x40(%rsp)
vmovdqa -0x50(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x60(%rax), %xmm2
movq -0x28(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm2, 0x250(%rsp)
vmovdqa %xmm0, 0x240(%rsp)
vmovdqa 0x250(%rsp), %xmm0
vpand 0x240(%rsp), %xmm0, %xmm0
vmovdqa %xmm1, 0x50(%rsp)
vmovdqa %xmm0, 0x40(%rsp)
vmovdqa 0x50(%rsp), %xmm0
vpxor 0x40(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x50(%rsp)
movq -0x20(%rsp), %rax
vmovdqa -0x40(%rsp), %xmm0
movq %rax, 0x238(%rsp)
vmovdqa %xmm0, 0x220(%rsp)
vmovdqa 0x220(%rsp), %xmm0
movq 0x238(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x20(%rsp), %rax
addq $0x10, %rax
vmovdqa -0x50(%rsp), %xmm0
movq %rax, 0x218(%rsp)
vmovdqa %xmm0, 0x200(%rsp)
vmovdqa 0x200(%rsp), %xmm0
movq 0x218(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm0, -0x60(%rsp)
movq -0x28(%rsp), %rax
vmovdqa 0x60(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm1, 0x1f0(%rsp)
vmovdqa %xmm0, 0x1e0(%rsp)
vmovdqa 0x1f0(%rsp), %xmm0
vmovdqa 0x1e0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x70(%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x50(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x60(%rax), %xmm0
vmovdqa %xmm1, 0x1d0(%rsp)
vmovdqa %xmm0, 0x1c0(%rsp)
vmovdqa 0x1d0(%rsp), %xmm0
vmovdqa 0x1c0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x60(%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x40(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x50(%rax), %xmm0
vmovdqa %xmm1, 0x1b0(%rsp)
vmovdqa %xmm0, 0x1a0(%rsp)
vmovdqa 0x1b0(%rsp), %xmm0
vmovdqa 0x1a0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x50(%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x30(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x40(%rax), %xmm0
vmovdqa %xmm1, 0x190(%rsp)
vmovdqa %xmm0, 0x180(%rsp)
vmovdqa 0x190(%rsp), %xmm0
vmovdqa 0x180(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x40(%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x20(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x30(%rax), %xmm0
vmovdqa %xmm1, 0x170(%rsp)
vmovdqa %xmm0, 0x160(%rsp)
vmovdqa 0x170(%rsp), %xmm0
vmovdqa 0x160(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x30(%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x10(%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x20(%rax), %xmm0
vmovdqa %xmm1, 0x150(%rsp)
vmovdqa %xmm0, 0x140(%rsp)
vmovdqa 0x150(%rsp), %xmm0
vmovdqa 0x140(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x20(%rax)
movq -0x28(%rsp), %rax
vmovdqa (%rax), %xmm1
movq -0x28(%rsp), %rax
vmovdqa 0x10(%rax), %xmm0
vmovdqa %xmm1, 0x130(%rsp)
vmovdqa %xmm0, 0x120(%rsp)
vmovdqa 0x130(%rsp), %xmm0
vmovdqa 0x120(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x10(%rax)
vmovdqa -0x60(%rsp), %xmm1
movq -0x28(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm1, 0x110(%rsp)
vmovdqa %xmm0, 0x100(%rsp)
vmovdqa 0x110(%rsp), %xmm0
vmovdqa 0x100(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x28(%rsp), %rax
vmovdqa (%rax), %xmm1
vmovdqa -0x70(%rsp), %xmm0
vmovdqa %xmm1, 0x30(%rsp)
vmovdqa %xmm0, 0x20(%rsp)
vmovdqa 0x30(%rsp), %xmm0
vpxor 0x20(%rsp), %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x28(%rsp), %rax
vmovdqa 0x40(%rax), %xmm1
vmovdqa -0x80(%rsp), %xmm0
vmovdqa %xmm1, 0x10(%rsp)
vmovdqa %xmm0, (%rsp)
vmovdqa 0x10(%rsp), %xmm0
vpxor (%rsp), %xmm0, %xmm0
movq -0x28(%rsp), %rax
vmovdqa %xmm0, 0x40(%rax)
addq $0x288, %rsp            # imm = 0x288
retq
nopl (%rax,%rax)