// File: /workspace/github_c_makefile_star2_O3/mjosaarinen[P]brutus/crypto_aead/riverkeyakv2/ref/Motorist.cpp
// Function: Motorist::Wrap(std::istream&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&, std::istream&, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&, bool, bool)
bool Motorist::Wrap(istream& I, stringstream& O, istream& A, stringstream& T, bool unwrapFlag, bool forgetFlag)
{
    if (phase != riding)
        throw Exception("The phase must be riding to call Motorist::Wrap().");
    if ((!hasMore(I)) && (!hasMore(A)))
        engine.Inject(A);
    while(hasMore(I)) {
        engine.Crypt(I, O, unwrapFlag);
        engine.Inject(A);
    }
    while(hasMore(A))
        engine.Inject(A);
    if ((Pi > 1) || forgetFlag)
        MakeKnot();
    bool res = HandleTag(true, T, unwrapFlag);
    if (!res)
        O.str(string(""));
    return res;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, 0x28(%rsp)
cmpl $0x1, 0x60(%rdi)
jne 0x94b9
movl %r9d, %ebp
movq %r8, %rbx
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, %r15
movq %rsi, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x93ba
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x93ba
leaq 0x20(%r15), %rdi
movq %r12, %rsi
callq 0x5710
movq %rbx, 0x30(%rsp)
movq %r13, %rdi
callq 0x52e0
movzbl %bpl, %ebp
testl %eax, %eax
js 0x9403
leaq 0x20(%r15), %r14
movq 0x28(%rsp), %rax
leaq 0x10(%rax), %rbx
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x5310
movq %r14, %rdi
movq %r12, %rsi
callq 0x5710
movq %r13, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x93dc
movb 0x70(%rsp), %r14b
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
js 0x942f
leaq 0x20(%r15), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5710
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x9418
cmpl $0x2, (%r15)
setb %al
xorb $0x1, %r14b
testb %r14b, %al
jne 0x9447
movq %r15, %rdi
callq 0x5560
movq %r15, %rdi
movl $0x1, %esi
movq 0x30(%rsp), %rdx
movl %ebp, %ecx
callq 0x5350
movl %eax, %ebp
testb %al, %al
jne 0x94a8
leaq 0x18(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1c55(%rip), %rdx      # 0xb0c6
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x5160
movq 0x28(%rsp), %rdi
addq $0x18, %rdi
leaq 0x8(%rsp), %rsi
callq 0x56e0
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x94a8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5060
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x20, %edi
callq 0x55a0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1f34(%rip), %rsi      # 0xb40a
leaq 0x1f5f(%rip), %rdx      # 0xb43c
leaq 0x8(%rsp), %rdi
callq 0x5160
movq %rbx, %rax
addq $0x10, %rax
movq %rax, (%rbx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x5170
xorl %ebp, %ebp
movq 0x5aae(%rip), %rsi      # 0xefc0
movq 0x5a9f(%rip), %rdx      # 0xefb8
movq %rbx, %rdi
callq 0x5270
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x956e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5060
jmp 0x956e
movq %rax, %r14
jmp 0x956e
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x955c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5060
testb %bpl, %bpl
jne 0x9566
jmp 0x956e
movq %rax, %r14
movq %rbx, %rdi
callq 0x5380
movq %r14, %rdi
callq 0x5670