// File: /workspace/github_c_makefile_star2_O1/mjosaarinen[P]brutus/crypto_aead/shellaes128v2d5n64/ref/shellaes.c
// Function: shellaesDecVef_fb
int shellaesDecVef_fb(const u8 key[], const u8 nonce[], const u8 ad[], unsigned long long int adlen, const u8 c[], unsigned long long int ctlen, u8 p[], const u8 tag[]){

    u8 V[16], U[16], checksum[16], keyprime[16], F[16], L[16], Lprime[16];

    u8* S;
    u8* I;
    u8* Z;

    S=(u8 *) malloc(ctlen);
    I=(u8 *) malloc(ctlen);
    Z=(u8 *) malloc(ctlen);

    memset(V, 0, 16);
    memset(U, 0, 16);
    memset(checksum, 0, 16);
    memset(keyprime, 0, 16);
    memset(F, 0, 16);
    memset(L, 0, 16);
    memset(Lprime, 0, 16);

    u32 mk[4*d], sk[12*d], isk[12*d], rk[44], irk[44], rkprime[44];

    /*setup key materials*/
    aesKeySetupEnc(rk, key);
    aesKeySetupDec(irk, key);
    KeySetupDec(mk, sk, isk, L, Lprime, keyprime, rk, key);
    aesKeySetupEnc(rkprime, keyprime);

    /*process associated data*/
    PXMAC(mk, sk, L, V, rk, ad, adlen);

    /*decryption of XEX layer*/
    XEXLayerDec(irk, Lprime, c, Z, ctlen);

    /*decryption of PXENC layer*/
    PXDEC(mk, isk, L, V, Z, rk, I, ctlen);

    /*CENC layer*/
    CENC(rkprime, S, F, nonce, ctlen);

    /*produce the plaintext*/
    memcpy(p, S, ctlen);
    xor_byte_string(I, p, ctlen);

    /*verify the validness of tag*/
    int flag;
    memcpy(U, V, 16);
    checksum_state_string(I, checksum, ctlen);

    flag=tagVef(rk, checksum, Lprime, U, F, tag, ctlen);

    free(I);
    free(S);
    free(Z);

    return flag;

}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x508, %rsp            # imm = 0x508
movq %r9, %r12
movq %r8, 0x70(%rsp)
movq %rcx, 0x68(%rsp)
movq %rdx, 0x60(%rsp)
movq %rsi, 0x78(%rsp)
movq %rdi, %rbx
movq 0x540(%rsp), %r13
movq %r9, %rdi
callq 0x10c0
movq %rax, 0x58(%rsp)
movq %r12, %rdi
callq 0x10c0
movq %rax, %r15
movq %r12, %rdi
callq 0x10c0
movq %rax, 0x8(%rsp)
vxorps %xmm0, %xmm0, %xmm0
leaq 0x40(%rsp), %rax
vmovaps %xmm0, (%rax)
vmovaps %xmm0, 0x30(%rsp)
vmovaps %xmm0, 0x10(%rsp)
leaq 0xa0(%rsp), %rax
vmovaps %xmm0, (%rax)
leaq 0x90(%rsp), %rax
vmovaps %xmm0, (%rax)
leaq 0x20(%rsp), %rax
vmovaps %xmm0, (%rax)
leaq 0x80(%rsp), %rbp
vmovaps %xmm0, (%rbp)
leaq 0xc0(%rsp), %rdi
movq %rbx, %rsi
callq 0x1130
leaq 0x270(%rsp), %rdi
movq %rbx, %rsi
callq 0x11c0
leaq 0x170(%rsp), %r14
leaq 0x410(%rsp), %rsi
leaq 0x320(%rsp), %rdx
movq %r14, %rdi
leaq 0x20(%rsp), %rcx
movq %rbp, %r8
leaq 0xa0(%rsp), %r9
pushq %rbx
leaq 0xc8(%rsp), %rax
pushq %rax
callq 0x1050
addq $0x10, %rsp
leaq 0x1c0(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
movq 0x8(%rsp), %rbp
callq 0x1130
subq $0x8, %rsp
movq %r14, %rdi
leaq 0x418(%rsp), %rsi
movq 0x60(%rsp), %r14
leaq 0x28(%rsp), %rdx
leaq 0x48(%rsp), %rbx
movq %rbx, %rcx
leaq 0xc8(%rsp), %r8
movq 0x68(%rsp), %r9
pushq 0x70(%rsp)
callq 0x1150
addq $0x10, %rsp
leaq 0x270(%rsp), %rdi
leaq 0x80(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq %rbp, %rcx
movq %r12, %r8
callq 0x1100
leaq 0x170(%rsp), %rdi
leaq 0x320(%rsp), %rsi
leaq 0x20(%rsp), %rdx
movq %rbx, %rcx
movq %rbp, %r8
leaq 0xc0(%rsp), %r9
pushq %r12
pushq %r15
callq 0x1090
addq $0x10, %rsp
leaq 0x1c0(%rsp), %rdi
movq %r14, %rsi
leaq 0x90(%rsp), %rdx
movq 0x78(%rsp), %rcx
movq %r12, %r8
callq 0x1140
movq %r13, %rdi
movq %r14, %rbp
movq %r14, %rsi
movq %r12, %rdx
callq 0x11d0
testq %r12, %r12
je 0x3c14
leaq 0x1f(%r12), %rax
andq $-0x20, %rax
leaq -0x1(%r12), %rcx
vpbroadcastq %rcx, %ymm0
xorl %ecx, %ecx
vpmovsxbq 0x56a6(%rip), %ymm1 # 0x9194
vpmovsxbq 0x56a1(%rip), %ymm2 # 0x9198
vpmovsxbq 0x569c(%rip), %ymm3 # 0x919c
vpmovsxbq 0x5697(%rip), %ymm4 # 0x91a0
vpmovsxbq 0x5692(%rip), %ymm5 # 0x91a4
vpmovsxbq 0x568d(%rip), %ymm6 # 0x91a8
vpmovsxbq 0x5668(%rip), %ymm7 # 0x918c
vpmovsxbq 0x5663(%rip), %ymm8 # 0x9190
vpbroadcastq %rcx, %ymm9
vpor %ymm1, %ymm9, %ymm10
vpor %ymm2, %ymm9, %ymm11
vpor %ymm3, %ymm9, %ymm12
vpor %ymm4, %ymm9, %ymm13
vpor %ymm5, %ymm9, %ymm14
vpor %ymm6, %ymm9, %ymm15
vporq %ymm7, %ymm9, %ymm16
vpor %ymm8, %ymm9, %ymm9
vpcmpleuq %ymm0, %ymm9, %k0
vpcmpleuq %ymm0, %ymm16, %k1
kshiftlb $0x4, %k1, %k1
korb %k1, %k0, %k0
vpcmpleuq %ymm0, %ymm15, %k1
vpcmpleuq %ymm0, %ymm14, %k2
kshiftlb $0x4, %k2, %k2
korb %k2, %k1, %k1
kunpckbw %k0, %k1, %k0
vpcmpleuq %ymm0, %ymm13, %k1
vpcmpleuq %ymm0, %ymm12, %k2
kshiftlb $0x4, %k2, %k2
korb %k2, %k1, %k1
vpcmpleuq %ymm0, %ymm11, %k2
vpcmpleuq %ymm0, %ymm10, %k3
kshiftlb $0x4, %k3, %k3
korb %k3, %k2, %k2
kunpckbw %k1, %k2, %k1
kunpckwd %k0, %k1, %k1
vmovdqu8 (%r15,%rcx), %ymm9 {%k1} {z}
vmovdqu8 (%r13,%rcx), %ymm10 {%k1} {z}
vpxor %ymm9, %ymm10, %ymm9
vmovdqu8 %ymm9, (%r13,%rcx) {%k1}
addq $0x20, %rcx
cmpq %rcx, %rax
jne 0x3b2d
vmovdqa 0x40(%rsp), %xmm0
vmovdqa %xmm0, 0x30(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %xmm0, 0x10(%rsp)
xorl %eax, %eax
vpxor (%r15,%rax), %xmm0, %xmm0
addq $0x10, %rax
cmpq %rax, %r12
jne 0x3c03
jmp 0x3c24
vmovdqa 0x40(%rsp), %xmm0
vmovdqa %xmm0, 0x30(%rsp)
vpxor %xmm0, %xmm0, %xmm0
vmovdqa %xmm0, 0x10(%rsp)
movq 0x548(%rsp), %rbx
subq $0x8, %rsp
leaq 0xc8(%rsp), %rdi
leaq 0x18(%rsp), %rsi
leaq 0x88(%rsp), %rdx
leaq 0x38(%rsp), %rcx
leaq 0x98(%rsp), %r8
leaq 0xb8(%rsp), %r9
pushq %r12
vzeroupper
callq 0x1070
addq $0x10, %rsp
kxorw %k0, %k0, %k0
xorl %eax, %eax
vmovq 0xb0(%rsp,%rax), %xmm0
vmovq (%rbx,%rax), %xmm1
vpcmpneqb %xmm1, %xmm0, %k1
korb %k1, %k0, %k0
addq $0x8, %rax
cmpq $0x10, %rax
jne 0x3c74
xorl %ebx, %ebx
kortestb %k0, %k0
sete %bl
movq %r15, %rdi
callq 0x1110
movq %rbp, %rdi
callq 0x1110
movq 0x8(%rsp), %rdi
callq 0x1110
movl %ebx, %eax
addq $0x508, %rsp            # imm = 0x508
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq