// File: /workspace/github_c_makefile_star2_O0/mjosaarinen[P]brutus/crypto_aead/riverkeyakv2/ref/encrypt.cpp
// Function: crypto_aead_encrypt
int crypto_aead_encrypt(
    unsigned char *c,unsigned long long *clen,
    const unsigned char *m,unsigned long long mlen,
    const unsigned char *ad,unsigned long long adlen,
    const unsigned char *nsec,
    const unsigned char *npub,
    const unsigned char *k
    )
{
    string K((const char *)k, (size_t)CRYPTO_KEYBYTES);
    string N((const char *)npub, (size_t)CRYPTO_NPUBBYTES);
    stringstream dummy;
    stringstream AD(string((const char *)ad, adlen));
    stringstream plaintext(string((const char *)m, mlen));
    stringstream ciphertext;
    stringstream tag;

    RiverKeyak instance;
    instance.StartEngine(K, N, false, dummy, false, false);
    instance.Wrap(plaintext, ciphertext, AD, tag, false, false);
    memcpy(c, ciphertext.str().data(), ciphertext.str().size());
    *clen = ciphertext.str().size();
    memcpy(c+ciphertext.str().size(), tag.str().data(), tag.str().size());
    *clen += tag.str().size();

    return 0;
}

// Assembly:
subq $0xad8, %rsp            # imm = 0xAD8
movq 0xaf0(%rsp), %rax
movq 0xae8(%rsp), %rax
movq 0xae0(%rsp), %rax
movq %rdi, 0xad0(%rsp)
movq %rsi, 0xac8(%rsp)
movq %rdx, 0xac0(%rsp)
movq %rcx, 0xab8(%rsp)
movq %r8, 0xab0(%rsp)
movq %r9, 0xaa8(%rsp)
movq 0xaf0(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0xa87(%rsp), %rdi
movq %rdi, 0xa0(%rsp)
callq 0xdce0
movq 0x98(%rsp), %rsi
movq 0xa0(%rsp), %rcx
leaq 0xa88(%rsp), %rdi
movl $0x10, %edx
callq 0xe060
jmp 0x19208
leaq 0xa87(%rsp), %rdi
callq 0xe050
movq 0xae8(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0xa4f(%rsp), %rdi
movq %rdi, 0x90(%rsp)
callq 0xdce0
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rcx
leaq 0xa50(%rsp), %rdi
movl $0x3a, %edx
callq 0xe060
jmp 0x1925e
leaq 0xa4f(%rsp), %rdi
callq 0xe050
leaq 0x8c0(%rsp), %rdi
callq 0xea00
jmp 0x1927a
movq 0xab0(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0xaa8(%rsp), %rax
movq %rax, 0x78(%rsp)
leaq 0x717(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0xdce0
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
movq 0x80(%rsp), %rcx
leaq 0x718(%rsp), %rdi
callq 0xe060
jmp 0x192ca
movl $0x10, %edi
movl $0x8, %esi
callq 0xe850
movl %eax, 0x6c(%rsp)
jmp 0x192df
movl 0x6c(%rsp), %edx
leaq 0x738(%rsp), %rdi
leaq 0x718(%rsp), %rsi
callq 0xd730
jmp 0x192fa
leaq 0x718(%rsp), %rdi
callq 0xe450
leaq 0x717(%rsp), %rdi
callq 0xe050
movq 0xac0(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0xab8(%rsp), %rax
movq %rax, 0x58(%rsp)
leaq 0x567(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0xdce0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rdx
movq 0x60(%rsp), %rcx
leaq 0x568(%rsp), %rdi
callq 0xe060
jmp 0x1935e
movl $0x10, %edi
movl $0x8, %esi
callq 0xe850
movl %eax, 0x4c(%rsp)
jmp 0x19373
movl 0x4c(%rsp), %edx
leaq 0x588(%rsp), %rdi
leaq 0x568(%rsp), %rsi
callq 0xd730
jmp 0x1938e
leaq 0x568(%rsp), %rdi
callq 0xe450
leaq 0x567(%rsp), %rdi
callq 0xe050
leaq 0x3d8(%rsp), %rdi
callq 0xea00
jmp 0x193b7
leaq 0x250(%rsp), %rdi
callq 0xea00
jmp 0x193c6
leaq 0x188(%rsp), %rdi
callq 0xd870
jmp 0x193d5
movq %rsp, %rax
movl $0x0, (%rax)
leaq 0x188(%rsp), %rdi
leaq 0xa88(%rsp), %rsi
leaq 0xa50(%rsp), %rdx
leaq 0x8c0(%rsp), %r8
xorl %r9d, %r9d
movl %r9d, %ecx
callq 0xd180
jmp 0x1940b
movq %rsp, %rax
movl $0x0, (%rax)
leaq 0x188(%rsp), %rdi
leaq 0x588(%rsp), %rsi
leaq 0x3d8(%rsp), %rdx
leaq 0x738(%rsp), %rcx
leaq 0x250(%rsp), %r8
xorl %r9d, %r9d
callq 0xdf90
jmp 0x19446
movq 0xad0(%rsp), %rax
movq %rax, 0x40(%rsp)
leaq 0x168(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0xe1f0
jmp 0x1946a
leaq 0x168(%rsp), %rdi
callq 0xd2b0
movq %rax, 0x38(%rsp)
leaq 0x148(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0xe1f0
jmp 0x19493
leaq 0x148(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0xdbb0
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq %rax, %rdx
callq 0xdbe0
movq 0x30(%rsp), %rdi
callq 0xe450
leaq 0x168(%rsp), %rdi
callq 0xe450
leaq 0x128(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0xe1f0
jmp 0x194e5
leaq 0x128(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xdbb0
movq 0x20(%rsp), %rdi
movq %rax, %rcx
movq 0xac8(%rsp), %rax
movq %rcx, (%rax)
callq 0xe450
movq 0xad0(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0x3d8(%rsp), %rsi
callq 0xe1f0
jmp 0x19533
leaq 0x108(%rsp), %rdi
callq 0xdbb0
movq %rax, %rcx
movq 0x28(%rsp), %rax
addq %rcx, %rax
movq %rax, 0x18(%rsp)
leaq 0xe8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0xe1f0
jmp 0x19567
leaq 0xe8(%rsp), %rdi
callq 0xd2b0
movq %rax, 0x10(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0xe1f0
jmp 0x19590
leaq 0xc8(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0xdbb0
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq %rax, %rdx
callq 0xdbe0
movq 0x8(%rsp), %rdi
callq 0xe450
leaq 0xe8(%rsp), %rdi
callq 0xe450
leaq 0x108(%rsp), %rdi
callq 0xe450
leaq 0xa8(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0xe1f0
jmp 0x195ef
leaq 0xa8(%rsp), %rdi
callq 0xdbb0
movq %rax, %rcx
movq 0xac8(%rsp), %rax
addq (%rax), %rcx
movq %rcx, (%rax)
leaq 0xa8(%rsp), %rdi
callq 0xe450
leaq 0x188(%rsp), %rdi
callq 0xdee0
leaq 0x250(%rsp), %rdi
callq 0xea90
leaq 0x3d8(%rsp), %rdi
callq 0xea90
leaq 0x588(%rsp), %rdi
callq 0xea90
leaq 0x738(%rsp), %rdi
callq 0xea90
leaq 0x8c0(%rsp), %rdi
callq 0xea90
leaq 0xa50(%rsp), %rdi
callq 0xe450
leaq 0xa88(%rsp), %rdi
callq 0xe450
xorl %eax, %eax
addq $0xad8, %rsp            # imm = 0xAD8
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0xa87(%rsp), %rdi
callq 0xe050
jmp 0x198b3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0xa4f(%rsp), %rdi
callq 0xe050
jmp 0x198a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19899
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19728
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0x718(%rsp), %rdi
callq 0xe450
leaq 0x717(%rsp), %rdi
callq 0xe050
jmp 0x1988c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19771
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0x568(%rsp), %rdi
callq 0xe450
leaq 0x567(%rsp), %rdi
callq 0xe050
jmp 0x1987f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19872
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19865
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x19858
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x1984b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0x168(%rsp), %rdi
callq 0xe450
jmp 0x1984b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
jmp 0x1983e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa78(%rsp)
movl %eax, 0xa74(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0xe450
leaq 0x108(%rsp), %rdi
callq 0xe450
leaq 0x188(%rsp), %rdi
callq 0xdee0
leaq 0x250(%rsp), %rdi
callq 0xea90
leaq 0x3d8(%rsp), %rdi
callq 0xea90
leaq 0x588(%rsp), %rdi
callq 0xea90
leaq 0x738(%rsp), %rdi
callq 0xea90
leaq 0x8c0(%rsp), %rdi
callq 0xea90
leaq 0xa50(%rsp), %rdi
callq 0xe450
leaq 0xa88(%rsp), %rdi
callq 0xe450
movq 0xa78(%rsp), %rdi
callq 0xe7c0