// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/aes128poetv2aes128ni/ref/poet.c
// Function: aes_expand_key
static void aes_expand_key(__m128i userkey, AES_KEY enc_key)
{
    __m128i temp1, temp2;
    __m128i *key = (__m128i*)enc_key;

    _mm_store_si128(&temp1, userkey);
    _mm_store_si128(&key[0], temp1);

    aes_create_round_key(temp1, temp2, 0x01, &key[1]);
    aes_create_round_key(temp1, temp2, 0x02, &key[2]);
    aes_create_round_key(temp1, temp2, 0x04, &key[3]);
    aes_create_round_key(temp1, temp2, 0x08, &key[4]);
    aes_create_round_key(temp1, temp2, 0x10, &key[5]);
    aes_create_round_key(temp1, temp2, 0x20, &key[6]);
    aes_create_round_key(temp1, temp2, 0x40, &key[7]);
    aes_create_round_key(temp1, temp2, 0x80, &key[8]);
    aes_create_round_key(temp1, temp2, 0x1b, &key[9]);
    aes_create_round_key(temp1, temp2, 0x36, &key[10]);
}

// Assembly:
vaeskeygenassist $0x1, %xmm0, %xmm1
vmovdqa %xmm0, (%rdi)
vpshufd $0xff, %xmm1, %xmm1     # xmm1 = xmm1[3,3,3,3]
vpslldq $0x4, %xmm0, %xmm2      # xmm2 = zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm0, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm0, %xmm4      # xmm4 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm0[0,1,2,3]
vpternlogq $0x96, %xmm3, %xmm2, %xmm4
vpternlogq $0x96, %xmm1, %xmm0, %xmm4
vmovdqa %xmm4, 0x10(%rdi)
vaeskeygenassist $0x2, %xmm4, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm4, %xmm1      # xmm1 = zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm4, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm4, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm3
vpternlogq $0x96, %xmm0, %xmm4, %xmm3
vaeskeygenassist $0x4, %xmm3, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm3, %xmm1      # xmm1 = zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm3, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm3, %xmm4      # xmm4 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm4
vpternlogq $0x96, %xmm0, %xmm3, %xmm4
vaeskeygenassist $0x8, %xmm4, %xmm0
vmovdqa %xmm3, 0x20(%rdi)
vmovdqa %xmm4, 0x30(%rdi)
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm4, %xmm1      # xmm1 = zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm4, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm4, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm3
vpternlogq $0x96, %xmm0, %xmm4, %xmm3
vmovdqa %xmm3, 0x40(%rdi)
vaeskeygenassist $0x10, %xmm3, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm3, %xmm1      # xmm1 = zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm3, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm3, %xmm4      # xmm4 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm4
vpternlogq $0x96, %xmm0, %xmm3, %xmm4
vaeskeygenassist $0x20, %xmm4, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm4, %xmm1      # xmm1 = zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm4, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm4, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm3
vpternlogq $0x96, %xmm0, %xmm4, %xmm3
vaeskeygenassist $0x40, %xmm3, %xmm0
vmovdqa %xmm4, 0x50(%rdi)
vmovdqa %xmm3, 0x60(%rdi)
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm3, %xmm1      # xmm1 = zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm3, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm3, %xmm4      # xmm4 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm4
vpternlogq $0x96, %xmm0, %xmm3, %xmm4
vmovdqa %xmm4, 0x70(%rdi)
vaeskeygenassist $0x80, %xmm4, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm4, %xmm1      # xmm1 = zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm4, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm4, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm3
vpternlogq $0x96, %xmm0, %xmm4, %xmm3
vaeskeygenassist $0x1b, %xmm3, %xmm0
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm3, %xmm1      # xmm1 = zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm3, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm3, %xmm4      # xmm4 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm3[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm4
vpternlogq $0x96, %xmm0, %xmm3, %xmm4
vaeskeygenassist $0x36, %xmm4, %xmm0
vmovdqa %xmm3, 0x80(%rdi)
vmovdqa %xmm4, 0x90(%rdi)
vpshufd $0xff, %xmm0, %xmm0     # xmm0 = xmm0[3,3,3,3]
vpslldq $0x4, %xmm4, %xmm1      # xmm1 = zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7,8,9,10,11]
vpslldq $0x8, %xmm4, %xmm2      # xmm2 = zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3,4,5,6,7]
vpslldq $0xc, %xmm4, %xmm3      # xmm3 = zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,zero,xmm4[0,1,2,3]
vpternlogq $0x96, %xmm2, %xmm1, %xmm3
vpternlogq $0x96, %xmm0, %xmm4, %xmm3
vmovdqa %xmm3, 0xa0(%rdi)
retq