// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/shellaes.c
// Function: tagGen
void tagGen(const u32 rk[], const u8 checksum[], const u8 Lprime[], const u8 U[], const u8 F[], u8 T[], unsigned long long int ptlen){
    u8 mask1[16], mask2[16];
    u8 temp[16];

    /*generate 3*Lprime and 7*Lprime and store them in mask1[] and mask2[] respectively*/
    memcpy(mask1, Lprime, 16);
    double_mask(mask1);
    memcpy(mask2, mask1, 16);
    xor_byte_string(Lprime, mask1, 16);

    double_mask(mask2);
    xor_byte_string(mask1, mask2, 16);

    /*generate 2^{lm+1}*3*Lprime and 2^{lm+1}*7*Lprime and store them in mask1[] and mask2[] respectively*/
    while(ptlen!=0){
        double_mask(mask1);
        double_mask(mask2);
        ptlen-=16;
    }
    double_mask(mask1);
    double_mask(mask2);

    /*produce the tag value*/
    xor_byte_string(checksum, mask1, 16);

    aesEncrypt(rk, mask1, temp);
    xor_byte_string(U, temp, 16);
    xor_byte_string(mask2, temp, 16);

    aesEncrypt(rk, temp, T);
    xor_byte_string(mask2, T, 16);
    xor_byte_string(F, T, 16);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r12
movq %rdi, %r15
vmovups (%rdx), %xmm0
movq 0x70(%rsp), %rax
vmovaps %xmm0, (%rsp)
movl $0xf, %ecx
xorl %r8d, %r8d
movb (%rsp), %dil
movb (%rsp,%rcx), %r9b
leal (%r9,%r9), %r10d
orb %r8b, %r10b
movb %r10b, (%rsp,%rcx)
shrb $0x7, %r9b
movl %r9d, %r8d
addq $-0x1, %rcx
jb 0x4867
testb %dil, %dil
jns 0x488d
xorb $-0x79, 0xf(%rsp)
vmovaps (%rsp), %xmm0
vmovaps %xmm0, 0x10(%rsp)
vxorps (%rdx), %xmm0, %xmm0
vmovaps %xmm0, (%rsp)
movl $0xf, %ecx
xorl %edi, %edi
movb 0x10(%rsp), %dl
movb 0x10(%rsp,%rcx), %r8b
leal (%r8,%r8), %r9d
orb %dil, %r9b
movb %r9b, 0x10(%rsp,%rcx)
shrb $0x7, %r8b
movl %r8d, %edi
addq $-0x1, %rcx
jb 0x48ac
testb %dl, %dl
jns 0x48d3
xorb $-0x79, 0x1f(%rsp)
vmovaps 0x10(%rsp), %xmm0
vxorps (%rsp), %xmm0, %xmm0
vmovaps %xmm0, 0x10(%rsp)
testq %rax, %rax
je 0x4950
movl $0xf, %edx
movb (%rsp), %cl
xorl %edi, %edi
movb (%rsp,%rdx), %r8b
leal (%r8,%r8), %r9d
orb %dil, %r9b
movb %r9b, (%rsp,%rdx)
shrb $0x7, %r8b
movl %r8d, %edi
addq $-0x1, %rdx
jb 0x48f3
testb %cl, %cl
jns 0x4918
xorb $-0x79, 0xf(%rsp)
movl $0xf, %edx
movb 0x10(%rsp), %cl
xorl %edi, %edi
movb 0x10(%rsp,%rdx), %r8b
leal (%r8,%r8), %r9d
orb %dil, %r9b
movb %r9b, 0x10(%rsp,%rdx)
shrb $0x7, %r8b
movl %r8d, %edi
addq $-0x1, %rdx
jb 0x4923
testb %cl, %cl
jns 0x494a
xorb $-0x79, 0x1f(%rsp)
addq $-0x10, %rax
jne 0x48e9
movl $0xf, %ecx
movb (%rsp), %al
xorl %edx, %edx
movb (%rsp,%rcx), %dil
leal (%rdi,%rdi), %r8d
orb %dl, %r8b
movb %r8b, (%rsp,%rcx)
shrb $0x7, %dil
movl %edi, %edx
addq $-0x1, %rcx
jb 0x495a
testb %al, %al
jns 0x497e
xorb $-0x79, 0xf(%rsp)
movl $0xf, %ecx
movb 0x10(%rsp), %al
xorl %edx, %edx
movb 0x10(%rsp,%rcx), %dil
leal (%rdi,%rdi), %r8d
orb %dl, %r8b
movb %r8b, 0x10(%rsp,%rcx)
shrb $0x7, %dil
movl %edi, %edx
addq $-0x1, %rcx
jb 0x4989
testb %al, %al
jns 0x49af
xorb $-0x79, 0x1f(%rsp)
movq %rsp, %rax
vmovaps (%rax), %xmm0
vxorps (%rsi), %xmm0, %xmm0
vmovaps %xmm0, (%rax)
leaq 0x30(%rsp), %r13
movq %r15, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x21e0
vmovdqa (%r13), %xmm0
vmovdqa 0x10(%rsp), %xmm1
vmovdqa %xmm1, 0x20(%rsp)
vpternlogq $0x96, (%r12), %xmm1, %xmm0
vmovdqa %xmm0, (%r13)
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x21e0
vmovaps 0x20(%rsp), %xmm0
vxorps (%rbx), %xmm0, %xmm0
vmovups %xmm0, (%rbx)
xorl %eax, %eax
movb (%r14,%rax), %cl
xorb %cl, (%rbx,%rax)
incq %rax
cmpq $0x10, %rax
jne 0x4a0f
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq