// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/stribob192r2/ssse3/encrypt.c
// Function: crypto_aead_decrypt
int crypto_aead_decrypt(
    unsigned char *m, unsigned long long *outputmlen,   // Plaintext out
    unsigned char *nsec,                                // Secret Nonce out
    const unsigned char *c, unsigned long long clen,    // Ciphertext in
    const unsigned char *ad, unsigned long long adlen,  // AAD in
    const unsigned char *npub,                          // Public Nonce in
    const unsigned char *k)                             // Secret Key in
{
    sbob_t  cb;                         // Local state

    if (clen < CRYPTO_ABYTES)
        return -1;
    clen -= CRYPTO_ABYTES;

    sbob_clr(&cb);                      // Clear state

#if (CRYPTO_KEYBYTES > 0)
    // Secret Key
    sbob_put(&cb, BLNK_KEY, k, CRYPTO_KEYBYTES);
    sbob_fin(&cb, BLNK_KEY);
#endif

#if (CRYPTO_NPUBBYTES > 0)
    // Mix the public seq. number
    sbob_put(&cb, BLNK_NPUB, npub, CRYPTO_NPUBBYTES);
    sbob_fin(&cb, BLNK_NPUB);
#endif

#if (CRYPTO_NSECBYTES > 0)
    // Decrypt Secret Sequence Number, store at start of c
    sbob_dec(&cb, BLNK_NSEC, nsec, c, CRYPTO_NSECBYTES);
    sbob_fin(&cb, BLNK_NSEC);
    c += CRYPTO_NSEC_BYTES:
#endif

    // Associated Data
    sbob_put(&cb, BLNK_AAD, ad, (size_t) adlen);
    sbob_fin(&cb, BLNK_AAD);

    // Decrypt Message
    sbob_dec(&cb, BLNK_MSG, m, c, (size_t) clen);
    sbob_fin(&cb, BLNK_MSG);
    c += clen;

#if (SBOB_MACSIZE > 0)
    if (sbob_cmp(&cb, BLNK_MAC, c, SBOB_MACSIZE) != 0)
        return -1;                      // Authentication Failure
    //sbob_fin(&cb, BLNK_MAC);          // Required if MAC-and-Continue
#endif

    sbob_clr(&cb);                      // Clear sensitive data
    *outputmlen = clen;

    return 0;       // Success.
}

// Assembly:
subq $0x88, %rsp
movq 0xa0(%rsp), %rax
movq 0x98(%rsp), %rax
movq 0x90(%rsp), %rax
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq %rcx, 0x60(%rsp)
movq %r8, 0x58(%rsp)
movq %r9, 0x50(%rsp)
cmpq $0x10, 0x58(%rsp)
jae 0x1345
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x1467
movq 0x58(%rsp), %rax
subq $0x10, %rax
movq %rax, 0x58(%rsp)
leaq 0x8(%rsp), %rdi
callq 0x1050
movq 0xa0(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movl $0x10, %esi
movl $0x18, %ecx
callq 0x10d0
leaq 0x8(%rsp), %rdi
movl $0x10, %esi
callq 0x10b0
movq 0x98(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movl $0x20, %esi
movl $0x10, %ecx
callq 0x10d0
leaq 0x8(%rsp), %rdi
movl $0x20, %esi
callq 0x10b0
movq 0x50(%rsp), %rdx
movq 0x90(%rsp), %rcx
leaq 0x8(%rsp), %rdi
movl $0x40, %esi
callq 0x10d0
leaq 0x8(%rsp), %rdi
movl $0x40, %esi
callq 0x10b0
movq 0x78(%rsp), %rdx
movq 0x60(%rsp), %rcx
movq 0x58(%rsp), %r8
leaq 0x8(%rsp), %rdi
movl $0x50, %esi
callq 0x1040
leaq 0x8(%rsp), %rdi
movl $0x50, %esi
callq 0x10b0
movq 0x58(%rsp), %rax
addq 0x60(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movl $0x60, %esi
movl $0x10, %ecx
callq 0x10c0
cmpl $0x0, %eax
je 0x1445
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x1467
leaq 0x8(%rsp), %rdi
callq 0x1050
movq 0x58(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)