// File: /workspace/github_c_makefile_star2_O1/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 0x9561
movl %r9d, %ebp
movq %r8, %rbx
movq %rcx, %r12
movq %rsi, %r13
movq %rdi, %r15
movq %rsi, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x9462
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x9462
leaq 0x20(%r15), %rdi
movq %r12, %rsi
callq 0x5720
movq %rbx, 0x30(%rsp)
movq %r13, %rdi
callq 0x52e0
movzbl %bpl, %ebp
testl %eax, %eax
js 0x94ab
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 0x5720
movq %r13, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x9484
movb 0x70(%rsp), %r14b
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
js 0x94d7
leaq 0x20(%r15), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5720
movq %r12, %rdi
callq 0x52e0
testl %eax, %eax
jns 0x94c0
cmpl $0x2, (%r15)
setb %al
xorb $0x1, %r14b
testb %r14b, %al
jne 0x94ef
movq %r15, %rdi
callq 0x5570
movq %r15, %rdi
movl $0x1, %esi
movq 0x30(%rsp), %rdx
movl %ebp, %ecx
callq 0x5350
movl %eax, %ebp
testb %al, %al
jne 0x9550
leaq 0x18(%rsp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x1bdd(%rip), %rdx      # 0xb0f6
leaq 0x8(%rsp), %rdi
movq %rdx, %rsi
callq 0x5160
movq 0x28(%rsp), %rdi
addq $0x18, %rdi
leaq 0x8(%rsp), %rsi
callq 0x56f0
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x9550
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 0x55b0
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x1eb0(%rip), %rsi      # 0xb42e
leaq 0x1edb(%rip), %rdx      # 0xb460
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 0x5a06(%rip), %rsi      # 0xefc0
movq 0x59f7(%rip), %rdx      # 0xefb8
movq %rbx, %rdi
callq 0x5270
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbx, %rdi
je 0x9619
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5060
jmp 0x9619
movq %rax, %r14
jmp 0x9619
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x960c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x5060
jmp 0x960c
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x9619
movq %rbx, %rdi
callq 0x5380
movq %r14, %rdi
callq 0x5680