// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/shellaes128v1d5n64/ref/shellaes.c
// Function: shellaesDec_fb
void shellaesDec_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[], 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];

    aesKeySetupEnc(rk, key);
    aesKeySetupDec(irk, key);
    KeySetupDec(mk, sk, isk, L, Lprime, keyprime, rk, key);
    aesKeySetupEnc(rkprime, keyprime);

    PXMAC(mk, sk, L, V, rk, ad, adlen);

    XEXLayerDec(irk, Lprime, c, Z, ctlen);
    PXDEC(mk, isk, L, V, Z, rk, I, ctlen);
    memcpy(U, V, 16);

    checksum_state_string(I, checksum, ctlen);

    CENC(rkprime, S, F, nonce, ctlen);

    memcpy(p, S, ctlen);
    xor_byte_string(I, p, ctlen);

    tagGen(rk, checksum, Lprime, U, F, tag, ctlen);

    free(I);
    free(S);
    free(Z);


}

// Assembly:
subq $0x518, %rsp            # imm = 0x518
movq 0x528(%rsp), %rax
movq 0x520(%rsp), %rax
movq %rdi, 0x510(%rsp)
movq %rsi, 0x508(%rsp)
movq %rdx, 0x500(%rsp)
movq %rcx, 0x4f8(%rsp)
movq %r8, 0x4f0(%rsp)
movq %r9, 0x4e8(%rsp)
movq 0x4e8(%rsp), %rdi
callq 0x20d0
movq %rax, 0x468(%rsp)
movq 0x4e8(%rsp), %rdi
callq 0x20d0
movq %rax, 0x460(%rsp)
movq 0x4e8(%rsp), %rdi
callq 0x20d0
movq %rax, 0x458(%rsp)
leaq 0x4d0(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x4c0(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x4b0(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x4a0(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x490(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x480(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x470(%rsp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x2070
leaq 0x170(%rsp), %rdi
movq 0x510(%rsp), %rsi
callq 0x2170
leaq 0xc0(%rsp), %rdi
movq 0x510(%rsp), %rsi
callq 0x2250
leaq 0x400(%rsp), %rdi
leaq 0x310(%rsp), %rsi
leaq 0x220(%rsp), %rdx
leaq 0x480(%rsp), %rcx
leaq 0x470(%rsp), %r8
leaq 0x4a0(%rsp), %r9
leaq 0x170(%rsp), %r10
movq 0x510(%rsp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x2060
leaq 0x10(%rsp), %rdi
leaq 0x4a0(%rsp), %rsi
callq 0x2170
leaq 0x400(%rsp), %rdi
leaq 0x310(%rsp), %rsi
leaq 0x480(%rsp), %rdx
leaq 0x4d0(%rsp), %rcx
leaq 0x170(%rsp), %r8
movq 0x500(%rsp), %r9
movq 0x4f8(%rsp), %rax
movq %rax, (%rsp)
callq 0x21a0
leaq 0xc0(%rsp), %rdi
leaq 0x470(%rsp), %rsi
movq 0x4f0(%rsp), %rdx
movq 0x458(%rsp), %rcx
movq 0x4e8(%rsp), %r8
callq 0x2140
leaq 0x400(%rsp), %rdi
leaq 0x220(%rsp), %rsi
leaq 0x480(%rsp), %rdx
leaq 0x4d0(%rsp), %rcx
movq 0x458(%rsp), %r8
leaq 0x170(%rsp), %r9
movq 0x460(%rsp), %r10
movq 0x4e8(%rsp), %rax
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x20a0
movq 0x4d0(%rsp), %rax
movq %rax, 0x4c0(%rsp)
movq 0x4d8(%rsp), %rax
movq %rax, 0x4c8(%rsp)
movq 0x460(%rsp), %rdi
leaq 0x4b0(%rsp), %rsi
movq 0x4e8(%rsp), %rdx
callq 0x21b0
leaq 0x10(%rsp), %rdi
movq 0x468(%rsp), %rsi
leaq 0x490(%rsp), %rdx
movq 0x508(%rsp), %rcx
movq 0x4e8(%rsp), %r8
callq 0x2180
movq 0x520(%rsp), %rdi
movq 0x468(%rsp), %rsi
movq 0x4e8(%rsp), %rdx
callq 0x2270
movq 0x460(%rsp), %rdi
movq 0x520(%rsp), %rsi
movq 0x4e8(%rsp), %rdx
callq 0x2240
leaq 0x170(%rsp), %rdi
leaq 0x4b0(%rsp), %rsi
leaq 0x470(%rsp), %rdx
leaq 0x4c0(%rsp), %rcx
leaq 0x490(%rsp), %r8
movq 0x528(%rsp), %r9
movq 0x4e8(%rsp), %rax
movq %rax, (%rsp)
callq 0x2080
movq 0x460(%rsp), %rdi
callq 0x2150
movq 0x468(%rsp), %rdi
callq 0x2150
movq 0x458(%rsp), %rdi
callq 0x2150
addq $0x518, %rsp            # imm = 0x518
retq
nopl (%rax)