// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/aegis128l/aesnic/encrypt.c
// Function: aegis128L_dec_aut_step
void aegis128L_dec_aut_step(unsigned char *plaintextblk,
       const unsigned char *ciphertextblk, __m128i *state)
{
        __m128i msg0 = _mm_load_si128((__m128i*)ciphertextblk);
        __m128i msg1 = _mm_load_si128((__m128i*)(ciphertextblk+16));
        __m128i tmp;

        //decryption
        msg0 = _mm_xor_si128(msg0, state[6]);
        msg0 = _mm_xor_si128(msg0, state[1]);
        msg1 = _mm_xor_si128(msg1, state[2]);
        msg1 = _mm_xor_si128(msg1, state[5]);
        msg0 = _mm_xor_si128(msg0, _mm_and_si128(state[2], state[3]));
        msg1 = _mm_xor_si128(msg1, _mm_and_si128(state[6], state[7]));
        _mm_store_si128((__m128i*)plaintextblk, msg0);
        _mm_store_si128((__m128i*)(plaintextblk+16), msg1);

        //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 $0x268, %rsp            # imm = 0x268
movq %rdi, -0x38(%rsp)
movq %rsi, -0x40(%rsp)
movq %rdx, -0x48(%rsp)
movq -0x40(%rsp), %rax
movq %rax, -0x28(%rsp)
movq -0x28(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x60(%rsp)
movq -0x40(%rsp), %rax
addq $0x10, %rax
movq %rax, -0x30(%rsp)
movq -0x30(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm0, -0x70(%rsp)
vmovdqa -0x60(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x60(%rax), %xmm0
vmovdqa %xmm1, 0xd0(%rsp)
vmovdqa %xmm0, 0xc0(%rsp)
vmovdqa 0xd0(%rsp), %xmm0
vpxor 0xc0(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x60(%rsp)
vmovdqa -0x60(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x10(%rax), %xmm0
vmovdqa %xmm1, 0xb0(%rsp)
vmovdqa %xmm0, 0xa0(%rsp)
vmovdqa 0xb0(%rsp), %xmm0
vpxor 0xa0(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x60(%rsp)
vmovdqa -0x70(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x20(%rax), %xmm0
vmovdqa %xmm1, 0x90(%rsp)
vmovdqa %xmm0, 0x80(%rsp)
vmovdqa 0x90(%rsp), %xmm0
vpxor 0x80(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x70(%rsp)
vmovdqa -0x70(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x50(%rax), %xmm0
vmovdqa %xmm1, 0x70(%rsp)
vmovdqa %xmm0, 0x60(%rsp)
vmovdqa 0x70(%rsp), %xmm0
vpxor 0x60(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x70(%rsp)
vmovdqa -0x60(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x20(%rax), %xmm2
movq -0x48(%rsp), %rax
vmovdqa 0x30(%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, -0x60(%rsp)
vmovdqa -0x70(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x60(%rax), %xmm2
movq -0x48(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm2, 0x230(%rsp)
vmovdqa %xmm0, 0x220(%rsp)
vmovdqa 0x230(%rsp), %xmm0
vpand 0x220(%rsp), %xmm0, %xmm0
vmovdqa %xmm1, 0x30(%rsp)
vmovdqa %xmm0, 0x20(%rsp)
vmovdqa 0x30(%rsp), %xmm0
vpxor 0x20(%rsp), %xmm0, %xmm0
vmovdqa %xmm0, -0x70(%rsp)
movq -0x38(%rsp), %rax
vmovdqa -0x60(%rsp), %xmm0
movq %rax, 0x218(%rsp)
vmovdqa %xmm0, 0x200(%rsp)
vmovdqa 0x200(%rsp), %xmm0
movq 0x218(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x38(%rsp), %rax
addq $0x10, %rax
vmovdqa -0x70(%rsp), %xmm0
movq %rax, 0x1f8(%rsp)
vmovdqa %xmm0, 0x1e0(%rsp)
vmovdqa 0x1e0(%rsp), %xmm0
movq 0x1f8(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm0, -0x80(%rsp)
movq -0x48(%rsp), %rax
vmovdqa 0x60(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x70(%rax), %xmm0
vmovdqa %xmm1, 0x1d0(%rsp)
vmovdqa %xmm0, 0x1c0(%rsp)
vmovdqa 0x1d0(%rsp), %xmm0
vmovdqa 0x1c0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x70(%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x50(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x60(%rax), %xmm0
vmovdqa %xmm1, 0x1b0(%rsp)
vmovdqa %xmm0, 0x1a0(%rsp)
vmovdqa 0x1b0(%rsp), %xmm0
vmovdqa 0x1a0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x60(%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x40(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x50(%rax), %xmm0
vmovdqa %xmm1, 0x190(%rsp)
vmovdqa %xmm0, 0x180(%rsp)
vmovdqa 0x190(%rsp), %xmm0
vmovdqa 0x180(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x50(%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x30(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x40(%rax), %xmm0
vmovdqa %xmm1, 0x170(%rsp)
vmovdqa %xmm0, 0x160(%rsp)
vmovdqa 0x170(%rsp), %xmm0
vmovdqa 0x160(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x40(%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x20(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x30(%rax), %xmm0
vmovdqa %xmm1, 0x150(%rsp)
vmovdqa %xmm0, 0x140(%rsp)
vmovdqa 0x150(%rsp), %xmm0
vmovdqa 0x140(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x30(%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x10(%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x20(%rax), %xmm0
vmovdqa %xmm1, 0x130(%rsp)
vmovdqa %xmm0, 0x120(%rsp)
vmovdqa 0x130(%rsp), %xmm0
vmovdqa 0x120(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x20(%rax)
movq -0x48(%rsp), %rax
vmovdqa (%rax), %xmm1
movq -0x48(%rsp), %rax
vmovdqa 0x10(%rax), %xmm0
vmovdqa %xmm1, 0x110(%rsp)
vmovdqa %xmm0, 0x100(%rsp)
vmovdqa 0x110(%rsp), %xmm0
vmovdqa 0x100(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x10(%rax)
vmovdqa -0x80(%rsp), %xmm1
movq -0x48(%rsp), %rax
vmovdqa (%rax), %xmm0
vmovdqa %xmm1, 0xf0(%rsp)
vmovdqa %xmm0, 0xe0(%rsp)
vmovdqa 0xf0(%rsp), %xmm0
vmovdqa 0xe0(%rsp), %xmm1
vaesenc %xmm1, %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x48(%rsp), %rax
vmovdqa (%rax), %xmm1
vmovdqa -0x60(%rsp), %xmm0
vmovdqa %xmm1, 0x10(%rsp)
vmovdqa %xmm0, (%rsp)
vmovdqa 0x10(%rsp), %xmm0
vpxor (%rsp), %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, (%rax)
movq -0x48(%rsp), %rax
vmovdqa 0x40(%rax), %xmm1
vmovdqa -0x70(%rsp), %xmm0
vmovdqa %xmm1, -0x10(%rsp)
vmovdqa %xmm0, -0x20(%rsp)
vmovdqa -0x10(%rsp), %xmm0
vpxor -0x20(%rsp), %xmm0, %xmm0
movq -0x48(%rsp), %rax
vmovdqa %xmm0, 0x40(%rax)
addq $0x268, %rsp            # imm = 0x268
retq
nop